Class AbstractUser

  • All Implemented Interfaces:
    java.security.Principal, User
    Direct Known Subclasses:
    GenericUser

    public abstract class AbstractUser
    extends java.lang.Object
    implements User

    Convenience base class for User implementations.

    Since:
    4.1
    Author:
    Craig R. McClanahan
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String fullName
      The full name of this user.
      protected java.lang.String password
      The logon password of this user.
      protected java.lang.String username
      The logon username of this user.
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractUser()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void addGroup​(Group group)
      Add a new Group to those this user belongs to.
      abstract void addRole​(Role role)
      Add a new Role to those assigned specifically to this user.
      java.lang.String getFullName()
      Return the full name of this user.
      abstract java.util.Iterator<Group> getGroups()
      Return the set of Groups to which this user belongs.
      java.lang.String getName()
      Make the principal name the same as the group name.
      java.lang.String getPassword()
      Return the logon password of this user, optionally prefixed with the identifier of an encoding scheme surrounded by curly braces, such as {md5}xxxxx.
      abstract java.util.Iterator<Role> getRoles()
      Return the set of Roles assigned specifically to this user.
      java.lang.String getUsername()
      Return the logon username of this user, which must be unique within the scope of a UserDatabase.
      abstract boolean isInGroup​(Group group)
      Is this user in the specified Group?
      abstract boolean isInRole​(Role role)
      Is this user specifically assigned the specified Role?
      abstract void removeGroup​(Group group)
      Remove a Group from those this user belongs to.
      abstract void removeGroups()
      Remove all Groups from those this user belongs to.
      abstract void removeRole​(Role role)
      Remove a Role from those assigned to this user.
      abstract void removeRoles()
      Remove all Roles from those assigned to this user.
      void setFullName​(java.lang.String fullName)
      Set the full name of this user.
      void setPassword​(java.lang.String password)
      Set the logon password of this user, optionally prefixed with the identifier of an encoding scheme surrounded by curly braces, such as {md5}xxxxx.
      void setUsername​(java.lang.String username)
      Set the logon username of this user, which must be unique within the scope of a UserDatabase.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.security.Principal

        equals, hashCode, implies, toString
    • Field Detail

      • fullName

        protected java.lang.String fullName
        The full name of this user.
      • password

        protected java.lang.String password
        The logon password of this user.
      • username

        protected java.lang.String username
        The logon username of this user.
    • Constructor Detail

      • AbstractUser

        public AbstractUser()
    • Method Detail

      • getFullName

        public java.lang.String getFullName()
        Return the full name of this user.
        Specified by:
        getFullName in interface User
        Returns:
        the full name of this user.
      • setFullName

        public void setFullName​(java.lang.String fullName)
        Set the full name of this user.
        Specified by:
        setFullName in interface User
        Parameters:
        fullName - The new full name
      • getGroups

        public abstract java.util.Iterator<Group> getGroups()
        Return the set of Groups to which this user belongs.
        Specified by:
        getGroups in interface User
        Returns:
        the set of Groups to which this user belongs.
      • getPassword

        public java.lang.String getPassword()
        Return the logon password of this user, optionally prefixed with the identifier of an encoding scheme surrounded by curly braces, such as {md5}xxxxx.
        Specified by:
        getPassword in interface User
        Returns:
        the logon password of this user, optionally prefixed with the identifier of an encoding scheme surrounded by curly braces, such as {md5}xxxxx.
      • setPassword

        public void setPassword​(java.lang.String password)
        Set the logon password of this user, optionally prefixed with the identifier of an encoding scheme surrounded by curly braces, such as {md5}xxxxx.
        Specified by:
        setPassword in interface User
        Parameters:
        password - The new logon password
      • getRoles

        public abstract java.util.Iterator<Role> getRoles()
        Return the set of Roles assigned specifically to this user.
        Specified by:
        getRoles in interface User
        Returns:
        the set of Roles assigned specifically to this user.
      • getUsername

        public java.lang.String getUsername()
        Return the logon username of this user, which must be unique within the scope of a UserDatabase.
        Specified by:
        getUsername in interface User
        Returns:
        the logon username of this user, which must be unique within the scope of a UserDatabase.
      • setUsername

        public void setUsername​(java.lang.String username)
        Set the logon username of this user, which must be unique within the scope of a UserDatabase.
        Specified by:
        setUsername in interface User
        Parameters:
        username - The new logon username
      • addGroup

        public abstract void addGroup​(Group group)
        Add a new Group to those this user belongs to.
        Specified by:
        addGroup in interface User
        Parameters:
        group - The new group
      • addRole

        public abstract void addRole​(Role role)
        Add a new Role to those assigned specifically to this user.
        Specified by:
        addRole in interface User
        Parameters:
        role - The new role
      • isInGroup

        public abstract boolean isInGroup​(Group group)
        Is this user in the specified Group?
        Specified by:
        isInGroup in interface User
        Parameters:
        group - The group to check
        Returns:
        true if the user is in the specified group
      • isInRole

        public abstract boolean isInRole​(Role role)
        Is this user specifically assigned the specified Role? This method does NOT check for roles inherited based on Group membership.
        Specified by:
        isInRole in interface User
        Parameters:
        role - The role to check
        Returns:
        true if the user has the specified role
      • removeGroup

        public abstract void removeGroup​(Group group)
        Remove a Group from those this user belongs to.
        Specified by:
        removeGroup in interface User
        Parameters:
        group - The old group
      • removeGroups

        public abstract void removeGroups()
        Remove all Groups from those this user belongs to.
        Specified by:
        removeGroups in interface User
      • removeRole

        public abstract void removeRole​(Role role)
        Remove a Role from those assigned to this user.
        Specified by:
        removeRole in interface User
        Parameters:
        role - The old role
      • removeRoles

        public abstract void removeRoles()
        Remove all Roles from those assigned to this user.
        Specified by:
        removeRoles in interface User
      • getName

        public java.lang.String getName()
        Make the principal name the same as the group name.
        Specified by:
        getName in interface java.security.Principal