Example usage for org.springframework.security.config.annotation.authentication.builders AuthenticationManagerBuilder AuthenticationManagerBuilder

List of usage examples for org.springframework.security.config.annotation.authentication.builders AuthenticationManagerBuilder AuthenticationManagerBuilder

Introduction

In this page you can find the example usage for org.springframework.security.config.annotation.authentication.builders AuthenticationManagerBuilder AuthenticationManagerBuilder.

Prototype

public AuthenticationManagerBuilder(ObjectPostProcessor<Object> objectPostProcessor) 

Source Link

Document

Creates a new instance

Usage

From source file:com.bcknds.demo.oauth2.security.AuthorizationServer.java

@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
    AuthenticationManager authenticationManager = new AuthenticationManagerBuilder(objectPostProcessor)
            .userDetailsService(userService).passwordEncoder(new BCryptPasswordEncoder()).and().getOrBuild();
    endpoints.authenticationManager(authenticationManager);
}

From source file:com.gopivotal.cla.security.SecurityConfiguration.java

@Bean
public AuthenticationManager authenticationManager(ObjectPostProcessor<Object> objectPostProcessor)
        throws Exception {
    return new AuthenticationManagerBuilder(objectPostProcessor).inMemoryAuthentication().and().build();
}

From source file:com.test.config.BackendConsoleConfig.java

@Bean(name = { "defaultAuthenticationManager", "authenticationManager" })
public AuthenticationManager defaultAuthenticationManager() throws Exception {
    return new AuthenticationManagerBuilder(opp).authenticationProvider(defaultRestAuthenticationProvider())
            .build();//from  w  w w. ja va  2 s.c  o m
}

From source file:cn.timeoff.config.hackspring.WebSecurityConfigurerAdapter.java

@Autowired
public void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcessor) {
    this.objectPostProcessor = objectPostProcessor;

    authenticationBuilder = new AuthenticationManagerBuilder(objectPostProcessor);
    localConfigureAuthenticationBldr = new AuthenticationManagerBuilder(objectPostProcessor) {
        @Override//w ww  .  j  a  v  a  2 s. co m
        public AuthenticationManagerBuilder eraseCredentials(boolean eraseCredentials) {
            authenticationBuilder.eraseCredentials(eraseCredentials);
            return super.eraseCredentials(eraseCredentials);
        }

    };
}

From source file:org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration.java

@Bean
@ConditionalOnBean(AuthenticationManagerBuilder.class)
@ConditionalOnMissingBean/*from www. j a  va2  s  .  co m*/
public AuthenticationManager authenticationManager(AuthenticationManagerBuilder builder,
        ObjectPostProcessor<Object> processor) throws Exception {
    if (!isBuilt(builder)) {
        authentication(builder, securityProperties());
    } else if (builder.getOrBuild() == null) {
        builder = new AuthenticationManagerBuilder(processor);
        authentication(builder, securityProperties());
    }
    return builder.getOrBuild();
}

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
 *//*  w w w . j ava  2  s  . c om*/
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;
}