Package org.springframework.security.web.authentication

# Interface AuthenticationFailureHandler

All Known Implementing Classes:
  `AuthenticationEntryPointFailureHandler`, `DelegatingAuthenticationFailureHandler`, `ExceptionMappingAuthenticationFailureHandler`, `ForwardAuthenticationFailureHandler`, `SimpleUrlAuthenticationFailureHandler`

public interface AuthenticationFailureHandler
Strategy used to handle a failed authentication attempt.

Typical behaviour might be to redirect the user to the authentication page (in the case of a form login) to allow them to try again. More sophisticated logic might be implemented depending on the type of the exception. For example, a `CredentialsExpiredException` might cause a redirect to a web controller which allowed the user to change their password.

Since:
  3.0

## 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)`
Called when an authentication attempt fails.

## Method Details

### onAuthenticationFailure

void onAuthenticationFailure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException exception) throws IOException, jakarta.servlet.ServletException
Called when an authentication attempt fails.

Parameters:
  `request` - the request during which the authentication attempt occurred.
  `response` - the response.
  `exception` - the exception which was thrown to reject the authentication request.
Throws:
  `IOException`
  `jakarta.servlet.ServletException`