Package org.apache.catalina.users
Class GenericUser<UD extends UserDatabase>
- java.lang.Object
-
- org.apache.catalina.users.AbstractUser
-
- org.apache.catalina.users.GenericUser<UD>
-
- Type Parameters:
UD
- The specific type of UserDase with which this role is associated
- All Implemented Interfaces:
java.security.Principal
,User
- Direct Known Subclasses:
MemoryUser
public class GenericUser<UD extends UserDatabase> extends AbstractUser
Concrete implementation of
User
for aUserDatabase
.- Author:
- Craig R. McClanahan
-
-
Field Summary
Fields Modifier and Type Field Description protected UD
database
TheUserDatabase
that owns this user.protected java.util.concurrent.CopyOnWriteArrayList<Group>
groups
The set ofGroup
s that this user is a member of.protected java.util.concurrent.CopyOnWriteArrayList<Role>
roles
The set ofRole
s associated with this user.-
Fields inherited from class org.apache.catalina.users.AbstractUser
fullName, password, username
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGroup(Group group)
Add a newGroup
to those this user belongs to.void
addRole(Role role)
Add a newRole
to those assigned specifically to this user.boolean
equals(java.lang.Object obj)
java.util.Iterator<Group>
getGroups()
Return the set ofGroup
s to which this user belongs.java.util.Iterator<Role>
getRoles()
Return the set ofRole
s assigned specifically to this user.UserDatabase
getUserDatabase()
Return theUserDatabase
within which this User is defined.int
hashCode()
boolean
isInGroup(Group group)
Is this user in the specified group?boolean
isInRole(Role role)
Is this user specifically assigned the specifiedRole
?void
removeGroup(Group group)
Remove aGroup
from those this user belongs to.void
removeGroups()
Remove allGroup
s from those this user belongs to.void
removeRole(Role role)
Remove aRole
from those assigned to this user.void
removeRoles()
Remove allRole
s 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 aUserDatabase
.-
Methods inherited from class org.apache.catalina.users.AbstractUser
getFullName, getName, getPassword, getUsername
-
-
-
-
Field Detail
-
database
protected final UD extends UserDatabase database
TheUserDatabase
that owns this user.
-
groups
protected final java.util.concurrent.CopyOnWriteArrayList<Group> groups
The set ofGroup
s that this user is a member of.
-
-
Method Detail
-
getGroups
public java.util.Iterator<Group> getGroups()
Return the set ofGroup
s to which this user belongs.- Specified by:
getGroups
in interfaceUser
- Specified by:
getGroups
in classAbstractUser
- Returns:
- the set of
Group
s to which this user belongs.
-
getRoles
public java.util.Iterator<Role> getRoles()
Return the set ofRole
s assigned specifically to this user.- Specified by:
getRoles
in interfaceUser
- Specified by:
getRoles
in classAbstractUser
- Returns:
- the set of
Role
s assigned specifically to this user.
-
getUserDatabase
public UserDatabase getUserDatabase()
Return theUserDatabase
within which this User is defined.- Returns:
- the
UserDatabase
within which this User is defined.
-
addGroup
public void addGroup(Group group)
Add a newGroup
to those this user belongs to.- Specified by:
addGroup
in interfaceUser
- Specified by:
addGroup
in classAbstractUser
- Parameters:
group
- The new group
-
addRole
public void addRole(Role role)
Add a newRole
to those assigned specifically to this user.- Specified by:
addRole
in interfaceUser
- Specified by:
addRole
in classAbstractUser
- Parameters:
role
- The new role
-
isInGroup
public boolean isInGroup(Group group)
Is this user in the specified group?- Specified by:
isInGroup
in interfaceUser
- Specified by:
isInGroup
in classAbstractUser
- Parameters:
group
- The group to check- Returns:
true
if the user is in the specified group
-
isInRole
public boolean isInRole(Role role)
Is this user specifically assigned the specifiedRole
? This method does NOT check for roles inherited based onGroup
membership.- Specified by:
isInRole
in interfaceUser
- Specified by:
isInRole
in classAbstractUser
- Parameters:
role
- The role to check- Returns:
true
if the user has the specified role
-
removeGroup
public void removeGroup(Group group)
Remove aGroup
from those this user belongs to.- Specified by:
removeGroup
in interfaceUser
- Specified by:
removeGroup
in classAbstractUser
- Parameters:
group
- The old group
-
removeGroups
public void removeGroups()
Remove allGroup
s from those this user belongs to.- Specified by:
removeGroups
in interfaceUser
- Specified by:
removeGroups
in classAbstractUser
-
removeRole
public void removeRole(Role role)
Remove aRole
from those assigned to this user.- Specified by:
removeRole
in interfaceUser
- Specified by:
removeRole
in classAbstractUser
- Parameters:
role
- The old role
-
removeRoles
public void removeRoles()
Remove allRole
s from those assigned to this user.- Specified by:
removeRoles
in interfaceUser
- Specified by:
removeRoles
in classAbstractUser
-
setFullName
public void setFullName(java.lang.String fullName)
Description copied from class:AbstractUser
Set the full name of this user.- Specified by:
setFullName
in interfaceUser
- Overrides:
setFullName
in classAbstractUser
- Parameters:
fullName
- The new full name
-
setPassword
public void setPassword(java.lang.String password)
Description copied from class:AbstractUser
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 interfaceUser
- Overrides:
setPassword
in classAbstractUser
- Parameters:
password
- The new logon password
-
setUsername
public void setUsername(java.lang.String username)
Description copied from class:AbstractUser
Set the logon username of this user, which must be unique within the scope of aUserDatabase
.- Specified by:
setUsername
in interfaceUser
- Overrides:
setUsername
in classAbstractUser
- Parameters:
username
- The new logon username
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.security.Principal
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.security.Principal
- Overrides:
hashCode
in classjava.lang.Object
-
-