Class XXssProtectionHeaderWriter
java.lang.Object
org.springframework.security.web.header.writers.XXssProtectionHeaderWriter
- All Implemented Interfaces:
HeaderWriter
Renders the X-XSS-Protection header.
- Since:
- 3.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe value of the x-xss-protection header. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetBlock(boolean block) Deprecated.voidsetEnabled(boolean enabled) Deprecated.usesetHeaderValue(HeaderValue)insteadvoidsetHeaderValue(XXssProtectionHeaderWriter.HeaderValue headerValue) Sets the value of the X-XSS-PROTECTION header.toString()voidwriteHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Create aHeaderinstance.
-
Constructor Details
-
XXssProtectionHeaderWriter
public XXssProtectionHeaderWriter()Create a new instance
-
-
Method Details
-
writeHeaders
public void writeHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Description copied from interface:HeaderWriterCreate aHeaderinstance.- Specified by:
writeHeadersin interfaceHeaderWriter- Parameters:
request- the requestresponse- the response
-
setEnabled
Deprecated.usesetHeaderValue(HeaderValue)insteadIf true, will contain a value of 1. For example:X-XSS-Protection: 1
or ifsetBlock(boolean)is trueX-XSS-Protection: 1; mode=block
If false, will explicitly disable specify that X-XSS-Protection is disabled. For example:X-XSS-Protection: 0
- Parameters:
enabled- the new value
-
setBlock
Deprecated.usesetHeaderValue(HeaderValue)insteadIf false, will not specify the mode as blocked. In this instance, any content will be attempted to be fixed. If true, the content will be replaced with "#".- Parameters:
block- the new value
-
setHeaderValue
Sets the value of the X-XSS-PROTECTION header.If
XXssProtectionHeaderWriter.HeaderValue.DISABLED, will specify that X-XSS-Protection is disabled. For example:X-XSS-Protection: 0
If
XXssProtectionHeaderWriter.HeaderValue.ENABLED, will contain a value of 1, but will not specify the mode as blocked. In this instance, any content will be attempted to be fixed. For example:X-XSS-Protection: 1
If
XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK, will contain a value of 1 and will specify mode as blocked. The content will be replaced with "#". For example:X-XSS-Protection: 1; mode=block
- Parameters:
headerValue- the new header value- Throws:
IllegalArgumentException- when headerValue is null- Since:
- 5.8
-
toString
-
setHeaderValue(HeaderValue)instead