@Override public void removeAllUserLoginFailures(RealmModel realm) { Iterator<LoginFailureKey> itr = loginFailureCache.entrySet().stream().filter(UserLoginFailurePredicate.create(realm.getId())).map(Mappers.loginFailureId()).iterator(); while (itr.hasNext()) { LoginFailureKey key = itr.next(); tx.remove(loginFailureCache, key); } }
private void removeExpiredClientInitialAccess(RealmModel realm) { Iterator<String> itr = sessionCache.entrySet().stream().filter(ClientInitialAccessPredicate.create(realm.getId()).expired(Time.currentTime())).map(Mappers.sessionId()).iterator(); while (itr.hasNext()) { tx.remove(sessionCache, itr.next()); } }
private void removeExpiredClientSessions(RealmModel realm) { int expiredDettachedClientSession = Time.currentTime() - RealmInfoUtil.getDettachedClientSessionLifespan(realm); Iterator<Map.Entry<String, SessionEntity>> itr = sessionCache.entrySet().stream().filter(ClientSessionPredicate.create(realm.getId()).expiredRefresh(expiredDettachedClientSession).requireNullUserSession()).iterator(); while (itr.hasNext()) { tx.remove(sessionCache, itr.next().getKey()); } }
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); } } } }
private void onClientRemoved(RealmModel realm, ClientModel client, boolean offline) { Cache<String, SessionEntity> cache = getCache(offline); Map<String, ClientSessionEntity> map = new MapReduceTask(cache) .mappedWith(ClientSessionMapper.create(realm.getId()).client(client.getId())) .reducedWith(new FirstResultReducer()) .execute(); for (Map.Entry<String, ClientSessionEntity> entry : map.entrySet()) { // detach from userSession ClientSessionAdapter adapter = wrap(realm, entry.getValue(), offline); adapter.setUserSession(null); tx.remove(cache, entry.getKey()); } }
@Override public void removeClientInitialAccessModel(RealmModel realm, String id) { tx.remove(getCache(false), id); }
@Override public void removeUserLoginFailure(RealmModel realm, String username) { tx.remove(loginFailureCache, new LoginFailureKey(realm.getId(), username)); }
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); } } }
protected void removeClientSession(RealmModel realm, ClientSessionModel clientSession, boolean offline) { Cache<String, SessionEntity> cache = getCache(offline); UserSessionModel userSession = clientSession.getUserSession(); if (userSession != null) { UserSessionEntity entity = ((UserSessionAdapter) userSession).getEntity(); if (entity.getClientSessions() != null) { entity.getClientSessions().remove(clientSession.getId()); } tx.replace(cache, entity.getId(), entity); } tx.remove(cache, clientSession.getId()); }
@Override public void removeUserLoginFailure(RealmModel realm, String username) { LoginFailureKey key = new LoginFailureKey(realm.getId(), username); tx.remove(loginFailureCache, key); }
private void onClientRemoved(RealmModel realm, ClientModel client, boolean offline) { Cache<String, SessionEntity> cache = getCache(offline); Iterator<Map.Entry<String, SessionEntity>> itr = cache.entrySet().stream().filter(ClientSessionPredicate.create(realm.getId()).client(client.getId())).iterator(); while (itr.hasNext()) { ClientSessionEntity entity = (ClientSessionEntity) itr.next().getValue(); ClientSessionAdapter adapter = wrap(realm, entity, offline); adapter.setUserSession(null); tx.remove(cache, entity.getId()); } }
protected void removeClientSession(RealmModel realm, ClientSessionModel clientSession, boolean offline) { Cache<String, SessionEntity> cache = getCache(offline); UserSessionModel userSession = clientSession.getUserSession(); if (userSession != null) { UserSessionEntity entity = ((UserSessionAdapter) userSession).getEntity(); if (entity.getClientSessions() != null) { entity.getClientSessions().remove(clientSession.getId()); } tx.replace(cache, entity.getId(), entity); } tx.remove(cache, clientSession.getId()); }
@Override public void removeAllUserLoginFailures(RealmModel realm) { Map<LoginFailureKey, Object> sessions = new MapReduceTask(loginFailureCache) .mappedWith(UserLoginFailureMapper.create(realm.getId()).emitKey()) .reducedWith(new FirstResultReducer()) .execute(); for (LoginFailureKey id : sessions.keySet()) { tx.remove(loginFailureCache, id); } }
protected void removeUserSession(RealmModel realm, String userSessionId, boolean offline) { Cache<String, SessionEntity> cache = getCache(offline); tx.remove(cache, userSessionId); UserSessionEntity sessionEntity = (UserSessionEntity) cache.get(userSessionId); if (sessionEntity.getClientSessions() != null) { for (String clientSessionId : sessionEntity.getClientSessions()) { tx.remove(cache, clientSessionId); } } }
private void removeExpiredOfflineClientSessions(RealmModel realm) { UserSessionPersisterProvider persister = session.getProvider(UserSessionPersisterProvider.class); int expiredOffline = Time.currentTime() - realm.getOfflineSessionIdleTimeout(); Iterator<String> itr = offlineSessionCache.entrySet().stream().filter(ClientSessionPredicate.create(realm.getId()).expiredRefresh(expiredOffline)).map(Mappers.sessionId()).iterator(); while (itr.hasNext()) { String sessionId = itr.next(); tx.remove(offlineSessionCache, sessionId); persister.removeClientSession(sessionId, true); } }
protected void removeUserSession(RealmModel realm, String userSessionId, boolean offline) { Cache<String, SessionEntity> cache = getCache(offline); tx.remove(cache, userSessionId); // TODO: Isn't more effective to retrieve from userSessionEntity directly? Map<String, String> map = new MapReduceTask(cache) .mappedWith(ClientSessionMapper.create(realm.getId()).userSession(userSessionId).emitKey()) .reducedWith(new FirstResultReducer()) .execute(); for (String id : map.keySet()) { tx.remove(cache, id); } }