Package org.springframework.security.web.authentication

# Class DelegatingAuthenticationFailureHandler

java.lang.Object
org.springframework.security.web.authentication.DelegatingAuthenticationFailureHandler

All Implemented Interfaces:
  `AuthenticationFailureHandler`

public class DelegatingAuthenticationFailureHandler extends Object implements AuthenticationFailureHandler
An `AuthenticationFailureHandler` that delegates to other `AuthenticationFailureHandler` instances based upon the type of `AuthenticationException` passed into `onAuthenticationFailure(HttpServletRequest, HttpServletResponse, AuthenticationException)` .

Since:
  4.0

## Constructor Summary

Constructors
Constructor
Description
`DelegatingAuthenticationFailureHandler(LinkedHashMap<Class<? extends org.springframework.security.core.AuthenticationException>,AuthenticationFailureHandler> handlers, AuthenticationFailureHandler defaultHandler)`
Creates a new 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)`
Called when an authentication attempt fails.

### Methods inherited from class java.lang.Object

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

## Constructor Details

### DelegatingAuthenticationFailureHandler

public DelegatingAuthenticationFailureHandler(LinkedHashMap<Class<? extends org.springframework.security.core.AuthenticationException>,AuthenticationFailureHandler> handlers, AuthenticationFailureHandler defaultHandler)
Creates a new instance

Parameters:
  `handlers` - a map of the `AuthenticationException` class to the `AuthenticationFailureHandler` that should be used. Each is considered in the order they are specified and only the first `AuthenticationFailureHandler` is ued. This parameter cannot specify null or empty.
  `defaultHandler` - the default `AuthenticationFailureHandler` that should be used if none of the handlers matches. This parameter cannot specify null.
Throws:
  `IllegalArgumentException` - if invalid argument is specified

## 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
Description copied from interface: `AuthenticationFailureHandler`
Called when an authentication attempt fails.

Specified by:
  `onAuthenticationFailure` in interface `AuthenticationFailureHandler`
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`