public RootAuthenticationSessionPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException { RootAuthenticationSessionPredicate res = new RootAuthenticationSessionPredicate(MarshallUtil.unmarshallString(input)); res.expired(KeycloakMarshallUtil.unmarshallInteger(input)); return res; } }
@Override public void removeExpired(RealmModel realm) { log.debugf("Removing expired sessions"); int expired = Time.currentTime() - RealmInfoUtil.getDettachedClientSessionLifespan(realm); // Each cluster node cleanups just local sessions, which are those owned by himself (+ few more taking l1 cache into account) Iterator<Map.Entry<String, RootAuthenticationSessionEntity>> itr = CacheDecorators.localCache(cache) .entrySet() .stream() .filter(RootAuthenticationSessionPredicate.create(realm.getId()).expired(expired)) .iterator(); int counter = 0; while (itr.hasNext()) { counter++; RootAuthenticationSessionEntity entity = itr.next().getValue(); tx.remove(cache, entity.getId()); } log.debugf("Removed %d expired authentication sessions for realm '%s'", counter, realm.getName()); }
public static RootAuthenticationSessionPredicate create(String realm) { return new RootAuthenticationSessionPredicate(realm); }
protected void onRealmRemovedEvent(String realmId) { Iterator<Map.Entry<String, RootAuthenticationSessionEntity>> itr = CacheDecorators.localCache(cache) .entrySet() .stream() .filter(RootAuthenticationSessionPredicate.create(realmId)) .iterator(); while (itr.hasNext()) { CacheDecorators.localCache(cache) .remove(itr.next().getKey()); } }