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


Java JdbcUserDetailsManager类代码示例

本文整理汇总了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);
    }};
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:17,代码来源:SecurityConfig.java

示例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
}
 
开发者ID:arnaldop,项目名称:enhanced-pet-clinic,代码行数:25,代码来源:MultiHttpSecurityConfig.java

示例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);
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:10,代码来源:SecurityConfig.java

示例4: userDetailsService

import org.springframework.security.provisioning.JdbcUserDetailsManager; //导入依赖的package包/类
/**
 * 授权服务器(定义UserDetails类)
 */
@Bean
public UserDetailsService userDetailsService() {
    JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
    manager.setDataSource(dataSource);
    return manager;
}
 
开发者ID:openmg,项目名称:metagraph-auth,代码行数:10,代码来源:WebSecurityConfigurer.java

示例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);
    }};
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:19,代码来源:SecurityConfig.java

示例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);
    }};
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:13,代码来源:SecurityConfig.java

示例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;
}
 
开发者ID:restbucks,项目名称:restbucks-member,代码行数:8,代码来源:AuthenticationManagerConfiguration.java

示例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);
    }
}
 
开发者ID:jame-developer,项目名称:spring-boot-mvc-sec-db-wf,代码行数:16,代码来源:WebSecurityConfig.java

示例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;
}
 
开发者ID:petrbouda,项目名称:joyrest,代码行数:9,代码来源:JdbcUserDetailsServiceConfigurer.java

示例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;
}
 
开发者ID:arnaldop,项目名称:enhanced-pet-clinic,代码行数:14,代码来源:MultiHttpSecurityConfig.java


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