38 lines
1.3 KiB
Java
38 lines
1.3 KiB
Java
package org.baeldung.spring;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.ImportResource;
|
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
|
|
|
@Configuration
|
|
@ComponentScan(basePackages = { "org.baeldung.security" })
|
|
@ImportResource({ "classpath:webSecurityConfig.xml" })
|
|
public class SecSecurityConfig {
|
|
|
|
@Autowired
|
|
UserDetailsService userDetailsService;
|
|
|
|
public SecSecurityConfig() {
|
|
super();
|
|
}
|
|
|
|
@Bean
|
|
public BCryptPasswordEncoder encoder() {
|
|
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(11);
|
|
return encoder;
|
|
}
|
|
|
|
@Bean
|
|
public DaoAuthenticationProvider authProvider() {
|
|
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
|
|
authProvider.setUserDetailsService(userDetailsService);
|
|
authProvider.setPasswordEncoder(encoder());
|
|
return authProvider;
|
|
}
|
|
|
|
} |