Package org.springframework.security.web.server.savedrequest

# Class WebSessionServerRequestCache

java.lang.Object
org.springframework.security.web.server.savedrequest.WebSessionServerRequestCache

All Implemented Interfaces:
  `ServerRequestCache`

public class WebSessionServerRequestCache extends Object implements ServerRequestCache
An implementation of `ServerRequestCache` that saves the `ServerHttpRequest` in the `WebSession`. The current implementation only saves the URL that was requested.

Since:
  5.0

## Constructor Summary

Constructors
Constructor
Description
`WebSessionServerRequestCache()`

## Method Summary

Modifier and Type
Method
Description
`reactor.core.publisher.Mono<URI>`
`getRedirectUri(org.springframework.web.server.ServerWebExchange exchange)`
Get the URI that can be redirected to trigger the saved request to be used
`reactor.core.publisher.Mono<org.springframework.http.server.reactive.ServerHttpRequest>`
`removeMatchingRequest(org.springframework.web.server.ServerWebExchange exchange)`
If the provided `ServerWebExchange` matches the saved `ServerHttpRequest` gets the saved `ServerHttpRequest`
`reactor.core.publisher.Mono<Void>`
`saveRequest(org.springframework.web.server.ServerWebExchange exchange)`
Save the `ServerHttpRequest`
`void`
`setMatchingRequestParameterName(String matchingRequestParameterName)`
Specify the name of a query parameter that is added to the URL in `getRedirectUri(ServerWebExchange)` and is required for `removeMatchingRequest(ServerWebExchange)` to look up the `ServerHttpRequest`.
`void`
`setSaveRequestMatcher(ServerWebExchangeMatcher saveRequestMatcher)`
Sets the matcher to determine if the request should be saved.

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

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

## Constructor Details

### WebSessionServerRequestCache

public WebSessionServerRequestCache()

## Method Details

### setSaveRequestMatcher

public void setSaveRequestMatcher(ServerWebExchangeMatcher saveRequestMatcher)
Sets the matcher to determine if the request should be saved. The default is to match on any GET request.

Parameters:
  `saveRequestMatcher` -

### saveRequest

public reactor.core.publisher.Mono<Void> saveRequest(org.springframework.web.server.ServerWebExchange exchange)
Description copied from interface: `ServerRequestCache`
Save the `ServerHttpRequest`

Specified by:
  `saveRequest` in interface `ServerRequestCache`
Parameters:
  `exchange` - the exchange to save
Returns:
  Return a `Mono<Void>` which only replays complete and error signals from this `Mono`.

### getRedirectUri

public reactor.core.publisher.Mono<URI> getRedirectUri(org.springframework.web.server.ServerWebExchange exchange)
Description copied from interface: `ServerRequestCache`
Get the URI that can be redirected to trigger the saved request to be used

Specified by:
  `getRedirectUri` in interface `ServerRequestCache`
Parameters:
  `exchange` - the exchange to obtain the saved `ServerHttpRequest` from
Returns:
  the URI that can be redirected to trigger the saved request to be used

### removeMatchingRequest

public reactor.core.publisher.Mono<org.springframework.http.server.reactive.ServerHttpRequest> removeMatchingRequest(org.springframework.web.server.ServerWebExchange exchange)
Description copied from interface: `ServerRequestCache`
If the provided `ServerWebExchange` matches the saved `ServerHttpRequest` gets the saved `ServerHttpRequest`

Specified by:
  `removeMatchingRequest` in interface `ServerRequestCache`
Parameters:
  `exchange` - the exchange to obtain the request from
Returns:
  the `ServerHttpRequest`

### setMatchingRequestParameterName

public void setMatchingRequestParameterName(String matchingRequestParameterName)
Specify the name of a query parameter that is added to the URL in `getRedirectUri(ServerWebExchange)` and is required for `removeMatchingRequest(ServerWebExchange)` to look up the `ServerHttpRequest`.

Parameters:
  `matchingRequestParameterName` - the parameter name that must be in the request for `removeMatchingRequest(ServerWebExchange)` to check the session.