Class GenericPrincipal

  • All Implemented Interfaces:
    Principal

    public class GenericPrincipal
    extends Object
    implements Principal
    Generic implementation of java.security.Principal that is available for use by Realm implementations.
    Version:
    $Revision: 1.2 $ $Date: 2005/12/08 01:27:52 $
    Author:
    Craig R. McClanahan
    • Field Detail

      • name

        protected String name
        The username of the user represented by this Principal.
      • password

        protected char[] password
        The authentication credentials for the user represented by this Principal.
      • realm

        protected Realm realm
        The Realm with which this Principal is associated.
      • roles

        protected String[] roles
        The set of roles associated with this user.
    • Constructor Detail

      • GenericPrincipal

        public GenericPrincipal​(Realm realm,
                                String name,
                                char[] password)
        Construct a new Principal, associated with the specified Realm, for the specified username and password.
        Parameters:
        realm - The Realm that owns this Principal
        name - The username of the user represented by this Principal
        password - Credentials used to authenticate this user
      • GenericPrincipal

        public GenericPrincipal​(Realm realm,
                                String name,
                                char[] password,
                                List<String> roles)
        Construct a new Principal, associated with the specified Realm, for the specified username and password, with the specified role names (as Strings).
        Parameters:
        realm - The Realm that owns this principal
        name - The username of the user represented by this Principal
        password - Credentials used to authenticate this user
        roles - List of roles (must be Strings) possessed by this user
      • GenericPrincipal

        public GenericPrincipal​(String name,
                                char[] password,
                                List<String> roles)
    • Method Detail

      • getPassword

        public char[] getPassword()
      • getRealm

        public Realm getRealm()
      • getRoles

        public String[] getRoles()
      • hasRole

        public boolean hasRole​(String role)
        Does the user represented by this Principal possess the specified role?
        Parameters:
        role - Role to be tested
      • toString

        public String toString()
        Return a String representation of this object, which exposes only information that should be public.
        Specified by:
        toString in interface Principal
        Overrides:
        toString in class Object