本文整理汇总了Java中org.springframework.security.provisioning.JdbcUserDetailsManager.setDataSource方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcUserDetailsManager.setDataSource方法的具体用法?Java JdbcUserDetailsManager.setDataSource怎么用?Java JdbcUserDetailsManager.setDataSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.provisioning.JdbcUserDetailsManager
的用法示例。
在下文中一共展示了JdbcUserDetailsManager.setDataSource方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
}
示例2: 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);
}
示例3: userDetailsService
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入方法依赖的package包/类
/**
* 授权服务器(定义UserDetails类)
*/
@Bean
public UserDetailsService userDetailsService() {
JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
manager.setDataSource(dataSource);
return manager;
}
示例4: userDetailsManager
import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入方法依赖的package包/类
@Bean
protected UserDetailsManager userDetailsManager() {
JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
manager.setDataSource(dataSource);
manager.setRolePrefix("ROLE_");
return manager;
}
示例5: 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);
}
}
示例6: 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;
}
示例7: 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;
}