TODO Auto-generated method stub
return this.password;
} while returning the password i want to return password2 also . means user can login with any of those password can anyone tell me the solution?
Long story short, you can't do that with UserDetails + UserDetailsService. These classes are not mandatory, but rather are an out-of-the-box mechanism for username+password authentication. And obviously it's designed for classic username + single password use-case. For other types of authentication (which includes your case with 2 alternative passwords too) you just need to skip using UserDetails+UserDetailsService and use different AuthenticationManager/AuthenticationProvider implementations. Since your requirement is very exotic, you'll have to write your own AuthenticationProvider (or AuthenticationManager, but I recommend AuthenticationProvider, it will be more flexible), there won't be any built-in solution. Though you should be able to re-use built-in UsernamePasswordAuthenticationFilter for username+password since user will pass only one password in request, not both. So this should be re-usable.
Thank you I created my own AuthProvider and it solve the problem.
Обсуждают сегодня