Class CustomAuthenticationFailureHandler

java.lang.Object
org.apache.fineract.infrastructure.security.service.CustomAuthenticationFailureHandler
All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationFailureHandler

public class CustomAuthenticationFailureHandler extends Object implements org.springframework.security.web.authentication.AuthenticationFailureHandler
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.springframework.security.web.RedirectStrategy
     
    protected boolean
     
    protected boolean
     
    void
    onAuthenticationFailure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException exception)
    Performs the redirect or forward to the defaultFailureUrl if set, otherwise returns a 401 error code.
    protected final void
    saveException(jakarta.servlet.http.HttpServletRequest request, org.springframework.security.core.AuthenticationException exception)
    Caches the AuthenticationException for use in view rendering.
    void
    setAllowSessionCreation(boolean allowSessionCreation)
     
    void
    setDefaultFailureUrl(String defaultFailureUrl)
    The URL which will be used as the failure destination.
    void
    setRedirectStrategy(org.springframework.security.web.RedirectStrategy redirectStrategy)
    Allows overriding of the behaviour when redirecting to a target URL.
    void
    setUseForward(boolean forwardToDestination)
    If set to true, performs a forward to the failure destination URL instead of a redirect.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomAuthenticationFailureHandler

      public CustomAuthenticationFailureHandler()
  • Method Details

    • onAuthenticationFailure

      public void onAuthenticationFailure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException exception) throws IOException, jakarta.servlet.ServletException
      Performs the redirect or forward to the defaultFailureUrl if set, otherwise returns a 401 error code.

      If redirecting or forwarding, saveException will be called to cache the exception for use in the target view.

      Specified by:
      onAuthenticationFailure in interface org.springframework.security.web.authentication.AuthenticationFailureHandler
      Throws:
      IOException
      jakarta.servlet.ServletException
    • saveException

      protected final void saveException(jakarta.servlet.http.HttpServletRequest request, org.springframework.security.core.AuthenticationException exception)
      Caches the AuthenticationException for use in view rendering.

      If forwardToDestination is set to true, request scope will be used, otherwise it will attempt to store the exception in the session. If there is no session and allowSessionCreation is true a session will be created. Otherwise the exception will not be stored.

    • setDefaultFailureUrl

      public void setDefaultFailureUrl(String defaultFailureUrl)
      The URL which will be used as the failure destination.
      Parameters:
      defaultFailureUrl - the failure URL, for example "/loginFailed.jsp".
    • isUseForward

      protected boolean isUseForward()
    • setUseForward

      public void setUseForward(boolean forwardToDestination)
      If set to true, performs a forward to the failure destination URL instead of a redirect. Defaults to false.
    • setRedirectStrategy

      public void setRedirectStrategy(org.springframework.security.web.RedirectStrategy redirectStrategy)
      Allows overriding of the behaviour when redirecting to a target URL.
    • getRedirectStrategy

      protected org.springframework.security.web.RedirectStrategy getRedirectStrategy()
    • isAllowSessionCreation

      protected boolean isAllowSessionCreation()
    • setAllowSessionCreation

      public void setAllowSessionCreation(boolean allowSessionCreation)