protected void removeUserSessions(RealmModel realm, UserModel user, boolean offline) { Cache<String, SessionEntity> cache = getCache(offline); Iterator<String> itr = cache.entrySet().stream().filter(UserSessionPredicate.create(realm.getId()).user(user.getId())).map(Mappers.sessionId()).iterator(); while (itr.hasNext()) { removeUserSession(realm, itr.next(), offline); } }
@Override public List<ClientSessionModel> getOfflineClientSessions(RealmModel realm, UserModel user) { Iterator<Map.Entry<String, SessionEntity>> itr = offlineSessionCache.entrySet().stream().filter(UserSessionPredicate.create(realm.getId()).user(user.getId())).iterator(); List<ClientSessionModel> clientSessions = new LinkedList<>(); while(itr.hasNext()) { UserSessionEntity entity = (UserSessionEntity) itr.next().getValue(); Set<String> currClientSessions = entity.getClientSessions(); for (String clientSessionId : currClientSessions) { ClientSessionEntity cls = (ClientSessionEntity) offlineSessionCache.get(clientSessionId); if (cls != null) { clientSessions.add(wrap(realm, cls, true)); } } } return clientSessions; }
@Override public List<UserSessionModel> getUserSessions(final RealmModel realm, UserModel user) { return getUserSessions(realm, UserSessionPredicate.create(realm.getId()).user(user.getId()), false); }
@Override public List<UserSessionModel> getUserSessions(final RealmModel realm, UserModel user) { return getUserSessions(realm, UserSessionPredicate.create(realm.getId()).user(user.getId()), false); }
@Override public List<UserSessionModel> getOfflineUserSessions(RealmModel realm, UserModel user) { List<UserSessionModel> userSessions = new LinkedList<>(); Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = CacheDecorators.skipCacheLoaders(offlineSessionCache); Iterator<UserSessionEntity> itr = cache.entrySet().stream() .filter(UserSessionPredicate.create(realm.getId()).user(user.getId())) .map(Mappers.userSessionEntity()) .iterator(); while (itr.hasNext()) { UserSessionEntity userSessionEntity = itr.next(); UserSessionModel userSession = wrap(realm, userSessionEntity, true); userSessions.add(userSession); } return userSessions; }
protected void removeUserSessions(RealmModel realm, UserModel user, boolean offline) { Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = getCache(offline); cache = CacheDecorators.skipCacheLoaders(cache); Iterator<UserSessionEntity> itr = cache.entrySet().stream().filter(UserSessionPredicate.create(realm.getId()).user(user.getId())).map(Mappers.userSessionEntity()).iterator(); while (itr.hasNext()) { UserSessionEntity userSessionEntity = itr.next(); removeUserSession(userSessionEntity, offline); } }
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; } }