Package org.keycloak.models.session
Class DisabledUserSessionPersisterProvider
java.lang.Object
org.keycloak.models.session.DisabledUserSessionPersisterProvider
- All Implemented Interfaces:
UserSessionPersisterProvider,UserSessionPersisterProviderFactory,org.keycloak.provider.Provider,org.keycloak.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()create(org.keycloak.models.KeycloakSession session) voidcreateClientSession(org.keycloak.models.AuthenticatedClientSessionModel clientSession, boolean offline) voidcreateUserSession(org.keycloak.models.UserSessionModel userSession, boolean offline) getId()intgetUserSessionsCount(boolean offline) Retrieves the count of user sessions for all realms.intgetUserSessionsCount(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel clientModel, boolean offline) Retrieves the count of user client-sessions for the given clientgetUserSessionsCountsByClients(org.keycloak.models.RealmModel realm, boolean offline) Returns aMapcontaining the number of user-sessions aggregated by client id for the given realm.voidinit(org.keycloak.Config.Scope config) org.keycloak.models.AuthenticatedClientSessionModelloadClientSession(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client, org.keycloak.models.UserSessionModel userSession, boolean offline) Loads client session from the db by provided user session and client.org.keycloak.models.UserSessionModelloadUserSession(org.keycloak.models.RealmModel realm, String userSessionId, boolean offline) Loads the user session with the given userSessionId.Stream<org.keycloak.models.UserSessionModel>loadUserSessionsStream(Integer firstResult, Integer maxResults, boolean offline, String lastUserSessionId) Called during startup.Stream<org.keycloak.models.UserSessionModel>loadUserSessionsStream(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client, boolean offline, Integer firstResult, Integer maxResults) Loads the user sessions for the givenClientModelin the givenRealmModelif present.Stream<org.keycloak.models.UserSessionModel>loadUserSessionsStream(org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, boolean offline, Integer firstResult, Integer maxResults) Loads the user sessions for the givenUserModelin the givenRealmModelif present.voidonClientRemoved(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client) voidonRealmRemoved(org.keycloak.models.RealmModel realm) voidonUserRemoved(org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user) voidpostInit(org.keycloak.models.KeycloakSessionFactory factory) Stream<org.keycloak.models.UserSessionModel>readOnlyUserSessionStream(org.keycloak.models.RealmModel realm, boolean offline) Stream all the sessions belonging to the realm.Stream<org.keycloak.models.UserSessionModel>readOnlyUserSessionStream(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client, boolean offline, int skip, int maxResults) Stream all the sessions belonging to the realm and having a client session from the client.voidremoveClientSession(String userSessionId, String clientUUID, boolean offline) voidremoveExpired(org.keycloak.models.RealmModel realm) voidremoveUserSession(String userSessionId, boolean offline) voidupdateLastSessionRefreshes(org.keycloak.models.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
findUserSessionsByUserId, loadUserSessionsStreamByBrokerSessionId, lockClientSession, lockUserSession, removeUserSessions, removeUserSessions
-
Field Details
-
ID
- See Also:
-
-
Constructor Details
-
DisabledUserSessionPersisterProvider
public DisabledUserSessionPersisterProvider()
-
-
Method Details
-
create
- Specified by:
createin interfaceorg.keycloak.provider.ProviderFactory<UserSessionPersisterProvider>
-
init
public void init(org.keycloak.Config.Scope config) - Specified by:
initin interfaceorg.keycloak.provider.ProviderFactory<UserSessionPersisterProvider>
-
postInit
public void postInit(org.keycloak.models.KeycloakSessionFactory factory) - Specified by:
postInitin interfaceorg.keycloak.provider.ProviderFactory<UserSessionPersisterProvider>
-
close
public void close()- Specified by:
closein interfaceorg.keycloak.provider.Provider- Specified by:
closein interfaceorg.keycloak.provider.ProviderFactory<UserSessionPersisterProvider>
-
getId
- Specified by:
getIdin interfaceorg.keycloak.provider.ProviderFactory<UserSessionPersisterProvider>
-
createUserSession
public void createUserSession(org.keycloak.models.UserSessionModel userSession, boolean offline) - Specified by:
createUserSessionin interfaceUserSessionPersisterProvider
-
createClientSession
public void createClientSession(org.keycloak.models.AuthenticatedClientSessionModel clientSession, boolean offline) - Specified by:
createClientSessionin interfaceUserSessionPersisterProvider
-
removeUserSession
- Specified by:
removeUserSessionin interfaceUserSessionPersisterProvider
-
removeClientSession
- Specified by:
removeClientSessionin interfaceUserSessionPersisterProvider
-
onRealmRemoved
public void onRealmRemoved(org.keycloak.models.RealmModel realm) - Specified by:
onRealmRemovedin interfaceUserSessionPersisterProvider
-
onClientRemoved
public void onClientRemoved(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client) - Specified by:
onClientRemovedin interfaceUserSessionPersisterProvider
-
onUserRemoved
public void onUserRemoved(org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user) - Specified by:
onUserRemovedin interfaceUserSessionPersisterProvider
-
updateLastSessionRefreshes
public void updateLastSessionRefreshes(org.keycloak.models.RealmModel realm, int lastSessionRefresh, Collection<String> userSessionIds, boolean offline) - Specified by:
updateLastSessionRefreshesin interfaceUserSessionPersisterProvider
-
removeExpired
public void removeExpired(org.keycloak.models.RealmModel realm) - Specified by:
removeExpiredin interfaceUserSessionPersisterProvider
-
loadUserSession
public org.keycloak.models.UserSessionModel loadUserSession(org.keycloak.models.RealmModel realm, String userSessionId, boolean offline) Description copied from interface:UserSessionPersisterProviderLoads the user session with the given userSessionId.- Specified by:
loadUserSessionin interfaceUserSessionPersisterProvider- Returns:
-
loadUserSessionsStream
public Stream<org.keycloak.models.UserSessionModel> loadUserSessionsStream(org.keycloak.models.RealmModel realm, org.keycloak.models.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<org.keycloak.models.UserSessionModel> loadUserSessionsStream(org.keycloak.models.RealmModel realm, org.keycloak.models.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<org.keycloak.models.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 org.keycloak.models.AuthenticatedClientSessionModel loadClientSession(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client, org.keycloak.models.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
public int getUserSessionsCount(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel clientModel, boolean offline) Description copied from interface:UserSessionPersisterProviderRetrieves the count of user client-sessions for the given client- Specified by:
getUserSessionsCountin interfaceUserSessionPersisterProvider- Returns:
-
getUserSessionsCountsByClients
public Map<String,Long> getUserSessionsCountsByClients(org.keycloak.models.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 interfaceUserSessionPersisterProvider- Returns:
- the count
Mapwith clientId as key and session count as value
-
readOnlyUserSessionStream
public Stream<org.keycloak.models.UserSessionModel> readOnlyUserSessionStream(org.keycloak.models.RealmModel realm, boolean offline) Description copied from interface:UserSessionPersisterProviderStream all the sessions belonging to the realm.The returned
UserSessionModelinstances are immutable. More precisely, the entity is not tracked by the JPA and any modification may throw anUnsupportedOperationException.- Specified by:
readOnlyUserSessionStreamin interfaceUserSessionPersisterProvider- Parameters:
realm- TheRealmModelinstance.offline- Iftrue, it streams the offline sessions, otherwise the regular sessions.- Returns:
- A
Streamfor all the sessions in the realm.
-
readOnlyUserSessionStream
public Stream<org.keycloak.models.UserSessionModel> readOnlyUserSessionStream(org.keycloak.models.RealmModel realm, org.keycloak.models.ClientModel client, boolean offline, int skip, int maxResults) Description copied from interface:UserSessionPersisterProviderStream all the sessions belonging to the realm and having a client session from the client.The returned
UserSessionModelinstances are immutable. More precisely, the entity is not tracked by the JPA and any modification may throw anUnsupportedOperationException.The
skipandmaxResultsparameters control how many sessions should be streamed. A negative value for either parameter is ignored (no skip/limit applied). IfmaxResultsis zero, an empty stream is returned.- Specified by:
readOnlyUserSessionStreamin interfaceUserSessionPersisterProvider- Parameters:
realm- TheRealmModelinstance.client- TheClientModelinstance.offline- Iftrue, it streams the offline sessions, otherwise the regular sessions.skip- The number of leading elements to skip.maxResults- The number of elements the stream should be limited to.- Returns:
- A
Streamfor all the sessions matching the parameters.
-