public class DefaultAuthenticationEventPublisher extends java.lang.Object implements AuthenticationEventPublisher, org.springframework.context.ApplicationEventPublisherAware
Maps well-known AuthenticationException types to events and publishes them via the application context. If configured as a bean, it will pick up the ApplicationEventPublisher automatically. Otherwise, the constructor which takes the publisher as an argument should be used.
The exception-mapping system can be fine-tuned by setting the
additionalExceptionMappings as a java.util.Properties
object. In
the properties object, each of the keys represent the fully qualified classname of the
exception, and each of the values represent the name of an event class which subclasses
AbstractAuthenticationFailureEvent
and provides its constructor. The additionalExceptionMappings will be merged
with the default ones.
Constructor and Description |
---|
DefaultAuthenticationEventPublisher() |
DefaultAuthenticationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
Modifier and Type | Method and Description |
---|---|
void |
publishAuthenticationFailure(AuthenticationException exception,
Authentication authentication) |
void |
publishAuthenticationSuccess(Authentication authentication) |
void |
setAdditionalExceptionMappings(java.util.Map<java.lang.Class<? extends AuthenticationException>,java.lang.Class<? extends AbstractAuthenticationFailureEvent>> mappings)
Sets additional exception to event mappings.
|
void |
setAdditionalExceptionMappings(java.util.Properties additionalExceptionMappings)
Deprecated.
|
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
void |
setDefaultAuthenticationFailureEvent(java.lang.Class<? extends AbstractAuthenticationFailureEvent> defaultAuthenticationFailureEventClass)
Sets a default authentication failure event as a fallback event for any unmapped
exceptions not mapped in the exception mappings.
|
public DefaultAuthenticationEventPublisher()
public DefaultAuthenticationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
public void publishAuthenticationSuccess(Authentication authentication)
publishAuthenticationSuccess
in interface AuthenticationEventPublisher
public void publishAuthenticationFailure(AuthenticationException exception, Authentication authentication)
publishAuthenticationFailure
in interface AuthenticationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface org.springframework.context.ApplicationEventPublisherAware
@Deprecated public void setAdditionalExceptionMappings(java.util.Properties additionalExceptionMappings)
setAdditionalExceptionMappings(Map)
ProviderManager
defines.additionalExceptionMappings
- where keys are the fully-qualified string name
of the exception class and the values are the fully-qualified string name of the
event class to fire.public void setAdditionalExceptionMappings(java.util.Map<java.lang.Class<? extends AuthenticationException>,java.lang.Class<? extends AbstractAuthenticationFailureEvent>> mappings)
ProviderManager
defines.mappings
- where keys are exception classes and values are event classes.public void setDefaultAuthenticationFailureEvent(java.lang.Class<? extends AbstractAuthenticationFailureEvent> defaultAuthenticationFailureEventClass)
defaultAuthenticationFailureEventClass
- is the authentication failure event class
to be fired for unmapped exceptions.