Class FeaturePolicyHeaderWriter
java.lang.Object
org.springframework.security.web.header.writers.FeaturePolicyHeaderWriter
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionFeaturePolicyHeaderWriter(String policyDirectives) Create a new instance ofFeaturePolicyHeaderWriterwith supplied security policy directive(s). -
Method Summary
Modifier and TypeMethodDescriptionvoidsetPolicyDirectives(String policyDirectives) Set the security policy directive(s) to be used in the response header.toString()voidwriteHeaders(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Create aHeaderinstance.
-
Constructor Details
-
FeaturePolicyHeaderWriter
Create a new instance ofFeaturePolicyHeaderWriterwith supplied security policy directive(s).- Parameters:
policyDirectives- the security policy directive(s)- Throws:
IllegalArgumentException- if policyDirectives isnullor empty
-
-
Method Details
-
writeHeaders
public void writeHeaders(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:HeaderWriterCreate aHeaderinstance.- Specified by:
writeHeadersin interfaceHeaderWriter- Parameters:
request- the requestresponse- the response
-
setPolicyDirectives
Set the security policy directive(s) to be used in the response header.- Parameters:
policyDirectives- the security policy directive(s)- Throws:
IllegalArgumentException- if policyDirectives isnullor empty
-
toString
-