use of org.onebusaway.users.model.IndexedUserDetails in project onebusaway-application-modules by camsys.
the class LogoutEventListener method onApplicationEvent.
@Override
public void onApplicationEvent(HttpSessionDestroyedEvent event) {
SecurityContext securityContext = (SecurityContext) event.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
if (securityContext != null && securityContext.getAuthentication() != null && securityContext.getAuthentication().getPrincipal() != null) {
IndexedUserDetails userDetails = (IndexedUserDetails) securityContext.getAuthentication().getPrincipal();
String component = System.getProperty("admin.chefRole");
String message = "User '" + userDetails.getUsername() + "' logged out";
loggingService.log(component, Level.INFO, message);
}
}
use of org.onebusaway.users.model.IndexedUserDetails in project onebusaway-application-modules by camsys.
the class CurrentUserStrategyImpl method setCurrentUser.
@Override
public void setCurrentUser(UserIndex userIndex) {
IndexedUserDetails userDetails = new IndexedUserDetailsImpl(_authoritiesService, userIndex);
DefaultUserAuthenticationToken token = new DefaultUserAuthenticationToken(userDetails);
SecurityContextHolder.getContext().setAuthentication(token);
}
use of org.onebusaway.users.model.IndexedUserDetails in project onebusaway-application-modules by camsys.
the class EveryLastLoginAuthenticationProcessorFilter method attemptAuthentication.
@Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
String mode = request.getParameter("mode");
AuthenticationResult result = LoginManager.getResult(request);
if (result == null)
throw new EveryLastLoginAuthenticationException("AuthenticationResult not found", mode);
if (result.getCode() != EResultCode.SUCCESS)
throw new EveryLastLoginAuthenticationException("AuthenticationResult failure", mode);
IndexedUserDetails details = _currentUserService.handleUserAction(result.getProvider(), result.getIdentity(), result.getCredentials(), false, mode);
if (details == null)
throw new EveryLastLoginAuthenticationException("could not get user details", mode);
return new DefaultUserAuthenticationToken(details);
}
Aggregations