Package org.springframework.security.config.annotation.web.configurers

# Class RequestCacheConfigurer<H extends HttpSecurityBuilder<H>>

java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<RequestCacheConfigurer<H>,H>
org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer<H>

All Implemented Interfaces:
  `SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H>`

public final class RequestCacheConfigurer<H extends HttpSecurityBuilder<H>> extends AbstractHttpConfigurer<RequestCacheConfigurer<H>,H>
Adds request cache for Spring Security. Specifically this ensures that requests that are saved (i.e. after authentication is required) are later replayed. All properties have reasonable defaults, so no additional configuration is required other than applying this `SecurityConfigurer` .

## Security Filters

The following Filters are populated

- `RequestCacheAwareFilter`

## Shared Objects Created

No shared objects are created.

## Shared Objects Used

The following shared objects are used:

- If no explicit `RequestCache`, is provided a `RequestCache` shared object is used to replay the request after authentication is successful

Since:
  3.2
See Also:
  - `RequestCache`

## Constructor Summary

Constructors
Constructor
Description
`RequestCacheConfigurer()`

## Method Summary

Modifier and Type
Method
Description
`void`
`configure(H http)`
Configure the `SecurityBuilder` by setting the necessary properties on the `SecurityBuilder`.
`H`
`disable()`
Disables the `AbstractHttpConfigurer` by removing it.
`void`
`init(H http)`
Initialize the `SecurityBuilder`.
`RequestCacheConfigurer<H>`
`requestCache(org.springframework.security.web.savedrequest.RequestCache requestCache)`
Allows explicit configuration of the `RequestCache` to be used.

### Methods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer

`getSecurityContextHolderStrategy, withObjectPostProcessor, withObjectPostProcessor`

### Methods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter

`addObjectPostProcessor, addObjectPostProcessor, and, getBuilder, postProcess, setBuilder`

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

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

## Constructor Details

### RequestCacheConfigurer

public RequestCacheConfigurer()

## Method Details

### requestCache

public RequestCacheConfigurer<H> requestCache(org.springframework.security.web.savedrequest.RequestCache requestCache)
Allows explicit configuration of the `RequestCache` to be used. Defaults to try finding a `RequestCache` as a shared object. Then falls back to a `HttpSessionRequestCache`.

Parameters:
  `requestCache` - the explicit `RequestCache` to use
Returns:
  the `RequestCacheConfigurer` for further customization

### disable

public H disable()
Description copied from class: `AbstractHttpConfigurer`
Disables the `AbstractHttpConfigurer` by removing it. After doing so a fresh version of the configuration can be applied.

Overrides:
  `disable` in class `AbstractHttpConfigurer<RequestCacheConfigurer<H extends HttpSecurityBuilder<H>>,H extends HttpSecurityBuilder<H>>`
Returns:
  the `HttpSecurityBuilder` for additional customizations

### init

public void init(H http)
Description copied from interface: `SecurityConfigurer`
Initialize the `SecurityBuilder`. Here only shared state should be created and modified, but not properties on the `SecurityBuilder` used for building the object. This ensures that the `SecurityConfigurer.configure(SecurityBuilder)` method uses the correct shared objects when building. Configurers should be applied here.

Specified by:
  `init` in interface `SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>`
Overrides:
  `init` in class `SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>`

### configure

public void configure(H http)
Description copied from interface: `SecurityConfigurer`
Configure the `SecurityBuilder` by setting the necessary properties on the `SecurityBuilder`.

Specified by:
  `configure` in interface `SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>`
Overrides:
  `configure` in class `SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>`