I have implemented my own UserDetailsService. I am configuring spring security in java. How I can create default authentication provider with my custom user service details service and some password encoder?
Thanks in advance Best Regards EDIT: This is what I tried: Here is part of my user details service impl:
public class UserDetailsServiceImpl implements UserDetailsService
Later in my security config I have something like this:
@Bean
public UserDetailsServiceImpl userDetailsService(){
return new UserDetailsServiceImpl();
}
@Bean
public AuthenticationManager authenticationManager() throws Exception{
return auth.build();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
auth.userDetailsService(userDetailsService()).passwordEncoder(passwordEncoder);
However when I run this code I have exception :
Caused by: java.lang.IllegalArgumentException: Can not set com.xxx.UserDetailsServiceImpl field com.....MyAuthenticationProvider.service to com.sun.proxy.$Proxy59
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:741)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:504)
... 58 more
I guess I am doing something wrong