IBM WebSphere Application ServerTM
Release 7

com.ibm.wsspi.wssecurity.auth.token
Class UsernameToken

java.lang.Object
  extended by com.ibm.wsspi.wssecurity.auth.token.WSSToken
      extended by com.ibm.wsspi.wssecurity.auth.token.UsernameToken
All Implemented Interfaces:
PropagationToken, Token, java.lang.Cloneable

public class UsernameToken
extends WSSToken

This class is a token object implementation for a username token that stores the username and password information of the token. It extends the WSSToken class, which implements the Token class. It will typically be created by the UsernameTokenGenerator and process by the UsernameTokenConsumer. Protected by following Java 2 Security Permissions: com.ibm.websphere.security.WebSphereRuntimePermission("wssecurity.UsernameToken.setUsername") com.ibm.websphere.security.WebSphereRuntimePermission("wssecurity.UsernameToken.getPassword") com.ibm.websphere.security.WebSphereRuntimePermission("wssecurity.UsernameToken.setPassword") com.ibm.websphere.security.WebSphereRuntimePermission("wssecurity.UsernameToken.setExpiration")


Nested Class Summary
 
Nested classes/interfaces inherited from class com.ibm.wsspi.wssecurity.auth.token.WSSToken
WSSToken.AttributesEnumerator
 
Field Summary
 
Fields inherited from class com.ibm.wsspi.wssecurity.auth.token.WSSToken
_attributes, _callerChecked, _error, _keyInfoType, _processed, _referenced, _tokenelem, _tokenId, _trusted, _usedTokenConsumer, _usedTokenGenerator, _usedToLogin, _version, _vtype
 
Constructor Summary
UsernameToken(java.lang.String tokenId, java.lang.String username, char[] password)
          Constructor using a username and password.
UsernameToken(java.lang.String tokenId, java.lang.String username, char[] password, org.w3c.dom.Element elem)
          Constructor using a username, password and token element.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.util.Date getDate()
          Returns created date.
 long getExpiration()
           This returns the expiration time in milli-seconds.
 char[] getPassword()
          Returns the password char array.
 java.lang.String getPrincipal()
           Gets the principal that this Token belongs to.
 java.lang.String getUniqueID()
           Returns a unique identifier of the token based upon information that the provider considers to be unique.
 java.lang.String getUsername()
          Returns the username string.
 int hashCode()
           
 boolean isValid()
           Called by the runtime to determine if a token is valid still in terms of expiration, digital signature, etc.
 void setDate(java.util.Date date)
          Sets created date.
 void setExpiration(long expiration)
           
 void setPassword(char[] password)
          Sets the password string.
 void setUsername(java.lang.String username)
          Sets the username string.
 java.lang.String toString()
           
 
Methods inherited from class com.ibm.wsspi.wssecurity.auth.token.WSSToken
addAttribute, clone, getAttributeNames, getAttributes, getBytes, getCallerChecked, getElement, getError, getId, getKeyInfoType, getName, getType, getUsedTokenConsumer, getUsedTokenGenerator, getUsedToLogin, getVersion, isForwardable, isProcessed, isReadOnly, isReferenced, isTrusted, setCallerChecked, setElement, setError, setId, setKeyInfoType, setProcessed, setReadOnly, setReferenced, setTrusted, setType, setType, setUsedTokenConsumer, setUsedTokenGenerator, setUsedToLogin
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UsernameToken

public UsernameToken(java.lang.String tokenId,
                     java.lang.String username,
                     char[] password)
Constructor using a username and password.

Parameters:
tokenId - The token ID
username - The username string
password - The password as a char[]; may be null if the token does not have a password

UsernameToken

public UsernameToken(java.lang.String tokenId,
                     java.lang.String username,
                     char[] password,
                     org.w3c.dom.Element elem)
Constructor using a username, password and token element.

Parameters:
tokenId - The token ID
username - The username string
password - The password as a char[]; may be null if the token does not have a password
elem - The token element
Method Detail

setDate

public void setDate(java.util.Date date)
Sets created date.

Parameters:
date - The created date

getDate

public java.util.Date getDate()
Returns created date.

Returns:
Date The created date

setUsername

public void setUsername(java.lang.String username)
Sets the username string. Protected by Java 2 Security Permission com.ibm.websphere.security.WebSphereRuntimePermission("wssecurity.UsernameToken.setUsername")


getUsername

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

Returns:
String The username

setPassword

public void setPassword(char[] password)
Sets the password string. Protected by Java 2 Security Permission com.ibm.websphere.security.WebSphereRuntimePermission("wssecurity.UsernameToken.setPassword")


getPassword

public char[] getPassword()
Returns the password char array.

Returns:
char[] The password Protected by Java 2 Security permission com.ibm.websphere.security.WebSphereRuntimePermission("wssecurity.UsernameToken.getPassword")

getExpiration

public long getExpiration()
Description copied from interface: Token

This returns the expiration time in milli-seconds.

Returns:
long

setExpiration

public void setExpiration(long expiration)
Parameters:
expiration - Protected by Java 2 Security permission com.ibm.websphere.security.WebSphereRuntimePermission("wssecurity.UsernameToken.setExpiration")

getPrincipal

public java.lang.String getPrincipal()
Description copied from interface: Token

Gets the principal that this Token belongs to. If this is an authorization token, this principal string must match the authentication token principal string or the message will be rejected. CSIv2 has stringent rules about validating authorization tokens using either the Identity Token or Authentication Token principal.

Returns:
String

getUniqueID

public java.lang.String getUniqueID()
Description copied from interface: Token

Returns a unique identifier of the token based upon information that the provider considers to be unique. This will be used for caching purposes and may be used in combination with other token unique IDs that are part of the same Subject to form a Subject unique identifier.

An implementation of this method should be careful to only change the token uniqueness when required. Any login which generates a new unique ID will create a Subject entry in the cache, which will increase memory requirements.

This method should return null if the token does not need to affect the cache uniqueness. Typically, if using only static registry attributes, this should return null. However, if dynamic attributes are used including strength of authentication, time of day, etc. you may affect the cache uniqueness by returning a non-null value that reflects how you want the cache key too look. Typically, the token implementation will know what is most unique about the dynamic data, however, an alternative is to return a UUID. The values of getUniqueID() from all custom tokens present in the Subject will be added together and used in the SSO token for lookup. A one-way hash of this string will be created as the unique ID. When altering a token to contain a non-null value here, the token must be added to the Subject prior to the commit phase or before the wsMap module commit is called.

Returns:
String

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

isValid

public boolean isValid()
Description copied from interface: Token

Called by the runtime to determine if a token is valid still in terms of expiration, digital signature, etc. The implementation determines what valid means. If this returns false to the WebSphere runtime, an exception will be thrown (appropriate to where the call was made, e.g., NO_PERMISSION, WSLoginFailedException, etc.) and the request will be rejected.

Returns:
boolean

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

IBM WebSphere Application ServerTM
Release 7