List of usage examples for org.springframework.security.authentication DefaultAuthenticationEventPublisher DefaultAuthenticationEventPublisher
public DefaultAuthenticationEventPublisher()
From source file:ru.anr.base.services.SecurityConfig.java
/** * Defining a {@link AuthenticationManager} bean * /*from w w w. j a va 2s .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:cn.timeoff.config.hackspring.WebSecurityConfigurerAdapter.java
/** * Creates the {@link HttpSecurity} or returns the current instance * * @return the {@link HttpSecurity}//from w w w.j ava2 s. c o m * @throws Exception */ protected final HttpSecurity getHttp() throws Exception { if (http != null) { return http; } DefaultAuthenticationEventPublisher eventPublisher = objectPostProcessor .postProcess(new DefaultAuthenticationEventPublisher()); localConfigureAuthenticationBldr.authenticationEventPublisher(eventPublisher); AuthenticationManager authenticationManager = authenticationManager(); authenticationBuilder.parentAuthenticationManager(authenticationManager); http = new HttpSecurity(objectPostProcessor, authenticationBuilder, localConfigureAuthenticationBldr.getSharedObjects()); http.setSharedObject(UserDetailsService.class, userDetailsService()); http.setSharedObject(ApplicationContext.class, context); http.setSharedObject(ContentNegotiationStrategy.class, contentNegotiationStrategy); http.setSharedObject(AuthenticationTrustResolver.class, trustResolver); if (!disableDefaults) { http.csrf().and().addFilter(new WebAsyncManagerIntegrationFilter()).exceptionHandling().and().headers() .and().sessionManagement().and().securityContext().and().requestCache().and().anonymous().and() .servletApi().and().apply(new DefaultLoginPageConfigurer<HttpSecurity>()).and().logout(); } configure(http); return http; }
From source file:org.springframework.boot.actuate.autoconfigure.SecurityAutoConfiguration.java
@Bean @ConditionalOnMissingBean public AuthenticationEventPublisher authenticationEventPublisher() { return new DefaultAuthenticationEventPublisher(); }
From source file:org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration.java
/** * Allows providing a custom {@link AuthenticationManager}. The default is to use any * authentication mechanisms registered by * {@link #configure(AuthenticationManagerBuilder)}. If * {@link #configure(AuthenticationManagerBuilder)} was not overridden, then an * {@link AuthenticationManager} is attempted to be autowired by type. * * @return the {@link AuthenticationManager} to use *///from w w w . j ava 2 s . co m protected AuthenticationManager authenticationManager() throws Exception { if (authenticationManager == null) { DefaultAuthenticationEventPublisher eventPublisher = objectPostProcessor .postProcess(new DefaultAuthenticationEventPublisher()); auth = new AuthenticationManagerBuilder(objectPostProcessor); auth.authenticationEventPublisher(eventPublisher); configure(auth); if (disableAuthenticationRegistry) { authenticationManager = getAuthenticationConfiguration().getAuthenticationManager(); } else { authenticationManager = auth.build(); } } return authenticationManager; }
From source file:org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.java
/** * Creates the {@link HttpSecurity} or returns the current instance * * ] * @return the {@link HttpSecurity}/*from w w w .ja v a 2s .c o m*/ * @throws Exception */ @SuppressWarnings({ "rawtypes", "unchecked" }) protected final HttpSecurity getHttp() throws Exception { if (http != null) { return http; } DefaultAuthenticationEventPublisher eventPublisher = objectPostProcessor .postProcess(new DefaultAuthenticationEventPublisher()); localConfigureAuthenticationBldr.authenticationEventPublisher(eventPublisher); AuthenticationManager authenticationManager = authenticationManager(); authenticationBuilder.parentAuthenticationManager(authenticationManager); authenticationBuilder.authenticationEventPublisher(eventPublisher); Map<Class<? extends Object>, Object> sharedObjects = createSharedObjects(); http = new HttpSecurity(objectPostProcessor, authenticationBuilder, sharedObjects); if (!disableDefaults) { // @formatter:off http.csrf().and().addFilter(new WebAsyncManagerIntegrationFilter()).exceptionHandling().and().headers() .and().sessionManagement().and().securityContext().and().requestCache().and().anonymous().and() .servletApi().and().apply(new DefaultLoginPageConfigurer<>()).and().logout(); // @formatter:on ClassLoader classLoader = this.context.getClassLoader(); List<AbstractHttpConfigurer> defaultHttpConfigurers = SpringFactoriesLoader .loadFactories(AbstractHttpConfigurer.class, classLoader); for (AbstractHttpConfigurer configurer : defaultHttpConfigurers) { http.apply(configurer); } } configure(http); return http; }