Class DataSourceUserDatabase
java.lang.Object
org.apache.catalina.users.SparseUserDatabase
org.apache.catalina.users.DataSourceUserDatabase
- All Implemented Interfaces:
UserDatabase
UserDatabase backed by a data source.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConcurrentHashMap<String, Group> Groups that have been created but not yet persisted.protected final ConcurrentHashMap<String, Role> Roles that have been created but not yet persisted.protected final ConcurrentHashMap<String, User> Users that have been created but not yet persisted.protected final DataSourceDataSource to use.protected StringThe name of the JNDI JDBC DataSourceprotected StringThe column in the user group table that names a groupprotected StringThe table that holds the relation between groups and rolesprotected StringThe table that holds user data.protected final StringThe unique global identifier of this user database.protected final ConcurrentHashMap<String, Group> Groups that have been modified but not yet persisted.protected final ConcurrentHashMap<String, Role> Roles that have been modified but not yet persisted.protected final ConcurrentHashMap<String, User> Users that have been modified but not yet persisted.protected booleanA flag, indicating if the user database is read only.protected final ConcurrentHashMap<String, Group> Groups that have been removed but not yet persisted.protected final ConcurrentHashMap<String, Role> Roles that have been removed but not yet persisted.protected final ConcurrentHashMap<String, User> Users that have been removed but not yet persisted.protected StringThe column in the role and group tables for the descriptionprotected StringThe column in the user role table that names a roleprotected StringThe table that holds user data.protected StringThe column in the user table that holds the user's credentialsprotected StringThe column in the user table that holds the user's full nameprotected StringThe table that holds the relation between users and groupsprotected StringThe column in the user table that holds the user's nameprotected StringThe table that holds the relation between users and rolesprotected StringThe table that holds user data. -
Constructor Summary
ConstructorsConstructorDescriptionDataSourceUserDatabase(DataSource dataSource, String id) Create a new DataSourceUserDatabase. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Finalize access to this user database.protected voidcloseConnection(Connection dbConnection) Close the specified database connection.createGroup(String groupname, String description) Create and return a newGroupdefined in this user database.createRole(String rolename, String description) Create and return a newRoledefined in this user database.createUser(String username, String password, String fullName) Create and return a newUserdefined in this user database.Find theGroupwith the specified group name.findGroupInternal(Connection dbConnection, String groupName) Find a group by name using the provided database connection.Find theRolewith the specified role name.findRoleInternal(Connection dbConnection, String roleName) Find a role by name using the provided database connection.Find theUserwith the specified username.findUserInternal(Connection dbConnection, String userName) Deprecated.Will be made private in Tomcat 12Return the name of the JNDI JDBC DataSource.Return the column name used for group names.Return the table that holds the relation between groups and roles.Get the set ofGroups defined in this user database.Return the table that holds group data.getId()Get the unique global identifier of this user database.booleanReturn whether the user database is read only.Return the column name used for role and group descriptions.Return the column in the user role table that names a role.getRoles()Get the set ofRoles defined in this user database.Return the table that holds role data.Return the column in the user table that holds the user's credentials.Return the column name used for user full names.Return the table that holds the relation between users and groups.Return the column in the user table that holds the user's name.Return the table that holds the relation between user's and roles.getUsers()Get the set ofUsers defined in this user database.Return the table that holds user data.booleanIs the database available.protected booleanOnly use groups if the tables are fully defined.protected booleanOnly 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 ConnectionOpen 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) Save all pending changes to the database using the provided connection.voidsetDataSourceName(String dataSourceName) Set the name of the JNDI JDBC DataSource.voidsetGroupNameCol(String groupNameCol) Set the column name used for group names.voidsetGroupRoleTable(String groupRoleTable) Set the table that holds the relation between groups and roles.voidsetGroupTable(String groupTable) Set the table that holds group data.voidsetReadonly(boolean readonly) Set whether the user database is read only.voidsetRoleAndGroupDescriptionCol(String roleAndGroupDescriptionCol) Set the column name used for role and group descriptions.voidsetRoleNameCol(String roleNameCol) Set the column in the user role table that names a role.voidsetRoleTable(String roleTable) Set the table that holds role data.voidsetUserCredCol(String userCredCol) Set the column in the user table that holds the user's credentials.voidsetUserFullNameCol(String userFullNameCol) Set the column name used for user full names.voidsetUserGroupTable(String userGroupTable) Set the table that holds the relation between users and groups.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 SparseUserDatabase
isSparseMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface UserDatabase
backgroundProcess
-
Field Details
-
dataSource
DataSource to use. -
id
The unique global identifier of this user database. -
createdUsers
Users that have been created but not yet persisted. -
modifiedUsers
Users that have been modified but not yet persisted. -
removedUsers
Users that have been removed but not yet persisted. -
createdGroups
Groups that have been created but not yet persisted. -
modifiedGroups
Groups that have been modified but not yet persisted. -
removedGroups
Groups that have been removed but not yet persisted. -
createdRoles
Roles that have been created but not yet persisted. -
modifiedRoles
Roles that have been modified but not yet persisted. -
removedRoles
Roles that have been removed but not yet persisted. -
dataSourceName
The name of the JNDI JDBC DataSource -
roleNameCol
The column in the user role table that names a role -
roleAndGroupDescriptionCol
The column in the role and group tables for the description -
groupNameCol
The column in the user group table that names a group -
userCredCol
The column in the user table that holds the user's credentials -
userFullNameCol
The column in the user table that holds the user's full name -
userNameCol
The column in the user table that holds the user's name -
userRoleTable
The table that holds the relation between users and roles -
userGroupTable
The table that holds the relation between users and groups -
groupRoleTable
The table that holds the relation between groups and roles -
userTable
The table that holds user data. -
groupTable
The table that holds user data. -
roleTable
The table that holds user data. -
readonly
protected boolean readonlyA flag, indicating if the user database is read only.
-
-
Constructor Details
-
DataSourceUserDatabase
Create a new DataSourceUserDatabase.- Parameters:
dataSource- The data source to useid- The unique identifier for this user database
-
-
Method Details
-
getDataSourceName
Return the name of the JNDI JDBC DataSource.- Returns:
- the DataSource name
-
setDataSourceName
Set the name of the JNDI JDBC DataSource.- Parameters:
dataSourceName- the name of the JNDI JDBC DataSource to use
-
getRoleNameCol
Return the column in the user role table that names a role.- Returns:
- the role name column
-
setRoleNameCol
Set the column in the user role table that names a role.- Parameters:
roleNameCol- The column name to use
-
getUserCredCol
Return the column in the user table that holds the user's credentials.- Returns:
- the credentials column
-
setUserCredCol
Set the column in the user table that holds the user's credentials.- Parameters:
userCredCol- The column name to use
-
getUserNameCol
Return the column in the user table that holds the user's name.- Returns:
- the user name column
-
setUserNameCol
Set the column in the user table that holds the user's name.- Parameters:
userNameCol- The column name to use
-
getUserRoleTable
Return the table that holds the relation between user's and roles.- Returns:
- the user-role table name
-
setUserRoleTable
Set the table that holds the relation between user's and roles.- Parameters:
userRoleTable- The table name to use
-
getUserTable
-
setUserTable
Set the table that holds user data.- Parameters:
userTable- The table name to use
-
getRoleAndGroupDescriptionCol
Return the column name used for role and group descriptions.- Returns:
- the role and group description column name
-
setRoleAndGroupDescriptionCol
Set the column name used for role and group descriptions.- Parameters:
roleAndGroupDescriptionCol- the column name to use
-
getGroupNameCol
Return the column name used for group names.- Returns:
- the group name column
-
setGroupNameCol
Set the column name used for group names.- Parameters:
groupNameCol- the column name to use
-
getUserFullNameCol
Return the column name used for user full names.- Returns:
- the user full name column
-
setUserFullNameCol
Set the column name used for user full names.- Parameters:
userFullNameCol- the column name to use
-
getUserGroupTable
Return the table that holds the relation between users and groups.- Returns:
- the user-group table name
-
setUserGroupTable
Set the table that holds the relation between users and groups.- Parameters:
userGroupTable- the table name to use
-
getGroupRoleTable
Return the table that holds the relation between groups and roles.- Returns:
- the group-role table name
-
setGroupRoleTable
Set the table that holds the relation between groups and roles.- Parameters:
groupRoleTable- the table name to use
-
getGroupTable
-
setGroupTable
Set the table that holds group data.- Parameters:
groupTable- the table name to use
-
getRoleTable
-
setRoleTable
Set the table that holds role data.- Parameters:
roleTable- the table name to use
-
getReadonly
public boolean getReadonly()Return whether the user database is read only.- Returns:
- true if the database is read only
-
setReadonly
public void setReadonly(boolean readonly) Set whether the user database is read only.- Parameters:
readonly- true to make the database read only
-
getId
Description copied from interface:UserDatabaseGet the unique global identifier of this user database.- Returns:
- the unique global identifier of this user database.
-
getGroups
Description copied from interface:UserDatabaseGet the set ofGroups defined in this user database.- Returns:
- the set of
Groups defined in this user database.
-
getRoles
Description copied from interface:UserDatabaseGet the set ofRoles defined in this user database.- Returns:
- the set of
Roles defined in this user database.
-
getUsers
Description copied from interface:UserDatabaseGet the set ofUsers defined in this user database.- Returns:
- the set of
Users defined in this user database.
-
close
Description copied from interface:UserDatabaseFinalize access to this user database.- Throws:
Exception- if any exception is thrown during closing
-
createGroup
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, or
nullif there's a pre-existing group
-
createRole
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, or
nullif there's a pre-existing role
-
createUser
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, or
nullif there's a pre-existing user
-
findGroup
Description copied from interface:UserDatabaseFind theGroupwith the specified group name.- Parameters:
groupname- Name of the group to return- Returns:
- the
Groupwith the specified group name, if any; otherwise returnnull.
-
findGroupInternal
Find a group by name using the provided database connection.- Parameters:
dbConnection- The database connection to usegroupName- The name of the group to find- Returns:
- the group, or null if not found
-
findRole
Description copied from interface:UserDatabaseFind theRolewith the specified role name.- Parameters:
rolename- Name of the role to return- Returns:
- the
Rolewith the specified role name, if any; otherwise returnnull.
-
findRoleInternal
Find a role by name using the provided database connection.- Parameters:
dbConnection- The database connection to useroleName- The name of the role to find- Returns:
- the role, or null if not found
-
findUser
Description copied from interface:UserDatabaseFind theUserwith the specified username.- Parameters:
username- Name of the user to return- Returns:
- the
Userwith the specified username, if any; otherwise returnnull.
-
findUserInternal
Deprecated.Will be made private in Tomcat 12Find a user by name using the provided database connection.- Parameters:
dbConnection- The database connection to useuserName- The name of the user to find- Returns:
- the user, or null if not found
-
modifiedGroup
Description copied from interface:UserDatabaseSignal the specifiedGroupfrom this user database has been modified.- Parameters:
group- The group that has been modified
-
modifiedRole
Description copied from interface:UserDatabaseSignal the specifiedRolefrom this user database has been modified.- Parameters:
role- The role that has been modified
-
modifiedUser
Description copied from interface:UserDatabaseSignal the specifiedUserfrom this user database has been modified.- Parameters:
user- The user that has been modified
-
open
Description copied from interface:UserDatabaseInitialize access to this user database.- Throws:
Exception- if any exception is thrown during opening
-
removeGroup
Description copied from interface:UserDatabaseRemove the specifiedGroupfrom this user database.- Parameters:
group- The group to be removed
-
removeRole
Description copied from interface:UserDatabaseRemove the specifiedRolefrom this user database.- Parameters:
role- The role to be removed
-
removeUser
Description copied from interface:UserDatabaseRemove the specifiedUserfrom this user database.- Parameters:
user- The user to be removed
-
save
Description 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
Save all pending changes to the database using the provided connection.- Parameters:
dbConnection- The database connection to use
-
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
Open the specified database connection.- Returns:
- Connection to the database
-
closeConnection
Close the specified database connection.- Parameters:
dbConnection- The connection to be closed
-