Package org.apache.wss4j.dom.message
Class WSSecDerivedKeyBase
- java.lang.Object
-
- org.apache.wss4j.dom.message.WSSecBase
-
- org.apache.wss4j.dom.message.WSSecSignatureBase
-
- org.apache.wss4j.dom.message.WSSecDerivedKeyBase
-
- Direct Known Subclasses:
WSSecDKEncrypt
,WSSecDKSign
public abstract class WSSecDerivedKeyBase extends WSSecSignatureBase
Base class for DerivedKey encryption and signature
-
-
Field Summary
-
Fields inherited from class org.apache.wss4j.dom.message.WSSecBase
addWSUNamespace, attachmentCallbackHandler, callbackLookup, expandXopInclude, keyIdentifierType, password, storeBytesInAttachment, user
-
-
Constructor Summary
Constructors Constructor Description WSSecDerivedKeyBase(WSSecHeader securityHeader)
WSSecDerivedKeyBase(Document doc)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
appendDKElementToHeader()
void
clean()
protected SecretKey
getDerivedKey(String algorithm)
protected abstract int
getDerivedKeyLength()
The derived key will change depending on the sig/encr algorithm.Element
getdktElement()
String
getId()
Get the id generated duringprepare()
.Element
getStrElem()
String
getTokenIdentifier()
int
getWscVersion()
void
prepare(byte[] ephemeralKey)
Initialize a WSSec Derived key.void
prependDKElementToHeader()
Prepend the DerivedKey element to the elements already in the Security header.void
setClientLabel(String clientLabel)
Set the label value of the client.void
setCrypto(Crypto crypto)
void
setCustomValueType(String customValueType)
void
setServiceLabel(String serviceLabel)
Set the label value of the service.void
setStrElem(Element strElem)
void
setTokenIdDirectId(boolean b)
void
setTokenIdentifier(String tokenIdentifier)
void
setWscVersion(int wscVersion)
void
setX509Certificate(X509Certificate cer)
Set the X509 Certificate to use-
Methods inherited from class org.apache.wss4j.dom.message.WSSecSignatureBase
addReferencesToSign, cleanup, createSTRParameter, getInclusivePrefixes, getInclusivePrefixes
-
Methods inherited from class org.apache.wss4j.dom.message.WSSecBase
getDocument, getIdAllocator, getKeyIdentifierType, getParts, getSecurityHeader, getWsDocInfo, isExpandXopInclude, setAttachmentCallbackHandler, setBodyID, setCallbackLookup, setExpandXopInclude, setIdAllocator, setKeyIdentifierType, setStoreBytesInAttachment, setUserInfo, setWsDocInfo, setWsuId
-
-
-
-
Constructor Detail
-
WSSecDerivedKeyBase
public WSSecDerivedKeyBase(WSSecHeader securityHeader)
-
WSSecDerivedKeyBase
public WSSecDerivedKeyBase(Document doc)
-
-
Method Detail
-
getDerivedKeyLength
protected abstract int getDerivedKeyLength() throws WSSecurityException
The derived key will change depending on the sig/encr algorithm. Therefore the child classes are expected to provide this value.- Returns:
- the derived key length
- Throws:
WSSecurityException
-
getStrElem
public Element getStrElem()
-
setStrElem
public void setStrElem(Element strElem)
-
setTokenIdentifier
public void setTokenIdentifier(String tokenIdentifier)
-
getTokenIdentifier
public String getTokenIdentifier()
- Returns:
- Returns the tokenIdentifier.
-
setX509Certificate
public void setX509Certificate(X509Certificate cer)
Set the X509 Certificate to use- Parameters:
cer
- the X509 Certificate to use
-
getId
public String getId()
Get the id generated duringprepare()
. Returns the the value of wsu:Id attribute of the DerivedKeyToken element.- Returns:
- Return the wsu:Id of this token or null if
prepare()
was not called before.
-
setClientLabel
public void setClientLabel(String clientLabel)
Set the label value of the client.- Parameters:
clientLabel
-
-
setServiceLabel
public void setServiceLabel(String serviceLabel)
Set the label value of the service.- Parameters:
serviceLabel
-
-
prepare
public void prepare(byte[] ephemeralKey) throws WSSecurityException
Initialize a WSSec Derived key. The method prepares and initializes a WSSec derived key structure after the relevant information was set. This method also creates and initializes the derived token using the ephemeral key. After preparation references can be added, encrypted and signed as required. This method does not add any element to the security header. This must be done explicitly.- Parameters:
ephemeralKey
- The ephemeral key to use for derivation- Throws:
WSSecurityException
-
prependDKElementToHeader
public void prependDKElementToHeader()
Prepend the DerivedKey element to the elements already in the Security header. The method can be called any time afterprepare()
. This allows to insert the DerivedKey element at any position in the Security header.
-
appendDKElementToHeader
public void appendDKElementToHeader()
-
setWscVersion
public void setWscVersion(int wscVersion)
- Parameters:
wscVersion
- The wscVersion to set.
-
getWscVersion
public int getWscVersion()
-
getdktElement
public Element getdktElement()
-
setCustomValueType
public void setCustomValueType(String customValueType)
-
setTokenIdDirectId
public void setTokenIdDirectId(boolean b)
-
setCrypto
public void setCrypto(Crypto crypto)
-
-