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
ConstructorDescriptionFeaturePolicyHeaderWriter
(String policyDirectives) Create a new instance ofFeaturePolicyHeaderWriter
with supplied security policy directive(s). -
Method Summary
Modifier and TypeMethodDescriptionvoid
setPolicyDirectives
(String policyDirectives) Set the security policy directive(s) to be used in the response header.toString()
void
writeHeaders
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Create aHeader
instance.
-
Constructor Details
-
FeaturePolicyHeaderWriter
Create a new instance ofFeaturePolicyHeaderWriter
with supplied security policy directive(s).- Parameters:
policyDirectives
- the security policy directive(s)- Throws:
IllegalArgumentException
- if policyDirectives isnull
or empty
-
-
Method Details
-
writeHeaders
public void writeHeaders(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:HeaderWriter
Create aHeader
instance.- Specified by:
writeHeaders
in 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 isnull
or empty
-
toString
-