private void handleExpired(RedisSession session) { publishEvent(new SessionExpiredEvent(this, session)); }
@Override public void entryEvicted(EntryEvent<String, MapSession> event) { if (logger.isDebugEnabled()) { logger.debug("Session expired with id: " + event.getOldValue().getId()); } this.eventPublisher .publishEvent(new SessionExpiredEvent(this, event.getOldValue())); }
if (session.load()) { session.clearPrincipal(); publishEvent(new SessionExpiredEvent(this, session)); } else { publishEvent(new SessionExpiredEvent(this, id));
if (session.load()) { session.clearPrincipal(); publishEvent(new SessionExpiredEvent(this, session)); } else { publishEvent(new SessionExpiredEvent(this, id));
@Before public void setup() { String sessionId = "session-id"; MapSession session = new MapSession(sessionId); this.attributes = new HashMap<>(); SessionRepositoryMessageInterceptor.setSessionId(this.attributes, sessionId); given(this.wsSession.getAttributes()).willReturn(this.attributes); given(this.wsSession.getPrincipal()).willReturn(this.principal); given(this.wsSession.getId()).willReturn("wsSession-id"); given(this.wsSession2.getAttributes()).willReturn(this.attributes); given(this.wsSession2.getPrincipal()).willReturn(this.principal); given(this.wsSession2.getId()).willReturn("wsSession-id2"); Map<String, Object> headers = new HashMap<>(); headers.put(SimpMessageHeaderAccessor.SESSION_ATTRIBUTES, this.attributes); given(this.message.getHeaders()).willReturn(new MessageHeaders(headers)); this.listener = new WebSocketRegistryListener(); this.connect = new SessionConnectEvent(this.listener, this.wsSession); this.connect2 = new SessionConnectEvent(this.listener, this.wsSession2); this.disconnect = new SessionDisconnectEvent(this.listener, this.message, this.wsSession.getId(), CloseStatus.NORMAL); this.deleted = new SessionDeletedEvent(this.listener, session); this.expired = new SessionExpiredEvent(this.listener, session); }
protected void emitSessionExpiredEvent(String sessionId) { logger.debugf("Emitting session expired %s", sessionId); springEventsPublisher.ifPresent(p -> p.publishEvent(new SessionExpiredEvent(eventSource, sessionId))); }
/** * Constructs a new {@link SessionExpiredEvent} initialized with the given {@link Session}, * using the {@link #getSessionRepository() SessionRepository} as the event source. * * @param session {@link Session} that is the subject of the {@link AbstractSessionEvent event}. * @return a new {@link SessionExpiredEvent}. * @see org.springframework.session.events.SessionExpiredEvent * @see org.springframework.session.Session * @see #getSessionRepository() */ protected SessionExpiredEvent newSessionExpiredEvent(Session session) { return new SessionExpiredEvent(getSessionRepository(), session); }
@Override public void entryEvicted(EntryEvent<String, MapSession> event) { if (logger.isDebugEnabled()) { logger.debug("Session expired with id: " + event.getOldValue().getId()); } this.eventPublisher .publishEvent(new SessionExpiredEvent(this, event.getOldValue())); }
session.clearPrincipal(); publishEvent(new SessionExpiredEvent(this, session));
@Override public MongoSession findById(String id) { Document sessionWrapper = findSession(id); if (sessionWrapper == null) { return null; } MongoSession session = convertToSession(this.mongoSessionConverter, sessionWrapper); if (session.isExpired()) { publishEvent(new SessionExpiredEvent(this, session)); deleteById(id); return null; } return session; }