use of com.infiniteautomation.mango.spring.events.SessionLoadedEvent in project ma-core-public by infiniteautomation.
the class MangoJdbcSessionDataStore method doLoad.
@Override
public SessionData doLoad(String id) throws Exception {
MangoSessionDataVO vo = sessionDao.get(id, _context.getCanonicalContextPath(), _context.getVhost());
if (vo == null) {
return null;
}
SessionData data = newSessionData(id, vo.getCreateTime(), vo.getAccessTime(), vo.getLastAccessTime(), vo.getMaxInterval());
data.setContextPath(_context.getCanonicalContextPath());
data.setVhost(_context.getVhost());
data.setCookieSet(vo.getCookieTime());
data.setLastNode(vo.getLastNode());
data.setLastSaved(vo.getLastSavedTime());
data.setExpiry(vo.getExpiryTime());
if (vo.getUserId() > 0) {
User user = runAs.runAs(runAs.systemSuperadmin(), () -> userService.getByIdViaCache(vo.getUserId()));
SecurityContext sessionContext = SecurityContextHolder.createEmptyContext();
sessionContext.setAuthentication(MangoPasswordAuthenticationProvider.createAuthenticatedToken(user));
data.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, sessionContext);
this.eventPublisher.publishEvent(new SessionLoadedEvent(this, id, user));
}
return data;
}
Aggregations