Class UserNameToken

  • All Implemented Interfaces:
    SecurityToken

    public class UserNameToken
    extends Object
    implements SecurityToken
    This class UserNameToken represents an Username token that can be inserted into web services security header for message level security.

    This class implements SecurityToken and can be created through security token factory.

    • Constructor Detail

      • UserNameToken

        public UserNameToken​(UserNameTokenSpec tokenSpec)
                      throws SecurityException
        Constructs a user name token with the user name token specification.
        Parameters:
        tokenSpec - the user name token specification.
        Throws:
        SecurityException - if there is a failure.
      • UserNameToken

        public UserNameToken​(Element element)
                      throws SecurityException
        Constructor to create a username token using username token xml element.
        Parameters:
        element - username token xml element.
        Throws:
        SecurityException - if the element parsing fails.
    • Method Detail

      • getUserName

        public String getUserName()
        Returns the username in the username token.
        Returns:
        the user name
      • setUserName

        public void setUserName​(String username)
        Sets the user name in the username token.
        Parameters:
        username - the user name.
      • getPassword

        public String getPassword()
        Returns the password in the username token.
        Returns:
        the password in the username token.
      • getPasswordType

        public String getPasswordType()
        Returns the password type.
        Returns:
        the password type.
      • setPassword

        public void setPassword​(String passwd)
                         throws SecurityException
        Sets the password to the username token.
        Parameters:
        passwd - the password to the username token.
        Throws:
        SecurityException - if the password digest is failed when the digest password type is set.
      • getNonce

        public String getNonce()
        Returns the nonce
        Returns:
        the nonce
      • getCreated

        public String getCreated()
        Returns the created.
        Returns:
        the created.
      • getSigningId

        public String getSigningId()
        Returns the signing id for username token.
        Returns:
        the signing id for the username token.
      • toString

        public String toString()
        Returns as the string format for this username token
        Overrides:
        toString in class Object
      • getTokenType

        public String getTokenType()
        Returns this security token type.
        Specified by:
        getTokenType in interface SecurityToken
        Returns:
        user name security token.
      • getPasswordDigest

        public static String getPasswordDigest​(String password,
                                               String nonce,
                                               String created)
                                        throws SecurityException
        Returns the password digest for the given password using nonce and created timestamp.
        Parameters:
        password - the password that needs to be digested.
        nonce - the nonce that is used to digest the password.
        created - the created that is used to digest the password.
        Throws:
        SecurityException - if the password digest is failed.