org.apache.catalina.users
Class MemoryUserDatabase
java.lang.Object
org.apache.catalina.users.MemoryUserDatabase
- UserDatabase
public class MemoryUserDatabase
extends java.lang.Object
Concrete implementation of
UserDatabase
that loads all
defined users, groups, and roles into an in-memory data structure,
and uses a specified XML file for its persistent storage.
Version:
- Craig R. McClanahan
- 4.1
protected HashMap | groups - The set of
Group s defined in this database, keyed by
group name.
|
protected String | id - The unique global identifier of this user database.
|
protected String | pathname - The relative (to
catalina.base ) or absolute pathname to
the XML file in which we will save our persistent information.
|
protected String | pathnameNew - The relative or absolute pathname ot the file in which we write
our new information prior to renaming.
|
protected String | pathnameOld - The relative or absolute pathname to the file in which our old
information is stored while renaming is in progress.
|
protected HashMap | roles - The set of
Role s defined in this database, keyed by
role name.
|
protected HashMap | users - The set of
User s defined in this database, keyed by
user name.
|
void | close() - Finalize access to this user database.
|
Group | createGroup(String groupname, String description) - Create and return a new
Group defined in this user database.
|
Role | createRole(String rolename, String description) - Create and return a new
Role defined in this user database.
|
User | createUser(String username, String password, String fullName) - Create and return a new
User defined in this user database.
|
Group | findGroup(String groupname) - Return the
Group with the specified group name, if any;
otherwise return null .
|
Role | findRole(String rolename) - Return the
Role with the specified role name, if any;
otherwise return null .
|
User | findUser(String username) - Return the
User with the specified user name, if any;
otherwise return null .
|
Iterator | getGroups() - Return the set of
Group s defined in this user database.
|
String | getId() - Return the unique global identifier of this user database.
|
String | getPathname() - Return the relative or absolute pathname to the persistent storage file.
|
Iterator | getRoles() - Return the set of
Role s defined in this user database.
|
Iterator | getUsers() - Return the set of
User s defined in this user database.
|
void | open() - Initialize access to this user database.
|
void | removeGroup(Group group) - Remove the specified
Group from this user database.
|
void | removeRole(Role role) - Remove the specified
Role from this user database.
|
void | removeUser(User user) - Remove the specified
User from this user database.
|
void | save() - Save any updated information to the persistent storage location for
this user database.
|
void | setPathname(String pathname) - Set the relative or absolute pathname to the persistent storage file.
|
String | toString() - Return a String representation of this UserDatabase.
|
groups
protected HashMap groups
The set of
Group
s defined in this database, keyed by
group name.
id
protected String id
The unique global identifier of this user database.
pathname
protected String pathname
The relative (to catalina.base
) or absolute pathname to
the XML file in which we will save our persistent information.
pathnameNew
protected String pathnameNew
The relative or absolute pathname ot the file in which we write
our new information prior to renaming.
pathnameOld
protected String pathnameOld
The relative or absolute pathname to the file in which our old
information is stored while renaming is in progress.
roles
protected HashMap roles
The set of
Role
s defined in this database, keyed by
role name.
users
protected HashMap users
The set of
User
s defined in this database, keyed by
user name.
MemoryUserDatabase
public MemoryUserDatabase()
Create a new instance with default values.
MemoryUserDatabase
public MemoryUserDatabase(String id)
Create a new instance with the specified values.
id
- Unique global identifier of this user database
close
public void close()
throws Exception
Finalize access to this user database.
- close in interface UserDatabase
createGroup
public Group createGroup(String groupname,
String description)
Create and return a new
Group
defined in this user database.
- createGroup in interface UserDatabase
groupname
- The group name of the new group (must be unique)description
- The description of this group
createRole
public Role createRole(String rolename,
String description)
Create and return a new
Role
defined in this user database.
- createRole in interface UserDatabase
rolename
- The role name of the new group (must be unique)description
- The description of this group
createUser
public User createUser(String username,
String password,
String fullName)
Create and return a new
User
defined in this user database.
- createUser in interface UserDatabase
username
- The logon username of the new user (must be unique)password
- The logon password of the new userfullName
- The full name of the new user
findGroup
public Group findGroup(String groupname)
Return the
Group
with the specified group name, if any;
otherwise return
null
.
- findGroup in interface UserDatabase
groupname
- Name of the group to return
findRole
public Role findRole(String rolename)
Return the
Role
with the specified role name, if any;
otherwise return
null
.
- findRole in interface UserDatabase
rolename
- Name of the role to return
findUser
public User findUser(String username)
Return the
User
with the specified user name, if any;
otherwise return
null
.
- findUser in interface UserDatabase
username
- Name of the user to return
getId
public String getId()
Return the unique global identifier of this user database.
- getId in interface UserDatabase
getPathname
public String getPathname()
Return the relative or absolute pathname to the persistent storage file.
getRoles
public Iterator getRoles()
Return the set of
Role
s defined in this user database.
- getRoles in interface UserDatabase
getUsers
public Iterator getUsers()
Return the set of
User
s defined in this user database.
- getUsers in interface UserDatabase
open
public void open()
throws Exception
Initialize access to this user database.
- open in interface UserDatabase
removeGroup
public void removeGroup(Group group)
Remove the specified
Group
from this user database.
- removeGroup in interface UserDatabase
group
- The group to be removed
removeRole
public void removeRole(Role role)
Remove the specified
Role
from this user database.
- removeRole in interface UserDatabase
role
- The role to be removed
removeUser
public void removeUser(User user)
Remove the specified
User
from this user database.
- removeUser in interface UserDatabase
user
- The user to be removed
save
public void save()
throws Exception
Save any updated information to the persistent storage location for
this user database.
- save in interface UserDatabase
setPathname
public void setPathname(String pathname)
Set the relative or absolute pathname to the persistent storage file.
pathname
- The new pathname
toString
public String toString()
Return a String representation of this UserDatabase.
Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.