use of org.springframework.security.core.AuthenticationException in project oc-explorer by devgateway.
the class SSAuthenticatedWebSession method authenticate.
@Override
public boolean authenticate(final String username, final String password) {
boolean authenticated;
try {
Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
SecurityContextHolder.getContext().setAuthentication(authentication);
// httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
// SecurityContextHolder.getContext());
authenticated = authentication.isAuthenticated();
if (authenticated && rememberMeServices != null) {
rememberMeServices.loginSuccess((HttpServletRequest) RequestCycle.get().getRequest().getContainerRequest(), (HttpServletResponse) RequestCycle.get().getResponse().getContainerResponse(), authentication);
}
} catch (AuthenticationException e) {
this.setAe(e);
log.warn("User '{}' failed to login. Reason: {}", username, e.getMessage());
authenticated = false;
}
return authenticated;
}
Aggregations