Package org.apache.ws.security.message
Class WSSecUsernameToken
java.lang.Object
org.apache.ws.security.message.WSSecBase
org.apache.ws.security.message.WSSecUsernameToken
Builds a WS UsernameToken.
Refer to the WS specification, UsernameToken profile
- Author:
- Werner Dittmann (werner@apache.org).
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a Created element to the UsernameToken.void
addNonce()
Add a Nonce element to the UsernameToken.void
appendToHeader
(WSSecHeader secHeader) Appends the UsernameToken element to the elements already in the Security header.build
(Document doc, WSSecHeader secHeader) Adds a newUsernameToken
to a soap envelope.getId()
Get the id generated duringprepare()
.byte[]
Get the derived secret key.Returns theUsernameToken
element.void
Creates a Username token.void
prependToHeader
(WSSecHeader secHeader) Prepends the UsernameToken element to the elements already in the Security header.void
setPasswordType
(String pwType) Defines how to construct the password element of theUsernameToken
.Methods inherited from class org.apache.ws.security.message.WSSecBase
getKeyIdentifierType, setBodyID, setKeyIdentifierType, setParts, setUserInfo, setWsConfig, setWsuId
-
Constructor Details
-
WSSecUsernameToken
public WSSecUsernameToken()Constructor.
-
-
Method Details
-
setPasswordType
Defines how to construct the password element of theUsernameToken
.- Parameters:
pwType
- contains the password type. Only allowed values areWSConstants.PASSWORD_DIGEST
andWSConstants.PASSWORD_TEXT
.
-
addNonce
public void addNonce()Add a Nonce element to the UsernameToken. -
addCreated
public void addCreated()Add a Created element to the UsernameToken. -
getSecretKey
public byte[] getSecretKey()Get the derived secret key. After theprepare()
method was called use this method to compute a derived secret key. The generation of this secret key is according to WS-Trust specification.- Returns:
- Return the derived secret key of this token or null if
prepare()
was not called before.
-
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
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 completeUsernameToken
is constructed.- Parameters:
doc
- The SOAP enevlope as W3C document
-
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.- Parameters:
secHeader
- The security header that holds the Signature element.
-
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.- Parameters:
secHeader
- The security header that holds the Signature element.
-
build
Adds a newUsernameToken
to a soap envelope. Before callingbuild()
all parameters such as user, password, passwordType etc. must be set. A completeUsernameToken
is constructed and added to thewsse:Security
header.- Parameters:
doc
- The SOAP enevlope as W3C documentsecHeader
- The security header inside the SOAP envelope- Returns:
- Document with UsernameToken added
-
getUsernameTokenElement
Returns theUsernameToken
element. The method can be called any time afterprepare()
. This allows to insert the UsernameToken element at any position in the Security header.- Returns:
-