List of usage examples for org.springframework.security.core.context SecurityContextImpl getAuthentication
@Override
public Authentication getAuthentication()
From source file:eu.supersede.fe.security.redis.session.AuthenticationSuccessListenerRedisSession.java
@Override public void onApplicationEvent(SessionCreatedEvent event) { log.debug("created session id: " + event.getSessionId()); MapSession ms = (MapSession) event.getSession(); Session s = new Session(); s.setId(ms.getId());/*from w w w.ja v a 2 s .c o m*/ s.setCreationTime(new Date(ms.getCreationTime())); s.setLastAccessTime(new Date(ms.getLastAccessedTime())); Object securetyContext = sessionObjectTemplate.opsForHash().get("spring:session:sessions:" + s.getId(), "sessionAttr:SPRING_SECURITY_CONTEXT"); if (securetyContext != null) { SecurityContextImpl sCI = (SecurityContextImpl) securetyContext; DatabaseUser dbU = (DatabaseUser) sCI.getAuthentication().getPrincipal(); s.setDatabaseUser(dbU); } sessionTemplate.opsForValue().set(Session.SUPERSEDE_SESSION_PREFIX + s.getId(), s); }