Class SavedRequestAwareAuthenticationSuccessHandler
java.lang.Object
org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandler
org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler
org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler
- All Implemented Interfaces:
- AuthenticationSuccessHandler
public class SavedRequestAwareAuthenticationSuccessHandler
extends SimpleUrlAuthenticationSuccessHandler
An authentication success strategy which can make use of the
 
DefaultSavedRequest which may
 have been stored in the session by the ExceptionTranslationFilter. When such a
 request is intercepted and requires authentication, the request data is stored to
 record the original destination before the authentication process commenced, and to
 allow the request to be reconstructed when a redirect to the same URL occurs. This
 class is responsible for performing the redirect to the original URL if appropriate.
 Following a successful authentication, it decides on the redirect destination, based on the following scenarios:
- If the alwaysUseDefaultTargetUrlproperty is set to true, thedefaultTargetUrlwill be used for the destination. AnyDefaultSavedRequeststored in the session will be removed.
- If the targetUrlParameterhas been set on the request, the value will be used as the destination. AnyDefaultSavedRequestwill again be removed.
- If a SavedRequestis found in theRequestCache(as set by theExceptionTranslationFilterto record the original destination before the authentication process commenced), a redirect will be performed to the Url of that original destination. TheSavedRequestobject will remain cached and be picked up when the redirected request is received (See SavedRequestAwareWrapper).
- If no SavedRequestis found, it will delegate to the base class.
- Since:
- 3.0
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidonAuthenticationSuccess(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Authentication authentication) Calls the parent classhandle()method to forward or redirect to the target URL, and then callsclearAuthenticationAttributes()to remove any leftover session data.voidsetRequestCache(RequestCache requestCache) Methods inherited from class org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandlerclearAuthenticationAttributesMethods inherited from class org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandlerdetermineTargetUrl, determineTargetUrl, getDefaultTargetUrl, getRedirectStrategy, getTargetUrlParameter, handle, isAlwaysUseDefaultTargetUrl, setAlwaysUseDefaultTargetUrl, setDefaultTargetUrl, setRedirectStrategy, setTargetUrlParameter, setUseRefererMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.security.web.authentication.AuthenticationSuccessHandleronAuthenticationSuccess
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log logger
 
- 
- 
Constructor Details- 
SavedRequestAwareAuthenticationSuccessHandlerpublic SavedRequestAwareAuthenticationSuccessHandler()
 
- 
- 
Method Details- 
onAuthenticationSuccesspublic void onAuthenticationSuccess(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Authentication authentication) throws jakarta.servlet.ServletException, IOException Description copied from class:SimpleUrlAuthenticationSuccessHandlerCalls the parent classhandle()method to forward or redirect to the target URL, and then callsclearAuthenticationAttributes()to remove any leftover session data.- Specified by:
- onAuthenticationSuccessin interface- AuthenticationSuccessHandler
- Overrides:
- onAuthenticationSuccessin class- SimpleUrlAuthenticationSuccessHandler
- Parameters:
- request- the request which caused the successful authentication
- response- the response
- authentication- the Authentication object which was created during the authentication process.
- Throws:
- jakarta.servlet.ServletException
- IOException
 
- 
setRequestCache
 
-