Apache Tomcat 7.0.28

org.apache.catalina.users
Class MemoryUser

java.lang.Object
  extended by org.apache.catalina.users.AbstractUser
      extended by org.apache.catalina.users.MemoryUser
All Implemented Interfaces:
Principal, User

public class MemoryUser
extends AbstractUser

Concrete implementation of User for the MemoryUserDatabase implementation of UserDatabase.

Since:
4.1
Version:
$Id: MemoryUser.java 1140070 2011-06-27 09:27:06Z markt $
Author:
Craig R. McClanahan

Field Summary
protected  MemoryUserDatabase database
          The MemoryUserDatabase that owns this user.
protected  ArrayList<Group> groups
          The set of Groups that this user is a member of.
protected  ArrayList<Role> roles
          The set of Roles associated with this user.
 
Fields inherited from class org.apache.catalina.users.AbstractUser
fullName, password, username
 
Method Summary
 void addGroup(Group group)
          Add a new Group to those this user belongs to.
 void addRole(Role role)
          Add a new Role to those assigned specifically to this user.
 Iterator<Group> getGroups()
          Return the set of Groups to which this user belongs.
 Iterator<Role> getRoles()
          Return the set of Roles assigned specifically to this user.
 UserDatabase getUserDatabase()
          Return the UserDatabase within which this User is defined.
 boolean isInGroup(Group group)
          Is this user in the specified group?
 boolean isInRole(Role role)
          Is this user specifically assigned the specified Role?
 void removeGroup(Group group)
          Remove a Group from those this user belongs to.
 void removeGroups()
          Remove all Groups from those this user belongs to.
 void removeRole(Role role)
          Remove a Role from those assigned to this user.
 void removeRoles()
          Remove all Roles from those assigned to this user.
 String toString()
          Return a String representation of this user.
 String toXml()
          Return a String representation of this user in XML format.
 
Methods inherited from class org.apache.catalina.users.AbstractUser
getFullName, getName, getPassword, getUsername, setFullName, setPassword, setUsername
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Principal
equals, hashCode
 

Field Detail

database

protected MemoryUserDatabase database
The MemoryUserDatabase that owns this user.


groups

protected ArrayList<Group> groups
The set of Groups that this user is a member of.


roles

protected ArrayList<Role> roles
The set of Roles associated with this user.

Method Detail

getGroups

public Iterator<Group> getGroups()
Return the set of Groups to which this user belongs.

Specified by:
getGroups in interface User
Specified by:
getGroups in class AbstractUser

getRoles

public Iterator<Role> getRoles()
Return the set of Roles assigned specifically to this user.

Specified by:
getRoles in interface User
Specified by:
getRoles in class AbstractUser

getUserDatabase

public UserDatabase getUserDatabase()
Return the UserDatabase within which this User is defined.


addGroup

public void addGroup(Group group)
Add a new Group to those this user belongs to.

Specified by:
addGroup in interface User
Specified by:
addGroup in class AbstractUser
Parameters:
group - The new group

addRole

public void addRole(Role role)
Add a new Role to those assigned specifically to this user.

Specified by:
addRole in interface User
Specified by:
addRole in class AbstractUser
Parameters:
role - The new role

isInGroup

public boolean isInGroup(Group group)
Is this user in the specified group?

Specified by:
isInGroup in interface User
Specified by:
isInGroup in class AbstractUser
Parameters:
group - The group to check

isInRole

public 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
Specified by:
isInRole in class AbstractUser
Parameters:
role - The role to check

removeGroup

public void removeGroup(Group group)
Remove a Group from those this user belongs to.

Specified by:
removeGroup in interface User
Specified by:
removeGroup in class AbstractUser
Parameters:
group - The old group

removeGroups

public void removeGroups()
Remove all Groups from those this user belongs to.

Specified by:
removeGroups in interface User
Specified by:
removeGroups in class AbstractUser

removeRole

public void removeRole(Role role)
Remove a Role from those assigned to this user.

Specified by:
removeRole in interface User
Specified by:
removeRole in class AbstractUser
Parameters:
role - The old role

removeRoles

public void removeRoles()
Remove all Roles from those assigned to this user.

Specified by:
removeRoles in interface User
Specified by:
removeRoles in class AbstractUser

toXml

public String toXml()

Return a String representation of this user in XML format.

IMPLEMENTATION NOTE - For backwards compatibility, the reader that processes this entry will accept either username or name for the username property.


toString

public String toString()

Return a String representation of this user.

Specified by:
toString in interface Principal
Overrides:
toString in class Object

Apache Tomcat 7.0.28

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.