Class ReferrerPolicyHeaderWriter
- java.lang.Object
-
- org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter
-
- All Implemented Interfaces:
HeaderWriter
public class ReferrerPolicyHeaderWriter extends java.lang.Object implements HeaderWriter
Provides support for Referrer Policy.
The list of policies defined can be found at Referrer Policies.
This implementation of
HeaderWriter
writes the following header:- Referrer-Policy
By default, the Referrer-Policy header is not included in the response. Policy no-referrer is used by default if no
ReferrerPolicyHeaderWriter.ReferrerPolicy
is set.- Since:
- 4.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReferrerPolicyHeaderWriter.ReferrerPolicy
-
Constructor Summary
Constructors Constructor Description ReferrerPolicyHeaderWriter()
Creates a new instance.ReferrerPolicyHeaderWriter(ReferrerPolicyHeaderWriter.ReferrerPolicy policy)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setPolicy(ReferrerPolicyHeaderWriter.ReferrerPolicy policy)
Sets the policy to be used in the response header.void
writeHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Create aHeader
instance.
-
-
-
Constructor Detail
-
ReferrerPolicyHeaderWriter
public ReferrerPolicyHeaderWriter()
Creates a new instance. Default value: no-referrer.
-
ReferrerPolicyHeaderWriter
public ReferrerPolicyHeaderWriter(ReferrerPolicyHeaderWriter.ReferrerPolicy policy)
Creates a new instance.- Parameters:
policy
- a referrer policy- Throws:
java.lang.IllegalArgumentException
- if policy is null
-
-
Method Detail
-
setPolicy
public void setPolicy(ReferrerPolicyHeaderWriter.ReferrerPolicy policy)
Sets the policy to be used in the response header.- Parameters:
policy
- a referrer policy- Throws:
java.lang.IllegalArgumentException
- if policy is null
-
writeHeaders
public void writeHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Description copied from interface:HeaderWriter
Create aHeader
instance.- Specified by:
writeHeaders
in interfaceHeaderWriter
- Parameters:
request
- the requestresponse
- the response- See Also:
HeaderWriter.writeHeaders(HttpServletRequest, HttpServletResponse)
-
-