Class 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 Detail

      • defaultFailureUrl

        protected String defaultFailureUrl
      • redirectStrategy

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

      • 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 Detail

      • onAuthenticationFailure

        public void onAuthenticationFailure​(HttpServletRequest request,
                                            HttpServletResponse response,
                                            org.springframework.security.core.AuthenticationException exception)
                                     throws IOException,
                                            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
        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".