Tabnine Logo
Mappers
Code IndexAdd Tabnine to your IDE (free)

How to use
Mappers
in
org.keycloak.models.sessions.infinispan.stream

Best Java code snippets using org.keycloak.models.sessions.infinispan.stream.Mappers (Showing top 16 results out of 315)

origin: org.keycloak/keycloak-model-sessions-infinispan

@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);
  }
}
origin: org.keycloak/keycloak-model-sessions-infinispan

protected long getUserSessionsCount(RealmModel realm, ClientModel client, boolean offline) {
  return getCache(offline).entrySet().stream().filter(ClientSessionPredicate.create(realm.getId()).client(client.getId()).requireUserSession()).map(Mappers.clientSessionToUserSessionId()).distinct().count();
}
origin: org.keycloak/keycloak-model-sessions-infinispan

.map(Mappers.clientSessionToUserSessionTimestamp())
.iterator();
origin: org.keycloak/keycloak-model-infinispan

.stream()
.filter(predicate)
.map(Mappers.userSessionEntity())
.forEach(new Consumer<UserSessionEntity>() {
.stream()
.filter(AuthenticatedClientSessionPredicate.create(realm.getId()).expired(expiredOffline))
.map(Mappers.clientSessionEntity())
.forEach(new Consumer<AuthenticatedClientSessionEntity>() {
origin: org.keycloak/keycloak-model-infinispan

protected List<UserSessionModel> getUserSessions(RealmModel realm, Predicate<Map.Entry<String, SessionEntityWrapper<UserSessionEntity>>> predicate, boolean offline) {
  Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = getCache(offline);
  cache = CacheDecorators.skipCacheLoaders(cache);
  Stream<Map.Entry<String, SessionEntityWrapper<UserSessionEntity>>> cacheStream = cache.entrySet().stream();
  List<UserSessionModel> resultSessions = new LinkedList<>();
  Iterator<UserSessionEntity> itr = cacheStream.filter(predicate)
      .map(Mappers.userSessionEntity())
      .iterator();
  while (itr.hasNext()) {
    UserSessionEntity userSessionEntity = itr.next();
    resultSessions.add(wrap(realm, userSessionEntity, offline));
  }
  return resultSessions;
}
origin: org.keycloak/keycloak-model-sessions-infinispan

protected void removeUserSessions(RealmModel realm, boolean offline) {
  Cache<String, SessionEntity> cache = getCache(offline);
  Iterator<String> itr = cache.entrySet().stream().filter(SessionPredicate.create(realm.getId())).map(Mappers.sessionId()).iterator();
  while (itr.hasNext()) {
    cache.remove(itr.next());
  }
}
origin: org.keycloak/keycloak-model-infinispan

@Override
public Map<String, Long> getActiveClientSessionStats(RealmModel realm, boolean offline) {
  Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = getCache(offline);
  cache = CacheDecorators.skipCacheLoaders(cache);
  return cache.entrySet().stream()
      .filter(UserSessionPredicate.create(realm.getId()))
      .map(Mappers.authClientSessionSetMapper())
      .flatMap((Serializable & Function<Set<String>, Stream<? extends String>>)Mappers::toStream)
      .collect(
          CacheCollectors.serializableCollector(
              () -> Collectors.groupingBy(Function.identity(), Collectors.counting())
          )
      );
}
origin: org.keycloak/keycloak-model-infinispan

.stream()
.filter(UserSessionPredicate.create(realm.getId()).expired(expired, expiredRefresh, expiredRememberMe, expiredRefreshRememberMe))
.map(Mappers.userSessionEntity())
.forEach(new Consumer<UserSessionEntity>() {
.stream()
.filter(AuthenticatedClientSessionPredicate.create(realm.getId()).expired(expired))
.map(Mappers.clientSessionEntity())
.forEach(new Consumer<AuthenticatedClientSessionEntity>() {
origin: org.keycloak/keycloak-model-infinispan

protected List<UserSessionModel> getUserSessionModels(RealmModel realm, int firstResult, int maxResults, boolean offline, UserSessionPredicate predicate) {
  Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = getCache(offline);
  cache = CacheDecorators.skipCacheLoaders(cache);
  Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache = getClientSessionCache(offline);
  Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCacheDecorated = CacheDecorators.skipCacheLoaders(clientSessionCache);
  Stream<UserSessionEntity> stream = cache.entrySet().stream()
      .filter(predicate)
      .map(Mappers.userSessionEntity())
      .sorted(Comparators.userSessionLastSessionRefresh());
  if (firstResult > 0) {
    stream = stream.skip(firstResult);
  }
  if (maxResults > 0) {
    stream = stream.limit(maxResults);
  }
  final List<UserSessionModel> sessions = new LinkedList<>();
  Iterator<UserSessionEntity> itr = stream.iterator();
  while (itr.hasNext()) {
    UserSessionEntity userSessionEntity = itr.next();
    sessions.add(wrap(realm, userSessionEntity, offline));
  }
  return sessions;
}
origin: org.keycloak/keycloak-model-sessions-infinispan

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());
  }
}
origin: org.keycloak/keycloak-model-infinispan

private void removeAllLocalUserLoginFailuresEvent(String realmId) {
  FuturesHelper futures = new FuturesHelper();
  Cache<LoginFailureKey, SessionEntityWrapper<LoginFailureEntity>> localCache = CacheDecorators.localCache(loginFailureCache);
  Cache<LoginFailureKey, SessionEntityWrapper<LoginFailureEntity>> localCacheStoreIgnore = CacheDecorators.skipCacheLoaders(localCache);
  localCacheStoreIgnore
      .entrySet()
      .stream()
      .filter(UserLoginFailurePredicate.create(realmId))
      .map(Mappers.loginFailureId())
      .forEach(loginFailureKey -> {
        // Remove loginFailure from remoteCache too. Use removeAsync for better perf
        Future future = localCache.removeAsync(loginFailureKey);
        futures.addTask(future);
      });
  futures.waitForAllToFinish();
  log.debugf("Removed %d login failures in realm %s", futures.size(), realmId);
}
origin: org.keycloak/keycloak-model-infinispan

@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;
}
origin: org.keycloak/keycloak-model-sessions-infinispan

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);
  }
}
origin: org.keycloak/keycloak-model-infinispan

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);
  }
}
origin: org.keycloak/keycloak-model-sessions-infinispan

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);
  }
}
origin: org.keycloak/keycloak-model-infinispan

private void removeLocalUserSessions(String realmId, boolean offline) {
  FuturesHelper futures = new FuturesHelper();
  Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = getCache(offline);
  Cache<String, SessionEntityWrapper<UserSessionEntity>> localCache = CacheDecorators.localCache(cache);
  Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache = getClientSessionCache(offline);
  Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> localClientSessionCache = CacheDecorators.localCache(clientSessionCache);
  Cache<String, SessionEntityWrapper<UserSessionEntity>> localCacheStoreIgnore = CacheDecorators.skipCacheLoaders(localCache);
  final AtomicInteger userSessionsSize = new AtomicInteger();
  localCacheStoreIgnore
      .entrySet()
      .stream()
      .filter(SessionPredicate.create(realmId))
      .map(Mappers.userSessionEntity())
      .forEach(new Consumer<UserSessionEntity>() {
        @Override
        public void accept(UserSessionEntity userSessionEntity) {
          userSessionsSize.incrementAndGet();
          // Remove session from remoteCache too. Use removeAsync for better perf
          Future future = localCache.removeAsync(userSessionEntity.getId());
          futures.addTask(future);
          userSessionEntity.getAuthenticatedClientSessions().forEach((clientUUID, clientSessionId) -> {
            Future f = localClientSessionCache.removeAsync(clientSessionId);
            futures.addTask(f);
          });
        }
      });
  futures.waitForAllToFinish();
  log.debugf("Removed %d sessions in realm %s. Offline: %b", (Object) userSessionsSize.get(), realmId, offline);
}
org.keycloak.models.sessions.infinispan.streamMappers

Most used methods

  • loginFailureId
  • authClientSessionSetMapper
  • clientSessionEntity
  • clientSessionToUserSessionId
  • clientSessionToUserSessionTimestamp
  • sessionId
  • userSessionEntity

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getSystemService (Context)
  • getSharedPreferences (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now