public UserSessionPredicate expired(Integer expired, Integer expiredRefresh) { return this.expired(expired, expiredRefresh, null, null); }
private void removeExpiredOfflineUserSessions(RealmModel realm) { UserSessionPersisterProvider persister = session.getProvider(UserSessionPersisterProvider.class); int expiredOffline = Time.currentTime() - realm.getOfflineSessionIdleTimeout(); Iterator<Map.Entry<String, SessionEntity>> itr = offlineSessionCache.entrySet().stream().filter(UserSessionPredicate.create(realm.getId()).expired(null, expiredOffline)).iterator(); while (itr.hasNext()) { UserSessionEntity entity = (UserSessionEntity) itr.next().getValue(); tx.remove(offlineSessionCache, entity.getId()); persister.removeUserSession(entity.getId(), true); for (String clientSessionId : entity.getClientSessions()) { tx.remove(offlineSessionCache, clientSessionId); } } }
private void removeExpiredUserSessions(RealmModel realm) { int expired = Time.currentTime() - realm.getSsoSessionMaxLifespan(); int expiredRefresh = Time.currentTime() - realm.getSsoSessionIdleTimeout(); Iterator<Map.Entry<String, SessionEntity>> itr = sessionCache.entrySet().stream().filter(UserSessionPredicate.create(realm.getId()).expired(expired, expiredRefresh)).iterator(); while (itr.hasNext()) { UserSessionEntity entity = (UserSessionEntity) itr.next().getValue(); tx.remove(sessionCache, entity.getId()); if (entity.getClientSessions() != null) { for (String clientSessionId : entity.getClientSessions()) { tx.remove(sessionCache, clientSessionId); } } } }
public UserSessionPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException { UserSessionPredicate res = new UserSessionPredicate(MarshallUtil.unmarshallString(input)); res.user(MarshallUtil.unmarshallString(input)); res.client(MarshallUtil.unmarshallString(input)); res.expired(KeycloakMarshallUtil.unmarshallInteger(input), KeycloakMarshallUtil.unmarshallInteger(input)); res.brokerSessionId(MarshallUtil.unmarshallString(input)); res.brokerUserId(MarshallUtil.unmarshallString(input)); return res; }
public UserSessionPredicate readObjectVersion2(ObjectInput input) throws IOException, ClassNotFoundException { UserSessionPredicate res = new UserSessionPredicate(MarshallUtil.unmarshallString(input)); res.user(MarshallUtil.unmarshallString(input)); res.client(MarshallUtil.unmarshallString(input)); res.expired(KeycloakMarshallUtil.unmarshallInteger(input), KeycloakMarshallUtil.unmarshallInteger(input), KeycloakMarshallUtil.unmarshallInteger(input), KeycloakMarshallUtil.unmarshallInteger(input)); res.brokerSessionId(MarshallUtil.unmarshallString(input)); res.brokerUserId(MarshallUtil.unmarshallString(input)); return res; } }
UserSessionPredicate predicate = UserSessionPredicate.create(realm.getId()).expired(null, expiredOffline);
.entrySet() .stream() .filter(UserSessionPredicate.create(realm.getId()).expired(expired, expiredRefresh, expiredRememberMe, expiredRefreshRememberMe)) .map(Mappers.userSessionEntity()) .forEach(new Consumer<UserSessionEntity>() {