Java Code Examples for org.springframework.security.provisioning.JdbcUserDetailsManager#setDataSource()

The following examples show how to use org.springframework.security.provisioning.JdbcUserDetailsManager#setDataSource() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@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
}
 
Example 2
@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;
}
 
Example 3
Source Project: tutorials   File: SecurityConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public JdbcUserDetailsManager userDetailsManager() {
    JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
    manager.setDataSource(dataSource);
    return manager;
}
 
Example 4
Source Project: tutorials   File: WebSecurityConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public UserDetailsService jdbcUserDetailsService(DataSource dataSource) {
    JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
    manager.setDataSource(dataSource);
    return manager;
}