Class UserNameAndPassword

java.lang.Object
org.glassfish.security.common.UserNameAndPassword
All Implemented Interfaces:
Serializable, Principal, UserPrincipal

public class UserNameAndPassword extends Object implements UserPrincipal
Concrete implementation of UserPrincipal with username and password.
  • The password is not mandatory, it can be null.
  • Two instances are equal if they have the same name and the same password.
Author:
David Matejcek
See Also:
  • Constructor Details

    • UserNameAndPassword

      public UserNameAndPassword(String name)
      Parameters:
      name - non-null name
    • UserNameAndPassword

      public UserNameAndPassword(String name, String password)
      Parameters:
      name - non-null name
      password - can be null.
    • UserNameAndPassword

      public UserNameAndPassword(String name, char[] password)
      Parameters:
      name - non-null name
      password - can be null.
  • Method Details

    • getName

      public final String getName()
      Specified by:
      getName in interface Principal
      Returns:
      never null.
    • getStringPassword

      public final String getStringPassword()
      Returns:
      password as a string, can be null.
    • getPassword

      public final char[] getPassword()
      Returns:
      password as a string, can be null.
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Principal
      Overrides:
      equals in class Object
      Returns:
      true if the object is an instance of UserNameAndPassword and has the same name and the same password.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Principal
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Specified by:
      toString in interface Principal
      Overrides:
      toString in class Object