Class HttpSessionRequestCache
java.lang.Object
org.springframework.security.web.savedrequest.HttpSessionRequestCache
- All Implemented Interfaces:
- RequestCache
RequestCache which stores the SavedRequest in the HttpSession.
 The DefaultSavedRequest class is used as the implementation.- Since:
- 3.0
- 
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 currentRequest, jakarta.servlet.http.HttpServletResponse response) Returns the saved request, leaving it cached.voidremoveRequest(jakarta.servlet.http.HttpServletRequest currentRequest, jakarta.servlet.http.HttpServletResponse response) Removes the cached request.voidsaveRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Stores the current request, provided the configuration properties allow it.voidsetCreateSessionAllowed(boolean createSessionAllowed) Iftrue, indicates that it is permitted to store the target URL and exception information in a newHttpSession(the default).voidsetMatchingRequestParameterName(String matchingRequestParameterName) Specify the name of a query parameter that is added to the URL that specifies the request cache should be checked ingetMatchingRequest(HttpServletRequest, HttpServletResponse)voidsetRequestMatcher(RequestMatcher requestMatcher) Allows selective use of saved requests for a subset of requests.voidsetSessionAttrName(String sessionAttrName) If thesessionAttrNameproperty is set, the request is stored in the session using this attribute name.
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log logger
 
- 
- 
Constructor Details- 
HttpSessionRequestCachepublic HttpSessionRequestCache()
 
- 
- 
Method Details- 
saveRequestpublic void saveRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Stores the current request, provided the configuration properties allow it.- Specified by:
- saveRequestin interface- RequestCache
- Parameters:
- request- the request to be stored
 
- 
getRequestpublic @Nullable SavedRequest getRequest(jakarta.servlet.http.HttpServletRequest currentRequest, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:RequestCacheReturns the saved request, leaving it cached.- Specified by:
- getRequestin interface- RequestCache
- Parameters:
- currentRequest- the current request
- Returns:
- the saved request which was previously cached, or null if there is none.
 
- 
removeRequestpublic void removeRequest(jakarta.servlet.http.HttpServletRequest currentRequest, jakarta.servlet.http.HttpServletResponse response) Description copied from interface:RequestCacheRemoves the cached request.- Specified by:
- removeRequestin interface- RequestCache
- Parameters:
- currentRequest- the current request, allowing access to the cache.
 
- 
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.
 
- 
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.
 
- 
setCreateSessionAllowedpublic void setCreateSessionAllowed(boolean createSessionAllowed) Iftrue, indicates that it is permitted to store the target URL and exception information in a newHttpSession(the default). In situations where you do not wish to unnecessarily createHttpSessions - because the user agent will know the failed URL, such as with BASIC or Digest authentication - you may wish to set this property tofalse.
- 
setSessionAttrNameIf thesessionAttrNameproperty is set, the request is stored in the session using this attribute name. Default is "SPRING_SECURITY_SAVED_REQUEST".- Parameters:
- sessionAttrName- a new session attribute name.
- Since:
- 4.2.1
 
- 
setMatchingRequestParameterNameSpecify the name of a query parameter that is added to the URL that specifies the request cache should be checked ingetMatchingRequest(HttpServletRequest, HttpServletResponse)- Parameters:
- matchingRequestParameterName- the parameter name that must be in the request for- getMatchingRequest(HttpServletRequest, HttpServletResponse)to check the session. Default is "continue".
 
 
-