Package org.apache.ws.security
Class WSUsernameTokenPrincipal
- java.lang.Object
-
- org.apache.ws.security.WSUsernameTokenPrincipal
-
- All Implemented Interfaces:
java.io.Serializable
,java.security.Principal
public class WSUsernameTokenPrincipal extends java.lang.Object implements java.security.Principal, java.io.Serializable
This class implements thePrincipal
interface and represents a UsernameToken user. In addition to the principal's name this principal object also conatins 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 typePasswordDigest
. 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. Theequals()
method use the prinicipal's name only and does not compare nonce or created time. Modeled 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
Constructors Constructor Description WSUsernameTokenPrincipal(java.lang.String name, boolean digest)
Create a WSUsernameTokenPrincipal with a WSUsernameToken username.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
Compares the specified Object with thisWSUsernameTokenPrincipal
for equality.java.lang.String
getCreatedTime()
Return the WSUsernameToken created time for thisWSUsernameTokenPrincipal
.java.lang.String
getName()
Return the WSUsernameToken username for thisWSUsernameTokenPrincipal
.java.lang.String
getNonce()
Return the WSUsernameToken nonce for thisWSUsernameTokenPrincipal
.java.lang.String
getPassword()
Return the WSUsernameToken password for thisWSUsernameTokenPrincipal
.java.lang.String
getPasswordType()
int
hashCode()
Return a hash code for thisWSUsernameTokenPrincipal
.boolean
isPasswordDigest()
Return the WSUsernameToken password type for thisWSUsernameTokenPrincipal
.void
setCreatedTime(java.lang.String createdTime)
Set the WSUsernameToken created time for thisWSUsernameTokenPrincipal
.void
setNonce(java.lang.String nonce)
Set the WSUsernameToken nonce for thisWSUsernameTokenPrincipal
.void
setPassword(java.lang.String password)
Set the WSUsernameToken password for thisWSUsernameTokenPrincipal
.void
setPasswordType(java.lang.String passwordType)
java.lang.String
toString()
Return a string representation of thisWSUsernameTokenPrincipal
.
-
-
-
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 thename
isnull
.
-
-
Method Detail
-
getName
public java.lang.String getName()
Return the WSUsernameToken username for thisWSUsernameTokenPrincipal
.- Specified by:
getName
in interfacejava.security.Principal
- Returns:
- the WSUsernameToken username for this
WSUsernameTokenPrincipal
-
isPasswordDigest
public boolean isPasswordDigest()
Return the WSUsernameToken password type for thisWSUsernameTokenPrincipal
.- Returns:
- true if the password type was
PassowrdDigest
-
setPassword
public void setPassword(java.lang.String password)
Set the WSUsernameToken password for thisWSUsernameTokenPrincipal
.- Parameters:
password
-
-
getPassword
public java.lang.String getPassword()
Return the WSUsernameToken password for thisWSUsernameTokenPrincipal
.- Returns:
- the WSUsernameToken password for this
WSUsernameTokenPrincipal
-
setNonce
public void setNonce(java.lang.String nonce)
Set the WSUsernameToken nonce for thisWSUsernameTokenPrincipal
.- Parameters:
nonce
-
-
getNonce
public java.lang.String getNonce()
Return the WSUsernameToken nonce for thisWSUsernameTokenPrincipal
.- Returns:
- the WSUsernameToken nonce for this
WSUsernameTokenPrincipal
-
setCreatedTime
public void setCreatedTime(java.lang.String createdTime)
Set the WSUsernameToken created time for thisWSUsernameTokenPrincipal
.- Parameters:
createdTime
-
-
getCreatedTime
public java.lang.String getCreatedTime()
Return the WSUsernameToken created time for thisWSUsernameTokenPrincipal
.- Returns:
- the WSUsernameToken created time for this
WSUsernameTokenPrincipal
-
toString
public java.lang.String toString()
Return a string representation of thisWSUsernameTokenPrincipal
.- Specified by:
toString
in interfacejava.security.Principal
- Overrides:
toString
in classjava.lang.Object
- 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 thisWSUsernameTokenPrincipal
for equality. Returns true if the given object is also aWSUsernameTokenPrincipal
and the two WSUsernameTokenPrincipals have the same username.- Specified by:
equals
in interfacejava.security.Principal
- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- Object to be compared for equality with thisWSUsernameTokenPrincipal
.- Returns:
- true if the specified Object is equal equal to this
WSUsernameTokenPrincipal
.
-
hashCode
public int hashCode()
Return a hash code for thisWSUsernameTokenPrincipal
.- Specified by:
hashCode
in interfacejava.security.Principal
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code for this
WSUsernameTokenPrincipal
.
-
-