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
-
-
Constructor Summary
Constructors Constructor Description DisabledUserSessionPersisterProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
This is called when the server shuts down.UserSessionPersisterProvider
create(KeycloakSession session)
void
createClientSession(AuthenticatedClientSessionModel clientSession, boolean offline)
void
createUserSession(UserSessionModel userSession, boolean offline)
String
getId()
int
getUserSessionsCount(boolean offline)
Retrieves the count of user sessions for all realms.int
getUserSessionsCount(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 aMap
containing the number of user-sessions aggregated by client id for the given realm.void
init(Config.Scope config)
Only called once when the factory is first created.UserSessionModel
loadUserSession(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 givenClientModel
in the givenRealmModel
if present.Stream<UserSessionModel>
loadUserSessionsStream(RealmModel realm, UserModel user, boolean offline, Integer firstResult, Integer maxResults)
Loads the user sessions for the givenUserModel
in the givenRealmModel
if present.void
onClientRemoved(RealmModel realm, ClientModel client)
void
onRealmRemoved(RealmModel realm)
void
onUserRemoved(RealmModel realm, UserModel user)
void
postInit(KeycloakSessionFactory factory)
Called after all provider factories have been initializedvoid
removeClientSession(String userSessionId, String clientUUID, boolean offline)
void
removeExpired(RealmModel realm)
void
removeUserSession(String userSessionId, boolean offline)
void
updateLastSessionRefreshes(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, wait
-
Methods inherited from interface org.keycloak.provider.ProviderFactory
getConfigMetadata, order
-
Methods inherited from interface org.keycloak.models.session.UserSessionPersisterProvider
loadUserSessions
-
-
-
-
Field Detail
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public UserSessionPersisterProvider create(KeycloakSession session)
- Specified by:
create
in interfaceProviderFactory<UserSessionPersisterProvider>
-
init
public void init(Config.Scope config)
Description copied from interface:ProviderFactory
Only called once when the factory is first created. This config is pulled from keycloak_server.json- Specified by:
init
in interfaceProviderFactory<UserSessionPersisterProvider>
-
postInit
public void postInit(KeycloakSessionFactory factory)
Description copied from interface:ProviderFactory
Called after all provider factories have been initialized- Specified by:
postInit
in interfaceProviderFactory<UserSessionPersisterProvider>
-
close
public void close()
Description copied from interface:ProviderFactory
This is called when the server shuts down.- Specified by:
close
in interfaceProvider
- Specified by:
close
in interfaceProviderFactory<UserSessionPersisterProvider>
-
getId
public String getId()
- Specified by:
getId
in interfaceProviderFactory<UserSessionPersisterProvider>
-
createUserSession
public void createUserSession(UserSessionModel userSession, boolean offline)
- Specified by:
createUserSession
in interfaceUserSessionPersisterProvider
-
createClientSession
public void createClientSession(AuthenticatedClientSessionModel clientSession, boolean offline)
- Specified by:
createClientSession
in interfaceUserSessionPersisterProvider
-
removeUserSession
public void removeUserSession(String userSessionId, boolean offline)
- Specified by:
removeUserSession
in interfaceUserSessionPersisterProvider
-
removeClientSession
public void removeClientSession(String userSessionId, String clientUUID, boolean offline)
- Specified by:
removeClientSession
in interfaceUserSessionPersisterProvider
-
onRealmRemoved
public void onRealmRemoved(RealmModel realm)
- Specified by:
onRealmRemoved
in interfaceUserSessionPersisterProvider
-
onClientRemoved
public void onClientRemoved(RealmModel realm, ClientModel client)
- Specified by:
onClientRemoved
in interfaceUserSessionPersisterProvider
-
onUserRemoved
public void onUserRemoved(RealmModel realm, UserModel user)
- Specified by:
onUserRemoved
in interfaceUserSessionPersisterProvider
-
updateLastSessionRefreshes
public void updateLastSessionRefreshes(RealmModel realm, int lastSessionRefresh, Collection<String> userSessionIds, boolean offline)
- Specified by:
updateLastSessionRefreshes
in interfaceUserSessionPersisterProvider
-
removeExpired
public void removeExpired(RealmModel realm)
- Specified by:
removeExpired
in interfaceUserSessionPersisterProvider
-
loadUserSession
public UserSessionModel loadUserSession(RealmModel realm, String userSessionId, boolean offline)
Description copied from interface:UserSessionPersisterProvider
Loads the user session with the given userSessionId.- Specified by:
loadUserSession
in interfaceUserSessionPersisterProvider
- Returns:
-
loadUserSessionsStream
public Stream<UserSessionModel> loadUserSessionsStream(RealmModel realm, ClientModel client, boolean offline, Integer firstResult, Integer maxResults)
Description copied from interface:UserSessionPersisterProvider
Loads the user sessions for the givenClientModel
in the givenRealmModel
if present.- Specified by:
loadUserSessionsStream
in interfaceUserSessionPersisterProvider
- Returns:
-
loadUserSessionsStream
public Stream<UserSessionModel> loadUserSessionsStream(RealmModel realm, UserModel user, boolean offline, Integer firstResult, Integer maxResults)
Description copied from interface:UserSessionPersisterProvider
Loads the user sessions for the givenUserModel
in the givenRealmModel
if present.- Specified by:
loadUserSessionsStream
in interfaceUserSessionPersisterProvider
- Returns:
-
loadUserSessionsStream
public Stream<UserSessionModel> loadUserSessionsStream(Integer firstResult, Integer maxResults, boolean offline, String lastUserSessionId)
Description copied from interface:UserSessionPersisterProvider
Called during startup. For each userSession, it loads also clientSessions.- Specified by:
loadUserSessionsStream
in interfaceUserSessionPersisterProvider
- Parameters:
firstResult
-Integer
Index of the first desired user session. Ignored if negative ornull
.maxResults
-Integer
Maximum number of returned user sessions. Ignored if negative ornull
.offline
-boolean
Flag to include offline sessions.lastUserSessionId
-String
Id 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
.
-
getUserSessionsCount
public int getUserSessionsCount(boolean offline)
Description copied from interface:UserSessionPersisterProvider
Retrieves the count of user sessions for all realms.- Specified by:
getUserSessionsCount
in interfaceUserSessionPersisterProvider
- Returns:
-
getUserSessionsCount
public int getUserSessionsCount(RealmModel realm, ClientModel clientModel, boolean offline)
Description copied from interface:UserSessionPersisterProvider
Retrieves the count of user client-sessions for the given client- Specified by:
getUserSessionsCount
in interfaceUserSessionPersisterProvider
- Returns:
-
getUserSessionsCountsByClients
public Map<String,Long> getUserSessionsCountsByClients(RealmModel realm, boolean offline)
Description copied from interface:UserSessionPersisterProvider
Returns aMap
containing the number of user-sessions aggregated by client id for the given realm.- Specified by:
getUserSessionsCountsByClients
in interfaceUserSessionPersisterProvider
- Returns:
- the count
Map
with clientId as key and session count as value
-
-