Additional top-level classes in compilation unit: MemoryGroupCreationFactory, MemoryRoleCreationFactory, MemoryUserCreationFactory.
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.
This class is thread-safe.
This class does not enforce what, in an RDBMS, would be called referential integrity. Concurrent modifications may result in inconsistent data such as a User retaining a reference to a Role that has been removed from the database.
| Modifier and Type | Field and Description |
|---|---|
| private final ReentrantReadWriteLock | |
| protected final Map | |
| protected final String | id
The unique global identifier of this user database. |
| private volatile long | |
| private static final Log | |
| protected String | pathname
The relative (to |
| protected String | pathnameNew
The relative or absolute pathname of 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. |
| private final Lock | |
| protected boolean | readonly
A flag, indicating if the user database is read only. |
| protected final Map | |
| private static final StringManager | |
| protected final Map | |
| private boolean | |
| private final Lock |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MemoryUserDatabase(String
Unique global identifier of this user database id)Create a new instance with the specified values. |
| Modifier and Type | Method and Description |
|---|---|
| public void | backgroundProcess()
Overrides default org. Perform any background processing (e.g. checking for changes in persisted storage) required for the user database. |
| public void | |
| public Group | createGroup(String
The group name of the new group (must be unique) groupname, String The description of this group description)Implements org. Create and return a new |
| public Role | createRole(String
The role name of the new group (must be unique) rolename, String The description of this group description)Implements org. Create and return a new |
| public User | createUser(String
The logon username of the new user (must be unique) username, String The logon password of the new user password, String The full name of the new user fullName)Implements org. Create and return a new |
| public Group | findGroup(String
Name of the group to return groupname)Implements org. Return the |
| public Role | findRole(String
Name of the role to return rolename)Implements org. Return the |
| public User | findUser(String
Name of the user to return username)Implements org. Return the |
| public Iterator | Returns: the set ofGroups defined in this user database.Implements org.
|
| public String | Returns: the unique global identifier of this user database.Implements org.
|
| public String | |
| public boolean | |
| public Iterator | Returns: the set ofRoles defined in this user database.Implements org.
|
| public Iterator | Returns: the set ofUsers defined in this user database.Implements org.
|
| public boolean | |
| public boolean | Returns: true if the database is writableCheck for permissions to save this user database to persistent storage location. |
| public void | |
| public void | removeGroup(Group
The group to be removed group)Implements org. Remove the specified |
| public void | removeRole(Role
The role to be removed role)Implements org. Remove the specified |
| public void | removeUser(User
The user to be removed user)Implements org. Remove the specified |
| public void | save()
Implements org. Save any updated information to the persistent storage location for this user database. |
| public void | setPathname(String
The new pathname pathname)Set the relative or absolute pathname to the persistent storage file. |
| public void | |
| public void | |
| public String |
| dbLock | back to summary |
|---|---|
| private final ReentrantReadWriteLock dbLock | |
| groups | back to summary |
|---|---|
| protected final Map<String, Group> groups The set of | |
| id | back to summary |
|---|---|
| protected final String id The unique global identifier of this user database. | |
| lastModified | back to summary |
|---|---|
| private volatile long lastModified | |
| log | back to summary |
|---|---|
| private static final Log log | |
| pathname | back to summary |
|---|---|
| protected String pathname The relative (to | |
| pathnameNew | back to summary |
|---|---|
| protected String pathnameNew The relative or absolute pathname of the file in which we write our new information prior to renaming. | |
| pathnameOld | back to summary |
|---|---|
| protected String pathnameOld The relative or absolute pathname to the file in which our old information is stored while renaming is in progress. | |
| readLock | back to summary |
|---|---|
| private final Lock readLock | |
| readonly | back to summary |
|---|---|
| protected boolean readonly A flag, indicating if the user database is read only. | |
| roles | back to summary |
|---|---|
| protected final Map<String, Role> roles The set of | |
| sm | back to summary |
|---|---|
| private static final StringManager sm | |
| users | back to summary |
|---|---|
| protected final Map<String, User> users The set of | |
| watchSource | back to summary |
|---|---|
| private boolean watchSource | |
| writeLock | back to summary |
|---|---|
| private final Lock writeLock | |
| MemoryUserDatabase | back to summary |
|---|---|
| public MemoryUserDatabase() Create a new instance with default values. | |
| MemoryUserDatabase | back to summary |
|---|---|
| public MemoryUserDatabase(String id) Create a new instance with the specified values.
| |
| backgroundProcess | back to summary |
|---|---|
| public void backgroundProcess() Overrides default org. Doc from org. Perform any background processing (e.g. checking for changes in persisted storage) required for the user database.
| |
| close | back to summary |
|---|---|
| public void close() throws Exception Implements org. Finalize access to this user database. | |
| createGroup | back to summary |
|---|---|
| public Group createGroup(String groupname, String description) Implements org. Create and return a new
| |
| createRole | back to summary |
|---|---|
| public Role createRole(String rolename, String description) Implements org. Create and return a new
| |
| createUser | back to summary |
|---|---|
| public User createUser(String username, String password, String fullName) Implements org. Create and return a new | |
| findGroup | back to summary |
|---|---|
| public Group findGroup(String groupname) Implements org. Return the
| |
| findRole | back to summary |
|---|---|
| public Role findRole(String rolename) Implements org. Return the
| |
| findUser | back to summary |
|---|---|
| public User findUser(String username) Implements org. Return the
| |
| getGroups | back to summary |
|---|---|
| public Iterator Implements org. | |
| getId | back to summary |
|---|---|
| public String getId() Implements org. | |
| getPathname | back to summary |
|---|---|
public String getPathname()
| |
| getReadonly | back to summary |
|---|---|
public boolean getReadonly()
| |
| getRoles | back to summary |
|---|---|
| public Iterator Implements org. | |
| getUsers | back to summary |
|---|---|
| public Iterator Implements org. | |
| getWatchSource | back to summary |
|---|---|
| public boolean getWatchSource() | |
| isWritable | back to summary |
|---|---|
| public boolean isWritable() Check for permissions to save this user database to persistent storage location.
| |
| open | back to summary |
|---|---|
| public void open() throws Exception Implements org. Initialize access to this user database. | |
| removeGroup | back to summary |
|---|---|
| public void removeGroup(Group group) Implements org. Remove the specified | |
| removeRole | back to summary |
|---|---|
| public void removeRole(Role role) Implements org. Remove the specified | |
| removeUser | back to summary |
|---|---|
| public void removeUser(User user) Implements org. Remove the specified | |
| save | back to summary |
|---|---|
| public void save() throws Exception Implements org. Save any updated information to the persistent storage location for this user database. | |
| setPathname | back to summary |
|---|---|
| public void setPathname(String pathname) Set the relative or absolute pathname to the persistent storage file.
| |
| setReadonly | back to summary |
|---|---|
| public void setReadonly(boolean readonly) Setting the readonly status of the user database
| |
| setWatchSource | back to summary |
|---|---|
| public void setWatchSource(boolean watchSource) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Return a String representation of this UserDatabase.
| |