DataSourceUserDatabase (Apache Tomcat 9.0.111 API Documentation)
Description: declaration: package: org.apache.catalina.users, class: DataSourceUserDatabase

# 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 final ConcurrentHashMap<String,Group>`
  `createdGroups`
  `protected final ConcurrentHashMap<String,Role>`
  `createdRoles`
  `protected final ConcurrentHashMap<String,User>`
  `createdUsers`
  `protected final 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 final String`
  `id`
  The unique global identifier of this user database.
  `protected final ConcurrentHashMap<String,Group>`
  `modifiedGroups`
  `protected final ConcurrentHashMap<String,Role>`
  `modifiedRoles`
  `protected final ConcurrentHashMap<String,User>`
  `modifiedUsers`
  `protected boolean`
  `readonly`
  A flag, indicating if the user database is read only.
  `protected final ConcurrentHashMap<String,Group>`
  `removedGroups`
  `protected final ConcurrentHashMap<String,Role>`
  `removedRoles`
  `protected final ConcurrentHashMap<String,User>`
  `removedUsers`
  `protected String`
  `roleAndGroupDescriptionCol`
  The column in the role and group tables for the description
  `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 Summary

  Constructors
  Constructor
  Description
  `DataSourceUserDatabase(DataSource dataSource, String id)`

- ## Method Summary

  Modifier and Type
  Method
  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.

  ### Methods inherited from class SparseUserDatabase

  `isSparse`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface UserDatabase

  `backgroundProcess`

- ## Field Details

  - ### 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 Details

  - ### DataSourceUserDatabase

    public DataSourceUserDatabase(DataSource dataSource, String id)

- ## Method Details

  - ### 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 `Group`s defined in this user database.

  - ### getRoles

    public Iterator<Role> getRoles()
    Returns:
      the set of `Role`s defined in this user database.

  - ### getUsers

    public Iterator<User> getUsers()
    Returns:
      the set of `User`s defined in this user database.

  - ### close

    public void close() throws Exception
    Description copied from interface: `UserDatabase`
    Finalize 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: `UserDatabase`
    Create and return a new `Group` 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(String rolename, String description)
    Description copied from interface: `UserDatabase`
    Create and return a new `Role` 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(String username, String password, String fullName)
    Description copied from interface: `UserDatabase`
    Create and return a new `User` defined 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

  - ### findGroup

    public Group findGroup(String groupname)
    Parameters:
      `groupname` - Name of the group to return
    Returns:
      the `Group` with the specified group name, if any; otherwise return `null`.

  - ### findGroupInternal

    public Group findGroupInternal(Connection dbConnection, String groupName)

  - ### findRole

    public Role findRole(String rolename)
    Parameters:
      `rolename` - Name of the role to return
    Returns:
      the `Role` with the specified role name, if any; otherwise return `null`.

  - ### findRoleInternal

    public Role findRoleInternal(Connection dbConnection, String roleName)

  - ### findUser

    public User findUser(String username)
    Parameters:
      `username` - Name of the user to return
    Returns:
      the `User` with the specified username, if any; otherwise return `null`.

  - ### findUserInternal

    public User findUserInternal(Connection dbConnection, String userName)

  - ### modifiedGroup

    public void modifiedGroup(Group group)
    Description copied from interface: `UserDatabase`
    Signal the specified `Group` 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 specified `Role` 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 specified `User` from this user database has been modified.
    Parameters:
      `user` - The user that has been modified

  - ### open

    public void open() throws Exception
    Description copied from interface: `UserDatabase`
    Initialize access to this user database.
    Throws:
      `Exception` - if any exception is thrown during opening

  - ### removeGroup

    public void removeGroup(Group group)
    Description copied from interface: `UserDatabase`
    Remove the specified `Group` from this user database.
    Parameters:
      `group` - The group to be removed

  - ### removeRole

    public void removeRole(Role role)
    Description copied from interface: `UserDatabase`
    Remove the specified `Role` from this user database.
    Parameters:
      `role` - The role to be removed

  - ### removeUser

    public void removeUser(User user)
    Description copied from interface: `UserDatabase`
    Remove the specified `User` from this user database.
    Parameters:
      `user` - The user to be removed

  - ### save

    public void save() throws Exception
    Description copied from interface: `UserDatabase`
    Save 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: `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 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