Package org.apache.wss4j.dom.message
Class WSSecUsernameToken
java.lang.Object
org.apache.wss4j.dom.message.WSSecBase
org.apache.wss4j.dom.message.WSSecUsernameToken
Builds a WS UsernameToken.
Refer to the WS specification, UsernameToken profile
-
Field Summary
Fields inherited from class org.apache.wss4j.dom.message.WSSecBase
addWSUNamespace, attachmentCallbackHandler, callbackLookup, expandXopInclude, keyIdentifierType, password, storeBytesInAttachment, user -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a Created element to the UsernameToken.voidaddDerivedKey(int iteration) Add a derived key to the UsernameTokenvoidaddNonce()Add a Nonce element to the UsernameToken.voidAppends the UsernameToken element to the elements already in the Security header.build()build(byte[] salt) Adds a newUsernameTokento a soap envelope.byte[]getDerivedKey(byte[] saltValue) Get the derived key.getId()Get the id generated duringprepare().booleanReturns theUsernameTokenelement.booleanvoidprepare()Creates a Username token.voidprepare(byte[] saltValue) voidPrepends the UsernameToken element to the elements already in the Security header.voidsetPasswordsAreEncoded(boolean passwordsAreEncoded) voidsetPasswordType(String pwType) Defines how to construct the password element of theUsernameToken.voidsetPrecisionInMilliSeconds(boolean precisionInMilliSeconds) voidsetWsTimeSource(WSTimeSource wsTimeSource) Methods inherited from class org.apache.wss4j.dom.message.WSSecBase
clean, getDocument, getIdAllocator, getKeyIdentifierType, getParts, getSecurityHeader, getWsDocInfo, isExpandXopInclude, setAttachmentCallbackHandler, setBodyID, setCallbackLookup, setExpandXopInclude, setIdAllocator, setKeyIdentifierType, setStoreBytesInAttachment, setUserInfo, setWsDocInfo, setWsuId
-
Constructor Details
-
WSSecUsernameToken
-
WSSecUsernameToken
-
-
Method Details
-
setPasswordType
Defines how to construct the password element of theUsernameToken.- Parameters:
pwType- contains the password type. Only allowed values areWSS4JConstants.PASSWORD_DIGESTandWSS4JConstants.PASSWORD_TEXT. or null when no password is needed.
-
addNonce
public void addNonce()Add a Nonce element to the UsernameToken. -
addCreated
public void addCreated()Add a Created element to the UsernameToken. -
addDerivedKey
public void addDerivedKey(int iteration) Add a derived key to the UsernameToken- Parameters:
iteration- The number of iterations to use in deriving a key
-
getDerivedKey
Get the derived key. After theprepare()method was called use this method to compute a derived key. The generation of this secret key is according to the UsernameTokenProfile 1.1 specification (section 4 - Key Derivation).- Parameters:
saltValue- The salt value to use- Returns:
- Return the derived key of this token or null if
prepare()was not called before. - Throws:
WSSecurityException
-
setPasswordsAreEncoded
public void setPasswordsAreEncoded(boolean passwordsAreEncoded) - Parameters:
passwordsAreEncoded- whether passwords are encoded
-
getPasswordsAreEncoded
public boolean getPasswordsAreEncoded()- Returns:
- whether passwords are encoded
-
getId
Get the id generated duringprepare(). Returns the the value of wsu:Id attribute of this UsernameToken.- Returns:
- Return the wsu:Id of this token or null if
prepare()was not called before.
-
prepare
public void prepare()Creates a Username token. The method prepares and initializes a WSSec UsernameToken structure after the relevant information was set. A Before callingprepare()all parameters such as user, password, passwordType etc. must be set. A completeUsernameTokenis constructed. -
prepare
public void prepare(byte[] saltValue) -
prependToHeader
public void prependToHeader()Prepends the UsernameToken element to the elements already in the Security header. The method can be called any time afterprepare(). This allows to insert the UsernameToken element at any position in the Security header. -
appendToHeader
public void appendToHeader()Appends the UsernameToken element to the elements already in the Security header. The method can be called any time afterprepare(). This allows to insert the UsernameToken element at any position in the Security header. -
build
Adds a newUsernameTokento a soap envelope. Before callingbuild()all parameters such as user, password, passwordType etc. must be set. A completeUsernameTokenis constructed and added to thewsse:Securityheader.- Parameters:
salt- the salt value to add if we are using a derived key- Returns:
- Document with UsernameToken added
-
build
-
getUsernameTokenElement
Returns theUsernameTokenelement. The method can be called any time afterprepare(). This allows to insert the UsernameToken element at any position in the Security header.- Returns:
- the Username Token element
-
isPrecisionInMilliSeconds
public boolean isPrecisionInMilliSeconds() -
setPrecisionInMilliSeconds
public void setPrecisionInMilliSeconds(boolean precisionInMilliSeconds) -
getWsTimeSource
-
setWsTimeSource
-