当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationManagerBuilder类代码示例

本文整理汇总了Java中org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationManagerBuilder类的具体用法?Java AuthenticationManagerBuilder怎么用?Java AuthenticationManagerBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticationManagerBuilder类属于org.springframework.security.config.annotation.authentication.builders包,在下文中一共展示了AuthenticationManagerBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:25,代码来源:WebSecurityConfig.java

示例2: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:XiaoMi,项目名称:shepher,代码行数:18,代码来源:WebSecurityConfig.java

示例3: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@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");*/
    }
 
开发者ID:helloworldtang,项目名称:sns-todo,代码行数:10,代码来源:FormLoginSecurityConfig.java

示例4: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    AuthenticationProvider[] providers = primaryAuthProviders();
    for (AuthenticationProvider provider : providers) {
        auth = auth.authenticationProvider(provider);
    }

    auth.authenticationProvider(tokenProvider);
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:10,代码来源:BaseSecurityInitializer.java

示例5: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
/**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);
     }
 }
 
开发者ID:ChristophKnabe,项目名称:spring-ddd-bank,代码行数:10,代码来源:WebSecurityConfig.java

示例6: init

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:18,代码来源:FileAuthenticationConfiguration.java

示例7: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@Override
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
    auth
        // Define our custom user details service.
        .userDetailsService(new CustomUserDetailsService(userRepository))
        .passwordEncoder(getPasswordEncoder());
}
 
开发者ID:SourceLabOrg,项目名称:kafka-webview,代码行数:8,代码来源:SecurityConfig.java

示例8: configAuthentication

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@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 = ?");
}
 
开发者ID:ericywl,项目名称:InfoSys-1D,代码行数:9,代码来源:ProfChoperSecurityConfig.java

示例9: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
/**
 * Configure AuthenticationManager with inMemory credentials.
 *
 * @param auth       AuthenticationManagerBuilder
 * @throws Exception Authentication exception
 */
@Override
public void configure(final AuthenticationManagerBuilder auth) throws Exception {

    auth.inMemoryAuthentication()
            .withUser("user").password("user").roles("USER")
            .and().withUser("admin").password("admin").roles("USER", "ADMIN")
            .and().withUser("[email protected]").password("user1").roles("USER")
            .and().withUser("[email protected]").password("admin1").roles("USER", "ADMIN")
    ;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:17,代码来源:SecurityConfig.java

示例10: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .jdbcAuthentication()
            .dataSource(dataSource)
            .passwordEncoder(passwordEncoder())
    ;// END AUTH CONFIG
}
 
开发者ID:Dawn-Team,项目名称:dawn,代码行数:9,代码来源:SecurityConfig.java

示例11: configureAuthentication

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@Autowired
public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
    authenticationManagerBuilder
            // 设置UserDetailsService
            .userDetailsService(this.userDetailsService)
            // 使用BCrypt进行密码的hash
            .passwordEncoder(passwordEncoder());
}
 
开发者ID:CFshuming,项目名称:bf-editor,代码行数:9,代码来源:WebSecurityConfig.java

示例12: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@Autowired
public void configureGlobal(AuthenticationManagerBuilder authManagerBuilder) throws Exception {
    authManagerBuilder
            .inMemoryAuthentication()
            .withUser("user").password("password").roles("USER")
            .and().withUser("admin").password("password").roles("ADMIN", "USER");
}
 
开发者ID:chaokunyang,项目名称:microservices-event-sourcing,代码行数:8,代码来源:AuthorizationServerConfig.java

示例13: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@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");
}
 
开发者ID:linkedin,项目名称:custom-gradle-plugin-portal,代码行数:10,代码来源:WebSecurityConfig.java

示例14: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
@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());
}
 
开发者ID:activeviam,项目名称:autopivot,代码行数:10,代码来源:SecurityConfig.java

示例15: SecurityConfiguration

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //导入依赖的package包/类
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService,
        TokenProvider tokenProvider,
    CorsFilter corsFilter) {

    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.tokenProvider = tokenProvider;
    this.corsFilter = corsFilter;
}
 
开发者ID:AppertaFoundation,项目名称:Code4Health-Platform,代码行数:10,代码来源:SecurityConfiguration.java


注:本文中的org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。