Class InfinispanUserSessionProvider
- java.lang.Object
-
- org.keycloak.models.sessions.infinispan.InfinispanUserSessionProvider
-
- All Implemented Interfaces:
UserSessionProvider,Provider
public class InfinispanUserSessionProvider extends Object implements UserSessionProvider
- Author:
- Stian Thorgersen
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description InfinispanUserSessionProvider(KeycloakSession session, RemoteCacheInvoker remoteCacheInvoker, CrossDCLastSessionRefreshStore lastSessionRefreshStore, CrossDCLastSessionRefreshStore offlineLastSessionRefreshStore, PersisterLastSessionRefreshStore persisterLastSessionRefreshStore, InfinispanKeyGenerator keyGenerator, org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> sessionCache, org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> offlineSessionCache, org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache, org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> offlineClientSessionCache, boolean loadOfflineSessionsFromDatabase)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.keycloak.models.UserSessionProvider
addUserLoginFailure, getOfflineUserSessionByBrokerUserId, getOfflineUserSessions, getOfflineUserSessions, getUserLoginFailure, getUserSessionByBrokerUserId, getUserSessions, getUserSessions, getUserSessions, removeAllUserLoginFailures, removeUserLoginFailure
-
-
-
-
Field Detail
-
session
protected final KeycloakSession session
-
sessionCache
protected final org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> sessionCache
-
offlineSessionCache
protected final org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> offlineSessionCache
-
clientSessionCache
protected final org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache
-
offlineClientSessionCache
protected final org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> offlineClientSessionCache
-
sessionTx
protected final InfinispanChangelogBasedTransaction<String,UserSessionEntity> sessionTx
-
offlineSessionTx
protected final InfinispanChangelogBasedTransaction<String,UserSessionEntity> offlineSessionTx
-
clientSessionTx
protected final InfinispanChangelogBasedTransaction<UUID,AuthenticatedClientSessionEntity> clientSessionTx
-
offlineClientSessionTx
protected final InfinispanChangelogBasedTransaction<UUID,AuthenticatedClientSessionEntity> offlineClientSessionTx
-
clusterEventsSenderTx
protected final SessionEventsSenderTransaction clusterEventsSenderTx
-
lastSessionRefreshStore
protected final CrossDCLastSessionRefreshStore lastSessionRefreshStore
-
offlineLastSessionRefreshStore
protected final CrossDCLastSessionRefreshStore offlineLastSessionRefreshStore
-
persisterLastSessionRefreshStore
protected final PersisterLastSessionRefreshStore persisterLastSessionRefreshStore
-
remoteCacheInvoker
protected final RemoteCacheInvoker remoteCacheInvoker
-
keyGenerator
protected final InfinispanKeyGenerator keyGenerator
-
loadOfflineSessionsFromDatabase
protected final boolean loadOfflineSessionsFromDatabase
-
-
Constructor Detail
-
InfinispanUserSessionProvider
public InfinispanUserSessionProvider(KeycloakSession session, RemoteCacheInvoker remoteCacheInvoker, CrossDCLastSessionRefreshStore lastSessionRefreshStore, CrossDCLastSessionRefreshStore offlineLastSessionRefreshStore, PersisterLastSessionRefreshStore persisterLastSessionRefreshStore, InfinispanKeyGenerator keyGenerator, org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> sessionCache, org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> offlineSessionCache, org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache, org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> offlineClientSessionCache, boolean loadOfflineSessionsFromDatabase)
-
-
Method Detail
-
getCache
protected org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> getCache(boolean offline)
-
getTransaction
protected InfinispanChangelogBasedTransaction<String,UserSessionEntity> getTransaction(boolean offline)
-
getClientSessionCache
protected org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> getClientSessionCache(boolean offline)
-
getClientSessionTransaction
protected InfinispanChangelogBasedTransaction<UUID,AuthenticatedClientSessionEntity> getClientSessionTransaction(boolean offline)
-
getLastSessionRefreshStore
protected CrossDCLastSessionRefreshStore getLastSessionRefreshStore()
-
getOfflineLastSessionRefreshStore
protected CrossDCLastSessionRefreshStore getOfflineLastSessionRefreshStore()
-
getPersisterLastSessionRefreshStore
protected PersisterLastSessionRefreshStore getPersisterLastSessionRefreshStore()
-
getKeycloakSession
public KeycloakSession getKeycloakSession()
- Specified by:
getKeycloakSessionin interfaceUserSessionProvider
-
createClientSession
public AuthenticatedClientSessionModel createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession)
- Specified by:
createClientSessionin interfaceUserSessionProvider
-
createUserSession
public UserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId)
- Specified by:
createUserSessionin interfaceUserSessionProvider
-
createUserSession
public UserSessionModel createUserSession(String id, RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId, UserSessionModel.SessionPersistenceState persistenceState)
- Specified by:
createUserSessionin interfaceUserSessionProvider
-
getUserSession
public UserSessionModel getUserSession(RealmModel realm, String id)
- Specified by:
getUserSessionin interfaceUserSessionProvider
-
getUserSession
protected UserSessionAdapter getUserSession(RealmModel realm, String id, boolean offline)
-
getUserSessionsStream
protected Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, UserSessionPredicate predicate, boolean offline)
-
getClientSession
public AuthenticatedClientSessionAdapter getClientSession(UserSessionModel userSession, ClientModel client, String clientSessionId, boolean offline)
- Specified by:
getClientSessionin interfaceUserSessionProvider
-
getClientSession
public AuthenticatedClientSessionAdapter getClientSession(UserSessionModel userSession, ClientModel client, UUID clientSessionId, boolean offline)
- Specified by:
getClientSessionin interfaceUserSessionProvider
-
getUserSessionsStream
public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, UserModel user)
- Specified by:
getUserSessionsStreamin interfaceUserSessionProvider
-
getUserSessionByBrokerUserIdStream
public Stream<UserSessionModel> getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)
- Specified by:
getUserSessionByBrokerUserIdStreamin interfaceUserSessionProvider
-
getUserSessionByBrokerSessionId
public UserSessionModel getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)
- Specified by:
getUserSessionByBrokerSessionIdin interfaceUserSessionProvider
-
getUserSessionsStream
public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client)
- Specified by:
getUserSessionsStreamin interfaceUserSessionProvider
-
getUserSessionsStream
public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults)
- Specified by:
getUserSessionsStreamin interfaceUserSessionProvider
-
getUserSessionsStream
protected Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults, boolean offline)
-
getUserSessionModels
protected Stream<UserSessionModel> getUserSessionModels(RealmModel realm, Integer firstResult, Integer maxResults, boolean offline, UserSessionPredicate predicate)
-
getUserSessionWithPredicate
public UserSessionModel getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate)
- Specified by:
getUserSessionWithPredicatein interfaceUserSessionProvider
-
getActiveUserSessions
public long getActiveUserSessions(RealmModel realm, ClientModel client)
- Specified by:
getActiveUserSessionsin interfaceUserSessionProvider
-
getActiveClientSessionStats
public Map<String,Long> getActiveClientSessionStats(RealmModel realm, boolean offline)
- Specified by:
getActiveClientSessionStatsin interfaceUserSessionProvider
-
getUserSessionsCount
protected long getUserSessionsCount(RealmModel realm, ClientModel client, boolean offline)
-
removeUserSession
public void removeUserSession(RealmModel realm, UserSessionModel session)
- Specified by:
removeUserSessionin interfaceUserSessionProvider
-
removeUserSessions
public void removeUserSessions(RealmModel realm, UserModel user)
- Specified by:
removeUserSessionsin interfaceUserSessionProvider
-
removeUserSessions
protected void removeUserSessions(RealmModel realm, UserModel user, boolean offline)
-
removeAllExpired
public void removeAllExpired()
- Specified by:
removeAllExpiredin interfaceUserSessionProvider
-
removeExpired
public void removeExpired(RealmModel realm)
- Specified by:
removeExpiredin interfaceUserSessionProvider
-
removeUserSessions
public void removeUserSessions(RealmModel realm)
- Specified by:
removeUserSessionsin interfaceUserSessionProvider
-
onRemoveUserSessionsEvent
protected void onRemoveUserSessionsEvent(String realmId)
-
removeLocalUserSessions
public void removeLocalUserSessions(String realmId, boolean offline)
-
onRealmRemoved
public void onRealmRemoved(RealmModel realm)
- Specified by:
onRealmRemovedin interfaceUserSessionProvider
-
onRealmRemovedEvent
protected void onRealmRemovedEvent(String realmId)
-
onClientRemoved
public void onClientRemoved(RealmModel realm, ClientModel client)
- Specified by:
onClientRemovedin interfaceUserSessionProvider
-
onUserRemoved
protected void onUserRemoved(RealmModel realm, UserModel user)
-
close
public void close()
- Specified by:
closein interfaceProvider- Specified by:
closein interfaceUserSessionProvider
-
getStartupTime
public int getStartupTime(RealmModel realm)
- Specified by:
getStartupTimein interfaceUserSessionProvider
-
removeUserSession
protected void removeUserSession(UserSessionEntity sessionEntity, boolean offline)
-
createOfflineUserSession
public UserSessionModel createOfflineUserSession(UserSessionModel userSession)
- Specified by:
createOfflineUserSessionin interfaceUserSessionProvider
-
getOfflineUserSession
public UserSessionAdapter getOfflineUserSession(RealmModel realm, String userSessionId)
- Specified by:
getOfflineUserSessionin interfaceUserSessionProvider
-
getOfflineUserSessionByBrokerSessionId
public UserSessionModel getOfflineUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)
- Specified by:
getOfflineUserSessionByBrokerSessionIdin interfaceUserSessionProvider
-
getOfflineUserSessionByBrokerUserIdStream
public Stream<UserSessionModel> getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)
- Specified by:
getOfflineUserSessionByBrokerUserIdStreamin interfaceUserSessionProvider
-
removeOfflineUserSession
public void removeOfflineUserSession(RealmModel realm, UserSessionModel userSession)
- Specified by:
removeOfflineUserSessionin interfaceUserSessionProvider
-
createOfflineClientSession
public AuthenticatedClientSessionModel createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession)
- Specified by:
createOfflineClientSessionin interfaceUserSessionProvider
-
getOfflineUserSessionsStream
public Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, UserModel user)
- Specified by:
getOfflineUserSessionsStreamin interfaceUserSessionProvider
-
getOfflineSessionsCount
public long getOfflineSessionsCount(RealmModel realm, ClientModel client)
- Specified by:
getOfflineSessionsCountin interfaceUserSessionProvider
-
getOfflineUserSessionsStream
public Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, ClientModel client, Integer first, Integer max)
- Specified by:
getOfflineUserSessionsStreamin interfaceUserSessionProvider
-
importUserSessions
public void importUserSessions(Collection<UserSessionModel> persistentUserSessions, boolean offline)
- Specified by:
importUserSessionsin interfaceUserSessionProvider
-
importUserSession
protected UserSessionAdapter importUserSession(UserSessionModel userSession, boolean offline)
-
-