Package org.keycloak.models.session
Class DisabledUserSessionPersisterProvider
java.lang.Object
org.keycloak.models.session.DisabledUserSessionPersisterProvider
- All Implemented Interfaces:
UserSessionPersisterProvider,UserSessionPersisterProviderFactory,Provider,ProviderFactory<UserSessionPersisterProvider>
public class DisabledUserSessionPersisterProvider
extends Object
implements UserSessionPersisterProviderFactory, UserSessionPersisterProvider
Persistence of userSessions is disabled . Useful just if you never need survive of userSessions/clientSessions
among server restart. Offline sessions / offline tokens will be invalid after server restart as well,
- Author:
- Marek Posolda
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This is called when the server shuts down.create(KeycloakSession session) voidcreateClientSession(AuthenticatedClientSessionModel clientSession, boolean offline) voidcreateUserSession(UserSessionModel userSession, boolean offline) getId()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 clientgetUserSessionsCountsByClients(RealmModel realm, boolean offline) Returns aMapcontaining the number of user-sessions aggregated by client id for the given realm.voidinit(Config.Scope config) Only called once when the factory is first created.loadClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession, boolean offline) Loads client session from the db by provided user session and client.loadUserSession(RealmModel realm, String userSessionId, boolean offline) Loads the user session with the given userSessionId.loadUserSessionsStream(Integer firstResult, Integer maxResults, boolean offline, String lastUserSessionId) Called during startup.loadUserSessionsStream(RealmModel realm, ClientModel client, boolean offline, Integer firstResult, Integer maxResults) Loads the user sessions for the givenClientModelin the givenRealmModelif present.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) voidpostInit(KeycloakSessionFactory factory) Called after all provider factories have been initializedvoidremoveClientSession(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.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.provider.ProviderFactory
dependsOn, getConfigMetadata, orderMethods inherited from interface org.keycloak.models.session.UserSessionPersisterProvider
loadUserSessionsStreamByBrokerSessionId, removeUserSessions, removeUserSessions
-
Field Details
-
ID
- See Also:
-
-
Constructor Details
-
DisabledUserSessionPersisterProvider
public DisabledUserSessionPersisterProvider()
-
-
Method Details
-
create
- Specified by:
createin interfaceProviderFactory<UserSessionPersisterProvider>
-
init
Description copied from interface:ProviderFactoryOnly called once when the factory is first created.- Specified by:
initin interfaceProviderFactory<UserSessionPersisterProvider>
-
postInit
Description copied from interface:ProviderFactoryCalled after all provider factories have been initialized- Specified by:
postInitin interfaceProviderFactory<UserSessionPersisterProvider>
-
close
public void close()Description copied from interface:ProviderFactoryThis is called when the server shuts down.- Specified by:
closein interfaceProvider- Specified by:
closein interfaceProviderFactory<UserSessionPersisterProvider>
-
getId
- Specified by:
getIdin interfaceProviderFactory<UserSessionPersisterProvider>
-
createUserSession
- Specified by:
createUserSessionin interfaceUserSessionPersisterProvider
-
createClientSession
- Specified by:
createClientSessionin interfaceUserSessionPersisterProvider
-
removeUserSession
- Specified by:
removeUserSessionin interfaceUserSessionPersisterProvider
-
removeClientSession
- Specified by:
removeClientSessionin interfaceUserSessionPersisterProvider
-
onRealmRemoved
- Specified by:
onRealmRemovedin interfaceUserSessionPersisterProvider
-
onClientRemoved
- Specified by:
onClientRemovedin interfaceUserSessionPersisterProvider
-
onUserRemoved
- Specified by:
onUserRemovedin interfaceUserSessionPersisterProvider
-
updateLastSessionRefreshes
public void updateLastSessionRefreshes(RealmModel realm, int lastSessionRefresh, Collection<String> userSessionIds, boolean offline) - Specified by:
updateLastSessionRefreshesin interfaceUserSessionPersisterProvider
-
removeExpired
- Specified by:
removeExpiredin interfaceUserSessionPersisterProvider
-
loadUserSession
Description copied from interface:UserSessionPersisterProviderLoads the user session with the given userSessionId.- Specified by:
loadUserSessionin interfaceUserSessionPersisterProvider- Returns:
-
loadUserSessionsStream
public 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 interfaceUserSessionPersisterProvider- Returns:
-
loadUserSessionsStream
public 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 interfaceUserSessionPersisterProvider- Returns:
-
loadUserSessionsStream
public 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 interfaceUserSessionPersisterProvider- Parameters:
firstResult-IntegerIndex of the first desired user session. Ignored if negative ornull.maxResults-IntegerMaximum number of returned user sessions. Ignored if negative ornull.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.
-
loadClientSession
public 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 interfaceUserSessionPersisterProvider- 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.
-
getUserSessionsCount
public int getUserSessionsCount(boolean offline) Description copied from interface:UserSessionPersisterProviderRetrieves the count of user sessions for all realms.- Specified by:
getUserSessionsCountin interfaceUserSessionPersisterProvider- Returns:
-
getUserSessionsCount
Description copied from interface:UserSessionPersisterProviderRetrieves the count of user client-sessions for the given client- Specified by:
getUserSessionsCountin interfaceUserSessionPersisterProvider- Returns:
-
getUserSessionsCountsByClients
Description copied from interface:UserSessionPersisterProviderReturns aMapcontaining the number of user-sessions aggregated by client id for the given realm.- Specified by:
getUserSessionsCountsByClientsin interfaceUserSessionPersisterProvider- Returns:
- the count
Mapwith clientId as key and session count as value
-