Search in sources :

Example 1 with InfinispanConnectionProvider

use of org.keycloak.connections.infinispan.InfinispanConnectionProvider in project keycloak by keycloak.

the class InfinispanStickySessionEncoderProvider method getRoute.

private String getRoute(String sessionId) {
    InfinispanConnectionProvider ispnProvider = session.getProvider(InfinispanConnectionProvider.class);
    Cache cache = ispnProvider.getCache(InfinispanConnectionProvider.AUTHENTICATION_SESSIONS_CACHE_NAME);
    return InfinispanUtil.getTopologyInfo(session).getRouteName(cache, sessionId);
}
Also used : InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) Cache(org.infinispan.Cache)

Example 2 with InfinispanConnectionProvider

use of org.keycloak.connections.infinispan.InfinispanConnectionProvider in project keycloak by keycloak.

the class InfinispanClusterProviderFactory method lazyInit.

private void lazyInit(KeycloakSession session) {
    if (workCache == null) {
        synchronized (this) {
            if (workCache == null) {
                InfinispanConnectionProvider ispnConnections = session.getProvider(InfinispanConnectionProvider.class);
                workCache = ispnConnections.getCache(InfinispanConnectionProvider.WORK_CACHE_NAME);
                workCacheListener = new ViewChangeListener();
                workCache.getCacheManager().addListener(workCacheListener);
                // See if we have RemoteStore (external JDG) configured for cross-Data-Center scenario
                Set<RemoteStore> remoteStores = InfinispanUtil.getRemoteStores(workCache);
                crossDCAwareCacheFactory = CrossDCAwareCacheFactory.getFactory(workCache, remoteStores);
                clusterStartupTime = initClusterStartupTime(session);
                TopologyInfo topologyInfo = InfinispanUtil.getTopologyInfo(session);
                String myAddress = topologyInfo.getMyNodeName();
                String mySite = topologyInfo.getMySiteName();
                notificationsManager = InfinispanNotificationsManager.create(session, workCache, myAddress, mySite, remoteStores);
            }
        }
    }
}
Also used : InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) TopologyInfo(org.keycloak.connections.infinispan.TopologyInfo) RemoteStore(org.infinispan.persistence.remote.RemoteStore)

Example 3 with InfinispanConnectionProvider

use of org.keycloak.connections.infinispan.InfinispanConnectionProvider in project keycloak by keycloak.

the class InfinispanUserLoginFailureProviderFactory method checkRemoteCaches.

protected void checkRemoteCaches(KeycloakSession session) {
    InfinispanConnectionProvider ispn = session.getProvider(InfinispanConnectionProvider.class);
    Cache<LoginFailureKey, SessionEntityWrapper<LoginFailureEntity>> loginFailuresCache = ispn.getCache(InfinispanConnectionProvider.LOGIN_FAILURE_CACHE_NAME);
    checkRemoteCache(session, loginFailuresCache, (RealmModel realm) -> Time.toMillis(realm.getMaxDeltaTimeSeconds()), SessionTimeouts::getLoginFailuresLifespanMs, SessionTimeouts::getLoginFailuresMaxIdleMs);
}
Also used : RealmModel(org.keycloak.models.RealmModel) SessionTimeouts(org.keycloak.models.sessions.infinispan.util.SessionTimeouts) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) LoginFailureKey(org.keycloak.models.sessions.infinispan.entities.LoginFailureKey) SessionEntityWrapper(org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)

Example 4 with InfinispanConnectionProvider

use of org.keycloak.connections.infinispan.InfinispanConnectionProvider in project keycloak by keycloak.

the class InfinispanUserLoginFailureProviderFactory method create.

@Override
public UserLoginFailureProvider create(KeycloakSession session) {
    InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class);
    Cache<LoginFailureKey, SessionEntityWrapper<LoginFailureEntity>> loginFailures = connections.getCache(InfinispanConnectionProvider.LOGIN_FAILURE_CACHE_NAME);
    return new InfinispanUserLoginFailureProvider(session, remoteCacheInvoker, loginFailures);
}
Also used : InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) LoginFailureKey(org.keycloak.models.sessions.infinispan.entities.LoginFailureKey) SessionEntityWrapper(org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)

Example 5 with InfinispanConnectionProvider

use of org.keycloak.connections.infinispan.InfinispanConnectionProvider in project keycloak by keycloak.

the class InfinispanUserSessionProviderFactory method create.

@Override
public InfinispanUserSessionProvider create(KeycloakSession session) {
    InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class);
    Cache<String, SessionEntityWrapper<UserSessionEntity>> cache = connections.getCache(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME);
    Cache<String, SessionEntityWrapper<UserSessionEntity>> offlineSessionsCache = connections.getCache(InfinispanConnectionProvider.OFFLINE_USER_SESSION_CACHE_NAME);
    Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache = connections.getCache(InfinispanConnectionProvider.CLIENT_SESSION_CACHE_NAME);
    Cache<UUID, SessionEntityWrapper<AuthenticatedClientSessionEntity>> offlineClientSessionsCache = connections.getCache(InfinispanConnectionProvider.OFFLINE_CLIENT_SESSION_CACHE_NAME);
    return new InfinispanUserSessionProvider(session, remoteCacheInvoker, lastSessionRefreshStore, offlineLastSessionRefreshStore, persisterLastSessionRefreshStore, keyGenerator, cache, offlineSessionsCache, clientSessionCache, offlineClientSessionsCache, !preloadOfflineSessionsFromDatabase);
}
Also used : UUID(java.util.UUID) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) SessionEntityWrapper(org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)

Aggregations

InfinispanConnectionProvider (org.keycloak.connections.infinispan.InfinispanConnectionProvider)16 Cache (org.infinispan.Cache)5 SessionEntityWrapper (org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)5 RemoteCache (org.infinispan.client.hotrod.RemoteCache)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Test (org.junit.Test)3 KeycloakModelTest (org.keycloak.testsuite.model.KeycloakModelTest)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 UUID (java.util.UUID)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 KeycloakSession (org.keycloak.models.KeycloakSession)2 KeycloakSessionTask (org.keycloak.models.KeycloakSessionTask)2 RealmModel (org.keycloak.models.RealmModel)2 UserModel (org.keycloak.models.UserModel)2 LoginFailureKey (org.keycloak.models.sessions.infinispan.entities.LoginFailureKey)2 InfinispanCacheInitializer (org.keycloak.models.sessions.infinispan.initializer.InfinispanCacheInitializer)2 RemoteCacheSessionsLoader (org.keycloak.models.sessions.infinispan.remotestore.RemoteCacheSessionsLoader)2 SessionTimeouts (org.keycloak.models.sessions.infinispan.util.SessionTimeouts)2 RequireProvider (org.keycloak.testsuite.model.RequireProvider)2