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 voidappendDKElementToHeader()voidclean()protected SecretKeygetDerivedKey(String algorithm)protected abstract intgetDerivedKeyLength()The derived key will change depending on the sig/encr algorithm.ElementgetdktElement()StringgetId()Get the id generated duringprepare().ElementgetStrElem()StringgetTokenIdentifier()intgetWscVersion()voidprepare(byte[] ephemeralKey)Initialize a WSSec Derived key.voidprependDKElementToHeader()Prepend the DerivedKey element to the elements already in the Security header.voidsetClientLabel(String clientLabel)Set the label value of the client.voidsetCrypto(Crypto crypto)voidsetCustomValueType(String customValueType)voidsetServiceLabel(String serviceLabel)Set the label value of the service.voidsetStrElem(Element strElem)voidsetTokenIdDirectId(boolean b)voidsetTokenIdentifier(String tokenIdentifier)voidsetWscVersion(int wscVersion)voidsetX509Certificate(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 WSSecurityExceptionThe 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 WSSecurityExceptionInitialize 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)
-
-