PropertiesRoleMappingListener (Apache Tomcat 10.1.54 API Documentation)
Description: declaration: package: org.apache.catalina.core, class: PropertiesRoleMappingListener

# Class PropertiesRoleMappingListener

java.lang.Object
org.apache.catalina.core.PropertiesRoleMappingListener

All Implemented Interfaces:
  `LifecycleListener`

public class PropertiesRoleMappingListener extends Object implements LifecycleListener
Implementation of `LifecycleListener` that will populate the context's role mapping from a properties file.

This listener must only be nested within `Context` elements.

The keys represent application roles (e.g., admin, user, uservisor, etc.) while the values represent technical roles (e.g., DNs, SIDs, UUIDs, etc.). A key can also be prefixed if, e.g., the properties file contains generic application configuration as well: `app-roles.`.

Note: The default value for the `roleMappingFile` is `webapp:/WEB-INF/role-mapping.properties`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PropertiesRoleMappingListener()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getKeyPrefix()`
  Gets the prefix to filter from property keys.
  `String`
  `getRoleMappingFile()`
  Gets the path to the role mapping properties file.
  `void`
  `lifecycleEvent(LifecycleEvent event)`
  Acknowledge the occurrence of the specified event.
  `void`
  `setKeyPrefix(String keyPrefix)`
  Sets the prefix to filter from property keys.
  `void`
  `setRoleMappingFile(String roleMappingFile)`
  Sets the path to the role mapping properties file.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### PropertiesRoleMappingListener

    public PropertiesRoleMappingListener()

- ## Method Details

  - ### setRoleMappingFile

    public void setRoleMappingFile(String roleMappingFile)
    Sets the path to the role mapping properties file. You can use protocol `webapp:` and whatever `ConfigFileLoader` supports.
    Parameters:
      `roleMappingFile` - the role mapping properties file to load from
    Throws:
      `NullPointerException` - if roleMappingFile is null
      `IllegalArgumentException` - if roleMappingFile is empty

  - ### getRoleMappingFile

    public String getRoleMappingFile()
    Gets the path to the role mapping properties file.
    Returns:
      the path to the role mapping properties file

  - ### setKeyPrefix

    public void setKeyPrefix(String keyPrefix)
    Sets the prefix to filter from property keys. All other keys will be ignored which do not have the prefix.
    Parameters:
      `keyPrefix` - the properties key prefix

  - ### getKeyPrefix

    public String getKeyPrefix()
    Gets the prefix to filter from property keys.
    Returns:
      the properties key prefix

  - ### lifecycleEvent

    public void lifecycleEvent(LifecycleEvent event)
    Description copied from interface: `LifecycleListener`
    Acknowledge the occurrence of the specified event.
    Specified by:
      `lifecycleEvent` in interface `LifecycleListener`
    Parameters:
      `event` - LifecycleEvent that has occurred