Class FeaturePolicyHeaderWriter

java.lang.Object
org.springframework.security.web.header.writers.FeaturePolicyHeaderWriter
All Implemented Interfaces:
HeaderWriter

public final class FeaturePolicyHeaderWriter extends Object implements HeaderWriter
Provides support for Feature Policy.

Feature 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 feature policy contains a set of security policy directives, each responsible for declaring the restrictions for a particular feature type.

Since:
5.1
  • Constructor Details

    • FeaturePolicyHeaderWriter

      public FeaturePolicyHeaderWriter(String policyDirectives)
      Create a new instance of FeaturePolicyHeaderWriter with supplied security policy directive(s).
      Parameters:
      policyDirectives - the security policy directive(s)
      Throws:
      IllegalArgumentException - if policyDirectives is null or empty
  • Method Details

    • 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
    • setPolicyDirectives

      public void setPolicyDirectives(String policyDirectives)
      Set the security policy directive(s) to be used in the response header.
      Parameters:
      policyDirectives - the security policy directive(s)
      Throws:
      IllegalArgumentException - if policyDirectives is null or empty
    • toString

      public String toString()
      Overrides:
      toString in class Object