Class CookieRequestCache
java.lang.Object
org.springframework.security.web.savedrequest.CookieRequestCache
- All Implemented Interfaces:
- RequestCache
An Implementation of 
RequestCache which saves the original request URI in a
 cookie.- Since:
- 5.4
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription@Nullable jakarta.servlet.http.HttpServletRequestgetMatchingRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Returns a wrapper around the saved request, if it matches the current request.@Nullable SavedRequestgetRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Returns the saved request, leaving it cached.voidremoveRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Removes the cached request.voidsaveRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Caches the current request for later retrieval, once authentication has taken place.voidsetCookieCustomizer(Consumer<jakarta.servlet.http.Cookie> cookieCustomizer) Sets theConsumer, allowing customization of cookie.voidsetRequestMatcher(RequestMatcher requestMatcher) Allows selective use of saved requests for a subset of requests.
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log logger
 
- 
- 
Constructor Details- 
CookieRequestCachepublic CookieRequestCache()
 
- 
- 
Method Details- 
saveRequestpublic void saveRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:RequestCacheCaches the current request for later retrieval, once authentication has taken place. Used by ExceptionTranslationFilter.- Specified by:
- saveRequestin interface- RequestCache
- Parameters:
- request- the request to be stored
 
- 
getRequestpublic @Nullable SavedRequest getRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:RequestCacheReturns the saved request, leaving it cached.- Specified by:
- getRequestin interface- RequestCache
- Parameters:
- request- the current request
- Returns:
- the saved request which was previously cached, or null if there is none.
 
- 
getMatchingRequestpublic @Nullable jakarta.servlet.http.HttpServletRequest getMatchingRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:RequestCacheReturns a wrapper around the saved request, if it matches the current request. The saved request should be removed from the cache.- Specified by:
- getMatchingRequestin interface- RequestCache
- Returns:
- the wrapped save request, if it matches the original, or null if there is no cached request or it doesn't match.
 
- 
removeRequestpublic void removeRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:RequestCacheRemoves the cached request.- Specified by:
- removeRequestin interface- RequestCache
- Parameters:
- request- the current request, allowing access to the cache.
 
- 
setRequestMatcherAllows selective use of saved requests for a subset of requests. By default any request will be cached by thesaveRequestmethod.If set, only matching requests will be cached. - Parameters:
- requestMatcher- a request matching strategy which defines which requests should be cached.
 
- 
setCookieCustomizerSets theConsumer, allowing customization of cookie.- Parameters:
- cookieCustomizer- customize for cookie
- Since:
- 6.4
 
 
-