Class InfinispanUserSessionProvider
java.lang.Object
org.keycloak.models.sessions.infinispan.InfinispanUserSessionProvider
- All Implemented Interfaces:
ClientSessionManager,SessionRefreshStore,UserSessionProvider,Provider
public class InfinispanUserSessionProvider
extends Object
implements UserSessionProvider, SessionRefreshStore, ClientSessionManager
- Author:
- Stian Thorgersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey,AuthenticatedClientSessionEntity> protected final SessionEventsSenderTransactionprotected final InfinispanKeyGeneratorprotected final SessionFunction<AuthenticatedClientSessionEntity>protected final InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey,AuthenticatedClientSessionEntity> protected final SessionFunction<UserSessionEntity>protected final InfinispanChangelogBasedTransaction<String,UserSessionEntity> protected final PersisterLastSessionRefreshStoreprotected final KeycloakSessionprotected final InfinispanChangelogBasedTransaction<String,UserSessionEntity> -
Constructor Summary
ConstructorsConstructorDescriptionInfinispanUserSessionProvider(KeycloakSession session, PersisterLastSessionRefreshStore persisterLastSessionRefreshStore, InfinispanKeyGenerator keyGenerator, InfinispanChangelogBasedTransaction<String, UserSessionEntity> sessionTx, InfinispanChangelogBasedTransaction<String, UserSessionEntity> offlineSessionTx, InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey, AuthenticatedClientSessionEntity> clientSessionTx, InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey, AuthenticatedClientSessionEntity> offlineClientSessionTx, SessionFunction<UserSessionEntity> offlineSessionCacheEntryLifespanAdjuster, SessionFunction<AuthenticatedClientSessionEntity> offlineClientSessionCacheEntryLifespanAdjuster) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChange(EmbeddedClientSessionKey key, PersistentSessionUpdateTask<AuthenticatedClientSessionEntity> task) Adds a update task to the changelog for a specific client session.voidclose()createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession) createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession) createOfflineUserSession(UserSessionModel userSession) createUserSession(String id, RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId, UserSessionModel.SessionPersistenceState persistenceState) getActiveClientSessionStats(RealmModel realm, boolean offline) longgetActiveUserSessions(RealmModel realm, ClientModel client) protected org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> getCache(boolean offline) getClientSession(UserSessionModel userSession, ClientModel client, boolean offline) protected org.infinispan.Cache<EmbeddedClientSessionKey,SessionEntityWrapper<AuthenticatedClientSessionEntity>> getClientSessionCache(boolean offline) protected InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey,AuthenticatedClientSessionEntity> getClientSessionTransaction(boolean offline) longgetOfflineSessionsCount(RealmModel realm, ClientModel client) getOfflineUserSession(RealmModel realm, String userSessionId) getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) getOfflineUserSessionsStream(RealmModel realm, ClientModel client, Integer first, Integer max) getOfflineUserSessionsStream(RealmModel realm, UserModel user) intgetStartupTime(RealmModel realm) getTransaction(boolean offline) getUserSession(RealmModel realm, String id) protected UserSessionAdapter<InfinispanUserSessionProvider>getUserSession(RealmModel realm, String id, boolean offline) getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId) getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) protected longgetUserSessionsCount(RealmModel realm, ClientModel client, boolean offline) getUserSessionsStream(RealmModel realm, ClientModel client) getUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults) protected Stream<UserSessionModel>getUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults, boolean offline) protected Stream<UserSessionModel>getUserSessionsStream(RealmModel realm, UserSessionPredicate predicate, boolean offline) getUserSessionsStream(RealmModel realm, UserModel user) getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate) protected UserSessionAdapter<InfinispanUserSessionProvider>importUserSession(UserSessionModel userSession) voidimportUserSessions(Collection<UserSessionModel> persistentUserSessions, boolean offline) Deprecated, for removal: This API element is subject to removal in a future version.voidvoidonClientRemoved(RealmModel realm, ClientModel client) voidonRealmRemoved(RealmModel realm) protected voidonRealmRemovedEvent(String realmId) protected voidonRemoveUserSessionsEvent(String realmId) protected voidonUserRemoved(RealmModel realm, UserModel user) voidvoidremoveExpired(RealmModel realm) voidremoveLocalUserSessions(String realmId, boolean offline) voidremoveOfflineUserSession(RealmModel realm, UserSessionModel userSession) voidremoveUserSession(RealmModel realm, UserSessionModel session) protected voidremoveUserSession(UserSessionEntity sessionEntity, boolean offline) voidremoveUserSessions(RealmModel realm) voidremoveUserSessions(RealmModel realm, UserModel user) protected voidremoveUserSessions(RealmModel realm, UserModel user, boolean offline) voidrestartEntity(EmbeddedClientSessionKey key, PersistentSessionUpdateTask<AuthenticatedClientSessionEntity> task) Resets and replaces the state of the persistedAuthenticatedClientSessionEntityfor the given session.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.models.UserSessionProvider
createUserSession, getClientSession, getClientSession, getUserSessionIfClientExists
-
Field Details
-
session
-
sessionTx
-
offlineSessionTx
-
clientSessionTx
protected final InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey,AuthenticatedClientSessionEntity> clientSessionTx -
offlineClientSessionTx
protected final InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey,AuthenticatedClientSessionEntity> offlineClientSessionTx -
clusterEventsSenderTx
-
persisterLastSessionRefreshStore
-
keyGenerator
-
offlineSessionCacheEntryLifespanAdjuster
-
offlineClientSessionCacheEntryLifespanAdjuster
protected final SessionFunction<AuthenticatedClientSessionEntity> offlineClientSessionCacheEntryLifespanAdjuster
-
-
Constructor Details
-
InfinispanUserSessionProvider
public InfinispanUserSessionProvider(KeycloakSession session, PersisterLastSessionRefreshStore persisterLastSessionRefreshStore, InfinispanKeyGenerator keyGenerator, InfinispanChangelogBasedTransaction<String, UserSessionEntity> sessionTx, InfinispanChangelogBasedTransaction<String, UserSessionEntity> offlineSessionTx, InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey, AuthenticatedClientSessionEntity> clientSessionTx, InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey, AuthenticatedClientSessionEntity> offlineClientSessionTx, SessionFunction<UserSessionEntity> offlineSessionCacheEntryLifespanAdjuster, SessionFunction<AuthenticatedClientSessionEntity> offlineClientSessionCacheEntryLifespanAdjuster)
-
-
Method Details
-
getCache
protected org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> getCache(boolean offline) -
getTransaction
protected InfinispanChangelogBasedTransaction<String,UserSessionEntity> getTransaction(boolean offline) -
getClientSessionCache
protected org.infinispan.Cache<EmbeddedClientSessionKey,SessionEntityWrapper<AuthenticatedClientSessionEntity>> getClientSessionCache(boolean offline) -
getClientSessionTransaction
protected InfinispanChangelogBasedTransaction<EmbeddedClientSessionKey,AuthenticatedClientSessionEntity> getClientSessionTransaction(boolean offline) -
getPersisterLastSessionRefreshStore
- Specified by:
getPersisterLastSessionRefreshStorein interfaceSessionRefreshStore
-
getKeycloakSession
- Specified by:
getKeycloakSessionin interfaceUserSessionProvider
-
createClientSession
public AuthenticatedClientSessionModel createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession) - Specified by:
createClientSessionin 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
- Specified by:
getUserSessionin interfaceUserSessionProvider
-
migrate
- Specified by:
migratein interfaceUserSessionProvider
-
getUserSession
protected UserSessionAdapter<InfinispanUserSessionProvider> 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, boolean offline) - Specified by:
getClientSessionin interfaceUserSessionProvider
-
getUserSessionsStream
- Specified by:
getUserSessionsStreamin interfaceUserSessionProvider
-
getUserSessionByBrokerUserIdStream
public Stream<UserSessionModel> getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) - Specified by:
getUserSessionByBrokerUserIdStreamin interfaceUserSessionProvider
-
getUserSessionByBrokerSessionId
- Specified by:
getUserSessionByBrokerSessionIdin interfaceUserSessionProvider
-
getUserSessionsStream
- 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) -
getUserSessionWithPredicate
public UserSessionModel getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate) - Specified by:
getUserSessionWithPredicatein interfaceUserSessionProvider
-
getActiveUserSessions
- Specified by:
getActiveUserSessionsin interfaceUserSessionProvider
-
getActiveClientSessionStats
- Specified by:
getActiveClientSessionStatsin interfaceUserSessionProvider
-
getUserSessionsCount
-
removeUserSession
- Specified by:
removeUserSessionin interfaceUserSessionProvider
-
removeUserSessions
- Specified by:
removeUserSessionsin interfaceUserSessionProvider
-
removeUserSessions
-
removeAllExpired
public void removeAllExpired()- Specified by:
removeAllExpiredin interfaceUserSessionProvider
-
removeExpired
- Specified by:
removeExpiredin interfaceUserSessionProvider
-
removeUserSessions
- Specified by:
removeUserSessionsin interfaceUserSessionProvider
-
onRemoveUserSessionsEvent
-
removeLocalUserSessions
-
onRealmRemoved
- Specified by:
onRealmRemovedin interfaceUserSessionProvider
-
onRealmRemovedEvent
-
onClientRemoved
- Specified by:
onClientRemovedin interfaceUserSessionProvider
-
onUserRemoved
-
close
public void close()- Specified by:
closein interfaceProvider- Specified by:
closein interfaceUserSessionProvider
-
getStartupTime
- Specified by:
getStartupTimein interfaceUserSessionProvider
-
removeUserSession
-
createOfflineUserSession
- Specified by:
createOfflineUserSessionin interfaceUserSessionProvider
-
getOfflineUserSession
public UserSessionAdapter<InfinispanUserSessionProvider> getOfflineUserSession(RealmModel realm, String userSessionId) - Specified by:
getOfflineUserSessionin interfaceUserSessionProvider
-
getOfflineUserSessionByBrokerUserIdStream
public Stream<UserSessionModel> getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) - Specified by:
getOfflineUserSessionByBrokerUserIdStreamin interfaceUserSessionProvider
-
removeOfflineUserSession
- Specified by:
removeOfflineUserSessionin interfaceUserSessionProvider
-
createOfflineClientSession
public AuthenticatedClientSessionModel createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession) - Specified by:
createOfflineClientSessionin interfaceUserSessionProvider
-
getOfflineUserSessionsStream
- Specified by:
getOfflineUserSessionsStreamin interfaceUserSessionProvider
-
getOfflineSessionsCount
- Specified by:
getOfflineSessionsCountin interfaceUserSessionProvider
-
getOfflineUserSessionsStream
public Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, ClientModel client, Integer first, Integer max) - Specified by:
getOfflineUserSessionsStreamin interfaceUserSessionProvider
-
importUserSessions
@Deprecated(forRemoval=true, since="25.0") public void importUserSessions(Collection<UserSessionModel> persistentUserSessions, boolean offline) Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
importUserSessionsin interfaceUserSessionProvider
-
importUserSession
protected UserSessionAdapter<InfinispanUserSessionProvider> importUserSession(UserSessionModel userSession) -
addChange
public void addChange(EmbeddedClientSessionKey key, PersistentSessionUpdateTask<AuthenticatedClientSessionEntity> task) Description copied from interface:ClientSessionManagerAdds a update task to the changelog for a specific client session.When the transaction commits, this task will apply its changes to the persisted
AuthenticatedClientSessionEntity, effectively updating the correspondingAuthenticatedClientSessionModel. MultipleaddChangecalls for the same session are accumulated (merged).- Specified by:
addChangein interfaceClientSessionManager- Parameters:
key- The identifier for the target client session.task- The operation containing the changes to apply to the persisted entity.
-
restartEntity
public void restartEntity(EmbeddedClientSessionKey key, PersistentSessionUpdateTask<AuthenticatedClientSessionEntity> task) Description copied from interface:ClientSessionManagerResets and replaces the state of the persistedAuthenticatedClientSessionEntityfor the given session.All previously added changes via
addChangefor this session are discarded, and the provided task is executed to set the new state of the client session entity.- Specified by:
restartEntityin interfaceClientSessionManager- Parameters:
key- The identifier for the target client session.task- The operation that must set the complete new state of the persisted entity.
-