org.springframework.security.web.authentication
Class ExceptionMappingAuthenticationFailureHandler

java.lang.Object
  extended by org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
      extended by org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler
All Implemented Interfaces:
AuthenticationFailureHandler

public class ExceptionMappingAuthenticationFailureHandler
extends SimpleUrlAuthenticationFailureHandler

Uses the internal map of exceptions types to URLs to determine the destination on authentication failure. The keys are the full exception class names.

If a match isn't found, falls back to the behaviour of the parent class, SimpleUrlAuthenticationFailureHandler.

The map of exception names to URLs should be injected by setting the exceptionMappings property.

Since:
3.0
Version:
$Id: ExceptionMappingAuthenticationFailureHandler.java 3842 2009-08-27 10:42:11Z ltaylor $
Author:
Luke Taylor

Field Summary
 
Fields inherited from class org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
logger
 
Constructor Summary
ExceptionMappingAuthenticationFailureHandler()
           
 
Method Summary
 void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception)
          Called when an authentication attempt fails.
 void setExceptionMappings(Map<?,?> failureUrlMap)
          Sets the map of exception types (by name) to URLs.
 
Methods inherited from class org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
getRedirectStrategy, isUseForward, setDefaultFailureUrl, setRedirectStrategy, setUseForward
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionMappingAuthenticationFailureHandler

public ExceptionMappingAuthenticationFailureHandler()
Method Detail

onAuthenticationFailure

public void onAuthenticationFailure(HttpServletRequest request,
                                    HttpServletResponse response,
                                    AuthenticationException exception)
                             throws IOException,
                                    ServletException
Description copied from interface: AuthenticationFailureHandler
Called when an authentication attempt fails.

Specified by:
onAuthenticationFailure in interface AuthenticationFailureHandler
Overrides:
onAuthenticationFailure in class SimpleUrlAuthenticationFailureHandler
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
ServletException

setExceptionMappings

public void setExceptionMappings(Map<?,?> failureUrlMap)
Sets the map of exception types (by name) to URLs.

Parameters:
failureUrlMap - the map keyed by the fully-qualified name of the exception class, with the corresponding failure URL as the value.
Throws:
IllegalArgumentException - if the entries are not Strings or the URL is not valid.


Copyright © 2004-2009 SpringSource, Inc. All Rights Reserved.