Package org.springframework.security.web.header.writers

# Class PermissionsPolicyHeaderWriter

java.lang.Object
org.springframework.security.web.header.writers.PermissionsPolicyHeaderWriter

All Implemented Interfaces:
  `HeaderWriter`

public final class PermissionsPolicyHeaderWriter extends Object implements HeaderWriter
Provides support for Permisisons Policy.

Permissions Policy allows web developers to selectively enable, disable, and modify the behavior of certain APIs and web features in the browser.

A declaration of a permissions policy contains a set of security policies, each responsible for declaring the restrictions for a particular feature type.

Since:
  5.5

## Constructor Summary

Constructors
Constructor
Description
`PermissionsPolicyHeaderWriter()`
Create a new instance of `PermissionsPolicyHeaderWriter`.
`PermissionsPolicyHeaderWriter(String policy)`
Create a new instance of `PermissionsPolicyHeaderWriter` with supplied security policy.

## Method Summary

Modifier and Type
Method
Description
`void`
`setPolicy(String policy)`
Sets the policy to be used in the response header.
`String`
`toString()`
`void`
`writeHeaders(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)`
Create a `Header` instance.

### Methods inherited from class java.lang.Object

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

## Constructor Details

### PermissionsPolicyHeaderWriter

public PermissionsPolicyHeaderWriter()
Create a new instance of `PermissionsPolicyHeaderWriter`.

### PermissionsPolicyHeaderWriter

public PermissionsPolicyHeaderWriter(String policy)
Create a new instance of `PermissionsPolicyHeaderWriter` with supplied security policy.

Parameters:
  `policy` - the security policy
Throws:
  `IllegalArgumentException` - if policy is `null` or empty

## Method Details

### setPolicy

public void setPolicy(String policy)
Sets the policy to be used in the response header.

Parameters:
  `policy` - a permissions policy
Throws:
  `IllegalArgumentException` - if policy is null

### writeHeaders

public void writeHeaders(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
Description copied from interface: `HeaderWriter`
Create a `Header` instance.

Specified by:
  `writeHeaders` in interface `HeaderWriter`
Parameters:
  `request` - the request
  `response` - the response

### toString

public String toString()

Overrides:
  `toString` in class `Object`