Java Code Examples for org.springframework.security.authentication.dao.DaoAuthenticationProvider#setUserDetailsService()

The following examples show how to use org.springframework.security.authentication.dao.DaoAuthenticationProvider#setUserDetailsService() . 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
Source File: SecurityConfig.java    From konker-platform with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
    authenticationProvider.setUserDetailsService(detailsService);
    authenticationProvider.setPasswordEncoder(new PlaintextPasswordEncoder() {
        @Override
        public boolean isPasswordValid(String encPass, String rawPass, Object salt) {
            try {
                return new PasswordManager().validatePassword(rawPass, encPass);
            } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
                LOGGER.error(e.getMessage(), e);
                return false;
            }
        }
    });
    auth.authenticationProvider(authenticationProvider);
}
 
Example 2
Source File: SecurityConfiguration.java    From code-examples with MIT License 5 votes vote down vote up
@Bean
public AuthenticationProvider daoAuthenticationProvider() {
  DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
  provider.setPasswordEncoder(passwordEncoder());
  provider.setUserDetailsPasswordService(this.databaseUserDetailPasswordService);
  provider.setUserDetailsService(this.databaseUserDetailsService);
  return provider;
}
 
Example 3
Source File: WithBasicAuthSecurityConfiguration.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
@Bean
DaoAuthenticationProvider daoAuthenticationProvider() {
    final DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setUserDetailsService(userDetailsService());
    provider.setPasswordEncoder(passwordEncoder());
    return provider;
}
 
Example 4
Source File: AppSecurityModelJ.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
Example 5
Source File: AppSecurityModelE2.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
Example 6
Source File: AppSecurityModelG.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
Example 7
Source File: RbacBaseSecurityConfigurerAdapter.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//		.jdbcAuthentication().authoritiesByUsernameQuery(query)
//		.authenticationProvider(authenticationProvider)
		DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
		daoProvider.setUserDetailsService(userDetailsService);
		daoProvider.afterPropertiesSet();
		auth.authenticationProvider(daoProvider);
    }
 
Example 8
Source File: SecurityConfig.java    From market with MIT License 5 votes vote down vote up
@Bean
public DaoAuthenticationProvider daoAuthenticationProvider(
	UserDetailsServiceImpl customUserDetailsService, PasswordEncoder passwordEncoder)
{
	DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
	provider.setUserDetailsService(customUserDetailsService);
	provider.setPasswordEncoder(passwordEncoder);
	return provider;
}
 
Example 9
Source File: AppSecurityModelJ.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
Example 10
Source File: SecurityConfig.java    From Using-Spring-Oauth2-to-secure-REST with MIT License 5 votes vote down vote up
@Bean
public DaoAuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setPasswordEncoder( passwordEncoder );
    provider.setUserDetailsService( userDetailsService() );
    return provider;
}
 
Example 11
Source File: WebSecurityConfiguration.java    From Parrit with MIT License 5 votes vote down vote up
@Bean
public AuthenticationProvider authenticationProvider(UserDetailsService userDetailsService, PasswordEncoder passwordEncoder) {
    DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
    daoAuthenticationProvider.setUserDetailsService(userDetailsService);
    daoAuthenticationProvider.setPasswordEncoder(passwordEncoder);
    daoAuthenticationProvider.setHideUserNotFoundExceptions(false);
    return daoAuthenticationProvider;
}
 
Example 12
Source File: SecurityConfig.java    From WeBASE-Node-Manager with Apache License 2.0 5 votes vote down vote up
@Bean
public DaoAuthenticationProvider userAuthenticationProvider(){
    DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
    daoAuthenticationProvider.setUserDetailsService(userDetailService);
    daoAuthenticationProvider.setHideUserNotFoundExceptions(false);
    daoAuthenticationProvider.setPasswordEncoder(passwordEncoder());
    return daoAuthenticationProvider;
}
 
Example 13
Source File: ServerSecurityConfig.java    From spring-glee-o-meter with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public DaoAuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setPasswordEncoder(passwordEncoder());
    provider.setUserDetailsService(userDetailsService);
    return provider;
}
 
Example 14
Source File: InceptionSecurity.java    From inception with Apache License 2.0 5 votes vote down vote up
@Bean(name = "authenticationProvider")
@Profile("auto-mode-builtin")
public DaoAuthenticationProvider internalAuthenticationProvider()
{
    DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
    authProvider.setUserDetailsService(userDetailsService());
    authProvider.setPasswordEncoder(passwordEncoder);
    return authProvider;
}
 
Example 15
Source File: SpringMvcSecurityConfig.java    From Hands-On-High-Performance-with-Spring-5 with MIT License 5 votes vote down vote up
@Bean
public AuthenticationProvider authenticationProviderBean() {
    DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
    authenticationProvider.setPasswordEncoder(passwordEncoder);
    authenticationProvider.setUserCache(userCache);
    authenticationProvider.setUserDetailsService(userDetailsService());
    
    return authenticationProvider;
}
 
Example 16
Source File: SecurityConfiguration.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
@Bean
// One of your authentication providers.
// They ensure that the credentials are valid and populate the user's authorities.
DaoAuthenticationProvider daoAuthenticationProvider() {
    final DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setUserDetailsService(userDetailsService());
    provider.setPasswordEncoder(passwordEncoder());
    return provider;
}
 
Example 17
Source File: WebSecurityConfigurer.java    From spring-oauth-server with GNU General Public License v2.0 5 votes vote down vote up
@Bean
public AuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
    daoAuthenticationProvider.setUserDetailsService(userService);
    daoAuthenticationProvider.setPasswordEncoder(passwordEncoder());
    return daoAuthenticationProvider;
}
 
Example 18
Source File: MolgenisWebAppSecurityConfig.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void configure(AuthenticationManagerBuilder auth) {
  try {
    DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
    authenticationProvider.setPasswordEncoder(passwordEncoder());
    authenticationProvider.setUserDetailsService(userDetailsServiceBean());
    authenticationProvider.setPreAuthenticationChecks(userDetailsChecker());
    auth.authenticationProvider(authenticationProvider);
  } catch (Exception e) {
    throw new WebAppSecurityConfigException(e);
  }
}
 
Example 19
Source File: SecurityConfig.java    From ChengFeng1.5 with MIT License 5 votes vote down vote up
@Bean("daoAuthenticationProvider")
protected AuthenticationProvider daoAuthenticationProvider() throws Exception{
    DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
    daoProvider.setPasswordEncoder(passwordEncoder());
    daoProvider.setUserDetailsService(userInfoService());
    return daoProvider;
}
 
Example 20
Source File: WebSecurityConfig.java    From Milkomeda with MIT License 4 votes vote down vote up
@Override
protected void configureProvider(DaoAuthenticationProvider provider) {
    provider.setUserDetailsService(userDetailsService());
}