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 SummaryFields Modifier and Type Field Description protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Group>createdGroupsprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,Role>createdRolesprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,User>createdUsersprotected javax.sql.DataSourcedataSourceDataSource to use.protected java.lang.StringdataSourceNameThe name of the JNDI JDBC DataSourceprotected java.lang.StringgroupNameColThe column in the user group table that names a groupprotected java.lang.StringgroupRoleTableThe table that holds the relation between groups and rolesprotected java.lang.StringgroupTableThe table that holds user data.protected java.lang.StringidThe unique global identifier of this user database.protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Group>modifiedGroupsprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,Role>modifiedRolesprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,User>modifiedUsersprotected booleanreadonlyA flag, indicating if the user database is read only.protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Group>removedGroupsprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,Role>removedRolesprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,User>removedUsersprotected java.lang.StringroleAndGroupDescriptionColThe column in the role and group tables for the descriptionprotected java.lang.StringroleNameColThe column in the user role table that names a roleprotected java.lang.StringroleTableThe table that holds user data.protected java.lang.StringuserCredColThe column in the user table that holds the user's credentialsprotected java.lang.StringuserFullNameColThe column in the user table that holds the user's full nameprotected java.lang.StringuserGroupTableThe table that holds the relation between users and groupsprotected java.lang.StringuserNameColThe column in the user table that holds the user's nameprotected java.lang.StringuserRoleTableThe table that holds the relation between users and rolesprotected java.lang.StringuserTableThe table that holds user data.
 - 
Constructor SummaryConstructors Constructor Description DataSourceUserDatabase(javax.sql.DataSource dataSource, java.lang.String id)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Finalize access to this user database.protected voidcloseConnection(java.sql.Connection dbConnection)Close the specified database connection.GroupcreateGroup(java.lang.String groupname, java.lang.String description)Create and return a newGroupdefined in this user database.RolecreateRole(java.lang.String rolename, java.lang.String description)Create and return a newRoledefined in this user database.UsercreateUser(java.lang.String username, java.lang.String password, java.lang.String fullName)Create and return a newUserdefined in this user database.GroupfindGroup(java.lang.String groupname)GroupfindGroupInternal(java.sql.Connection dbConnection, java.lang.String groupName)RolefindRole(java.lang.String rolename)RolefindRoleInternal(java.sql.Connection dbConnection, java.lang.String roleName)UserfindUser(java.lang.String username)UserfindUserInternal(java.sql.Connection dbConnection, java.lang.String userName)java.lang.StringgetDataSourceName()java.lang.StringgetGroupNameCol()java.lang.StringgetGroupRoleTable()java.util.Iterator<Group>getGroups()java.lang.StringgetGroupTable()java.lang.StringgetId()booleangetReadonly()java.lang.StringgetRoleAndGroupDescriptionCol()java.lang.StringgetRoleNameCol()java.util.Iterator<Role>getRoles()java.lang.StringgetRoleTable()java.lang.StringgetUserCredCol()java.lang.StringgetUserFullNameCol()java.lang.StringgetUserGroupTable()java.lang.StringgetUserNameCol()java.lang.StringgetUserRoleTable()java.util.Iterator<User>getUsers()java.lang.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 java.sql.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(java.sql.Connection dbConnection)voidsetDataSourceName(java.lang.String dataSourceName)Set the name of the JNDI JDBC DataSource.voidsetGroupNameCol(java.lang.String groupNameCol)voidsetGroupRoleTable(java.lang.String groupRoleTable)voidsetGroupTable(java.lang.String groupTable)voidsetReadonly(boolean readonly)voidsetRoleAndGroupDescriptionCol(java.lang.String roleAndGroupDescriptionCol)voidsetRoleNameCol(java.lang.String roleNameCol)Set the column in the user role table that names a role.voidsetRoleTable(java.lang.String roleTable)voidsetUserCredCol(java.lang.String userCredCol)Set the column in the user table that holds the user's credentials.voidsetUserFullNameCol(java.lang.String userFullNameCol)voidsetUserGroupTable(java.lang.String userGroupTable)voidsetUserNameCol(java.lang.String userNameCol)Set the column in the user table that holds the user's name.voidsetUserRoleTable(java.lang.String userRoleTable)Set the table that holds the relation between user's and roles.voidsetUserTable(java.lang.String userTable)Set the table that holds user data.- 
Methods inherited from class org.apache.catalina.users.SparseUserDatabaseisSparse
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.catalina.UserDatabasebackgroundProcess
 
- 
 
- 
- 
- 
Field Detail- 
dataSourceprotected final javax.sql.DataSource dataSource DataSource to use.
 - 
idprotected final java.lang.String id The unique global identifier of this user database.
 - 
createdUsersprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,User> createdUsers 
 - 
modifiedUsersprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,User> modifiedUsers 
 - 
removedUsersprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,User> removedUsers 
 - 
createdGroupsprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Group> createdGroups 
 - 
modifiedGroupsprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Group> modifiedGroups 
 - 
removedGroupsprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Group> removedGroups 
 - 
createdRolesprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Role> createdRoles 
 - 
modifiedRolesprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Role> modifiedRoles 
 - 
removedRolesprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Role> removedRoles 
 - 
dataSourceNameprotected java.lang.String dataSourceName The name of the JNDI JDBC DataSource
 - 
roleNameColprotected java.lang.String roleNameCol The column in the user role table that names a role
 - 
roleAndGroupDescriptionColprotected java.lang.String roleAndGroupDescriptionCol The column in the role and group tables for the description
 - 
groupNameColprotected java.lang.String groupNameCol The column in the user group table that names a group
 - 
userCredColprotected java.lang.String userCredCol The column in the user table that holds the user's credentials
 - 
userFullNameColprotected java.lang.String userFullNameCol The column in the user table that holds the user's full name
 - 
userNameColprotected java.lang.String userNameCol The column in the user table that holds the user's name
 - 
userRoleTableprotected java.lang.String userRoleTable The table that holds the relation between users and roles
 - 
userGroupTableprotected java.lang.String userGroupTable The table that holds the relation between users and groups
 - 
groupRoleTableprotected java.lang.String groupRoleTable The table that holds the relation between groups and roles
 - 
userTableprotected java.lang.String userTable The table that holds user data.
 - 
groupTableprotected java.lang.String groupTable The table that holds user data.
 - 
roleTableprotected java.lang.String roleTable The table that holds user data.
 - 
readonlyprotected boolean readonly A flag, indicating if the user database is read only.
 
- 
 - 
Method Detail- 
getDataSourceNamepublic java.lang.String getDataSourceName() - Returns:
- the name of the JNDI JDBC DataSource.
 
 - 
setDataSourceNamepublic void setDataSourceName(java.lang.String dataSourceName) Set the name of the JNDI JDBC DataSource.- Parameters:
- dataSourceName- the name of the JNDI JDBC DataSource
 
 - 
getRoleNameColpublic java.lang.String getRoleNameCol() - Returns:
- the column in the user role table that names a role.
 
 - 
setRoleNameColpublic void setRoleNameCol(java.lang.String roleNameCol) Set the column in the user role table that names a role.- Parameters:
- roleNameCol- The column name
 
 - 
getUserCredColpublic java.lang.String getUserCredCol() - Returns:
- the column in the user table that holds the user's credentials.
 
 - 
setUserCredColpublic void setUserCredCol(java.lang.String userCredCol) Set the column in the user table that holds the user's credentials.- Parameters:
- userCredCol- The column name
 
 - 
getUserNameColpublic java.lang.String getUserNameCol() - Returns:
- the column in the user table that holds the user's name.
 
 - 
setUserNameColpublic void setUserNameCol(java.lang.String userNameCol) Set the column in the user table that holds the user's name.- Parameters:
- userNameCol- The column name
 
 - 
getUserRoleTablepublic java.lang.String getUserRoleTable() - Returns:
- the table that holds the relation between user's and roles.
 
 - 
setUserRoleTablepublic void setUserRoleTable(java.lang.String userRoleTable) Set the table that holds the relation between user's and roles.- Parameters:
- userRoleTable- The table name
 
 - 
getUserTablepublic java.lang.String getUserTable() - Returns:
- the table that holds user data..
 
 - 
setUserTablepublic void setUserTable(java.lang.String userTable) Set the table that holds user data.- Parameters:
- userTable- The table name
 
 - 
getRoleAndGroupDescriptionColpublic java.lang.String getRoleAndGroupDescriptionCol() - Returns:
- the roleAndGroupDescriptionCol
 
 - 
setRoleAndGroupDescriptionColpublic void setRoleAndGroupDescriptionCol(java.lang.String roleAndGroupDescriptionCol) - Parameters:
- roleAndGroupDescriptionCol- the roleAndGroupDescriptionCol to set
 
 - 
getGroupNameColpublic java.lang.String getGroupNameCol() - Returns:
- the groupNameCol
 
 - 
setGroupNameColpublic void setGroupNameCol(java.lang.String groupNameCol) - Parameters:
- groupNameCol- the groupNameCol to set
 
 - 
getUserFullNameColpublic java.lang.String getUserFullNameCol() - Returns:
- the userFullNameCol
 
 - 
setUserFullNameColpublic void setUserFullNameCol(java.lang.String userFullNameCol) - Parameters:
- userFullNameCol- the userFullNameCol to set
 
 - 
getUserGroupTablepublic java.lang.String getUserGroupTable() - Returns:
- the userGroupTable
 
 - 
setUserGroupTablepublic void setUserGroupTable(java.lang.String userGroupTable) - Parameters:
- userGroupTable- the userGroupTable to set
 
 - 
getGroupRoleTablepublic java.lang.String getGroupRoleTable() - Returns:
- the groupRoleTable
 
 - 
setGroupRoleTablepublic void setGroupRoleTable(java.lang.String groupRoleTable) - Parameters:
- groupRoleTable- the groupRoleTable to set
 
 - 
getGroupTablepublic java.lang.String getGroupTable() - Returns:
- the groupTable
 
 - 
setGroupTablepublic void setGroupTable(java.lang.String groupTable) - Parameters:
- groupTable- the groupTable to set
 
 - 
getRoleTablepublic java.lang.String getRoleTable() - Returns:
- the roleTable
 
 - 
setRoleTablepublic void setRoleTable(java.lang.String roleTable) - Parameters:
- roleTable- the roleTable to set
 
 - 
getReadonlypublic boolean getReadonly() - Returns:
- the readonly
 
 - 
setReadonlypublic void setReadonly(boolean readonly) - Parameters:
- readonly- the readonly to set
 
 - 
getIdpublic java.lang.String getId() - Returns:
- the unique global identifier of this user database.
 
 - 
getGroupspublic java.util.Iterator<Group> getGroups() - Returns:
- the set of Groups defined in this user database.
 
 - 
getRolespublic java.util.Iterator<Role> getRoles() - Returns:
- the set of Roles defined in this user database.
 
 - 
getUserspublic java.util.Iterator<User> getUsers() - Returns:
- the set of Users defined in this user database.
 
 - 
closepublic void close() throws java.lang.ExceptionDescription copied from interface:UserDatabaseFinalize access to this user database.- Throws:
- java.lang.Exception- if any exception is thrown during closing
 
 - 
createGrouppublic Group createGroup(java.lang.String groupname, java.lang.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
 
 - 
createRolepublic Role createRole(java.lang.String rolename, java.lang.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
 
 - 
createUserpublic User createUser(java.lang.String username, java.lang.String password, java.lang.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 user
- fullName- The full name of the new user
- Returns:
- The new user
 
 - 
findGrouppublic Group findGroup(java.lang.String groupname) - Parameters:
- groupname- Name of the group to return
- Returns:
- the Groupwith the specified group name, if any; otherwise returnnull.
 
 - 
findGroupInternalpublic Group findGroupInternal(java.sql.Connection dbConnection, java.lang.String groupName) 
 - 
findRolepublic Role findRole(java.lang.String rolename) - Parameters:
- rolename- Name of the role to return
- Returns:
- the Rolewith the specified role name, if any; otherwise returnnull.
 
 - 
findRoleInternalpublic Role findRoleInternal(java.sql.Connection dbConnection, java.lang.String roleName) 
 - 
findUserpublic User findUser(java.lang.String username) - Parameters:
- username- Name of the user to return
- Returns:
- the Userwith the specified user name, if any; otherwise returnnull.
 
 - 
findUserInternalpublic User findUserInternal(java.sql.Connection dbConnection, java.lang.String userName) 
 - 
modifiedGrouppublic 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
 
 - 
modifiedRolepublic 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
 
 - 
modifiedUserpublic 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
 
 - 
openpublic void open() throws java.lang.ExceptionDescription copied from interface:UserDatabaseInitialize access to this user database.- Throws:
- java.lang.Exception- if any exception is thrown during opening
 
 - 
removeGrouppublic void removeGroup(Group group) Description copied from interface:UserDatabaseRemove the specifiedGroupfrom this user database.- Parameters:
- group- The group to be removed
 
 - 
removeRolepublic void removeRole(Role role) Description copied from interface:UserDatabaseRemove the specifiedRolefrom this user database.- Parameters:
- role- The role to be removed
 
 - 
removeUserpublic void removeUser(User user) Description copied from interface:UserDatabaseRemove the specifiedUserfrom this user database.- Parameters:
- user- The user to be removed
 
 - 
savepublic void save() throws java.lang.ExceptionDescription copied from interface:UserDatabaseSave any updated information to the persistent storage location for this user database.- Throws:
- java.lang.Exception- if any exception is thrown during saving
 
 - 
saveInternalprotected void saveInternal(java.sql.Connection dbConnection) 
 - 
isAvailablepublic boolean isAvailable() Description copied from interface:UserDatabaseIs the database available.- Returns:
- true
 
 - 
isGroupStoreDefinedprotected boolean isGroupStoreDefined() Only use groups if the tables are fully defined.- Returns:
- true when groups are used
 
 - 
isRoleStoreDefinedprotected boolean isRoleStoreDefined() Only use roles if the tables are fully defined.- Returns:
- true when roles are used
 
 - 
openConnectionprotected java.sql.Connection openConnection() Open the specified database connection.- Returns:
- Connection to the database
 
 - 
closeConnectionprotected void closeConnection(java.sql.Connection dbConnection) Close the specified database connection.- Parameters:
- dbConnection- The connection to be closed
 
 
- 
 
-