Closed shahbour closed 5 years ago
I end up creating MultipleUserDetailsService , not sure if it is the correct approach but it do work
public class MultipleUserDetailsService implements UserDetailsService {
private List<UserDetailsService> userDetailsServiceList = new ArrayList<>();
public MultipleUserDetailsService(UserDetailsService ... userDetailsServices) {
this.userDetailsServiceList.addAll(Arrays.asList(userDetailsServices));
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
for (UserDetailsService userDetailsService : userDetailsServiceList) {
try {
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
if(userDetails != null) {
return userDetails;
}
}
catch (UsernameNotFoundException exception) {
log.debug("User not found in {} trying next UserDetailsService", userDetailsService);
}
}
throw new UsernameNotFoundException("Unable to find user " + username);
}
}
I am facing a similer error to issues-19 but in my case i do have two provider ldap and dao thus two UserDetailsService so i was not able to explicity set the sugessted solution in issue 19 .