Java 类org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder 实例源码

项目:testing_security_development_enterprise_systems    文件:WebSecurityConfig.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) {

    try {
        auth.jdbcAuthentication()
                .dataSource(dataSource)
                .usersByUsernameQuery(
                        "SELECT username, password, enabled " +
                                "FROM users " +
                                "WHERE username = ?"
                )
                .authoritiesByUsernameQuery(
                        "SELECT x.username, y.roles " +
                                "FROM users x, user_entity_roles y " +
                                "WHERE x.username = ? and y.user_entity_username = x.username "
                )
                /*
                    Note: in BCrypt, the "password" field also contains the salt
                 */
                .passwordEncoder(passwordEncoder);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:shepher    文件:WebSecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    if (ShepherConstants.LOGIN_TYPE_LDAP.equals(loginType.toUpperCase())) {
        auth.ldapAuthentication()
                .userDnPatterns("uid={0},ou=people")
                .groupSearchBase("ou=groups")
                .contextSource()
                .url(ldapUrl)
                .managerPassword(ldapPassword)
                .managerDn(ldapDn);
    } else if (ShepherConstants.LOGIN_TYPE_DEMO.equals(loginType.toUpperCase())) {
        auth.inMemoryAuthentication()
                .withUser(demoAdminName)
                .password(demoAdminPassword)
                .roles("USER");
    }
}
项目:sns-todo    文件:FormLoginSecurityConfig.java   
@Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService)
                .passwordEncoder(passwordEncoder());
/*        auth.inMemoryAuthentication()
                .withUser("admin").password("yigepingguo.com").roles("ADMIN", "USER")
                .and()
                .withUser("user").password("user").roles("USER");*/
    }
项目:ARCLib    文件:BaseSecurityInitializer.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    AuthenticationProvider[] providers = primaryAuthProviders();
    for (AuthenticationProvider provider : providers) {
        auth = auth.authenticationProvider(provider);
    }

    auth.authenticationProvider(tokenProvider);
}
项目:spring-ddd-bank    文件:WebSecurityConfig.java   
/**Configures the {@link #predefinedUsernames} as known users with their password equal to the user name.*/
 @Autowired
 public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
     final InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication = auth.inMemoryAuthentication();
     for(final String username: predefinedUsernames) {
        final String role = username.equalsIgnoreCase(BANK_ROLE) ? BANK_ROLE : CLIENT_ROLE;
inMemoryAuthentication.withUser(username).password("").roles(role);
     }
 }
项目:spring-cloud-dashboard    文件:FileAuthenticationConfiguration.java   
/**
 * Initializes the {@link AuthenticationManagerBuilder}. Creates an
 * {@link InMemoryUserDetailsManager} with the provided {@link FileAuthenticationConfiguration#getUsers()}.
 * {@link FileAuthenticationConfiguration#getUsers()} must contain at least 1 user.
 *
 * @throws IllegalArgumentException if {@link FileAuthenticationConfiguration#getUsers()} is empty.
 */
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {

    Assert.notEmpty(this.users,
        String.format("No user specified. Please specify at least 1 user (e.g. via '%s')",
            CONFIGURATION_PROPERTIES_PREFIX + ".users"));

    final InMemoryUserDetailsManager inMemory = new InMemoryUserDetailsManager(getUsers());
    auth.userDetailsService(inMemory);
}
项目:kafka-webview    文件:SecurityConfig.java   
@Override
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
    auth
        // Define our custom user details service.
        .userDetailsService(new CustomUserDetailsService(userRepository))
        .passwordEncoder(getPasswordEncoder());
}
项目:InfoSys-1D    文件:ProfChoperSecurityConfig.java   
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
    // Authentication via JDBC, look up PostgreSQL database
    auth.jdbcAuthentication()
            .dataSource(dataSource)
            .usersByUsernameQuery("SELECT username, password, enabled FROM users WHERE username = ?")
            .authoritiesByUsernameQuery("SELECT username, role FROM user_roles WHERE username = ?");
}
项目:dawn    文件:SecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .jdbcAuthentication()
            .dataSource(dataSource)
            .passwordEncoder(passwordEncoder())
    ;// END AUTH CONFIG
}
项目:bf-editor    文件:WebSecurityConfig.java   
@Autowired
public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
    authenticationManagerBuilder
            // 设置UserDetailsService
            .userDetailsService(this.userDetailsService)
            // 使用BCrypt进行密码的hash
            .passwordEncoder(passwordEncoder());
}
项目:microservices-event-sourcing    文件:AuthorizationServerConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder authManagerBuilder) throws Exception {
    authManagerBuilder
            .inMemoryAuthentication()
            .withUser("user").password("password").roles("USER")
            .and().withUser("admin").password("password").roles("ADMIN", "USER");
}
项目:custom-gradle-plugin-portal    文件:WebSecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    String username = environment.getRequiredProperty("user.login");
    String password = environment.getRequiredProperty("user.password");

    auth
            .inMemoryAuthentication()
            .withUser(username).password(password).roles("ADMIN");
}
项目:autopivot    文件:SecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .eraseCredentials(false)
            // Add an LDAP authentication provider instead of this to support LDAP
            .userDetailsService(userDetailsService()).and()
            // Required to allow JWT
            .authenticationProvider(jwtConfig.jwtAuthenticationProvider());
}
项目:Code4Health-Platform    文件:SecurityConfiguration.java   
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService,
        TokenProvider tokenProvider,
    CorsFilter corsFilter) {

    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.tokenProvider = tokenProvider;
    this.corsFilter = corsFilter;
}
项目:gamesboard    文件:SecurityContext.java   
/**
 * Configures the authentication manager bean which processes authentication
 * requests.
 */
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .userDetailsService(userDetailsService())
            .passwordEncoder(passwordEncoder());
}
项目:ToDoApp-Spring    文件:SpringSecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .inMemoryAuthentication()
            .withUser("user").password("password").roles("USER")
            .and().withUser("admin").password("admin").roles("ADMIN");
}
项目:apollo-custom    文件:TestWebSecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
  auth.inMemoryAuthentication().withUser("user").password("").roles("USER");
  auth.inMemoryAuthentication().withUser("apollo").password("").roles("USER", "ADMIN");
  auth.inMemoryAuthentication().withUser("created").password("").roles("TEST");
  auth.inMemoryAuthentication().withUser("updated").password("").roles("TEST");
  auth.inMemoryAuthentication().withUser("deleted").password("").roles("TEST");
}
项目:JenkinsHue    文件:SecurityConfiguration.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    //noinspection ConstantConditions
    if(ldapAuthentication != null) {
        auth.authenticationProvider(userAuthenticationProvider);
        ldapAuthentication.enable(auth);
    } else {
        auth.userDetailsService(userDetailsService());
    }
}
项目:spring-data-examples    文件:Application.java   
/**
 * This section defines the user accounts which can be used for authentication as well as the roles each user has.
 * 
 * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configure(org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder)
 */
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {

    auth.inMemoryAuthentication().//
            withUser("greg").password("turnquist").roles("USER").and().//
            withUser("ollie").password("gierke").roles("USER", "ADMIN");
}
项目:sentry    文件:SecurityConfiguration.java   
@Inject
public void configureGlobal(AuthenticationManagerBuilder auth) {
    try {
        auth
            .userDetailsService(userDetailsService)
                .passwordEncoder(passwordEncoder());
    } catch (Exception e) {
        throw new BeanInitializationException("Security configuration failed", e);
    }
}
项目:spring-cloud-dashboard    文件:FileAuthenticationConfigurationTests.java   
@Test
public void testInitAuthenticationManagerBuilder() throws Exception {

    try {
        final FileAuthenticationConfiguration fileAuthenticationConfiguration =
                new FileAuthenticationConfiguration();
        fileAuthenticationConfiguration.init(mock(AuthenticationManagerBuilder.class));
    }
    catch (IllegalArgumentException anIllegalArgumentException) {
        assertThat(anIllegalArgumentException.getMessage(),
                is("No user specified. Please specify at least 1 user (e.g. "
                        + "via 'dataflow.security.authentication.file.users')"));
    }
}
项目:microservices-basics-spring-boot    文件:OAuthServerConfiguration.java   
/**
 * Setup 2 users with different roles
 */
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
    // @formatter:off
    auth.jdbcAuthentication().dataSource(dataSource).withUser("dave").password("secret").roles("USER").and()
            .withUser("anil").password("password").roles("ADMIN", "USER").and().getUserDetailsService();
    // @formatter:on

    // Add the default service
    jdbcUserDetailsService.addService(auth.getDefaultUserDetailsService());
}
项目:second-opinion-api    文件:SecondOpinionSecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
            .withUser(secondOpinionSecurityProperties.getUsername())
            .password(secondOpinionSecurityProperties.getPassword())
            .roles("USER");
}
项目:microservice-skeleton    文件:JdbcServerSecurityConfig.java   
@Override
protected void configure(AuthenticationManagerBuilder auth)
        throws Exception {
    auth.userDetailsService(userDetailsService)
            .passwordEncoder(passwordEncoder);
}
项目:minsx-authorization-server    文件:SecurityConfig.java   
@Autowired
public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder());
}
项目:Building-Web-Apps-with-Spring-5-and-Angular    文件:SecurityConfiguration.java   
@Override
protected void configure(AuthenticationManagerBuilder authBuilder) {
    authBuilder.authenticationProvider(this.authProvider);
}
项目:shootmimi    文件:CasSecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .authenticationProvider(casAuthenticationProvider());
}
项目:EventSoft    文件:SecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
项目:Using-Spring-Oauth2-to-secure-REST    文件:SecurityConfig.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .userDetailsService(userDetailsService)
            .passwordEncoder(passwordEncoder);
}
项目:FantaParrocchie    文件:WebSecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .inMemoryAuthentication()
            .withUser("root").password("password").roles("ADMIN");
}
项目:oasp-tutorial-sources    文件:BaseUserDetailsService.java   
/**
 * @param amBuilder new value of {@link #getAmBuilder}.
 */
@Inject
public void setAmBuilder(AuthenticationManagerBuilder amBuilder) {

  this.amBuilder = amBuilder;
}
项目:Spring-5.0-Cookbook    文件:AppSecurityModelI.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
   auth.inMemoryAuthentication()
      .withUser("sjctrags").password("sjctrags").roles("USER");
}
项目:syndesis    文件:SecurityConfiguration.java   
@Override
protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) {
    authenticationManagerBuilder.authenticationProvider(authenticationProvider());
}
项目:Spring-5.0-Cookbook    文件:AppSecurityModelF.java   
@Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authProvider());
auth.eraseCredentials(false);
  }
项目:Spring-5.0-Cookbook    文件:AppSecurityConfig.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
   auth.inMemoryAuthentication()
      .withUser("sjctrags").password("sjctrags").roles("USER");
}
项目:spring-boot-oauth2-demo    文件:SecurityConfig.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService())
        .passwordEncoder(passwordEncoder());
}
项目:Spring-5.0-Cookbook    文件:AppSecurityModelA.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
   auth.inMemoryAuthentication()
      .withUser("sjctrags").password("sjctrags").roles("USER");
}
项目:Spring-5.0-Cookbook    文件:AppSecurityModelG.java   
@Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {    
auth.authenticationProvider(authProvider());
auth.eraseCredentials(false);
  }
项目:Spring-5.0-Cookbook    文件:AppSecurityModelC.java   
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {  }