Example usage for org.springframework.security.authentication ProviderManager setAuthenticationEventPublisher

List of usage examples for org.springframework.security.authentication ProviderManager setAuthenticationEventPublisher

Introduction

In this page you can find the example usage for org.springframework.security.authentication ProviderManager setAuthenticationEventPublisher.

Prototype

public void setAuthenticationEventPublisher(AuthenticationEventPublisher eventPublisher) 

Source Link

Usage

From source file:ru.anr.base.services.SecurityConfig.java

/**
 * Defining a {@link AuthenticationManager} bean
 * /*from   ww  w .  j  av a2  s .c o  m*/
 * @param messageSource
 *            Message source instance
 * @return A bean instance
 * 
 * @throws Exception
 *             In case of ProviderManager initialization error
 */
@Bean(name = "authenticationManager")
@DependsOn("messageSource")
public AuthenticationManager authenticationManager(MessageSource messageSource) throws Exception {

    ProviderManager providerManager = new ProviderManager(providers);
    providerManager.setMessageSource(messageSource);
    providerManager.setAuthenticationEventPublisher(new DefaultAuthenticationEventPublisher());

    providerManager.afterPropertiesSet();
    return providerManager;
}

From source file:org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder.java

@Override
protected ProviderManager performBuild() throws Exception {
    if (!isConfigured()) {
        logger.debug("No authenticationProviders and no parentAuthenticationManager defined. Returning null.");
        return null;
    }/*from   ww w . jav  a 2s.  c o  m*/
    ProviderManager providerManager = new ProviderManager(authenticationProviders, parentAuthenticationManager);
    if (eraseCredentials != null) {
        providerManager.setEraseCredentialsAfterAuthentication(eraseCredentials);
    }
    if (eventPublisher != null) {
        providerManager.setAuthenticationEventPublisher(eventPublisher);
    }
    providerManager = postProcess(providerManager);
    return providerManager;
}