org.apache.ws.security
Class WSUsernameTokenPrincipal

java.lang.Object
  extended byorg.apache.ws.security.WSUsernameTokenPrincipal
All Implemented Interfaces:
java.security.Principal, java.io.Serializable

public class WSUsernameTokenPrincipal
extends java.lang.Object
implements java.security.Principal, java.io.Serializable

This class implements the Principal interface and represents a UsernameToken user.

In addition to the principal's name this principal object also contains the nonce and created time of the UsernameToken (refer to the OASIS WS Security specification, UsernameToken profile). These values are set only if the password of UsernameToken was of type PasswordDigest.

Furthermore the password type is provided to the application. The password type is the string of the type attribute of the password element inside the username token. Refer to the OASIS WSS specification for predefined password types.

The equals() method use the prinicipal's name only and does not compare nonce or created time.

Modelled according to the example provided by JAAS documentation

Author:
Davanum Srinivas (dims@yahoo.com)., Werner Dittmann (Werner.Dittmann@siemens.com).
See Also:
Principal, Subject, Serialized Form

Constructor Summary
WSUsernameTokenPrincipal(java.lang.String name, boolean digest)
          Create a WSUsernameTokenPrincipal with a WSUsernameToken username.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified Object with this WSUsernameTokenPrincipal for equality.
 java.lang.String getCreatedTime()
          Return the WSUsernameToken created time for this WSUsernameTokenPrincipal.
 java.lang.String getName()
          Return the WSUsernameToken username for this WSUsernameTokenPrincipal.
 java.lang.String getNonce()
          Return the WSUsernameToken nonce for this WSUsernameTokenPrincipal.
 java.lang.String getPassword()
          Return the WSUsernameToken password for this WSUsernameTokenPrincipal.
 java.lang.String getPasswordType()
           
 int hashCode()
          Return a hash code for this WSUsernameTokenPrincipal.
 boolean isPasswordDigest()
          Return the WSUsernameToken password type for this WSUsernameTokenPrincipal.
 void setCreatedTime(java.lang.String createdTime)
          Set the WSUsernameToken created time for this WSUsernameTokenPrincipal.
 void setNonce(java.lang.String nonce)
          Set the WSUsernameToken nonce for this WSUsernameTokenPrincipal.
 void setPassword(java.lang.String password)
          Set the WSUsernameToken password for this WSUsernameTokenPrincipal.
 void setPasswordType(java.lang.String passwordType)
           
 java.lang.String toString()
          Return a string representation of this WSUsernameTokenPrincipal.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WSUsernameTokenPrincipal

public WSUsernameTokenPrincipal(java.lang.String name,
                                boolean digest)
Create a WSUsernameTokenPrincipal with a WSUsernameToken username.

Parameters:
name - the WSUsernameToken username for this user.
Throws:
java.lang.NullPointerException - if the name is null.
Method Detail

getName

public java.lang.String getName()
Return the WSUsernameToken username for this WSUsernameTokenPrincipal.

Specified by:
getName in interface java.security.Principal
Returns:
the WSUsernameToken username for this WSUsernameTokenPrincipal

isPasswordDigest

public boolean isPasswordDigest()
Return the WSUsernameToken password type for this WSUsernameTokenPrincipal.

Returns:
true if the password type was PassowrdDigest

setPassword

public void setPassword(java.lang.String password)
Set the WSUsernameToken password for this WSUsernameTokenPrincipal.

Parameters:
password -

getPassword

public java.lang.String getPassword()
Return the WSUsernameToken password for this WSUsernameTokenPrincipal.

Returns:
the WSUsernameToken password for this WSUsernameTokenPrincipal

setNonce

public void setNonce(java.lang.String nonce)
Set the WSUsernameToken nonce for this WSUsernameTokenPrincipal.

Parameters:
nonce -

getNonce

public java.lang.String getNonce()
Return the WSUsernameToken nonce for this WSUsernameTokenPrincipal.

Returns:
the WSUsernameToken nonce for this WSUsernameTokenPrincipal

setCreatedTime

public void setCreatedTime(java.lang.String createdTime)
Set the WSUsernameToken created time for this WSUsernameTokenPrincipal.

Parameters:
createdTime -

getCreatedTime

public java.lang.String getCreatedTime()
Return the WSUsernameToken created time for this WSUsernameTokenPrincipal.

Returns:
the WSUsernameToken created time for this WSUsernameTokenPrincipal

toString

public java.lang.String toString()
Return a string representation of this WSUsernameTokenPrincipal.

Specified by:
toString in interface java.security.Principal
Returns:
a string representation of this WSUsernameTokenPrincipal.

getPasswordType

public java.lang.String getPasswordType()
Returns:
Returns the passwordType.

setPasswordType

public void setPasswordType(java.lang.String passwordType)
Parameters:
passwordType - The passwordType to set.

equals

public boolean equals(java.lang.Object o)
Compares the specified Object with this WSUsernameTokenPrincipal for equality. Returns true if the given object is also a WSUsernameTokenPrincipal and the two WSUsernameTokenPrincipals have the same username.

Specified by:
equals in interface java.security.Principal
Parameters:
o - Object to be compared for equality with this WSUsernameTokenPrincipal.
Returns:
true if the specified Object is equal equal to this WSUsernameTokenPrincipal.

hashCode

public int hashCode()
Return a hash code for this WSUsernameTokenPrincipal.

Specified by:
hashCode in interface java.security.Principal
Returns:
a hash code for this WSUsernameTokenPrincipal.


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.