public class DataSourceUserDatabase extends SparseUserDatabase
Modifier and Type | Field and Description |
---|---|
protected ConcurrentHashMap<String,Group> |
createdGroups |
protected ConcurrentHashMap<String,Role> |
createdRoles |
protected ConcurrentHashMap<String,User> |
createdUsers |
protected DataSource |
dataSource
DataSource to use.
|
protected String |
dataSourceName
The name of the JNDI JDBC DataSource
|
protected String |
groupNameCol
The column in the user group table that names a group
|
protected String |
groupRoleTable
The table that holds the relation between groups and roles
|
protected String |
groupTable
The table that holds user data.
|
protected String |
id
The unique global identifier of this user database.
|
protected ConcurrentHashMap<String,Group> |
modifiedGroups |
protected ConcurrentHashMap<String,Role> |
modifiedRoles |
protected ConcurrentHashMap<String,User> |
modifiedUsers |
protected boolean |
readonly
A flag, indicating if the user database is read only.
|
protected ConcurrentHashMap<String,Group> |
removedGroups |
protected ConcurrentHashMap<String,Role> |
removedRoles |
protected ConcurrentHashMap<String,User> |
removedUsers |
protected String |
roleAndGroupDescriptionCol
The column in the role and group tables for the decription
|
protected String |
roleNameCol
The column in the user role table that names a role
|
protected String |
roleTable
The table that holds user data.
|
protected String |
userCredCol
The column in the user table that holds the user's credentials
|
protected String |
userFullNameCol
The column in the user table that holds the user's full name
|
protected String |
userGroupTable
The table that holds the relation between users and groups
|
protected String |
userNameCol
The column in the user table that holds the user's name
|
protected String |
userRoleTable
The table that holds the relation between users and roles
|
protected String |
userTable
The table that holds user data.
|
Constructor and Description |
---|
DataSourceUserDatabase(DataSource dataSource,
String id) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Finalize access to this user database.
|
protected void |
closeConnection(Connection dbConnection)
Close the specified database connection.
|
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) |
Group |
findGroupInternal(Connection dbConnection,
String groupName) |
Role |
findRole(String rolename) |
Role |
findRoleInternal(Connection dbConnection,
String roleName) |
User |
findUser(String username) |
User |
findUserInternal(Connection dbConnection,
String userName) |
String |
getDataSourceName() |
String |
getGroupNameCol() |
String |
getGroupRoleTable() |
Iterator<Group> |
getGroups() |
String |
getGroupTable() |
String |
getId() |
boolean |
getReadonly() |
String |
getRoleAndGroupDescriptionCol() |
String |
getRoleNameCol() |
Iterator<Role> |
getRoles() |
String |
getRoleTable() |
String |
getUserCredCol() |
String |
getUserFullNameCol() |
String |
getUserGroupTable() |
String |
getUserNameCol() |
String |
getUserRoleTable() |
Iterator<User> |
getUsers() |
String |
getUserTable() |
boolean |
isAvailable()
Is the database available.
|
protected boolean |
isGroupStoreDefined()
Only use groups if the tables are fully defined.
|
protected boolean |
isRoleStoreDefined()
Only use roles if the tables are fully defined.
|
void |
modifiedGroup(Group group)
Signal the specified
Group from this user database has been
modified. |
void |
modifiedRole(Role role)
Signal the specified
Role from this user database has been
modified. |
void |
modifiedUser(User user)
Signal the specified
User from this user database has been
modified. |
void |
open()
Initialize access to this user database.
|
protected Connection |
openConnection()
Open the specified database connection.
|
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.
|
protected void |
saveInternal(Connection dbConnection) |
void |
setDataSourceName(String dataSourceName)
Set the name of the JNDI JDBC DataSource.
|
void |
setGroupNameCol(String groupNameCol) |
void |
setGroupRoleTable(String groupRoleTable) |
void |
setGroupTable(String groupTable) |
void |
setReadonly(boolean readonly) |
void |
setRoleAndGroupDescriptionCol(String roleAndGroupDescriptionCol) |
void |
setRoleNameCol(String roleNameCol)
Set the column in the user role table that names a role.
|
void |
setRoleTable(String roleTable) |
void |
setUserCredCol(String userCredCol)
Set the column in the user table that holds the user's credentials.
|
void |
setUserFullNameCol(String userFullNameCol) |
void |
setUserGroupTable(String userGroupTable) |
void |
setUserNameCol(String userNameCol)
Set the column in the user table that holds the user's name.
|
void |
setUserRoleTable(String userRoleTable)
Set the table that holds the relation between user's and roles.
|
void |
setUserTable(String userTable)
Set the table that holds user data.
|
isSparse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
backgroundProcess
protected final DataSource dataSource
protected final String id
protected final ConcurrentHashMap<String,User> createdUsers
protected final ConcurrentHashMap<String,User> modifiedUsers
protected final ConcurrentHashMap<String,User> removedUsers
protected final ConcurrentHashMap<String,Group> createdGroups
protected final ConcurrentHashMap<String,Group> modifiedGroups
protected final ConcurrentHashMap<String,Group> removedGroups
protected final ConcurrentHashMap<String,Role> createdRoles
protected final ConcurrentHashMap<String,Role> modifiedRoles
protected final ConcurrentHashMap<String,Role> removedRoles
protected String dataSourceName
protected String roleNameCol
protected String roleAndGroupDescriptionCol
protected String groupNameCol
protected String userCredCol
protected String userFullNameCol
protected String userNameCol
protected String userRoleTable
protected String userGroupTable
protected String groupRoleTable
protected String userTable
protected String groupTable
protected String roleTable
protected boolean readonly
public DataSourceUserDatabase(DataSource dataSource, String id)
public String getDataSourceName()
public void setDataSourceName(String dataSourceName)
dataSourceName
- the name of the JNDI JDBC DataSourcepublic String getRoleNameCol()
public void setRoleNameCol(String roleNameCol)
roleNameCol
- The column namepublic String getUserCredCol()
public void setUserCredCol(String userCredCol)
userCredCol
- The column namepublic String getUserNameCol()
public void setUserNameCol(String userNameCol)
userNameCol
- The column namepublic String getUserRoleTable()
public void setUserRoleTable(String userRoleTable)
userRoleTable
- The table namepublic String getUserTable()
public void setUserTable(String userTable)
userTable
- The table namepublic String getRoleAndGroupDescriptionCol()
public void setRoleAndGroupDescriptionCol(String roleAndGroupDescriptionCol)
roleAndGroupDescriptionCol
- the roleAndGroupDescriptionCol to setpublic String getGroupNameCol()
public void setGroupNameCol(String groupNameCol)
groupNameCol
- the groupNameCol to setpublic String getUserFullNameCol()
public void setUserFullNameCol(String userFullNameCol)
userFullNameCol
- the userFullNameCol to setpublic String getUserGroupTable()
public void setUserGroupTable(String userGroupTable)
userGroupTable
- the userGroupTable to setpublic String getGroupRoleTable()
public void setGroupRoleTable(String groupRoleTable)
groupRoleTable
- the groupRoleTable to setpublic String getGroupTable()
public void setGroupTable(String groupTable)
groupTable
- the groupTable to setpublic String getRoleTable()
public void setRoleTable(String roleTable)
roleTable
- the roleTable to setpublic boolean getReadonly()
public void setReadonly(boolean readonly)
readonly
- the readonly to setpublic String getId()
public Iterator<Group> getGroups()
Group
s defined in this user database.public void close() throws Exception
UserDatabase
Exception
- if any exception is thrown during closingpublic Group createGroup(String groupname, String description)
UserDatabase
Group
defined in this user database.groupname
- The group name of the new group (must be unique)description
- The description of this grouppublic Role createRole(String rolename, String description)
UserDatabase
Role
defined in this user database.rolename
- The role name of the new role (must be unique)description
- The description of this rolepublic User createUser(String username, String password, String fullName)
UserDatabase
User
defined in this user database.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 userpublic Group findGroup(String groupname)
groupname
- Name of the group to returnGroup
with the specified group name, if any;
otherwise return null
.public Group findGroupInternal(Connection dbConnection, String groupName)
public Role findRole(String rolename)
rolename
- Name of the role to returnRole
with the specified role name, if any; otherwise
return null
.public Role findRoleInternal(Connection dbConnection, String roleName)
public User findUser(String username)
username
- Name of the user to returnUser
with the specified user name, if any; otherwise
return null
.public User findUserInternal(Connection dbConnection, String userName)
public void modifiedGroup(Group group)
UserDatabase
Group
from this user database has been
modified.group
- The group that has been modifiedpublic void modifiedRole(Role role)
UserDatabase
Role
from this user database has been
modified.role
- The role that has been modifiedpublic void modifiedUser(User user)
UserDatabase
User
from this user database has been
modified.user
- The user that has been modifiedpublic void open() throws Exception
UserDatabase
Exception
- if any exception is thrown during openingpublic void removeGroup(Group group)
UserDatabase
Group
from this user database.group
- The group to be removedpublic void removeRole(Role role)
UserDatabase
Role
from this user database.role
- The role to be removedpublic void removeUser(User user)
UserDatabase
User
from this user database.user
- The user to be removedpublic void save() throws Exception
UserDatabase
Exception
- if any exception is thrown during savingprotected void saveInternal(Connection dbConnection)
public boolean isAvailable()
UserDatabase
protected boolean isGroupStoreDefined()
protected boolean isRoleStoreDefined()
protected Connection openConnection()
protected void closeConnection(Connection dbConnection)
dbConnection
- The connection to be closedCopyright © 2000-2022 Apache Software Foundation. All Rights Reserved.