Class ExceptionMappingAuthenticationFailureHandler
- java.lang.Object
-
- org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
-
- 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
-
-
Field Summary
-
Fields inherited from class org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
logger
-
-
Constructor Summary
Constructors Constructor Description ExceptionMappingAuthenticationFailureHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onAuthenticationFailure(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AuthenticationException exception)
Performs the redirect or forward to thedefaultFailureUrl
if set, otherwise returns a 401 error code.void
setExceptionMappings(java.util.Map<?,?> failureUrlMap)
Sets the map of exception types (by name) to URLs.-
Methods inherited from class org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
getRedirectStrategy, isAllowSessionCreation, isUseForward, saveException, setAllowSessionCreation, setDefaultFailureUrl, setRedirectStrategy, setUseForward
-
-
-
-
Method Detail
-
onAuthenticationFailure
public void onAuthenticationFailure(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AuthenticationException exception) throws java.io.IOException, javax.servlet.ServletException
Description copied from class:SimpleUrlAuthenticationFailureHandler
Performs the redirect or forward to thedefaultFailureUrl
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 interfaceAuthenticationFailureHandler
- Overrides:
onAuthenticationFailure
in classSimpleUrlAuthenticationFailureHandler
- 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:
java.io.IOException
javax.servlet.ServletException
-
setExceptionMappings
public void setExceptionMappings(java.util.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:
java.lang.IllegalArgumentException
- if the entries are not Strings or the URL is not valid.
-
-