本文整理汇总了Java中org.springframework.security.provisioning.JdbcUserDetailsManager类的典型用法代码示例。如果您正苦于以下问题:Java JdbcUserDetailsManager类的具体用法?Java JdbcUserDetailsManager怎么用?Java JdbcUserDetailsManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JdbcUserDetailsManager类属于org.springframework.security.provisioning包,在下文中一共展示了JdbcUserDetailsManager类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: userDetailsService
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
/**
* The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService())
* originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager}
* UserDetailsManager vs UserDetailsService
*/
@Bean
@Override
public UserDetailsManager userDetailsService() {
return new JdbcUserDetailsManager() {{
setDataSource(dataSource);
// Override default SQL for JdbcUserDetailsManager
setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY);
// TODO: This is not available through AuthenticationManagerBuilder
setCreateUserSql(CUSTOM_CREATE_USER_SQL);
}};
}
示例2: init
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
//@formatter:off
String authoritiesByUsernameQuery = "select username, authority from user_authorities " +
"inner join users on user_authorities.user_id = users.id " +
"inner join authorities on user_authorities.authority_id = authorities.id " +
"where username = ?";
JdbcUserDetailsManager userDetailsService = new JdbcUserDetailsManager();
userDetailsService.setDataSource(dataSource);
userDetailsService.setAuthoritiesByUsernameQuery(authoritiesByUsernameQuery);
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
auth
.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder)
.and()
.jdbcAuthentication()
.authoritiesByUsernameQuery(authoritiesByUsernameQuery)
.passwordEncoder(passwordEncoder)
.dataSource(dataSource)
;
//@formatter:on
}
示例3: init
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
JdbcUserDetailsManager userDetailsService = new JdbcUserDetailsManager();
userDetailsService.setDataSource(dataSource);
PasswordEncoder encoder = new BCryptPasswordEncoder();
auth.userDetailsService(userDetailsService).passwordEncoder(encoder).and().jdbcAuthentication()
.dataSource(dataSource);
}
示例4: userDetailsService
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
/**
* 授权服务器(定义UserDetails类)
*/
@Bean
public UserDetailsService userDetailsService() {
JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
manager.setDataSource(dataSource);
return manager;
}
示例5: userDetailsService
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
/**
* The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService())
* originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager}
* UserDetailsManager vs UserDetailsService
*/
@Bean
@Override
public UserDetailsManager userDetailsService() {
return new JdbcUserDetailsManager() {{
setDataSource(dataSource);
// Override default SQL for JdbcUserDetailsManager
setGroupAuthoritiesByUsernameQuery(CUSTOM_GROUP_AUTHORITIES_BY_USERNAME_QUERY);
setUsersByUsernameQuery(CUSTOM_USERS_BY_USERNAME_QUERY);
setAuthoritiesByUsernameQuery(CUSTOM_AUTHORITIES_BY_USERNAME_QUERY);
// TODO: This is not available through AuthenticationManagerBuilder
setCreateUserSql(CUSTOM_CREATE_USER_SQL);
}};
}
示例6: userDetailsService
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
/**
* The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService())
* originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager}
* UserDetailsManager vs UserDetailsService
*/
@Bean
@Override
public UserDetailsManager userDetailsService() {
return new JdbcUserDetailsManager() {{
setDataSource(dataSource);
}};
}
示例7: userDetailsManager
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
@Bean
protected UserDetailsManager userDetailsManager() {
JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
manager.setDataSource(dataSource);
manager.setRolePrefix("ROLE_");
return manager;
}
示例8: configureGlobal
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
JdbcUserDetailsManager userDetailsService = new JdbcUserDetailsManager();
userDetailsService.setDataSource(datasource);
PasswordEncoder encoder = new BCryptPasswordEncoder();
auth.userDetailsService(userDetailsService).passwordEncoder(encoder);
auth.jdbcAuthentication().dataSource(datasource);
if(!userDetailsService.userExists("user")) {
List<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority("USER"));
User userDetails = new User("user", encoder.encode("password"), authorities);
userDetailsService.createUser(userDetails);
}
}
示例9: performBuild
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
@Override
protected UserDetailsService performBuild() {
JdbcUserDetailsManager userDetailsManager = new JdbcUserDetailsManager();
userDetailsManager.setDataSource(dataSource);
userDetails.forEach(userDetailsManager::createUser);
return userDetailsManager;
}
示例10: getRememberMeServices
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
@Bean
public RememberMeServices getRememberMeServices() {
JdbcUserDetailsManager jdbcUserDetailsManager = new JdbcUserDetailsManager();
jdbcUserDetailsManager.setDataSource(dataSource);
JdbcTokenRepositoryImpl jdbcTokenRepositoryImpl = new JdbcTokenRepositoryImpl();
jdbcTokenRepositoryImpl.setDataSource(dataSource);
PersistentTokenBasedRememberMeServices services = new PersistentTokenBasedRememberMeServices(
rememberMeToken, jdbcUserDetailsManager, jdbcTokenRepositoryImpl);
services.setParameter(rememberMeParameter);
return services;
}