Class DerivedKeyToken
- java.lang.Object
-
- org.apache.wss4j.dom.message.token.DerivedKeyToken
-
public class DerivedKeyToken extends Object
... ... ... ... ... ...
-
-
Constructor Summary
Constructors Constructor Description DerivedKeyToken(int version, Document doc)
This will create an empty DerivedKeyTokenDerivedKeyToken(Document doc)
This will create an empty DerivedKeyTokenDerivedKeyToken(Element elem, BSPEnforcer bspEnforcer)
This will create a DerivedKeyToken object with the given DerivedKeyToken element
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addWSUNamespace()
Add the WSU Namespace to this DKT.Principal
createPrincipal()
Create a WSDerivedKeyTokenPrincipal from this DerivedKeyToken objectbyte[]
deriveKey(int length, byte[] secret)
Derive a key from this DerivedKeyToken instanceboolean
equals(Object object)
String
getAlgorithm()
Gets the derivation algorithmElement
getElement()
Returns the dom element of thisSecurityContextToken
object.int
getGeneration()
String
getID()
Gets the id.String
getLabel()
Returns the label of the derived key tokenint
getLength()
String
getNonce()
Return the nonce of the derived key tokenint
getOffset()
Map<String,String>
getProperties()
SecurityTokenReference
getSecurityTokenReference()
Returns the SecurityTokenReference of the derived key tokenElement
getSecurityTokenReferenceElement()
Returns the SecurityTokenReference element of the derived key tokenint
hashCode()
void
setAlgorithm(String algo)
Set the derivation algorithm of this derived key token.void
setGeneration(int generation)
Sets the generation of the derived keyvoid
setID(String id)
Set the id of this derived key token.void
setLabel(String label)
Sets the label of the derived keyvoid
setLength(int length)
Sets the length of the derived keyvoid
setNonce(String nonce)
Sets the nonce value of the derived keyvoid
setOffset(int offset)
Sets the offsetvoid
setProperties(String name, String label, String nonce)
This is used to set the Name, Label and Nonce element values in the properties element At this point I'm not sure if these are the only properties that will appear in theProperties
element.void
setProperties(Map<String,String> properties)
If there are other types of properties other than Name, Label and Nonce This is provided for extensibility purposesvoid
setSecurityTokenReference(SecurityTokenReference ref)
Sets the security token reference of the derived key token This is the reference to the shared secret used in the conversation/contextvoid
setSecurityTokenReference(Element elem)
String
toString()
Returns the string representation of the token.
-
-
-
Constructor Detail
-
DerivedKeyToken
public DerivedKeyToken(Document doc) throws WSSecurityException
This will create an empty DerivedKeyToken- Parameters:
doc
- The DOM document- Throws:
WSSecurityException
-
DerivedKeyToken
public DerivedKeyToken(int version, Document doc) throws WSSecurityException
This will create an empty DerivedKeyToken- Parameters:
doc
- The DOM document- Throws:
WSSecurityException
-
DerivedKeyToken
public DerivedKeyToken(Element elem, BSPEnforcer bspEnforcer) throws WSSecurityException
This will create a DerivedKeyToken object with the given DerivedKeyToken element- Parameters:
elem
- The DerivedKeyToken DOM elementbspEnforcer
- a BSPEnforcer instance to enforce BSP rules- Throws:
WSSecurityException
- If the element is not a derived key token
-
-
Method Detail
-
addWSUNamespace
public void addWSUNamespace()
Add the WSU Namespace to this DKT. The namespace is not added by default for efficiency purposes.
-
setSecurityTokenReference
public void setSecurityTokenReference(SecurityTokenReference ref)
Sets the security token reference of the derived key token This is the reference to the shared secret used in the conversation/context- Parameters:
ref
- Security token reference
-
setSecurityTokenReference
public void setSecurityTokenReference(Element elem)
-
getSecurityTokenReference
public SecurityTokenReference getSecurityTokenReference() throws WSSecurityException
Returns the SecurityTokenReference of the derived key token- Returns:
- the Security Token Reference of the derived key token
- Throws:
WSSecurityException
-
getSecurityTokenReferenceElement
public Element getSecurityTokenReferenceElement()
Returns the SecurityTokenReference element of the derived key token- Returns:
- the Security Token Reference element of the derived key token
-
setProperties
public void setProperties(String name, String label, String nonce)
This is used to set the Name, Label and Nonce element values in the properties element At this point I'm not sure if these are the only properties that will appear in theProperties
element. There fore this method is provided If this is not required feel free to remove this :D- Parameters:
name
- Value of the Properties/Name elementlabel
- Value of the Properties/Label elementnonce
- Value of the Properties/Nonce element
-
setProperties
public void setProperties(Map<String,String> properties)
If there are other types of properties other than Name, Label and Nonce This is provided for extensibility purposes- Parameters:
properties
- The properties and values in a Map
-
setLength
public void setLength(int length)
Sets the length of the derived key- Parameters:
length
- The length of the derived key as a long
-
getLength
public int getLength()
-
setOffset
public void setOffset(int offset) throws WSSecurityException
Sets the offset- Parameters:
offset
- The offset value as an integer- Throws:
WSSecurityException
-
getOffset
public int getOffset()
-
setGeneration
public void setGeneration(int generation) throws WSSecurityException
Sets the generation of the derived key- Parameters:
generation
- generation value as an integer- Throws:
WSSecurityException
-
getGeneration
public int getGeneration()
-
setLabel
public void setLabel(String label)
Sets the label of the derived key- Parameters:
label
- Label value as a string
-
setNonce
public void setNonce(String nonce)
Sets the nonce value of the derived key- Parameters:
nonce
- Nonce value as a string
-
getLabel
public String getLabel()
Returns the label of the derived key token- Returns:
- Label of the derived key token
-
getNonce
public String getNonce()
Return the nonce of the derived key token- Returns:
- Nonce of the derived key token
-
getElement
public Element getElement()
Returns the dom element of thisSecurityContextToken
object.- Returns:
- the DerivedKeyToken element
-
toString
public String toString()
Returns the string representation of the token.
-
getID
public String getID()
Gets the id.- Returns:
- the value of the
wsu:Id
attribute of this DerivedKeyToken
-
setID
public void setID(String id)
Set the id of this derived key token.- Parameters:
id
- the value for thewsu:Id
attribute of this DerivedKeyToken
-
getAlgorithm
public String getAlgorithm()
Gets the derivation algorithm- Returns:
- the value of the
wsc:Algorithm
attribute of this DerivedKeyToken
-
createPrincipal
public Principal createPrincipal() throws WSSecurityException
Create a WSDerivedKeyTokenPrincipal from this DerivedKeyToken object- Throws:
WSSecurityException
-
setAlgorithm
public void setAlgorithm(String algo)
Set the derivation algorithm of this derived key token.- Parameters:
algo
- the value for theAlgorithm
attribute of this DerivedKeyToken
-
deriveKey
public byte[] deriveKey(int length, byte[] secret) throws WSSecurityException
Derive a key from this DerivedKeyToken instance- Parameters:
length
-secret
-- Throws:
WSSecurityException
-
-