UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword());
try {
Authentication auth = authenticationManager.authenticate(token);
SecurityContextHolder.getContext().setAuthentication(auth);
LoginStatus loginStatus = new LoginStatus(auth.isAuthenticated(), isAnonymous(auth), auth.getName());
return new Builder(true).resultObject(loginStatus).build();
}
catch (BadCredentialsException e) {
LoginStatus loginStatus = new LoginStatus(false, false, null);
return new Builder(false).errorCode(ErrorCode.INVALID_CREDENTIALS).resultObject(loginStatus).build();
}
}