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 java.util.concurrent.ConcurrentHashMap<java.lang.String,Group>
createdGroups
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Role>
createdRoles
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,User>
createdUsers
protected javax.sql.DataSource
dataSource
DataSource to use.protected java.lang.String
dataSourceName
The name of the JNDI JDBC DataSourceprotected java.lang.String
groupNameCol
The column in the user group table that names a groupprotected java.lang.String
groupRoleTable
The table that holds the relation between groups and rolesprotected java.lang.String
groupTable
The table that holds user data.protected java.lang.String
id
The unique global identifier of this user database.protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Group>
modifiedGroups
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Role>
modifiedRoles
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,User>
modifiedUsers
protected boolean
readonly
A flag, indicating if the user database is read only.protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Group>
removedGroups
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Role>
removedRoles
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,User>
removedUsers
protected java.lang.String
roleAndGroupDescriptionCol
The column in the role and group tables for the descriptionprotected java.lang.String
roleNameCol
The column in the user role table that names a roleprotected java.lang.String
roleTable
The table that holds user data.protected java.lang.String
userCredCol
The column in the user table that holds the user's credentialsprotected java.lang.String
userFullNameCol
The column in the user table that holds the user's full nameprotected java.lang.String
userGroupTable
The table that holds the relation between users and groupsprotected java.lang.String
userNameCol
The column in the user table that holds the user's nameprotected java.lang.String
userRoleTable
The table that holds the relation between users and rolesprotected java.lang.String
userTable
The table that holds user data.
-
Constructor Summary
Constructors Constructor Description DataSourceUserDatabase(javax.sql.DataSource dataSource, java.lang.String id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Finalize access to this user database.protected void
closeConnection(java.sql.Connection dbConnection)
Close the specified database connection.Group
createGroup(java.lang.String groupname, java.lang.String description)
Create and return a newGroup
defined in this user database.Role
createRole(java.lang.String rolename, java.lang.String description)
Create and return a newRole
defined in this user database.User
createUser(java.lang.String username, java.lang.String password, java.lang.String fullName)
Create and return a newUser
defined in this user database.Group
findGroup(java.lang.String groupname)
Group
findGroupInternal(java.sql.Connection dbConnection, java.lang.String groupName)
Role
findRole(java.lang.String rolename)
Role
findRoleInternal(java.sql.Connection dbConnection, java.lang.String roleName)
User
findUser(java.lang.String username)
User
findUserInternal(java.sql.Connection dbConnection, java.lang.String userName)
java.lang.String
getDataSourceName()
java.lang.String
getGroupNameCol()
java.lang.String
getGroupRoleTable()
java.util.Iterator<Group>
getGroups()
java.lang.String
getGroupTable()
java.lang.String
getId()
boolean
getReadonly()
java.lang.String
getRoleAndGroupDescriptionCol()
java.lang.String
getRoleNameCol()
java.util.Iterator<Role>
getRoles()
java.lang.String
getRoleTable()
java.lang.String
getUserCredCol()
java.lang.String
getUserFullNameCol()
java.lang.String
getUserGroupTable()
java.lang.String
getUserNameCol()
java.lang.String
getUserRoleTable()
java.util.Iterator<User>
getUsers()
java.lang.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 specifiedGroup
from this user database has been modified.void
modifiedRole(Role role)
Signal the specifiedRole
from this user database has been modified.void
modifiedUser(User user)
Signal the specifiedUser
from this user database has been modified.void
open()
Initialize access to this user database.protected java.sql.Connection
openConnection()
Open the specified database connection.void
removeGroup(Group group)
Remove the specifiedGroup
from this user database.void
removeRole(Role role)
Remove the specifiedRole
from this user database.void
removeUser(User user)
Remove the specifiedUser
from this user database.void
save()
Save any updated information to the persistent storage location for this user database.protected void
saveInternal(java.sql.Connection dbConnection)
void
setDataSourceName(java.lang.String dataSourceName)
Set the name of the JNDI JDBC DataSource.void
setGroupNameCol(java.lang.String groupNameCol)
void
setGroupRoleTable(java.lang.String groupRoleTable)
void
setGroupTable(java.lang.String groupTable)
void
setReadonly(boolean readonly)
void
setRoleAndGroupDescriptionCol(java.lang.String roleAndGroupDescriptionCol)
void
setRoleNameCol(java.lang.String roleNameCol)
Set the column in the user role table that names a role.void
setRoleTable(java.lang.String roleTable)
void
setUserCredCol(java.lang.String userCredCol)
Set the column in the user table that holds the user's credentials.void
setUserFullNameCol(java.lang.String userFullNameCol)
void
setUserGroupTable(java.lang.String userGroupTable)
void
setUserNameCol(java.lang.String userNameCol)
Set the column in the user table that holds the user's name.void
setUserRoleTable(java.lang.String userRoleTable)
Set the table that holds the relation between user's and roles.void
setUserTable(java.lang.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 javax.sql.DataSource dataSource
DataSource to use.
-
id
protected final java.lang.String id
The unique global identifier of this user database.
-
createdUsers
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,User> createdUsers
-
modifiedUsers
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,User> modifiedUsers
-
removedUsers
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,User> removedUsers
-
createdGroups
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Group> createdGroups
-
modifiedGroups
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Group> modifiedGroups
-
removedGroups
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Group> removedGroups
-
createdRoles
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Role> createdRoles
-
modifiedRoles
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Role> modifiedRoles
-
removedRoles
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,Role> removedRoles
-
dataSourceName
protected java.lang.String dataSourceName
The name of the JNDI JDBC DataSource
-
roleNameCol
protected java.lang.String roleNameCol
The column in the user role table that names a role
-
roleAndGroupDescriptionCol
protected java.lang.String roleAndGroupDescriptionCol
The column in the role and group tables for the description
-
groupNameCol
protected java.lang.String groupNameCol
The column in the user group table that names a group
-
userCredCol
protected java.lang.String userCredCol
The column in the user table that holds the user's credentials
-
userFullNameCol
protected java.lang.String userFullNameCol
The column in the user table that holds the user's full name
-
userNameCol
protected java.lang.String userNameCol
The column in the user table that holds the user's name
-
userRoleTable
protected java.lang.String userRoleTable
The table that holds the relation between users and roles
-
userGroupTable
protected java.lang.String userGroupTable
The table that holds the relation between users and groups
-
groupRoleTable
protected java.lang.String groupRoleTable
The table that holds the relation between groups and roles
-
userTable
protected java.lang.String userTable
The table that holds user data.
-
groupTable
protected java.lang.String groupTable
The table that holds user data.
-
roleTable
protected java.lang.String roleTable
The table that holds user data.
-
readonly
protected boolean readonly
A flag, indicating if the user database is read only.
-
-
Method Detail
-
getDataSourceName
public java.lang.String getDataSourceName()
- Returns:
- the name of the JNDI JDBC DataSource.
-
setDataSourceName
public void setDataSourceName(java.lang.String dataSourceName)
Set the name of the JNDI JDBC DataSource.- Parameters:
dataSourceName
- the name of the JNDI JDBC DataSource
-
getRoleNameCol
public java.lang.String getRoleNameCol()
- Returns:
- the column in the user role table that names a role.
-
setRoleNameCol
public void setRoleNameCol(java.lang.String roleNameCol)
Set the column in the user role table that names a role.- Parameters:
roleNameCol
- The column name
-
getUserCredCol
public java.lang.String getUserCredCol()
- Returns:
- the column in the user table that holds the user's credentials.
-
setUserCredCol
public void setUserCredCol(java.lang.String userCredCol)
Set the column in the user table that holds the user's credentials.- Parameters:
userCredCol
- The column name
-
getUserNameCol
public java.lang.String getUserNameCol()
- Returns:
- the column in the user table that holds the user's name.
-
setUserNameCol
public void setUserNameCol(java.lang.String userNameCol)
Set the column in the user table that holds the user's name.- Parameters:
userNameCol
- The column name
-
getUserRoleTable
public java.lang.String getUserRoleTable()
- Returns:
- the table that holds the relation between user's and roles.
-
setUserRoleTable
public void setUserRoleTable(java.lang.String userRoleTable)
Set the table that holds the relation between user's and roles.- Parameters:
userRoleTable
- The table name
-
getUserTable
public java.lang.String getUserTable()
- Returns:
- the table that holds user data..
-
setUserTable
public void setUserTable(java.lang.String userTable)
Set the table that holds user data.- Parameters:
userTable
- The table name
-
getRoleAndGroupDescriptionCol
public java.lang.String getRoleAndGroupDescriptionCol()
- Returns:
- the roleAndGroupDescriptionCol
-
setRoleAndGroupDescriptionCol
public void setRoleAndGroupDescriptionCol(java.lang.String roleAndGroupDescriptionCol)
- Parameters:
roleAndGroupDescriptionCol
- the roleAndGroupDescriptionCol to set
-
getGroupNameCol
public java.lang.String getGroupNameCol()
- Returns:
- the groupNameCol
-
setGroupNameCol
public void setGroupNameCol(java.lang.String groupNameCol)
- Parameters:
groupNameCol
- the groupNameCol to set
-
getUserFullNameCol
public java.lang.String getUserFullNameCol()
- Returns:
- the userFullNameCol
-
setUserFullNameCol
public void setUserFullNameCol(java.lang.String userFullNameCol)
- Parameters:
userFullNameCol
- the userFullNameCol to set
-
getUserGroupTable
public java.lang.String getUserGroupTable()
- Returns:
- the userGroupTable
-
setUserGroupTable
public void setUserGroupTable(java.lang.String userGroupTable)
- Parameters:
userGroupTable
- the userGroupTable to set
-
getGroupRoleTable
public java.lang.String getGroupRoleTable()
- Returns:
- the groupRoleTable
-
setGroupRoleTable
public void setGroupRoleTable(java.lang.String groupRoleTable)
- Parameters:
groupRoleTable
- the groupRoleTable to set
-
getGroupTable
public java.lang.String getGroupTable()
- Returns:
- the groupTable
-
setGroupTable
public void setGroupTable(java.lang.String groupTable)
- Parameters:
groupTable
- the groupTable to set
-
getRoleTable
public java.lang.String getRoleTable()
- Returns:
- the roleTable
-
setRoleTable
public void setRoleTable(java.lang.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 java.lang.String getId()
- Returns:
- the unique global identifier of this user database.
-
getGroups
public java.util.Iterator<Group> getGroups()
- Returns:
- the set of
Group
s defined in this user database.
-
getRoles
public java.util.Iterator<Role> getRoles()
- Returns:
- the set of
Role
s defined in this user database.
-
getUsers
public java.util.Iterator<User> getUsers()
- Returns:
- the set of
User
s defined in this user database.
-
close
public void close() throws java.lang.Exception
Description copied from interface:UserDatabase
Finalize access to this user database.- Throws:
java.lang.Exception
- if any exception is thrown during closing
-
createGroup
public Group createGroup(java.lang.String groupname, java.lang.String description)
Description copied from interface:UserDatabase
Create and return a newGroup
defined 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(java.lang.String rolename, java.lang.String description)
Description copied from interface:UserDatabase
Create and return a newRole
defined 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(java.lang.String username, java.lang.String password, java.lang.String fullName)
Description copied from interface:UserDatabase
Create and return a newUser
defined 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(java.lang.String groupname)
- Parameters:
groupname
- Name of the group to return- Returns:
- the
Group
with the specified group name, if any; otherwise returnnull
.
-
findGroupInternal
public Group findGroupInternal(java.sql.Connection dbConnection, java.lang.String groupName)
-
findRole
public Role findRole(java.lang.String rolename)
- Parameters:
rolename
- Name of the role to return- Returns:
- the
Role
with the specified role name, if any; otherwise returnnull
.
-
findRoleInternal
public Role findRoleInternal(java.sql.Connection dbConnection, java.lang.String roleName)
-
findUser
public User findUser(java.lang.String username)
- Parameters:
username
- Name of the user to return- Returns:
- the
User
with the specified user name, if any; otherwise returnnull
.
-
findUserInternal
public User findUserInternal(java.sql.Connection dbConnection, java.lang.String userName)
-
modifiedGroup
public void modifiedGroup(Group group)
Description copied from interface:UserDatabase
Signal the specifiedGroup
from this user database has been modified.- Parameters:
group
- The group that has been modified
-
modifiedRole
public void modifiedRole(Role role)
Description copied from interface:UserDatabase
Signal the specifiedRole
from this user database has been modified.- Parameters:
role
- The role that has been modified
-
modifiedUser
public void modifiedUser(User user)
Description copied from interface:UserDatabase
Signal the specifiedUser
from this user database has been modified.- Parameters:
user
- The user that has been modified
-
open
public void open() throws java.lang.Exception
Description copied from interface:UserDatabase
Initialize access to this user database.- Throws:
java.lang.Exception
- if any exception is thrown during opening
-
removeGroup
public void removeGroup(Group group)
Description copied from interface:UserDatabase
Remove the specifiedGroup
from this user database.- Parameters:
group
- The group to be removed
-
removeRole
public void removeRole(Role role)
Description copied from interface:UserDatabase
Remove the specifiedRole
from this user database.- Parameters:
role
- The role to be removed
-
removeUser
public void removeUser(User user)
Description copied from interface:UserDatabase
Remove the specifiedUser
from this user database.- Parameters:
user
- The user to be removed
-
save
public void save() throws java.lang.Exception
Description copied from interface:UserDatabase
Save any updated information to the persistent storage location for this user database.- Throws:
java.lang.Exception
- if any exception is thrown during saving
-
saveInternal
protected void saveInternal(java.sql.Connection dbConnection)
-
isAvailable
public boolean isAvailable()
Description copied from interface:UserDatabase
Is 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 java.sql.Connection openConnection()
Open the specified database connection.- Returns:
- Connection to the database
-
closeConnection
protected void closeConnection(java.sql.Connection dbConnection)
Close the specified database connection.- Parameters:
dbConnection
- The connection to be closed
-
-