MessagePolicy (JASPIC 3.1 API Documentation - Apache Tomcat 11.0.23)
Description: declaration: package: jakarta.security.auth.message, class: MessagePolicy

# Class MessagePolicy

java.lang.Object
jakarta.security.auth.message.MessagePolicy

public class MessagePolicy extends Object
Defines the security policy requirements for a message-based authentication module. A `MessagePolicy` specifies the target policies that determine which messages require authentication and the level of protection required.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `MessagePolicy.ProtectionPolicy`
  Defines the level of protection to be applied to a message.
  `static interface`
  `MessagePolicy.Target`
  Defines how to extract target information from a message for policy evaluation.
  `static class`
  `MessagePolicy.TargetPolicy`
  Associates a set of targets with a protection policy.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MessagePolicy(MessagePolicy.TargetPolicy[] targetPolicies, boolean mandatory)`
  Creates a new `MessagePolicy` with the specified target policies and mandatory flag.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `MessagePolicy.TargetPolicy[]`
  `getTargetPolicies()`
  Returns the target policies associated with this message policy.
  `boolean`
  `isMandatory()`
  Indicates whether this policy is mandatory.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### MessagePolicy

    public MessagePolicy(MessagePolicy.TargetPolicy[] targetPolicies, boolean mandatory)
    Creates a new `MessagePolicy` with the specified target policies and mandatory flag.
    Parameters:
      `targetPolicies` - the array of `TargetPolicy` objects defining the policy requirements; must not be `null`
      `mandatory` - `true` if the policy is mandatory and authentication must succeed; `false` if the policy is optional
    Throws:
      `IllegalArgumentException` - if `targetPolicies` is `null`

- ## Method Details

  - ### isMandatory

    public boolean isMandatory()
    Indicates whether this policy is mandatory. If mandatory, the authentication module must enforce the policy and authentication will fail if the policy cannot be satisfied.
    Returns:
      `true` if the policy is mandatory, `false` otherwise

  - ### getTargetPolicies

    public MessagePolicy.TargetPolicy[] getTargetPolicies()
    Returns the target policies associated with this message policy.
    Returns:
      an array of `TargetPolicy` objects, or `null` if no target policies are defined