Class RemoteUserSessionProvider
java.lang.Object
org.keycloak.models.sessions.infinispan.remote.RemoteUserSessionProvider
- All Implemented Interfaces:
UserSessionProvider,Provider
An
UserSessionProvider implementation that uses only RemoteCache as storage.-
Constructor Summary
ConstructorsConstructorDescriptionRemoteUserSessionProvider(KeycloakSession session, UserSessionTransaction transaction, int batchSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession) createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession) Will automatically attach newly created offline client session to the offlineUserSessioncreateOfflineUserSession(UserSessionModel userSession) Newly created userSession won't contain attached AuthenticatedClientSessionscreateUserSession(String id, RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId, UserSessionModel.SessionPersistenceState persistenceState) Creates a new user session with the given parameters.getActiveClientSessionStats(RealmModel realm, boolean offline) Returns a summary of client sessions key is client.getId()longgetActiveUserSessions(RealmModel realm, ClientModel client) getClientSession(UserSessionModel userSession, ClientModel client, boolean offline) Gets the authenticated client session for a given user session and client.Returns currently used Keycloak session.longgetOfflineSessionsCount(RealmModel realm, ClientModel client) getOfflineUserSession(RealmModel realm, String userSessionId) getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) Obtains the offline user sessions associated with the user that matches the specifiedbrokerUserId.getOfflineUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults) Obtains the offline user sessions associated with the specified client, starting from thefirstResultand containing at mostmaxResults.getOfflineUserSessionsStream(RealmModel realm, UserModel user) Obtains the offline user sessions associated with the specified user.intgetStartupTime(RealmModel realm) getUserSession(RealmModel realm, String id) getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId) getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) Obtains the online user sessions associated with the user that matches the specifiedbrokerUserId.getUserSessionsStream(RealmModel realm, ClientModel client) Obtains the online user sessions associated with the specified client.getUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults) Obtains the online user sessions associated with the specified client, starting from thefirstResultand containing at mostmaxResults.getUserSessionsStream(RealmModel realm, UserModel user) Obtains the online user sessions associated with the specified user.getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate) Return userSession of specified ID as long as the predicate passes.voidvoidonClientRemoved(RealmModel realm, ClientModel client) Callback method invoked when a client is removed.voidonRealmRemoved(RealmModel realm) Callback method invoked when a realm is removed.voidRemove expired user sessions and client sessions in all the realmsvoidremoveExpired(RealmModel realm) Removes expired user sessions owned by this realm from this provider.voidremoveOfflineUserSession(RealmModel realm, UserSessionModel userSession) Removes the attached clientSessions as wellvoidremoveUserSession(RealmModel realm, UserSessionModel userSession) This will remove attached ClientLoginSessionModels toovoidremoveUserSessions(RealmModel realm) Removes all user sessions (regular and offline) from the specified realm.voidremoveUserSessions(RealmModel realm, UserModel user) 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, importUserSessions
-
Constructor Details
-
RemoteUserSessionProvider
public RemoteUserSessionProvider(KeycloakSession session, UserSessionTransaction transaction, int batchSize)
-
-
Method Details
-
createClientSession
public AuthenticatedClientSessionModel createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession) - Specified by:
createClientSessionin interfaceUserSessionProvider
-
getClientSession
public AuthenticatedClientSessionModel getClientSession(UserSessionModel userSession, ClientModel client, boolean offline) Description copied from interface:UserSessionProviderGets the authenticated client session for a given user session and client.- Specified by:
getClientSessionin interfaceUserSessionProvider- Parameters:
userSession- The user's session model.client- The client model.offline- Iftrue, retrieves the offline session; otherwise, retrieves the online session.- Returns:
- The authenticated client session, or
nullif it doesn't exist.
-
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) Description copied from interface:UserSessionProviderCreates a new user session with the given parameters.- Specified by:
createUserSessionin interfaceUserSessionProvider- Parameters:
id- identifier. Is generated ifnullrealm- the realmuser- user associated with the created user session- Returns:
- Model of the created user session
-
getUserSession
- Specified by:
getUserSessionin interfaceUserSessionProvider
-
getUserSessionsStream
Description copied from interface:UserSessionProviderObtains the online user sessions associated with the specified user.- Specified by:
getUserSessionsStreamin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm.user- the user whose sessions are being searched.- Returns:
- a non-null
Streamof online user sessions.
-
getUserSessionsStream
Description copied from interface:UserSessionProviderObtains the online user sessions associated with the specified client.- Specified by:
getUserSessionsStreamin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm.client- the client whose user sessions are being searched.- Returns:
- a non-null
Streamof online user sessions.
-
getUserSessionsStream
public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults) Description copied from interface:UserSessionProviderObtains the online user sessions associated with the specified client, starting from thefirstResultand containing at mostmaxResults.- Specified by:
getUserSessionsStreamin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm.client- the client whose user sessions are being searched.firstResult- first result to return. Ignored if negative ornull.maxResults- maximum number of results to return. Ignored if negative ornull.- Returns:
- a non-null
Streamof online user sessions.
-
getUserSessionByBrokerUserIdStream
public Stream<UserSessionModel> getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) Description copied from interface:UserSessionProviderObtains the online user sessions associated with the user that matches the specifiedbrokerUserId.- Specified by:
getUserSessionByBrokerUserIdStreamin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm.brokerUserId- the id of the broker user whose sessions are being searched.- Returns:
- a non-null
Streamof online user sessions.
-
getUserSessionByBrokerSessionId
- Specified by:
getUserSessionByBrokerSessionIdin interfaceUserSessionProvider
-
getUserSessionWithPredicate
public UserSessionModel getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate) Description copied from interface:UserSessionProviderReturn userSession of specified ID as long as the predicate passes. Otherwise, returnsnull. If predicate doesn't pass, implementation can do some best-effort actions to try to have predicate passing (e.g. download userSession from other DC)- Specified by:
getUserSessionWithPredicatein interfaceUserSessionProvider
-
getActiveUserSessions
- Specified by:
getActiveUserSessionsin interfaceUserSessionProvider
-
getActiveClientSessionStats
Description copied from interface:UserSessionProviderReturns a summary of client sessions key is client.getId()- Specified by:
getActiveClientSessionStatsin interfaceUserSessionProvider- Returns:
-
removeUserSession
Description copied from interface:UserSessionProviderThis will remove attached ClientLoginSessionModels too- Specified by:
removeUserSessionin interfaceUserSessionProvider
-
removeUserSessions
- Specified by:
removeUserSessionsin interfaceUserSessionProvider
-
removeAllExpired
public void removeAllExpired()Description copied from interface:UserSessionProviderRemove expired user sessions and client sessions in all the realms- Specified by:
removeAllExpiredin interfaceUserSessionProvider
-
removeExpired
Description copied from interface:UserSessionProviderRemoves expired user sessions owned by this realm from this provider. If this `UserSessionProvider` uses `UserSessionPersister`, the removal of the expireduser sessionsis also propagated to relevant `UserSessionPersister`.- Specified by:
removeExpiredin interfaceUserSessionProvider- Parameters:
realm-RealmModelRealm where all the expired user sessions to be removed from.
-
removeUserSessions
Description copied from interface:UserSessionProviderRemoves all user sessions (regular and offline) from the specified realm.- Specified by:
removeUserSessionsin interfaceUserSessionProvider- Parameters:
realm- the realm whose sessions are to be removed.
-
onRealmRemoved
Description copied from interface:UserSessionProviderCallback method invoked when a realm is removed. Implementations should clear any sessions associated with the removed realm.- Specified by:
onRealmRemovedin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm being removed.
-
onClientRemoved
Description copied from interface:UserSessionProviderCallback method invoked when a client is removed. Implementations should clear any sessions associated with the removed client.- Specified by:
onClientRemovedin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm.client- a reference to the client being removed.
-
createOfflineUserSession
Description copied from interface:UserSessionProviderNewly created userSession won't contain attached AuthenticatedClientSessions- Specified by:
createOfflineUserSessionin interfaceUserSessionProvider
-
getOfflineUserSession
- Specified by:
getOfflineUserSessionin interfaceUserSessionProvider
-
removeOfflineUserSession
Description copied from interface:UserSessionProviderRemoves the attached clientSessions as well- Specified by:
removeOfflineUserSessionin interfaceUserSessionProvider
-
createOfflineClientSession
public AuthenticatedClientSessionModel createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession) Description copied from interface:UserSessionProviderWill automatically attach newly created offline client session to the offlineUserSession- Specified by:
createOfflineClientSessionin interfaceUserSessionProvider
-
getOfflineUserSessionsStream
Description copied from interface:UserSessionProviderObtains the offline user sessions associated with the specified user.- Specified by:
getOfflineUserSessionsStreamin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm.user- the user whose offline sessions are being searched.- Returns:
- a non-null
Streamof offline user sessions.
-
getOfflineUserSessionByBrokerUserIdStream
public Stream<UserSessionModel> getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) Description copied from interface:UserSessionProviderObtains the offline user sessions associated with the user that matches the specifiedbrokerUserId.- Specified by:
getOfflineUserSessionByBrokerUserIdStreamin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm.brokerUserId- the id of the broker user whose sessions are being searched.- Returns:
- a non-null
Streamof offline user sessions.
-
getOfflineSessionsCount
- Specified by:
getOfflineSessionsCountin interfaceUserSessionProvider
-
getOfflineUserSessionsStream
public Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults) Description copied from interface:UserSessionProviderObtains the offline user sessions associated with the specified client, starting from thefirstResultand containing at mostmaxResults.- Specified by:
getOfflineUserSessionsStreamin interfaceUserSessionProvider- Parameters:
realm- a reference to the realm.client- the client whose user sessions are being searched.firstResult- first result to return. Ignored if negative ornull.maxResults- maximum number of results to return. Ignored if negative ornull.- Returns:
- a non-null
Streamof offline user sessions.
-
getStartupTime
- Specified by:
getStartupTimein interfaceUserSessionProvider
-
getKeycloakSession
Description copied from interface:UserSessionProviderReturns currently used Keycloak session.- Specified by:
getKeycloakSessionin interfaceUserSessionProvider- Returns:
KeycloakSession
-
close
public void close()- Specified by:
closein interfaceProvider- Specified by:
closein interfaceUserSessionProvider
-
migrate
- Specified by:
migratein interfaceUserSessionProvider
-