Package org.apache.catalina.realm
Class UserDatabaseRealm.UserDatabasePrincipal
- java.lang.Object
-
- org.apache.catalina.realm.GenericPrincipal
-
- org.apache.catalina.realm.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 liveUserDatabase. Roles are fetched from the database on each call rather than cached at construction time.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.catalina.realm.GenericPrincipal
attributes, gssCredential, loginContext, name, roles, userPrincipal
-
-
Constructor Summary
Constructors Constructor Description UserDatabasePrincipal(User user, UserDatabase database)Constructs a new UserDatabasePrincipal.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]getRoles()Returns the set of roles associated with this user.booleanhasRole(java.lang.String role)Does the user represented by this Principal possess the specified role?-
Methods inherited from class org.apache.catalina.realm.GenericPrincipal
equals, getAttribute, getAttributeNames, getGssCredential, getName, getUserPrincipal, hashCode, logout, setGssCredential, toString
-
-
-
-
Constructor Detail
-
UserDatabasePrincipal
public UserDatabasePrincipal(User user, UserDatabase database)
Constructs a new UserDatabasePrincipal.- Parameters:
user- The userdatabase- The user database
-
-
Method Detail
-
getRoles
public java.lang.String[] getRoles()
Description copied from class:GenericPrincipalReturns the set of roles associated with this user.- Overrides:
getRolesin classGenericPrincipal- Returns:
- A cloned array of role names
-
hasRole
public boolean hasRole(java.lang.String role)
Description copied from class:GenericPrincipalDoes the user represented by this Principal possess the specified role?- Overrides:
hasRolein classGenericPrincipal- Parameters:
role- Role to be tested- Returns:
trueif this Principal has been assigned the given role, otherwisefalse
-
-