Package org.apache.catalina.users
Class DataSourceUserDatabase
- java.lang.Object
-
- org.apache.catalina.users.SparseUserDatabase
-
- org.apache.catalina.users.DataSourceUserDatabase
-
- All Implemented Interfaces:
UserDatabase
public class DataSourceUserDatabase extends SparseUserDatabase
UserDatabase backed by a data source.
-
-
Field Summary
Fields Modifier and Type Field Description protected ConcurrentHashMap<String,Group>createdGroupsprotected ConcurrentHashMap<String,Role>createdRolesprotected ConcurrentHashMap<String,User>createdUsersprotected DataSourcedataSourceDataSource to use.protected StringdataSourceNameThe name of the JNDI JDBC DataSourceprotected StringgroupNameColThe column in the user group table that names a groupprotected StringgroupRoleTableThe table that holds the relation between groups and rolesprotected StringgroupTableThe table that holds user data.protected StringidThe unique global identifier of this user database.protected ConcurrentHashMap<String,Group>modifiedGroupsprotected ConcurrentHashMap<String,Role>modifiedRolesprotected ConcurrentHashMap<String,User>modifiedUsersprotected booleanreadonlyA flag, indicating if the user database is read only.protected ConcurrentHashMap<String,Group>removedGroupsprotected ConcurrentHashMap<String,Role>removedRolesprotected ConcurrentHashMap<String,User>removedUsersprotected StringroleAndGroupDescriptionColThe column in the role and group tables for the descriptionprotected StringroleNameColThe column in the user role table that names a roleprotected StringroleTableThe table that holds user data.protected StringuserCredColThe column in the user table that holds the user's credentialsprotected StringuserFullNameColThe column in the user table that holds the user's full nameprotected StringuserGroupTableThe table that holds the relation between users and groupsprotected StringuserNameColThe column in the user table that holds the user's nameprotected StringuserRoleTableThe table that holds the relation between users and rolesprotected StringuserTableThe table that holds user data.
-
Constructor Summary
Constructors Constructor Description DataSourceUserDatabase(DataSource dataSource, String id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Finalize access to this user database.protected voidcloseConnection(Connection dbConnection)Close the specified database connection.GroupcreateGroup(String groupname, String description)Create and return a newGroupdefined in this user database.RolecreateRole(String rolename, String description)Create and return a newRoledefined in this user database.UsercreateUser(String username, String password, String fullName)Create and return a newUserdefined in this user database.GroupfindGroup(String groupname)GroupfindGroupInternal(Connection dbConnection, String groupName)RolefindRole(String rolename)RolefindRoleInternal(Connection dbConnection, String roleName)UserfindUser(String username)UserfindUserInternal(Connection dbConnection, String userName)StringgetDataSourceName()StringgetGroupNameCol()StringgetGroupRoleTable()Iterator<Group>getGroups()StringgetGroupTable()StringgetId()booleangetReadonly()StringgetRoleAndGroupDescriptionCol()StringgetRoleNameCol()Iterator<Role>getRoles()StringgetRoleTable()StringgetUserCredCol()StringgetUserFullNameCol()StringgetUserGroupTable()StringgetUserNameCol()StringgetUserRoleTable()Iterator<User>getUsers()StringgetUserTable()booleanisAvailable()Is the database available.protected booleanisGroupStoreDefined()Only use groups if the tables are fully defined.protected booleanisRoleStoreDefined()Only use roles if the tables are fully defined.voidmodifiedGroup(Group group)Signal the specifiedGroupfrom this user database has been modified.voidmodifiedRole(Role role)Signal the specifiedRolefrom this user database has been modified.voidmodifiedUser(User user)Signal the specifiedUserfrom this user database has been modified.voidopen()Initialize access to this user database.protected ConnectionopenConnection()Open the specified database connection.voidremoveGroup(Group group)Remove the specifiedGroupfrom this user database.voidremoveRole(Role role)Remove the specifiedRolefrom this user database.voidremoveUser(User user)Remove the specifiedUserfrom this user database.voidsave()Save any updated information to the persistent storage location for this user database.protected voidsaveInternal(Connection dbConnection)voidsetDataSourceName(String dataSourceName)Set the name of the JNDI JDBC DataSource.voidsetGroupNameCol(String groupNameCol)voidsetGroupRoleTable(String groupRoleTable)voidsetGroupTable(String groupTable)voidsetReadonly(boolean readonly)voidsetRoleAndGroupDescriptionCol(String roleAndGroupDescriptionCol)voidsetRoleNameCol(String roleNameCol)Set the column in the user role table that names a role.voidsetRoleTable(String roleTable)voidsetUserCredCol(String userCredCol)Set the column in the user table that holds the user's credentials.voidsetUserFullNameCol(String userFullNameCol)voidsetUserGroupTable(String userGroupTable)voidsetUserNameCol(String userNameCol)Set the column in the user table that holds the user's name.voidsetUserRoleTable(String userRoleTable)Set the table that holds the relation between user's and roles.voidsetUserTable(String userTable)Set the table that holds user data.-
Methods inherited from class org.apache.catalina.users.SparseUserDatabase
isSparse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.catalina.UserDatabase
backgroundProcess
-
-
-
-
Field Detail
-
dataSource
protected final DataSource dataSource
DataSource to use.
-
id
protected final String id
The unique global identifier of this user database.
-
createdUsers
protected final ConcurrentHashMap<String,User> createdUsers
-
modifiedUsers
protected final ConcurrentHashMap<String,User> modifiedUsers
-
removedUsers
protected final ConcurrentHashMap<String,User> removedUsers
-
createdGroups
protected final ConcurrentHashMap<String,Group> createdGroups
-
modifiedGroups
protected final ConcurrentHashMap<String,Group> modifiedGroups
-
removedGroups
protected final ConcurrentHashMap<String,Group> removedGroups
-
createdRoles
protected final ConcurrentHashMap<String,Role> createdRoles
-
modifiedRoles
protected final ConcurrentHashMap<String,Role> modifiedRoles
-
removedRoles
protected final ConcurrentHashMap<String,Role> removedRoles
-
dataSourceName
protected String dataSourceName
The name of the JNDI JDBC DataSource
-
roleNameCol
protected String roleNameCol
The column in the user role table that names a role
-
roleAndGroupDescriptionCol
protected String roleAndGroupDescriptionCol
The column in the role and group tables for the description
-
groupNameCol
protected String groupNameCol
The column in the user group table that names a group
-
userCredCol
protected String userCredCol
The column in the user table that holds the user's credentials
-
userFullNameCol
protected String userFullNameCol
The column in the user table that holds the user's full name
-
userNameCol
protected String userNameCol
The column in the user table that holds the user's name
-
userRoleTable
protected String userRoleTable
The table that holds the relation between users and roles
-
userGroupTable
protected String userGroupTable
The table that holds the relation between users and groups
-
groupRoleTable
protected String groupRoleTable
The table that holds the relation between groups and roles
-
userTable
protected String userTable
The table that holds user data.
-
groupTable
protected String groupTable
The table that holds user data.
-
roleTable
protected String roleTable
The table that holds user data.
-
readonly
protected boolean readonly
A flag, indicating if the user database is read only.
-
-
Constructor Detail
-
DataSourceUserDatabase
public DataSourceUserDatabase(DataSource dataSource, String id)
-
-
Method Detail
-
getDataSourceName
public String getDataSourceName()
- Returns:
- the name of the JNDI JDBC DataSource.
-
setDataSourceName
public void setDataSourceName(String dataSourceName)
Set the name of the JNDI JDBC DataSource.- Parameters:
dataSourceName- the name of the JNDI JDBC DataSource
-
getRoleNameCol
public String getRoleNameCol()
- Returns:
- the column in the user role table that names a role.
-
setRoleNameCol
public void setRoleNameCol(String roleNameCol)
Set the column in the user role table that names a role.- Parameters:
roleNameCol- The column name
-
getUserCredCol
public String getUserCredCol()
- Returns:
- the column in the user table that holds the user's credentials.
-
setUserCredCol
public void setUserCredCol(String userCredCol)
Set the column in the user table that holds the user's credentials.- Parameters:
userCredCol- The column name
-
getUserNameCol
public String getUserNameCol()
- Returns:
- the column in the user table that holds the user's name.
-
setUserNameCol
public void setUserNameCol(String userNameCol)
Set the column in the user table that holds the user's name.- Parameters:
userNameCol- The column name
-
getUserRoleTable
public String getUserRoleTable()
- Returns:
- the table that holds the relation between user's and roles.
-
setUserRoleTable
public void setUserRoleTable(String userRoleTable)
Set the table that holds the relation between user's and roles.- Parameters:
userRoleTable- The table name
-
getUserTable
public String getUserTable()
- Returns:
- the table that holds user data..
-
setUserTable
public void setUserTable(String userTable)
Set the table that holds user data.- Parameters:
userTable- The table name
-
getRoleAndGroupDescriptionCol
public String getRoleAndGroupDescriptionCol()
- Returns:
- the roleAndGroupDescriptionCol
-
setRoleAndGroupDescriptionCol
public void setRoleAndGroupDescriptionCol(String roleAndGroupDescriptionCol)
- Parameters:
roleAndGroupDescriptionCol- the roleAndGroupDescriptionCol to set
-
getGroupNameCol
public String getGroupNameCol()
- Returns:
- the groupNameCol
-
setGroupNameCol
public void setGroupNameCol(String groupNameCol)
- Parameters:
groupNameCol- the groupNameCol to set
-
getUserFullNameCol
public String getUserFullNameCol()
- Returns:
- the userFullNameCol
-
setUserFullNameCol
public void setUserFullNameCol(String userFullNameCol)
- Parameters:
userFullNameCol- the userFullNameCol to set
-
getUserGroupTable
public String getUserGroupTable()
- Returns:
- the userGroupTable
-
setUserGroupTable
public void setUserGroupTable(String userGroupTable)
- Parameters:
userGroupTable- the userGroupTable to set
-
getGroupRoleTable
public String getGroupRoleTable()
- Returns:
- the groupRoleTable
-
setGroupRoleTable
public void setGroupRoleTable(String groupRoleTable)
- Parameters:
groupRoleTable- the groupRoleTable to set
-
getGroupTable
public String getGroupTable()
- Returns:
- the groupTable
-
setGroupTable
public void setGroupTable(String groupTable)
- Parameters:
groupTable- the groupTable to set
-
getRoleTable
public String getRoleTable()
- Returns:
- the roleTable
-
setRoleTable
public void setRoleTable(String roleTable)
- Parameters:
roleTable- the roleTable to set
-
getReadonly
public boolean getReadonly()
- Returns:
- the readonly
-
setReadonly
public void setReadonly(boolean readonly)
- Parameters:
readonly- the readonly to set
-
getId
public String getId()
- Returns:
- the unique global identifier of this user database.
-
getGroups
public Iterator<Group> getGroups()
- Returns:
- the set of
Groups defined in this user database.
-
close
public void close() throws ExceptionDescription copied from interface:UserDatabaseFinalize access to this user database.- Throws:
Exception- if any exception is thrown during closing
-
createGroup
public Group createGroup(String groupname, String description)
Description copied from interface:UserDatabaseCreate and return a newGroupdefined in this user database.- Parameters:
groupname- The group name of the new group (must be unique)description- The description of this group- Returns:
- The new group
-
createRole
public Role createRole(String rolename, String description)
Description copied from interface:UserDatabaseCreate and return a newRoledefined in this user database.- Parameters:
rolename- The role name of the new role (must be unique)description- The description of this role- Returns:
- The new role
-
createUser
public User createUser(String username, String password, String fullName)
Description copied from interface:UserDatabaseCreate and return a newUserdefined in this user database.- Parameters:
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- Returns:
- The new user
-
findGroup
public Group findGroup(String groupname)
- Parameters:
groupname- Name of the group to return- Returns:
- the
Groupwith the specified group name, if any; otherwise returnnull.
-
findGroupInternal
public Group findGroupInternal(Connection dbConnection, String groupName)
-
findRole
public Role findRole(String rolename)
- Parameters:
rolename- Name of the role to return- Returns:
- the
Rolewith the specified role name, if any; otherwise returnnull.
-
findRoleInternal
public Role findRoleInternal(Connection dbConnection, String roleName)
-
findUser
public User findUser(String username)
- Parameters:
username- Name of the user to return- Returns:
- the
Userwith the specified user name, if any; otherwise returnnull.
-
findUserInternal
public User findUserInternal(Connection dbConnection, String userName)
-
modifiedGroup
public void modifiedGroup(Group group)
Description copied from interface:UserDatabaseSignal the specifiedGroupfrom this user database has been modified.- Parameters:
group- The group that has been modified
-
modifiedRole
public void modifiedRole(Role role)
Description copied from interface:UserDatabaseSignal the specifiedRolefrom this user database has been modified.- Parameters:
role- The role that has been modified
-
modifiedUser
public void modifiedUser(User user)
Description copied from interface:UserDatabaseSignal the specifiedUserfrom this user database has been modified.- Parameters:
user- The user that has been modified
-
open
public void open() throws ExceptionDescription copied from interface:UserDatabaseInitialize access to this user database.- Throws:
Exception- if any exception is thrown during opening
-
removeGroup
public void removeGroup(Group group)
Description copied from interface:UserDatabaseRemove the specifiedGroupfrom this user database.- Parameters:
group- The group to be removed
-
removeRole
public void removeRole(Role role)
Description copied from interface:UserDatabaseRemove the specifiedRolefrom this user database.- Parameters:
role- The role to be removed
-
removeUser
public void removeUser(User user)
Description copied from interface:UserDatabaseRemove the specifiedUserfrom this user database.- Parameters:
user- The user to be removed
-
save
public void save() throws ExceptionDescription copied from interface:UserDatabaseSave any updated information to the persistent storage location for this user database.- Throws:
Exception- if any exception is thrown during saving
-
saveInternal
protected void saveInternal(Connection dbConnection)
-
isAvailable
public boolean isAvailable()
Description copied from interface:UserDatabaseIs the database available.- Returns:
- true
-
isGroupStoreDefined
protected boolean isGroupStoreDefined()
Only use groups if the tables are fully defined.- Returns:
- true when groups are used
-
isRoleStoreDefined
protected boolean isRoleStoreDefined()
Only use roles if the tables are fully defined.- Returns:
- true when roles are used
-
openConnection
protected Connection openConnection()
Open the specified database connection.- Returns:
- Connection to the database
-
closeConnection
protected void closeConnection(Connection dbConnection)
Close the specified database connection.- Parameters:
dbConnection- The connection to be closed
-
-