Class LoginFailureHandler

java.lang.Object
com.avoka.fc.core.security.LoginFailureHandler
All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationFailureHandler

public class LoginFailureHandler extends Object implements org.springframework.security.web.authentication.AuthenticationFailureHandler
Provides a custom failure handler based on SimpleUrlAuthenticationFailureHandler that will increase failed login attempts, do locking, and finally redirect.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
     
    protected org.springframework.security.web.RedirectStrategy
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new SfmAuthenticationFailureHandler instance
    LoginFailureHandler(String defaultFailureUrl)
    Creates a new SfmAuthenticationFailureHandler instance
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onAuthenticationFailure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException exception)
    Performs the redirect to the defaultFailureUrl if set, otherwise returns a 401 error code.
    void
    setDefaultFailureUrl(String defaultFailureUrl)
    The URL which will be used as the failure destination.

    Methods inherited from class java.lang.Object

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

    • defaultFailureUrl

      protected String defaultFailureUrl
    • redirectStrategy

      protected org.springframework.security.web.RedirectStrategy redirectStrategy
  • Constructor Details

    • LoginFailureHandler

      public LoginFailureHandler()
      Creates a new SfmAuthenticationFailureHandler instance
    • LoginFailureHandler

      public LoginFailureHandler(String defaultFailureUrl)
      Creates a new SfmAuthenticationFailureHandler instance
      Parameters:
      defaultFailureUrl - the URL to redirect to in case of login failure
  • 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 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
      Parameters:
      request - the HTTP servlet request
      response - the HTTP servlet response
      exception - the authentication exception that occurred
      Throws:
      IOException - if an error occurs writing to the response
      jakarta.servlet.ServletException - if an error occurs during forwarding
      See Also:
      • AuthenticationFailureHandler.onAuthenticationFailure(HttpServletRequest, HttpServletResponse, AuthenticationException)
    • 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".