Package org.keycloak.models
Interface UserSessionProvider
- 
- All Superinterfaces:
- Provider
 - All Known Implementing Classes:
- InfinispanUserSessionProvider,- MapUserSessionProvider
 
 public interface UserSessionProvider extends Provider - Version:
- $Revision: 1 $
- Author:
- Bill Burke
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidclose()AuthenticatedClientSessionModelcreateClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession)AuthenticatedClientSessionModelcreateOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession)Will automatically attach newly created offline client session to the offlineUserSessionUserSessionModelcreateOfflineUserSession(UserSessionModel userSession)Newly created userSession won't contain attached AuthenticatedClientSessionsUserSessionModelcreateUserSession(String id, RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId, UserSessionModel.SessionPersistenceState persistenceState)UserSessionModelcreateUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId)Map<String,Long>getActiveClientSessionStats(RealmModel realm, boolean offline)Returns a summary of client sessions key is client.getId()longgetActiveUserSessions(RealmModel realm, ClientModel client)AuthenticatedClientSessionModelgetClientSession(UserSessionModel userSession, ClientModel client, String clientSessionId, boolean offline)default AuthenticatedClientSessionModelgetClientSession(UserSessionModel userSession, ClientModel client, UUID clientSessionId, boolean offline)Deprecated.KeycloakSessiongetKeycloakSession()Returns currently used Keycloak session.longgetOfflineSessionsCount(RealmModel realm, ClientModel client)UserSessionModelgetOfflineUserSession(RealmModel realm, String userSessionId)UserSessionModelgetOfflineUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)Stream<UserSessionModel>getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)Obtains the offline user sessions associated with the user that matches the specifiedbrokerUserId.Stream<UserSessionModel>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.Stream<UserSessionModel>getOfflineUserSessionsStream(RealmModel realm, UserModel user)Obtains the offline user sessions associated with the specified user.intgetStartupTime(RealmModel realm)UserSessionModelgetUserSession(RealmModel realm, String id)UserSessionModelgetUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)Stream<UserSessionModel>getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)Obtains the online user sessions associated with the user that matches the specifiedbrokerUserId.Stream<UserSessionModel>getUserSessionsStream(RealmModel realm, ClientModel client)Obtains the online user sessions associated with the specified client.Stream<UserSessionModel>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.Stream<UserSessionModel>getUserSessionsStream(RealmModel realm, UserModel user)Obtains the online user sessions associated with the specified user.UserSessionModelgetUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate)Return userSession of specified ID as long as the predicate passes.voidimportUserSessions(Collection<UserSessionModel> persistentUserSessions, boolean offline)Triggered by persister during pre-load.voidonClientRemoved(RealmModel realm, ClientModel client)voidonRealmRemoved(RealmModel realm)voidremoveAllExpired()Remove 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 session)This will remove attached ClientLoginSessionModels toovoidremoveUserSessions(RealmModel realm)voidremoveUserSessions(RealmModel realm, UserModel user)
 
- 
- 
- 
Method Detail- 
getKeycloakSessionKeycloakSession getKeycloakSession() Returns currently used Keycloak session.- Returns:
- KeycloakSession
 
 - 
createClientSessionAuthenticatedClientSessionModel createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession) 
 - 
getClientSessiondefault AuthenticatedClientSessionModel getClientSession(UserSessionModel userSession, ClientModel client, UUID clientSessionId, boolean offline) Deprecated.
 - 
getClientSessionAuthenticatedClientSessionModel getClientSession(UserSessionModel userSession, ClientModel client, String clientSessionId, boolean offline) 
 - 
createUserSessionUserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId) 
 - 
createUserSessionUserSessionModel createUserSession(String id, RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId, UserSessionModel.SessionPersistenceState persistenceState) 
 - 
getUserSessionUserSessionModel getUserSession(RealmModel realm, String id) 
 - 
getUserSessionsStreamStream<UserSessionModel> getUserSessionsStream(RealmModel realm, UserModel user) Obtains the online user sessions associated with the specified user.- Parameters:
- realm- a reference to the realm.
- user- the user whose sessions are being searched.
- Returns:
- a non-null Streamof online user sessions.
 
 - 
getUserSessionsStreamStream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client) Obtains the online user sessions associated with the specified client.- Parameters:
- realm- a reference to the realm.
- client- the client whose user sessions are being searched.
- Returns:
- a non-null Streamof online user sessions.
 
 - 
getUserSessionsStreamStream<UserSessionModel> 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.- Parameters:
- realm- a reference tot he realm.
- client- the client whose user sessions are being searched.
- firstResult- first result to return. Ignored if negative or- null.
- maxResults- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a non-null Streamof online user sessions.
 
 - 
getUserSessionByBrokerUserIdStreamStream<UserSessionModel> getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) Obtains the online user sessions associated with the user that matches the specifiedbrokerUserId.- 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.
 
 - 
getUserSessionByBrokerSessionIdUserSessionModel getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId) 
 - 
getUserSessionWithPredicateUserSessionModel getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate) Return 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 have predicate passing (eg. download userSession from other DC)
 - 
getActiveUserSessionslong getActiveUserSessions(RealmModel realm, ClientModel client) 
 - 
getActiveClientSessionStatsMap<String,Long> getActiveClientSessionStats(RealmModel realm, boolean offline) Returns a summary of client sessions key is client.getId()- Parameters:
- realm-
- offline-
- Returns:
 
 - 
removeUserSessionvoid removeUserSession(RealmModel realm, UserSessionModel session) This will remove attached ClientLoginSessionModels too
 - 
removeUserSessionsvoid removeUserSessions(RealmModel realm, UserModel user) 
 - 
removeAllExpiredvoid removeAllExpired() Remove expired user sessions and client sessions in all the realms
 - 
removeExpiredvoid removeExpired(RealmModel realm) Removes 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`.- Parameters:
- realm-- RealmModelRealm where all the expired user sessions to be removed from.
 
 - 
removeUserSessionsvoid removeUserSessions(RealmModel realm) 
 - 
onRealmRemovedvoid onRealmRemoved(RealmModel realm) 
 - 
onClientRemovedvoid onClientRemoved(RealmModel realm, ClientModel client) 
 - 
createOfflineUserSessionUserSessionModel createOfflineUserSession(UserSessionModel userSession) Newly created userSession won't contain attached AuthenticatedClientSessions
 - 
getOfflineUserSessionUserSessionModel getOfflineUserSession(RealmModel realm, String userSessionId) 
 - 
removeOfflineUserSessionvoid removeOfflineUserSession(RealmModel realm, UserSessionModel userSession) Removes the attached clientSessions as well
 - 
createOfflineClientSessionAuthenticatedClientSessionModel createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession) Will automatically attach newly created offline client session to the offlineUserSession
 - 
getOfflineUserSessionsStreamStream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, UserModel user) Obtains the offline user sessions associated with the specified user.- Parameters:
- realm- a reference to the realm.
- user- the user whose offline sessions are being searched.
- Returns:
- a non-null Streamof offline user sessions.
 
 - 
getOfflineUserSessionByBrokerSessionIdUserSessionModel getOfflineUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId) 
 - 
getOfflineUserSessionByBrokerUserIdStreamStream<UserSessionModel> getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId) Obtains the offline user sessions associated with the user that matches the specifiedbrokerUserId.- 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.
 
 - 
getOfflineSessionsCountlong getOfflineSessionsCount(RealmModel realm, ClientModel client) 
 - 
getOfflineUserSessionsStreamStream<UserSessionModel> 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.- Parameters:
- realm- a reference tot he realm.
- client- the client whose user sessions are being searched.
- firstResult- first result to return. Ignored if negative or- null.
- maxResults- maximum number of results to return. Ignored if negative or- null.
- Returns:
- a non-null Streamof offline user sessions.
 
 - 
importUserSessionsvoid importUserSessions(Collection<UserSessionModel> persistentUserSessions, boolean offline) Triggered by persister during pre-load. It imports authenticatedClientSessions too
 - 
getStartupTimeint getStartupTime(RealmModel realm) 
 
- 
 
-