org.apache.ws.security.message
Class WSSAddUsernameToken

java.lang.Object
  extended byorg.apache.ws.security.message.WSBaseMessage
      extended byorg.apache.ws.security.message.WSSAddUsernameToken

public class WSSAddUsernameToken
extends WSBaseMessage

Builds a WS UsernameToken and inserts it into the SOAP Envelope. Refer to the WS specification, UsernameToken profile

Author:
Werner Dittmann (Werner.Dittmann@siemens.com).

Field Summary
 
Fields inherited from class org.apache.ws.security.message.WSBaseMessage
actor, doDebug, keyIdentifierType, mustunderstand, parts, password, timeToLive, user, wssConfig
 
Constructor Summary
WSSAddUsernameToken()
          Constructor.
WSSAddUsernameToken(java.lang.String actor)
          Constructor.
WSSAddUsernameToken(java.lang.String actor, boolean mu)
          Constructor.
WSSAddUsernameToken(WSSConfig wssConfig, java.lang.String actor, boolean mu)
          Constructor.
 
Method Summary
 void addCreated(org.w3c.dom.Document doc)
          Creates and adds a Created element to the UsernameToken
 void addNonce(org.w3c.dom.Document doc)
          Creates and adds a Nonce element to the UsernameToken
 org.w3c.dom.Document build(org.w3c.dom.Document doc, java.lang.String username, java.lang.String password)
          Adds a new UsernameToken to a soap envelope.
 java.lang.String getId()
          get the id
 byte[] getSecretKey()
           
 org.w3c.dom.Document preSetUsernameToken(org.w3c.dom.Document doc, java.lang.String username, java.lang.String password)
           
 void setId(java.lang.String id)
          set the id
 void setPasswordType(java.lang.String pwType)
          Defines how to construct the password element of the UsernameToken.
 
Methods inherited from class org.apache.ws.security.message.WSBaseMessage
getKeyIdentifierType, insertSecurityHeader, setActor, setBodyID, setKeyIdentifierType, setMustUnderstand, setParts, setTimeToLive, setUserInfo, setWsuId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSSAddUsernameToken

public WSSAddUsernameToken()
Constructor.


WSSAddUsernameToken

public WSSAddUsernameToken(java.lang.String actor)
Constructor.

Parameters:
actor - the name of the actor of the wsse:Security header

WSSAddUsernameToken

public WSSAddUsernameToken(java.lang.String actor,
                           boolean mu)
Constructor.

Parameters:
actor - The name of the actor of the wsse:Security header
mu - Set mustUnderstand to true or false

WSSAddUsernameToken

public WSSAddUsernameToken(WSSConfig wssConfig,
                           java.lang.String actor,
                           boolean mu)
Constructor.

Parameters:
wssConfig - Configuration options for processing and building the wsse:Security header
actor - The name of the actor of the wsse:Security header
mu - Set mustUnderstand to true or false
Method Detail

setPasswordType

public void setPasswordType(java.lang.String pwType)
Defines how to construct the password element of the UsernameToken.

Parameters:
pwType - contains the password type. Only allowed values are WSConstants.PASSWORD_DIGEST and WSConstants.PASSWORD_TEXT.

addNonce

public void addNonce(org.w3c.dom.Document doc)
Creates and adds a Nonce element to the UsernameToken


addCreated

public void addCreated(org.w3c.dom.Document doc)
Creates and adds a Created element to the UsernameToken


setId

public void setId(java.lang.String id)
set the id

Parameters:
id -

getSecretKey

public byte[] getSecretKey()

getId

public java.lang.String getId()
get the id

Returns:

preSetUsernameToken

public org.w3c.dom.Document preSetUsernameToken(org.w3c.dom.Document doc,
                                                java.lang.String username,
                                                java.lang.String password)

build

public org.w3c.dom.Document build(org.w3c.dom.Document doc,
                                  java.lang.String username,
                                  java.lang.String password)
Adds a new UsernameToken to a soap envelope.

A complete UsernameToken is constructed and added to the wsse:Security header.

Parameters:
doc - The SOAP enevlope as W3C document
username - The username to set in the UsernameToken
password - The password of the user
Returns:
Document with UsernameToken added