Package org.springframework.security.web.header.writers

# Class ClearSiteDataHeaderWriter

java.lang.Object
org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter

All Implemented Interfaces:
  `HeaderWriter`

public final class ClearSiteDataHeaderWriter extends Object implements HeaderWriter
Provides support for Clear Site Data.

Developers may instruct a user agent to clear various types of relevant data by delivering a Clear-Site-Data HTTP response header in response to a request.

Due to Incomplete Clearing section the header is only applied if the request is secure.

Since:
  5.2

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`ClearSiteDataHeaderWriter.Directive`
Represents the directive values expected by the `ClearSiteDataHeaderWriter`.

## Constructor Summary

Constructors
Constructor
Description
`ClearSiteDataHeaderWriter(ClearSiteDataHeaderWriter.Directive... directives)`
Creates a new instance of `ClearSiteDataHeaderWriter` with given sources.

## Method Summary

Modifier and Type
Method
Description
`String`
`toString()`
`void`
`writeHeaders(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)`
Create a `Header` instance.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### ClearSiteDataHeaderWriter

public ClearSiteDataHeaderWriter(ClearSiteDataHeaderWriter.Directive... directives)

Creates a new instance of `ClearSiteDataHeaderWriter` with given sources. The constructor also initializes requestMatcher with a new instance of SecureRequestMatcher to ensure that header is only applied if and when the request is secure as per the Incomplete Clearing section.

Parameters:
  `directives` - (i.e. "cache", "cookies", "storage", "executionContexts" or "*")
Throws:
  `IllegalArgumentException` - if sources 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

### toString

public String toString()

Overrides:
  `toString` in class `Object`