I use Spring MVC in my application and the login is authenticated by spring security. I have the following two methods in my UserServiceImpl.java class,
public
if you want, you can create your own AuthenticationProvider
public class CustomAuthenticationProvider implements AuthenticationProvider{
private UserDetailsService service;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) authentication;
String username = token.getName();
String password = token.getCredentials(); // retrieve the password
// do something here
// if ok then return the authentication
return new UsernamePasswordAuthenticationToken(username, password, authorities);
}
}
and plug it to your security configuration