com.sun.xml.ws.security.opt.impl.tokens
Class UsernameToken

java.lang.Object
  extended by com.sun.xml.ws.security.secext10.UsernameTokenType
      extended by com.sun.xml.ws.security.opt.impl.tokens.UsernameToken
All Implemented Interfaces:
SecurityElement, SecurityElementWriter, SecurityHeaderElement, UsernameToken

public class UsernameToken
extends UsernameTokenType
implements UsernameToken, SecurityHeaderElement, SecurityElementWriter

Representation of UsernameToken SecurityHeaderElement

Author:
Ashutosh.Shahi@sun.com

Field Summary
static long MAX_NONCE_AGE
           
 
Fields inherited from class com.sun.xml.ws.security.secext10.UsernameTokenType
any, created, id, iteration, nonce, password, salt, username
 
Constructor Summary
UsernameToken(SOAPVersion sv)
          Creates a new instance of UsernameToken
 
Method Summary
 String getAttribute(QName name)
           
 String getAttribute(String nsUri, String localName)
           
 String getCreatedValue()
          Returns the created which may be null meaning no time of creation.
 String getLocalPart()
          Gets the local name of this header element.
 String getNamespaceURI()
           
 String getNonceEncodingType()
           
 String getNonceValue()
           
 String getPasswordDigestValue()
           
 String getPasswordType()
           
 String getPasswordValue()
           
 String getUsernameValue()
           
 boolean isBSP()
           
 void isBSP(boolean flag)
           
 XMLStreamReader readHeader()
          Reads the header as a XMLStreamReader.
 boolean refersToSecHdrWithId(String id)
           
 void setCreationTime(String time)
          set the creation time.
 void setDigestOn()
           
 void setNonce(String nonceValue)
          set the nonce value.If nonce value is null then it will create one.
 void setPasswordValue(String passwd)
          Sets the password.
 void setUsernameValue(String username)
          sets the username value for this token
 void writeTo(OutputStream os)
           
 void writeTo(XMLStreamWriter streamWriter)
          Writes out the header.
 void writeTo(XMLStreamWriter streamWriter, HashMap props)
           
 
Methods inherited from class com.sun.xml.ws.security.secext10.UsernameTokenType
getAny, getCreated, getId, getIteration, getNonce, getOtherAttributes, getPassword, getSalt, getUsername, setCreated, setId, setIteration, setNonce, setPassword, setSalt, setUsername
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.xml.ws.security.opt.api.SecurityElement
getId, setId
 

Field Detail

MAX_NONCE_AGE

public static final long MAX_NONCE_AGE
See Also:
Constant Field Values
Constructor Detail

UsernameToken

public UsernameToken(SOAPVersion sv)
Creates a new instance of UsernameToken

Method Detail

getUsernameValue

public String getUsernameValue()
Specified by:
getUsernameValue in interface UsernameToken
Returns:
Returns the username.

setUsernameValue

public void setUsernameValue(String username)
Description copied from interface: UsernameToken
sets the username value for this token

Specified by:
setUsernameValue in interface UsernameToken
Parameters:
username - username value

getPasswordValue

public String getPasswordValue()
Specified by:
getPasswordValue in interface UsernameToken
Returns:
Returns the password which may be null meaning no password.

setPasswordValue

public void setPasswordValue(String passwd)
Sets the password.

Specified by:
setPasswordValue in interface UsernameToken
Parameters:
passwd -

getPasswordType

public String getPasswordType()
Returns:
Returns the passwordType.

getNonceEncodingType

public String getNonceEncodingType()
Returns:
Returns the Nonce Encoding type.

getNonceValue

public String getNonceValue()
                     throws SecurityTokenException
Returns:
Returns the encoded nonce. Null indicates no nonce was set.
Throws:
SecurityTokenException

getCreatedValue

public String getCreatedValue()
Returns the created which may be null meaning no time of creation.


getPasswordDigestValue

public String getPasswordDigestValue()

setNonce

public void setNonce(String nonceValue)
set the nonce value.If nonce value is null then it will create one.

Parameters:
nonceValue -

setCreationTime

public void setCreationTime(String time)
                     throws XWSSecurityException
set the creation time.

Parameters:
time - If null or empty then this method would create one.
Throws:
XWSSecurityException

setDigestOn

public void setDigestOn()
                 throws SecurityTokenException
Throws:
SecurityTokenException

isBSP

public void isBSP(boolean flag)

isBSP

public boolean isBSP()

getNamespaceURI

public String getNamespaceURI()
Specified by:
getNamespaceURI in interface SecurityElement
Returns:
namespace uri of the security header element.

getLocalPart

public String getLocalPart()
Description copied from interface: SecurityElement
Gets the local name of this header element.

Specified by:
getLocalPart in interface SecurityElement
Returns:
this string must be interned.

getAttribute

public String getAttribute(String nsUri,
                           String localName)

getAttribute

public String getAttribute(QName name)

readHeader

public XMLStreamReader readHeader()
                           throws XMLStreamException
Description copied from interface: SecurityElement
Reads the header as a XMLStreamReader.

The returned parser points at the start element of this header. (IOW, XMLStreamReader.getEventType() would return XMLStreamConstants.START_ELEMENT.

Performance Expectation

For some Header implementations, this operation is a non-trivial operation. Therefore, use of this method is discouraged unless the caller is interested in reading the whole header.

Similarly, if the caller wants to use this method only to do the API conversion (such as simply firing SAX events from XMLStreamReader), then the JAX-WS team requests that you talk to us.

Messages that come from tranport usually provides a reasonably efficient implementation of this method.

Specified by:
readHeader in interface SecurityElement
Returns:
must not null.
Throws:
XMLStreamException

writeTo

public void writeTo(OutputStream os)
Specified by:
writeTo in interface SecurityElementWriter

writeTo

public void writeTo(XMLStreamWriter streamWriter)
             throws XMLStreamException
Description copied from interface: SecurityElementWriter
Writes out the header.

Specified by:
writeTo in interface SecurityElementWriter
Throws:
XMLStreamException - if the operation fails for some reason. This leaves the writer to an undefined state.

refersToSecHdrWithId

public boolean refersToSecHdrWithId(String id)
Specified by:
refersToSecHdrWithId in interface SecurityHeaderElement
Parameters:
id -
Returns:

writeTo

public void writeTo(XMLStreamWriter streamWriter,
                    HashMap props)
             throws XMLStreamException
Specified by:
writeTo in interface SecurityElementWriter
Throws:
XMLStreamException


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.