List of usage examples for org.springframework.security.core.session SessionInformation SessionInformation
public SessionInformation(Object principal, String sessionId, Date lastRequest)
From source file:com.kuprowski.redis.security.core.session.RedisSessionRegistry.java
@Override public void registerNewSession(String sessionId, Object principal) { Assert.hasText(sessionId, "SessionId required as per interface contract"); Assert.notNull(principal, "Principal required as per interface contract"); if (logger.isDebugEnabled()) { logger.debug("Registering session " + sessionId + ", for principal " + principal); }/* ww w .j a v a 2s .c o m*/ if (getSessionInformation(sessionId) != null) { removeSessionInformation(sessionId); } sessionIdsTemplate.opsForValue().set(buildSessionIdsKey(sessionId), new SessionInformation(principal, sessionId, new Date())); principalsTemplate.opsForSet().add(buildPrincipalKey(principal), sessionId); }
From source file:org.codenergic.theskeleton.user.impl.UserServiceImpl.java
@Override public List<SessionInformation> findUserActiveSessions(@NotNull String username) { return sessionRegistry.getAllPrincipals().stream().filter(principal -> principal instanceof User).distinct() .filter(principal -> ((User) principal).getUsername().equals(username)) .flatMap(principal -> sessionRegistry.getAllSessions(principal, true).stream()).map(session -> { SessionInformation newSession = new SessionInformation(username, session.getSessionId(), session.getLastRequest()); if (session.isExpired()) newSession.expireNow(); return newSession; }).collect(Collectors.toList()); }
From source file:org.springframework.security.core.session.SessionRegistryImpl.java
public void registerNewSession(String sessionId, Object principal) { Assert.hasText(sessionId, "SessionId required as per interface contract"); Assert.notNull(principal, "Principal required as per interface contract"); if (getSessionInformation(sessionId) != null) { removeSessionInformation(sessionId); }/*from w w w . j a v a 2s . com*/ if (logger.isDebugEnabled()) { logger.debug("Registering session " + sessionId + ", for principal " + principal); } sessionIds.put(sessionId, new SessionInformation(principal, sessionId, new Date())); Set<String> sessionsUsedByPrincipal = principals.computeIfAbsent(principal, key -> new CopyOnWriteArraySet<>()); sessionsUsedByPrincipal.add(sessionId); if (logger.isTraceEnabled()) { logger.trace("Sessions used by '" + principal + "' : " + sessionsUsedByPrincipal); } }