Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* .
*
* @author Kazuki Shimizu
* @author Andrey Litvitski
* @since 4.0
*/
public class DelegatingAuthenticationFailureHandler implements AuthenticationFailureHandler {
Expand All @@ -52,7 +53,11 @@ public class DelegatingAuthenticationFailureHandler implements AuthenticationFai
* @param defaultHandler the default {@link AuthenticationFailureHandler} that should
* be used if none of the handlers matches. This parameter cannot specify null.
* @throws IllegalArgumentException if invalid argument is specified
* @deprecated Use
* {@link #DelegatingAuthenticationFailureHandler(Map, AuthenticationFailureHandler)}
* instead.
*/
@Deprecated(since = "7.0.6")
public DelegatingAuthenticationFailureHandler(
LinkedHashMap<Class<? extends AuthenticationException>, AuthenticationFailureHandler> handlers,
AuthenticationFailureHandler defaultHandler) {
Expand All @@ -62,6 +67,25 @@ public DelegatingAuthenticationFailureHandler(
this.defaultHandler = defaultHandler;
}

/**
* Creates a new instance
* @param handlers a map of the {@link AuthenticationException} class to the
* {@link AuthenticationFailureHandler} that should be used. Each is considered in the
* order they are specified and only the first {@link AuthenticationFailureHandler} is
* ued. This parameter cannot specify null or empty.
* @param defaultHandler the default {@link AuthenticationFailureHandler} that should
* be used if none of the handlers matches. This parameter cannot specify null.
* @throws IllegalArgumentException if invalid argument is specified
*/
public DelegatingAuthenticationFailureHandler(
Map<Class<? extends AuthenticationException>, AuthenticationFailureHandler> handlers,
AuthenticationFailureHandler defaultHandler) {
Assert.notEmpty(handlers, "handlers cannot be null or empty");
Assert.notNull(defaultHandler, "defaultHandler cannot be null");
this.handlers = new LinkedHashMap<>(handlers);
this.defaultHandler = defaultHandler;
}

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
AuthenticationException exception) throws IOException, ServletException {
Expand Down
Loading