本文整理匯總了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;
}