Class UserDatabaseRealm.UserDatabasePrincipal

  • All Implemented Interfaces:
    java.io.Serializable, java.security.Principal, TomcatPrincipal
    Enclosing class:
    UserDatabaseRealm

    public static final class UserDatabaseRealm.UserDatabasePrincipal
    extends GenericPrincipal
    Principal implementation backed by a live UserDatabase. Roles are fetched from the database on each call rather than cached at construction time.
    See Also:
    Serialized Form
    • Constructor Detail

      • UserDatabasePrincipal

        public UserDatabasePrincipal​(User user,
                                     UserDatabase database)
        Constructs a new UserDatabasePrincipal.
        Parameters:
        user - The user
        database - The user database
    • Method Detail

      • getRoles

        public java.lang.String[] getRoles()
        Description copied from class: GenericPrincipal
        Returns the set of roles associated with this user.
        Overrides:
        getRoles in class GenericPrincipal
        Returns:
        A cloned array of role names
      • hasRole

        public boolean hasRole​(java.lang.String role)
        Description copied from class: GenericPrincipal
        Does the user represented by this Principal possess the specified role?
        Overrides:
        hasRole in class GenericPrincipal
        Parameters:
        role - Role to be tested
        Returns:
        true if this Principal has been assigned the given role, otherwise false