Oracle Security Developer Tools Web Services Security Java API Reference
10g Release 2 (10.1.2.0.2)

B15570-01


oracle.security.xmlsec.wss.username
Class UsernameToken

java.lang.Object
  extended byoracle.security.xmlsec.util.XMLNode
      extended byoracle.security.xmlsec.util.XMLElement
          extended byoracle.security.xmlsec.wss.WSSElement
              extended byoracle.security.xmlsec.wss.username.UsernameToken

All Implemented Interfaces:
WSSecurityToken

public class UsernameToken
extends WSSElement
implements WSSecurityToken

Represents a WSS UsernameToken element.


Field Summary
static java.lang.String PASSWORD_DIGEST
Specifies that the type of password is a digest of the password.
static java.lang.String PASSWORD_TEXT
Specifies that the type of password is a plaintext password, derived password or a password hash.

Fields inherited from class oracle.security.xmlsec.util.XMLNode
node, systemId

Constructor Summary
UsernameToken(org.w3c.dom.Document owner)
Create a new UsernameToken instance.
UsernameToken(org.w3c.dom.Element element)
Create a new UsernameToken instance from the given XML element.
UsernameToken(org.w3c.dom.Element element, java.lang.String systemId)
Create a new UsernameToken instance from the given XML element.

Method Summary
static void addKeyDerivator(KeyDerivator resolver)
Register a KeyDerivatorResolver instance for use in key identifier resolver operations.
static void addPasswordRetriever(PasswordRetriever resolver)
Register a PasswordRetriever instance to lookup the password.
byte[] computePasswordDigest(byte[] nonce, WSUCreated created, char[] passwd)
Creates the SHA-1 digest of the the given password and optionally nonce and/or creation timpstamp.
byte[] createSecretKey()
Creates a secret key for HMAC signature from this Username token.
byte[] createSecretKey(char[] passwd)
Creates a secret key for HMAC signature from this Username token.
WSUCreated getCreated()
Returns the token creation timestamp.
SymmetricKey getKey()
Get the cryptographic key corresponding to the token contents.
byte[] getNonce()
Returns the nonce.
char[] getPassword()
Gets the plaintext password (or password equivalent) stored in the Password child element in this structure.
byte[] getPasswordDigest()
Gets the digest of the password and optionally nonce and/or creation timestamp stored in the Password child element in this structure.
java.lang.String getPasswordType()
Returns the type of password.
java.lang.Object getToken()
Get the token contents.
oracle.security.xmlsec.util.QName getTokenName()
Returns the token name.
java.lang.String getUsername()
Returns the username value.
boolean isValid()
Checks if the information stored in this token is valid.
boolean isValid(java.lang.String userName, char[] passwd)
Checks if the information stored in this token is valid against the given user name and password pair.
void setCreated(WSUCreated created)
Set the token creation timestamp.
void setNonce(byte[] nonce)
Sets the Nonce element with the specified value and the default Base64 encoding.
void setNonce(byte[] nonce, java.lang.String encType)
Sets the Nonce element with the specified value and encoding type of the nonce.
void setPassword(char[] passwd)
Sets the Password element with the plain text text password (or password equivalent) of the user.
void setPassword(char[] password, java.lang.String passwordType)
Sets the Password element.
void setUsername(java.lang.String userName)
Sets the username value.

Methods inherited from class oracle.security.xmlsec.wss.WSSElement
getId, getWsuId, setId, setWsuId

Methods inherited from class oracle.security.xmlsec.util.XMLElement
addNSPrefixAttr, addNSPrefixAttr, addNSPrefixAttrDefault, addNSPrefixAttrDefault, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getChildElementsByTagName, getChildElementsByTagName, getChildElementsByTagNameNS, getChildElementsByTagNameNS, getDefaultNSPrefix, getElementsByTagName, getElementsByTagNameNS, getTagName, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setDefaultNSPrefix

Methods inherited from class oracle.security.xmlsec.util.XMLNode
appendChild, appendChild, appendTo, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getSystemId, hasAttributes, hasChildNodes, insertBefore, insertBefore, isSupported, normalize, removeChild, removeChild, replaceChild, replaceChild, setNodeValue, setPrefix, setSystemId, toBytesXML, toStringXML

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface oracle.security.xmlsec.wss.WSSecurityToken
getNode

Field Detail

PASSWORD_TEXT

public static final java.lang.String PASSWORD_TEXT
Specifies that the type of password is a plaintext password, derived password or a password hash.
See Also:
Constant Field Values

PASSWORD_DIGEST

public static final java.lang.String PASSWORD_DIGEST
Specifies that the type of password is a digest of the password.
See Also:
Constant Field Values

Constructor Detail

UsernameToken

public UsernameToken(org.w3c.dom.Element element)
Create a new UsernameToken instance from the given XML element.
Parameters:
element - A wsse:UsernameToken element.

UsernameToken

public UsernameToken(org.w3c.dom.Element element,
                     java.lang.String systemId)
Create a new UsernameToken instance from the given XML element.
Parameters:
element - A wsse:UsernameToken element.
systemId - The URI string system ID for this element.

UsernameToken

public UsernameToken(org.w3c.dom.Document owner)
Create a new UsernameToken instance.
Parameters:
owner - A XML Document to be used as the owner document of this structure.

Method Detail

setUsername

public void setUsername(java.lang.String userName)
Sets the username value.
Parameters:
userName - The username string.

getUsername

public java.lang.String getUsername()
Returns the username value.
Returns:
The username string.

setNonce

public void setNonce(byte[] nonce)
Sets the Nonce element with the specified value and the default Base64 encoding.
Parameters:
nonce - The nonce bytes.

setNonce

public void setNonce(byte[] nonce,
                     java.lang.String encType)
Sets the Nonce element with the specified value and encoding type of the nonce.
Parameters:
nonce - The nonce bytes.
encType - The encoding type of the nonce.

getNonce

public byte[] getNonce()
Returns the nonce.
Returns:
The nonce bytes.

setCreated

public void setCreated(WSUCreated created)
Set the token creation timestamp.
Parameters:
created - The creation timestamp.

getCreated

public WSUCreated getCreated()
Returns the token creation timestamp.
Returns:
The creation timestamp.

setPassword

public void setPassword(char[] passwd)
Sets the Password element with the plain text text password (or password equivalent) of the user.
Parameters:
passwd - The clear text password (or password equivalent) of the user.

setPassword

public void setPassword(char[] password,
                        java.lang.String passwordType)
Sets the Password element. The actual value stored in this element depends on the password type provided.
Parameters:
password - The clear text password (or password equivalent) of the user. If the password is null, the PasswordRetriever will be used to lookup the passwd.
passwordType - The value for the Type attribute which specifies the type of password being provided in this token.

getPasswordType

public java.lang.String getPasswordType()
Returns the type of password.
Returns:
The password type URI.

getPassword

public char[] getPassword()
Gets the plaintext password (or password equivalent) stored in the Password child element in this structure. Returns null if PasswordDigest type is used.
Returns:
The raw bytes of the password.

getPasswordDigest

public byte[] getPasswordDigest()
Gets the digest of the password and optionally nonce and/or creation timestamp stored in the Password child element in this structure. Returns null if PasswordDigest type is not used.
Returns:
The raw bytes of the digested password.

isValid

public boolean isValid()
Checks if the information stored in this token is valid.
Returns:
Returns true if the supplied credentials match the token credentials or false otherwise.

isValid

public boolean isValid(java.lang.String userName,
                       char[] passwd)
Checks if the information stored in this token is valid against the given user name and password pair.
Parameters:
userName - The user name value.
passwd - The password value. If the password is null, the PasswordRetriever will be used to lookup the passwd.
Returns:
Returns true if the supplied credentials match the token credentials or false otherwise.

createSecretKey

public byte[] createSecretKey()
Creates a secret key for HMAC signature from this Username token.
Returns:
Returns the secret key bytes or null if the Password child element is not available.

createSecretKey

public byte[] createSecretKey(char[] passwd)
Creates a secret key for HMAC signature from this Username token.
Parameters:
passwd - The password to use in the secret key generation. If the password is null, the PasswordRetriever will be used to lookup the passwd.
Returns:
Returns the secret key bytes or null.

computePasswordDigest

public byte[] computePasswordDigest(byte[] nonce,
                                    WSUCreated created,
                                    char[] passwd)
Creates the SHA-1 digest of the the given password and optionally nonce and/or creation timpstamp.
Parameters:
nonce - The nonce bytes.
created - The token creation timestamp
passwd - The password bytes. If the password is null, the PasswordRetriever will be used to lookup the passwd.
Returns:
The computed password digest bytes.

getTokenName

public oracle.security.xmlsec.util.QName getTokenName()
Returns the token name.
Specified by:
getTokenName in interface WSSecurityToken
Returns:
The QName of the token.

getToken

public java.lang.Object getToken()
Get the token contents.

Returns a java.lang.String containing the Username from the Username token.

Specified by:
getToken in interface WSSecurityToken
Returns:
The Username.

getKey

public SymmetricKey getKey()
                    throws WSSException
Get the cryptographic key corresponding to the token contents.

Returns the secret HMAC or Key byte[] derived from the supplied password.

Returns:
The Username.
Throws:
WSSException

addPasswordRetriever

public static void addPasswordRetriever(PasswordRetriever resolver)
Register a PasswordRetriever instance to lookup the password.
Parameters:
resolver - The resolver to use to lookup the password.

addKeyDerivator

public static void addKeyDerivator(KeyDerivator resolver)
Register a KeyDerivatorResolver instance for use in key identifier resolver operations.
Parameters:
resolver - The resolver to use for key derivation.

Oracle Security Developer Tools Web Services Security Java API Reference
10g Release 2 (10.1.2.0.2)

B15570-01


Copyright © 2005 , Oracle. All rights reserved.