SimpleServerAuthConfig (Apache Tomcat 11.0.23 API Documentation)
Description: declaration: package: org.apache.catalina.authenticator.jaspic, class: SimpleServerAuthConfig

# Class SimpleServerAuthConfig

java.lang.Object
org.apache.catalina.authenticator.jaspic.SimpleServerAuthConfig

All Implemented Interfaces:
  `AuthConfig, ServerAuthConfig`

public class SimpleServerAuthConfig extends Object implements ServerAuthConfig
Basic implementation primarily intended for use when using third-party `ServerAuthModule` implementations that only provide the module. This implementation supports configuring the `ServerAuthContext` with multiple modules.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SimpleServerAuthConfig(String layer, String appContext, CallbackHandler handler, Map<String,Object> properties)`
  Creates a new SimpleServerAuthConfig.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected ServerAuthContext`
  `createServerAuthContext(List<ServerAuthModule> modules)`
  Creates the ServerAuthContext.
  `String`
  `getAppContext()`
  Returns the application context for which this configuration applies.
  `ServerAuthContext`
  `getAuthContext(String authContextID, Subject serviceSubject, Map<String,Object> properties)`
  Returns the `ServerAuthContext` for the given authentication context ID.
  `String`
  `getAuthContextID(MessageInfo messageInfo)`
  Determines the authentication context ID for the given message.
  `String`
  `getMessageLayer()`
  Returns the message layer for which this configuration applies.
  `boolean`
  `isProtected()`
  Indicates whether the authentication mechanism is protected, meaning that the configuration data is stored securely.
  `void`
  `refresh()`
  Refreshes the configuration, reloading any changed settings.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### SimpleServerAuthConfig

    public SimpleServerAuthConfig(String layer, String appContext, CallbackHandler handler, Map<String,Object> properties)
    Creates a new SimpleServerAuthConfig.
    Parameters:
      `layer` - Message layer
      `appContext` - Application context
      `handler` - Callback handler
      `properties` - Configuration properties

- ## Method Details

  - ### getMessageLayer

    public String getMessageLayer()
    Description copied from interface: `jakarta.security.auth.message.config.AuthConfig`
    Returns the message layer for which this configuration applies.
    Specified by:
      `getMessageLayer` in interface `AuthConfig`
    Returns:
      the message layer

  - ### getAppContext

    public String getAppContext()
    Description copied from interface: `jakarta.security.auth.message.config.AuthConfig`
    Returns the application context for which this configuration applies.
    Specified by:
      `getAppContext` in interface `AuthConfig`
    Returns:
      the application context

  - ### getAuthContextID

    public String getAuthContextID(MessageInfo messageInfo)
    Determines the authentication context ID for the given message.

    Returns the MessageInfo's string representation as the auth context ID.

    Specified by:
      `getAuthContextID` in interface `AuthConfig`
    Parameters:
      `messageInfo` - the message information used to determine the context ID
    Returns:
      the authentication context ID, or `null` if no context applies

  - ### refresh

    public void refresh()
    Refreshes the configuration, reloading any changed settings.

    Clears the cached ServerAuthConfig so it will be recreated on next use.

    Specified by:
      `refresh` in interface `AuthConfig`

  - ### isProtected

    public boolean isProtected()
    Indicates whether the authentication mechanism is protected, meaning that the configuration data is stored securely.

    This implementation always returns `false`.

    Specified by:
      `isProtected` in interface `AuthConfig`
    Returns:
      `true` if the mechanism is protected, `false` otherwise

  - ### getAuthContext

    public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map<String,Object> properties) throws AuthException
    Returns the `ServerAuthContext` for the given authentication context ID.

    Loads ServerAuthModule instances from properties keyed with `org.apache.catalina.authenticator.jaspic.ServerAuthModule.N` where N is 1-based index. The returned context is cached and reused for subsequent calls.

    Specified by:
      `getAuthContext` in interface `ServerAuthConfig`
    Parameters:
      `authContextID` - the authentication context identifier
      `serviceSubject` - the service subject
      `properties` - the configuration properties
    Returns:
      the server authentication context
    Throws:
      `AuthException` - if an error occurs during authentication context creation

  - ### createServerAuthContext

    protected ServerAuthContext createServerAuthContext(List<ServerAuthModule> modules)
    Creates the ServerAuthContext. Can be overridden by subclasses to provide a custom implementation.
    Parameters:
      `modules` - List of ServerAuthModule instances
    Returns:
      The ServerAuthContext instance