本文整理汇总了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");
}
}
示例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");*/
}
示例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);
}
示例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);
}
}
示例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);
}
示例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());
}
示例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 = ?");
}
示例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")
;
}
示例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
}
示例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());
}
示例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");
}
示例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");
}
示例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());
}
示例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;
}