public class MapUserSessionProvider extends Object implements UserSessionProvider
| Modifier and Type | Field and Description |
|---|---|
protected MapKeycloakTransaction<MapAuthenticatedClientSessionEntity,AuthenticatedClientSessionModel> |
clientSessionTx |
protected MapKeycloakTransaction<MapUserSessionEntity,UserSessionModel> |
userSessionTx |
| Constructor and Description |
|---|
MapUserSessionProvider(KeycloakSession session,
MapStorage<MapUserSessionEntity,UserSessionModel> userSessionStore,
MapStorage<MapAuthenticatedClientSessionEntity,AuthenticatedClientSessionModel> clientSessionStore) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
AuthenticatedClientSessionModel |
createClientSession(RealmModel realm,
ClientModel client,
UserSessionModel userSession) |
AuthenticatedClientSessionModel |
createOfflineClientSession(AuthenticatedClientSessionModel clientSession,
UserSessionModel offlineUserSession)
Will automatically attach newly created offline client session to the offlineUserSession
|
UserSessionModel |
createOfflineUserSession(UserSessionModel userSession)
Newly created userSession won't contain attached AuthenticatedClientSessions
|
UserSessionModel |
createUserSession(RealmModel realm,
UserModel user,
String loginUsername,
String ipAddress,
String authMethod,
boolean rememberMe,
String brokerSessionId,
String brokerUserId) |
UserSessionModel |
createUserSession(String id,
RealmModel realm,
UserModel user,
String loginUsername,
String ipAddress,
String authMethod,
boolean rememberMe,
String brokerSessionId,
String brokerUserId,
UserSessionModel.SessionPersistenceState persistenceState) |
Map<String,Long> |
getActiveClientSessionStats(RealmModel realm,
boolean offline)
Returns a summary of client sessions key is client.getId()
|
long |
getActiveUserSessions(RealmModel realm,
ClientModel client) |
AuthenticatedClientSessionModel |
getClientSession(UserSessionModel userSession,
ClientModel client,
String clientSessionId,
boolean offline) |
KeycloakSession |
getKeycloakSession()
Returns currently used Keycloak session.
|
long |
getOfflineSessionsCount(RealmModel realm,
ClientModel client) |
UserSessionModel |
getOfflineUserSession(RealmModel realm,
String userSessionId) |
UserSessionModel |
getOfflineUserSessionByBrokerSessionId(RealmModel realm,
String brokerSessionId) |
Stream<UserSessionModel> |
getOfflineUserSessionByBrokerUserIdStream(RealmModel realm,
String brokerUserId)
Obtains the offline user sessions associated with the user that matches the specified
brokerUserId. |
Stream<UserSessionModel> |
getOfflineUserSessionsStream(RealmModel realm,
ClientModel client,
Integer firstResult,
Integer maxResults)
Obtains the offline user sessions associated with the specified client, starting from the
firstResult and
containing at most maxResults. |
Stream<UserSessionModel> |
getOfflineUserSessionsStream(RealmModel realm,
UserModel user)
Obtains the offline user sessions associated with the specified user.
|
UserSessionModel |
getUserSession(RealmModel realm,
String id) |
UserSessionModel |
getUserSessionByBrokerSessionId(RealmModel realm,
String brokerSessionId) |
Stream<UserSessionModel> |
getUserSessionByBrokerUserIdStream(RealmModel realm,
String brokerUserId)
Obtains the online user sessions associated with the user that matches the specified
brokerUserId. |
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 the
firstResult and containing
at most maxResults. |
Stream<UserSessionModel> |
getUserSessionsStream(RealmModel realm,
UserModel user)
Obtains the online user sessions associated with the specified user.
|
UserSessionModel |
getUserSessionWithPredicate(RealmModel realm,
String id,
boolean offline,
Predicate<UserSessionModel> predicate)
Return userSession of specified ID as long as the predicate passes.
|
void |
importUserSessions(Collection<UserSessionModel> persistentUserSessions,
boolean offline)
Triggered by persister during pre-load.
|
void |
onClientRemoved(RealmModel realm,
ClientModel client) |
void |
onRealmRemoved(RealmModel realm) |
void |
removeAllExpired()
Remove expired user sessions and client sessions in all the realms
|
void |
removeExpired(RealmModel realm)
Removes expired user sessions owned by this realm from this provider.
|
void |
removeOfflineUserSession(RealmModel realm,
UserSessionModel userSession)
Removes the attached clientSessions as well
|
void |
removeUserSession(RealmModel realm,
UserSessionModel session)
This will remove attached ClientLoginSessionModels too
|
void |
removeUserSessions(RealmModel realm) |
void |
removeUserSessions(RealmModel realm,
UserModel user) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddUserLoginFailure, getClientSession, getOfflineUserSessionByBrokerUserId, getOfflineUserSessions, getOfflineUserSessions, getUserLoginFailure, getUserSessionByBrokerUserId, getUserSessions, getUserSessions, getUserSessions, removeAllUserLoginFailures, removeUserLoginFailureprotected final MapKeycloakTransaction<MapUserSessionEntity,UserSessionModel> userSessionTx
protected final MapKeycloakTransaction<MapAuthenticatedClientSessionEntity,AuthenticatedClientSessionModel> clientSessionTx
public MapUserSessionProvider(KeycloakSession session, MapStorage<MapUserSessionEntity,UserSessionModel> userSessionStore, MapStorage<MapAuthenticatedClientSessionEntity,AuthenticatedClientSessionModel> clientSessionStore)
public KeycloakSession getKeycloakSession()
UserSessionProvidergetKeycloakSession in interface UserSessionProviderKeycloakSessionpublic AuthenticatedClientSessionModel createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession)
createClientSession in interface UserSessionProviderpublic AuthenticatedClientSessionModel getClientSession(UserSessionModel userSession, ClientModel client, String clientSessionId, boolean offline)
getClientSession in interface UserSessionProviderpublic UserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId)
createUserSession in interface UserSessionProviderpublic UserSessionModel createUserSession(String id, RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId, UserSessionModel.SessionPersistenceState persistenceState)
createUserSession in interface UserSessionProviderpublic UserSessionModel getUserSession(RealmModel realm, String id)
getUserSession in interface UserSessionProviderpublic Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, UserModel user)
UserSessionProvidergetUserSessionsStream in interface UserSessionProviderrealm - a reference to the realm.user - the user whose sessions are being searched.Stream of online user sessions.public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client)
UserSessionProvidergetUserSessionsStream in interface UserSessionProviderrealm - a reference to the realm.client - the client whose user sessions are being searched.Stream of online user sessions.public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults)
UserSessionProviderfirstResult and containing
at most maxResults.getUserSessionsStream in interface UserSessionProviderrealm - 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.Stream of online user sessions.public Stream<UserSessionModel> getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)
UserSessionProviderbrokerUserId.getUserSessionByBrokerUserIdStream in interface UserSessionProviderrealm - a reference to the realm.brokerUserId - the id of the broker user whose sessions are being searched.Stream of online user sessions.public UserSessionModel getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)
getUserSessionByBrokerSessionId in interface UserSessionProviderpublic UserSessionModel getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate)
UserSessionProvidernull.
If predicate doesn't pass, implementation can do some best-effort actions to try have predicate passing (eg. download userSession from other DC)getUserSessionWithPredicate in interface UserSessionProviderpublic long getActiveUserSessions(RealmModel realm, ClientModel client)
getActiveUserSessions in interface UserSessionProviderpublic Map<String,Long> getActiveClientSessionStats(RealmModel realm, boolean offline)
UserSessionProvidergetActiveClientSessionStats in interface UserSessionProviderpublic void removeUserSession(RealmModel realm, UserSessionModel session)
UserSessionProviderremoveUserSession in interface UserSessionProviderpublic void removeUserSessions(RealmModel realm, UserModel user)
removeUserSessions in interface UserSessionProviderpublic void removeAllExpired()
UserSessionProviderremoveAllExpired in interface UserSessionProviderpublic void removeExpired(RealmModel realm)
UserSessionProvideruser sessions is also propagated to relevant `UserSessionPersister`.removeExpired in interface UserSessionProviderrealm - RealmModel Realm where all the expired user sessions to be removed from.public void removeUserSessions(RealmModel realm)
removeUserSessions in interface UserSessionProviderpublic void onRealmRemoved(RealmModel realm)
onRealmRemoved in interface UserSessionProviderpublic void onClientRemoved(RealmModel realm, ClientModel client)
onClientRemoved in interface UserSessionProviderpublic UserSessionModel createOfflineUserSession(UserSessionModel userSession)
UserSessionProvidercreateOfflineUserSession in interface UserSessionProviderpublic UserSessionModel getOfflineUserSession(RealmModel realm, String userSessionId)
getOfflineUserSession in interface UserSessionProviderpublic void removeOfflineUserSession(RealmModel realm, UserSessionModel userSession)
UserSessionProviderremoveOfflineUserSession in interface UserSessionProviderpublic AuthenticatedClientSessionModel createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession)
UserSessionProvidercreateOfflineClientSession in interface UserSessionProviderpublic Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, UserModel user)
UserSessionProvidergetOfflineUserSessionsStream in interface UserSessionProviderrealm - a reference to the realm.user - the user whose offline sessions are being searched.Stream of offline user sessions.public UserSessionModel getOfflineUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)
getOfflineUserSessionByBrokerSessionId in interface UserSessionProviderpublic Stream<UserSessionModel> getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)
UserSessionProviderbrokerUserId.getOfflineUserSessionByBrokerUserIdStream in interface UserSessionProviderrealm - a reference to the realm.brokerUserId - the id of the broker user whose sessions are being searched.Stream of offline user sessions.public long getOfflineSessionsCount(RealmModel realm, ClientModel client)
getOfflineSessionsCount in interface UserSessionProviderpublic Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults)
UserSessionProviderfirstResult and
containing at most maxResults.getOfflineUserSessionsStream in interface UserSessionProviderrealm - 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.Stream of offline user sessions.public void importUserSessions(Collection<UserSessionModel> persistentUserSessions, boolean offline)
UserSessionProviderimportUserSessions in interface UserSessionProviderpublic void close()
close in interface UserSessionProviderclose in interface ProviderCopyright © 2021 JBoss by Red Hat. All rights reserved.