Class WSUsernameTokenPrincipalImpl

java.lang.Object
org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl
All Implemented Interfaces:
Serializable, Principal, UsernameTokenPrincipal

public class WSUsernameTokenPrincipalImpl extends Object implements Serializable, UsernameTokenPrincipal
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

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    WSUsernameTokenPrincipalImpl(String name, boolean digest)
    Create a WSUsernameTokenPrincipalImpl with a WSUsernameToken username.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compares the specified Object with this WSUsernameTokenPrincipal for equality.
    Return the WSUsernameToken created time for this WSUsernameTokenPrincipalImpl.
    Return the WSUsernameToken username for this WSUsernameTokenPrincipalImpl.
    byte[]
    Return the WSUsernameToken nonce for this WSUsernameTokenPrincipalImpl.
    Return the WSUsernameToken password for this WSUsernameTokenPrincipalImpl.
     
    int
    Return a hash code for this WSUsernameTokenPrincipalImpl.
    boolean
    Return the WSUsernameToken password type for this WSUsernameTokenPrincipalImpl.
    void
    setCreatedTime(String createdTime)
    Set the WSUsernameToken created time for this WSUsernameTokenPrincipalImpl.
    void
    setNonce(byte[] nonce)
    Set the WSUsernameToken nonce for this WSUsernameTokenPrincipalImpl.
    void
    setPassword(String password)
    Set the WSUsernameToken password for this WSUsernameTokenPrincipalImpl.
    void
    setPasswordType(String passwordType)
     
    Return a string representation of this WSUsernameTokenPrincipalImpl.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.security.Principal

    implies
  • Constructor Details

    • WSUsernameTokenPrincipalImpl

      public WSUsernameTokenPrincipalImpl(String name, boolean digest)
      Create a WSUsernameTokenPrincipalImpl with a WSUsernameToken username.
      Parameters:
      name - the WSUsernameToken username for this user.
  • Method Details

    • getName

      public String getName()
      Return the WSUsernameToken username for this WSUsernameTokenPrincipalImpl.
      Specified by:
      getName in interface Principal
      Returns:
      the WSUsernameToken username for this WSUsernameTokenPrincipalImpl
    • isPasswordDigest

      public boolean isPasswordDigest()
      Return the WSUsernameToken password type for this WSUsernameTokenPrincipalImpl.
      Specified by:
      isPasswordDigest in interface UsernameTokenPrincipal
      Returns:
      true if the password type was PassowrdDigest
    • setPassword

      public void setPassword(String password)
      Set the WSUsernameToken password for this WSUsernameTokenPrincipalImpl.
      Parameters:
      password -
    • getPassword

      public String getPassword()
      Return the WSUsernameToken password for this WSUsernameTokenPrincipalImpl.
      Specified by:
      getPassword in interface UsernameTokenPrincipal
      Returns:
      the WSUsernameToken password for this WSUsernameTokenPrincipalImpl
    • setNonce

      public void setNonce(byte[] nonce)
      Set the WSUsernameToken nonce for this WSUsernameTokenPrincipalImpl.
      Parameters:
      nonce -
    • getNonce

      public byte[] getNonce()
      Return the WSUsernameToken nonce for this WSUsernameTokenPrincipalImpl.
      Specified by:
      getNonce in interface UsernameTokenPrincipal
      Returns:
      the WSUsernameToken nonce for this WSUsernameTokenPrincipalImpl
    • setCreatedTime

      public void setCreatedTime(String createdTime)
      Set the WSUsernameToken created time for this WSUsernameTokenPrincipalImpl.
      Parameters:
      createdTime -
    • getCreatedTime

      public String getCreatedTime()
      Return the WSUsernameToken created time for this WSUsernameTokenPrincipalImpl.
      Specified by:
      getCreatedTime in interface UsernameTokenPrincipal
      Returns:
      the WSUsernameToken created time for this WSUsernameTokenPrincipalImpl
    • toString

      public String toString()
      Return a string representation of this WSUsernameTokenPrincipalImpl.
      Specified by:
      toString in interface Principal
      Overrides:
      toString in class Object
      Returns:
      a string representation of this WSUsernameTokenPrincipalImpl.
    • getPasswordType

      public String getPasswordType()
      Specified by:
      getPasswordType in interface UsernameTokenPrincipal
      Returns:
      Returns the passwordType.
    • setPasswordType

      public void setPasswordType(String passwordType)
      Parameters:
      passwordType - The passwordType to set.
    • equals

      public boolean equals(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 Principal
      Overrides:
      equals in class Object
      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 WSUsernameTokenPrincipalImpl.
      Specified by:
      hashCode in interface Principal
      Overrides:
      hashCode in class Object
      Returns:
      a hash code for this WSUsernameTokenPrincipalImpl.