Search in sources :

Example 6 with IndexedUserDetails

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);
    }
}
Also used : IndexedUserDetails(org.onebusaway.users.model.IndexedUserDetails) SecurityContext(org.springframework.security.core.context.SecurityContext)

Example 7 with IndexedUserDetails

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);
}
Also used : IndexedUserDetails(org.onebusaway.users.model.IndexedUserDetails) DefaultUserAuthenticationToken(org.onebusaway.users.impl.authentication.DefaultUserAuthenticationToken)

Example 8 with IndexedUserDetails

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);
}
Also used : IndexedUserDetails(org.onebusaway.users.model.IndexedUserDetails) AuthenticationResult(org.onebusaway.everylastlogin.server.AuthenticationResult)

Aggregations

IndexedUserDetails (org.onebusaway.users.model.IndexedUserDetails)8 DefaultUserAuthenticationToken (org.onebusaway.users.impl.authentication.DefaultUserAuthenticationToken)3 UserIndexKey (org.onebusaway.users.model.UserIndexKey)3 Authentication (org.springframework.security.core.Authentication)2 ActionContext (com.opensymphony.xwork2.ActionContext)1 UUID (java.util.UUID)1 AuthenticationResult (org.onebusaway.everylastlogin.server.AuthenticationResult)1 SecurityContext (org.springframework.security.core.context.SecurityContext)1