Class SessionAndSavedRequestAwareAuthenticationSuccessHandler

java.lang.Object
org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandler
org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler
org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler
de.gustavblass.fsu.fmi.roombooking.configuration.SessionAndSavedRequestAwareAuthenticationSuccessHandler
All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationSuccessHandler

public class SessionAndSavedRequestAwareAuthenticationSuccessHandler extends org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler
A SavedRequestAwareAuthenticationSuccessHandler that uses the REDIRECT_TARGET session attribute in order to redirect the user to the correct target page after logging in successfully.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final @NonNull String
    The name of the session attribute used as the URI that the user shall be redirected to after successful authentication.

    Fields inherited from class org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler

    logger
  • Constructor Summary

    Constructors
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onAuthenticationSuccess(@NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull org.springframework.security.core.Authentication authentication)
    If session attribute named REDIRECT_TARGET is set (and of type URI), it will be used to redirect the user.

    Methods inherited from class org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler

    setRequestCache

    Methods inherited from class org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler

    clearAuthenticationAttributes

    Methods inherited from class org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandler

    determineTargetUrl, determineTargetUrl, getDefaultTargetUrl, getRedirectStrategy, getTargetUrlParameter, handle, isAlwaysUseDefaultTargetUrl, setAlwaysUseDefaultTargetUrl, setDefaultTargetUrl, setRedirectStrategy, setTargetUrlParameter, setUseReferer

    Methods inherited from class Object

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

    Methods inherited from interface org.springframework.security.web.authentication.AuthenticationSuccessHandler

    onAuthenticationSuccess
  • Field Details

    • REDIRECT_TARGET

      @NonNull public static final @NonNull String REDIRECT_TARGET
      The name of the session attribute used as the URI that the user shall be redirected to after successful authentication.
      See Also:
  • Constructor Details

    • SessionAndSavedRequestAwareAuthenticationSuccessHandler

      public SessionAndSavedRequestAwareAuthenticationSuccessHandler()
  • Method Details

    • onAuthenticationSuccess

      public void onAuthenticationSuccess(@NonNull @NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull @NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull @NonNull org.springframework.security.core.Authentication authentication) throws jakarta.servlet.ServletException, IOException

      If session attribute named REDIRECT_TARGET is set (and of type URI), it will be used to redirect the user.

      If no such session attribute is found, the supermethod is invoked instead.

      Specified by:
      onAuthenticationSuccess in interface org.springframework.security.web.authentication.AuthenticationSuccessHandler
      Overrides:
      onAuthenticationSuccess in class org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler
      Parameters:
      request - The request of the successful login.
      response - The server's response to the successful login request.
      authentication - Passed to the supermethod if no REDIRECT_TARGET session attribute is found.
      Throws:
      jakarta.servlet.ServletException - Thrown by the supermethod.
      IOException - Thrown by the supermethod.