Package org.keycloak.models.jpa.session
Class JpaUserSessionPersisterProvider
- java.lang.Object
- 
- org.keycloak.models.jpa.session.JpaUserSessionPersisterProvider
 
- 
- All Implemented Interfaces:
- UserSessionPersisterProvider,- Provider
 
 public class JpaUserSessionPersisterProvider extends Object implements UserSessionPersisterProvider - Author:
- Marek Posolda
 
- 
- 
Constructor SummaryConstructors Constructor Description JpaUserSessionPersisterProvider(KeycloakSession session, javax.persistence.EntityManager em)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcreateClientSession(AuthenticatedClientSessionModel clientSession, boolean offline)voidcreateUserSession(UserSessionModel userSession, boolean offline)intgetUserSessionsCount(boolean offline)Retrieves the count of user sessions for all realms.intgetUserSessionsCount(RealmModel realm, ClientModel clientModel, boolean offline)Retrieves the count of user client-sessions for the given clientMap<String,Long>getUserSessionsCountsByClients(RealmModel realm, boolean offline)Returns aMapcontaining the number of user-sessions aggregated by client id for the given realm.AuthenticatedClientSessionModelloadClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession, boolean offline)Loads client session from the db by provided user session and client.UserSessionModelloadUserSession(RealmModel realm, String userSessionId, boolean offline)Loads the user session with the given userSessionId.Stream<UserSessionModel>loadUserSessionsStream(Integer firstResult, Integer maxResults, boolean offline, String lastUserSessionId)Called during startup.Stream<UserSessionModel>loadUserSessionsStream(RealmModel realm, ClientModel client, boolean offline, Integer firstResult, Integer maxResults)Loads the user sessions for the givenClientModelin the givenRealmModelif present.Stream<UserSessionModel>loadUserSessionsStream(RealmModel realm, UserModel user, boolean offline, Integer firstResult, Integer maxResults)Loads the user sessions for the givenUserModelin the givenRealmModelif present.voidonClientRemoved(RealmModel realm, ClientModel client)voidonRealmRemoved(RealmModel realm)voidonUserRemoved(RealmModel realm, UserModel user)voidremoveClientSession(String userSessionId, String clientUUID, boolean offline)voidremoveExpired(RealmModel realm)voidremoveUserSession(String userSessionId, boolean offline)voidupdateLastSessionRefreshes(RealmModel realm, int lastSessionRefresh, Collection<String> userSessionIds, boolean offline)- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.models.session.UserSessionPersisterProviderloadUserSessions
 
- 
 
- 
- 
- 
Constructor Detail- 
JpaUserSessionPersisterProviderpublic JpaUserSessionPersisterProvider(KeycloakSession session, javax.persistence.EntityManager em) 
 
- 
 - 
Method Detail- 
createUserSessionpublic void createUserSession(UserSessionModel userSession, boolean offline) - Specified by:
- createUserSessionin interface- UserSessionPersisterProvider
 
 - 
createClientSessionpublic void createClientSession(AuthenticatedClientSessionModel clientSession, boolean offline) - Specified by:
- createClientSessionin interface- UserSessionPersisterProvider
 
 - 
removeUserSessionpublic void removeUserSession(String userSessionId, boolean offline) - Specified by:
- removeUserSessionin interface- UserSessionPersisterProvider
 
 - 
removeClientSessionpublic void removeClientSession(String userSessionId, String clientUUID, boolean offline) - Specified by:
- removeClientSessionin interface- UserSessionPersisterProvider
 
 - 
onRealmRemovedpublic void onRealmRemoved(RealmModel realm) - Specified by:
- onRealmRemovedin interface- UserSessionPersisterProvider
 
 - 
onClientRemovedpublic void onClientRemoved(RealmModel realm, ClientModel client) - Specified by:
- onClientRemovedin interface- UserSessionPersisterProvider
 
 - 
onUserRemovedpublic void onUserRemoved(RealmModel realm, UserModel user) - Specified by:
- onUserRemovedin interface- UserSessionPersisterProvider
 
 - 
updateLastSessionRefreshespublic void updateLastSessionRefreshes(RealmModel realm, int lastSessionRefresh, Collection<String> userSessionIds, boolean offline) - Specified by:
- updateLastSessionRefreshesin interface- UserSessionPersisterProvider
 
 - 
removeExpiredpublic void removeExpired(RealmModel realm) - Specified by:
- removeExpiredin interface- UserSessionPersisterProvider
 
 - 
getUserSessionsCountsByClientspublic Map<String,Long> getUserSessionsCountsByClients(RealmModel realm, boolean offline) Description copied from interface:UserSessionPersisterProviderReturns aMapcontaining the number of user-sessions aggregated by client id for the given realm.- Specified by:
- getUserSessionsCountsByClientsin interface- UserSessionPersisterProvider
- Returns:
- the count Mapwith clientId as key and session count as value
 
 - 
loadUserSessionpublic UserSessionModel loadUserSession(RealmModel realm, String userSessionId, boolean offline) Description copied from interface:UserSessionPersisterProviderLoads the user session with the given userSessionId.- Specified by:
- loadUserSessionin interface- UserSessionPersisterProvider
- Returns:
 
 - 
loadUserSessionsStreampublic Stream<UserSessionModel> loadUserSessionsStream(RealmModel realm, ClientModel client, boolean offline, Integer firstResult, Integer maxResults) Description copied from interface:UserSessionPersisterProviderLoads the user sessions for the givenClientModelin the givenRealmModelif present.- Specified by:
- loadUserSessionsStreamin interface- UserSessionPersisterProvider
- Returns:
 
 - 
loadUserSessionsStreampublic Stream<UserSessionModel> loadUserSessionsStream(RealmModel realm, UserModel user, boolean offline, Integer firstResult, Integer maxResults) Description copied from interface:UserSessionPersisterProviderLoads the user sessions for the givenUserModelin the givenRealmModelif present.- Specified by:
- loadUserSessionsStreamin interface- UserSessionPersisterProvider
- Returns:
 
 - 
loadUserSessionsStreampublic Stream<UserSessionModel> loadUserSessionsStream(Integer firstResult, Integer maxResults, boolean offline, String lastUserSessionId) Description copied from interface:UserSessionPersisterProviderCalled during startup. For each userSession, it loads also clientSessions.- Specified by:
- loadUserSessionsStreamin interface- UserSessionPersisterProvider
- Parameters:
- firstResult-- IntegerIndex of the first desired user session. Ignored if negative or- null.
- maxResults-- IntegerMaximum number of returned user sessions. Ignored if negative or- null.
- offline-- booleanFlag to include offline sessions.
- lastUserSessionId-- StringId of the user session. It will return only user sessions with id's lexicographically greater than this. it will compare the id in dictionary order and takes only those created later.
- Returns:
- Stream of UserSessionModel. Never returnsnull.
 
 - 
loadClientSessionpublic AuthenticatedClientSessionModel loadClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession, boolean offline) Description copied from interface:UserSessionPersisterProviderLoads client session from the db by provided user session and client.- Specified by:
- loadClientSessionin interface- UserSessionPersisterProvider
- Parameters:
- realm- RealmModel Realm for the associated client session.
- client- ClientModel Client used for the creation of client session.
- userSession- UserSessionModel User session for the associated client session.
- offline- boolean Flag that indicates the client session should be online/offline.
- Returns:
- Client session according the provided criteria or nullif not found.
 
 - 
getUserSessionsCountpublic int getUserSessionsCount(boolean offline) Description copied from interface:UserSessionPersisterProviderRetrieves the count of user sessions for all realms.- Specified by:
- getUserSessionsCountin interface- UserSessionPersisterProvider
- Returns:
 
 - 
getUserSessionsCountpublic int getUserSessionsCount(RealmModel realm, ClientModel clientModel, boolean offline) Description copied from interface:UserSessionPersisterProviderRetrieves the count of user client-sessions for the given client- Specified by:
- getUserSessionsCountin interface- UserSessionPersisterProvider
- Returns:
 
 
- 
 
-