# Class DataSourceUserDatabaseMBean

java.lang.Object
org.apache.tomcat.util.modeler.BaseModelMBean
org.apache.catalina.mbeans.DataSourceUserDatabaseMBean

All Implemented Interfaces:
  `DynamicMBean, MBeanRegistration, ModelMBeanNotificationBroadcaster, NotificationBroadcaster`

public class DataSourceUserDatabaseMBean extends BaseModelMBean

A ModelMBean implementation for the `org.apache.catalina.users.DataSourceUserDatabase` component.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final ManagedBean`
  `managed`
  The `ManagedBean` information describing this MBean.
  `protected final Registry`
  `registry`
  The configuration information registry for our managed beans.

  ### Fields inherited from class BaseModelMBean

  `attributeBroadcaster, generalBroadcaster, managedBean, oname, resource, resourceType`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DataSourceUserDatabaseMBean()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addGroupRole(String groupname, String rolename)`
  Add role to a group.
  `void`
  `addUserGroup(String username, String groupname)`
  Add group to user.
  `void`
  `addUserRole(String username, String rolename)`
  Add specified role to the user.
  `void`
  `changeUserPassword(String username, String password)`
  Change user credentials.
  `String`
  `createGroup(String groupname, String description)`
  Create a new Group and return the corresponding name.
  `String`
  `createRole(String rolename, String description)`
  Create a new Role and return the corresponding name.
  `String`
  `createUser(String username, String password, String fullName)`
  Create a new User and return the corresponding name.
  `String[]`
  `getGroupRoles(String groupname)`
  Get roles for a group.
  `String[]`
  `getGroups()`
  `String[]`
  `getRoles()`
  `String[]`
  `getUserGroups(String username)`
  Get groups for a user.
  `String[]`
  `getUserRoles(String username)`
  Get roles for a user.
  `String[]`
  `getUsers()`
  `void`
  `removeGroup(String groupname)`
  Remove an existing group.
  `void`
  `removeGroupRole(String groupname, String rolename)`
  Remove role from a group.
  `void`
  `removeRole(String rolename)`
  Remove an existing role.
  `void`
  `removeUser(String username)`
  Remove an existing user.
  `void`
  `removeUserGroup(String username, String groupname)`
  Remove group from user.
  `void`
  `removeUserRole(String username, String rolename)`
  Remove specified role from the user.

  ### Methods inherited from class BaseModelMBean

  `addAttributeChangeNotificationListener, addNotificationListener, getAttribute, getAttributes, getClassName, getJmxName, getManagedResource, getMBeanInfo, getModelerType, getNotificationInfo, getObjectName, invoke, postDeregister, postRegister, preDeregister, preRegister, removeAttributeChangeNotificationListener, removeNotificationListener, sendAttributeChangeNotification, sendAttributeChangeNotification, sendNotification, sendNotification, setAttribute, setAttributes, setManagedBean, setManagedResource, toString`

  ### Methods inherited from class Object

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

- ## Field Details

  - ### registry

    protected final Registry registry
    The configuration information registry for our managed beans.

  - ### managed

    protected final ManagedBean managed
    The `ManagedBean` information describing this MBean.

- ## Constructor Details

  - ### DataSourceUserDatabaseMBean

    public DataSourceUserDatabaseMBean()

- ## Method Details

  - ### getGroups

    public String[] getGroups()
    Returns:
      the names of all groups defined in this database.

  - ### getRoles

    public String[] getRoles()
    Returns:
      the names of all roles defined in this database.

  - ### getUsers

    public String[] getUsers()
    Returns:
      the names of all users defined in this database.

  - ### createGroup

    public String createGroup(String groupname, String description)
    Create a new Group and return the corresponding name.
    Parameters:
      `groupname` - Group name of the new group
      `description` - Description of the new group
    Returns:
      the new group name

  - ### createRole

    public String createRole(String rolename, String description)
    Create a new Role and return the corresponding name.
    Parameters:
      `rolename` - Group name of the new group
      `description` - Description of the new group
    Returns:
      the new role name

  - ### createUser

    public String createUser(String username, String password, String fullName)
    Create a new User and return the corresponding name.
    Parameters:
      `username` - Username of the new user
      `password` - Password for the new user
      `fullName` - Full name for the new user
    Returns:
      the new username

  - ### removeGroup

    public void removeGroup(String groupname)
    Remove an existing group.
    Parameters:
      `groupname` - Group name to remove

  - ### removeRole

    public void removeRole(String rolename)
    Remove an existing role.
    Parameters:
      `rolename` - Role name to remove

  - ### removeUser

    public void removeUser(String username)
    Remove an existing user.
    Parameters:
      `username` - Username to remove

  - ### changeUserPassword

    public void changeUserPassword(String username, String password)
    Change user credentials.
    Parameters:
      `username` - The username
      `password` - The new credentials

  - ### addUserRole

    public void addUserRole(String username, String rolename)
    Add specified role to the user.
    Parameters:
      `username` - The username
      `rolename` - The role name

  - ### removeUserRole

    public void removeUserRole(String username, String rolename)
    Remove specified role from the user.
    Parameters:
      `username` - The username
      `rolename` - The role name

  - ### getUserRoles

    public String[] getUserRoles(String username)
    Get roles for a user.
    Parameters:
      `username` - The username
    Returns:
      Array of role names

  - ### addUserGroup

    public void addUserGroup(String username, String groupname)
    Add group to user.
    Parameters:
      `username` - The username
      `groupname` - The group name

  - ### removeUserGroup

    public void removeUserGroup(String username, String groupname)
    Remove group from user.
    Parameters:
      `username` - The username
      `groupname` - The group name

  - ### getUserGroups

    public String[] getUserGroups(String username)
    Get groups for a user.
    Parameters:
      `username` - The username
    Returns:
      Array of group names

  - ### addGroupRole

    public void addGroupRole(String groupname, String rolename)
    Add role to a group.
    Parameters:
      `groupname` - The group name
      `rolename` - The role name

  - ### removeGroupRole

    public void removeGroupRole(String groupname, String rolename)
    Remove role from a group.
    Parameters:
      `groupname` - The group name
      `rolename` - The role name

  - ### getGroupRoles

    public String[] getGroupRoles(String groupname)
    Get roles for a group.
    Parameters:
      `groupname` - The group name
    Returns:
      Array of role names