# Class MessagePolicy.TargetPolicy

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

Enclosing class:
  `MessagePolicy`

public static class MessagePolicy.TargetPolicy extends Object
Associates a set of targets with a protection policy. A `TargetPolicy` defines the protection requirements for messages that match the specified targets.

## Constructor Summary

Constructors
Constructor
Description
`TargetPolicy(MessagePolicy.Target[] targets, MessagePolicy.ProtectionPolicy protectionPolicy)`
Creates a new `TargetPolicy` with the specified targets and protection policy.

## Method Summary

Modifier and Type
Method
Description
`MessagePolicy.ProtectionPolicy`
`getProtectionPolicy()`
Returns the protection policy associated with this target policy.
`MessagePolicy.Target[]`
`getTargets()`
Returns the targets associated with this target policy.

### Methods inherited from class Object

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

## Constructor Details

### TargetPolicy

public TargetPolicy(MessagePolicy.Target[] targets, MessagePolicy.ProtectionPolicy protectionPolicy)
Creates a new `TargetPolicy` with the specified targets and protection policy.

Parameters:
  `targets` - the array of `Target` objects, or `null` if not applicable
  `protectionPolicy` - the `ProtectionPolicy` to apply; must not be `null`
Throws:
  `IllegalArgumentException` - if `protectionPolicy` is `null`

## Method Details

### getTargets

public MessagePolicy.Target[] getTargets()
Returns the targets associated with this target policy.

Returns:
  an array of `Target` objects, or `null` if no targets are defined

### getProtectionPolicy

public MessagePolicy.ProtectionPolicy getProtectionPolicy()
Returns the protection policy associated with this target policy.

Returns:
  the `ProtectionPolicy` for this target policy