Class DefaultAuthenticationEventPublisher
java.lang.Object
org.springframework.security.authentication.DefaultAuthenticationEventPublisher
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationEventPublisherAware,AuthenticationEventPublisher
public class DefaultAuthenticationEventPublisher
extends Object
implements AuthenticationEventPublisher, org.springframework.context.ApplicationEventPublisherAware
The default strategy for publishing authentication events.
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.
- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultAuthenticationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionvoidpublishAuthenticationFailure(AuthenticationException exception, Authentication authentication) voidpublishAuthenticationSuccess(Authentication authentication) voidsetAdditionalExceptionMappings(Map<Class<? extends AuthenticationException>, Class<? extends AbstractAuthenticationFailureEvent>> mappings) Sets additional exception to event mappings.voidsetAdditionalExceptionMappings(Properties additionalExceptionMappings) Deprecated.voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) voidsetDefaultAuthenticationFailureEvent(Class<? extends AbstractAuthenticationFailureEvent> defaultAuthenticationFailureEventClass) Sets a default authentication failure event as a fallback event for any unmapped exceptions not mapped in the exception mappings.
-
Constructor Details
-
DefaultAuthenticationEventPublisher
public DefaultAuthenticationEventPublisher() -
DefaultAuthenticationEventPublisher
public DefaultAuthenticationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
-
-
Method Details
-
publishAuthenticationSuccess
- Specified by:
publishAuthenticationSuccessin interfaceAuthenticationEventPublisher
-
publishAuthenticationFailure
public void publishAuthenticationFailure(AuthenticationException exception, Authentication authentication) - Specified by:
publishAuthenticationFailurein interfaceAuthenticationEventPublisher
-
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) - Specified by:
setApplicationEventPublisherin interfaceorg.springframework.context.ApplicationEventPublisherAware
-
setAdditionalExceptionMappings
Deprecated.Sets additional exception to event mappings. These are automatically merged with the default exception to event mappings thatProviderManagerdefines.- Parameters:
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.
-
setAdditionalExceptionMappings
public void setAdditionalExceptionMappings(Map<Class<? extends AuthenticationException>, Class<? extends AbstractAuthenticationFailureEvent>> mappings) Sets additional exception to event mappings. These are automatically merged with the default exception to event mappings thatProviderManagerdefines.- Parameters:
mappings- where keys are exception classes and values are event classes.- Since:
- 5.3
-
setDefaultAuthenticationFailureEvent
public void setDefaultAuthenticationFailureEvent(Class<? extends AbstractAuthenticationFailureEvent> defaultAuthenticationFailureEventClass) Sets a default authentication failure event as a fallback event for any unmapped exceptions not mapped in the exception mappings.- Parameters:
defaultAuthenticationFailureEventClass- is the authentication failure event class to be fired for unmapped exceptions.
-
setAdditionalExceptionMappings(Map)