public class InfinispanUserSessionProvider extends Object implements UserSessionProvider
Constructor and Description |
---|
InfinispanUserSessionProvider(KeycloakSession session,
RemoteCacheInvoker remoteCacheInvoker,
CrossDCLastSessionRefreshStore lastSessionRefreshStore,
CrossDCLastSessionRefreshStore offlineLastSessionRefreshStore,
PersisterLastSessionRefreshStore persisterLastSessionRefreshStore,
InfinispanKeyGenerator keyGenerator,
org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> sessionCache,
org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> offlineSessionCache,
org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache,
org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> offlineClientSessionCache,
org.infinispan.Cache<LoginFailureKey,SessionEntityWrapper<LoginFailureEntity>> loginFailureCache) |
Modifier and Type | Method and Description |
---|---|
UserLoginFailureModel |
addUserLoginFailure(RealmModel realm,
String userId) |
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) |
protected org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> |
getCache(boolean offline) |
AuthenticatedClientSessionAdapter |
getClientSession(UserSessionModel userSession,
ClientModel client,
UUID clientSessionId,
boolean offline) |
protected org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> |
getClientSessionCache(boolean offline) |
protected InfinispanChangelogBasedTransaction<UUID,AuthenticatedClientSessionEntity> |
getClientSessionTransaction(boolean offline) |
protected CrossDCLastSessionRefreshStore |
getLastSessionRefreshStore() |
protected CrossDCLastSessionRefreshStore |
getOfflineLastSessionRefreshStore() |
long |
getOfflineSessionsCount(RealmModel realm,
ClientModel client) |
UserSessionAdapter |
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,
int first,
int max)
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.
|
protected PersisterLastSessionRefreshStore |
getPersisterLastSessionRefreshStore() |
protected InfinispanChangelogBasedTransaction<String,UserSessionEntity> |
getTransaction(boolean offline) |
UserLoginFailureModel |
getUserLoginFailure(RealmModel realm,
String userId) |
UserSessionModel |
getUserSession(RealmModel realm,
String id) |
protected UserSessionAdapter |
getUserSession(RealmModel realm,
String id,
boolean offline) |
UserSessionModel |
getUserSessionByBrokerSessionId(RealmModel realm,
String brokerSessionId) |
Stream<UserSessionModel> |
getUserSessionByBrokerUserIdStream(RealmModel realm,
String brokerUserId)
Obtains the user sessions associated with the user that matches the specified
brokerUserId . |
protected Stream<UserSessionModel> |
getUserSessionModels(RealmModel realm,
int firstResult,
int maxResults,
boolean offline,
UserSessionPredicate predicate) |
protected long |
getUserSessionsCount(RealmModel realm,
ClientModel client,
boolean offline) |
Stream<UserSessionModel> |
getUserSessionsStream(RealmModel realm,
ClientModel client)
Obtains the user sessions associated with the specified client.
|
Stream<UserSessionModel> |
getUserSessionsStream(RealmModel realm,
ClientModel client,
int firstResult,
int maxResults)
Obtains the user sessions associated with the specified client, starting from the
firstResult and containing
at most maxResults . |
protected Stream<UserSessionModel> |
getUserSessionsStream(RealmModel realm,
ClientModel client,
int firstResult,
int maxResults,
boolean offline) |
protected Stream<UserSessionModel> |
getUserSessionsStream(RealmModel realm,
Predicate<Map.Entry<String,SessionEntityWrapper<UserSessionEntity>>> predicate,
boolean offline) |
Stream<UserSessionModel> |
getUserSessionsStream(RealmModel realm,
UserModel user)
Obtains the 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.
|
protected UserSessionAdapter |
importUserSession(UserSessionModel userSession,
boolean offline) |
void |
importUserSessions(Collection<UserSessionModel> persistentUserSessions,
boolean offline)
Triggered by persister during pre-load.
|
void |
onClientRemoved(RealmModel realm,
ClientModel client) |
protected void |
onClientRemovedEvent(String realmId,
String clientUuid) |
void |
onRealmRemoved(RealmModel realm) |
protected void |
onRealmRemovedEvent(String realmId) |
protected void |
onRemoveAllUserLoginFailuresEvent(String realmId) |
protected void |
onRemoveUserSessionsEvent(String realmId) |
protected void |
onUserRemoved(RealmModel realm,
UserModel user) |
void |
removeAllUserLoginFailures(RealmModel realm) |
void |
removeExpired(RealmModel realm)
Implementation doesn't need to propagate removal of expired userSessions to userSessionPersister.
|
void |
removeOfflineUserSession(RealmModel realm,
UserSessionModel userSession)
Removes the attached clientSessions as well
|
void |
removeUserLoginFailure(RealmModel realm,
String userId) |
void |
removeUserSession(RealmModel realm,
UserSessionModel session)
This will remove attached ClientLoginSessionModels too
|
protected void |
removeUserSession(UserSessionEntity sessionEntity,
boolean offline) |
void |
removeUserSessions(RealmModel realm) |
void |
removeUserSessions(RealmModel realm,
UserModel user) |
protected void |
removeUserSessions(RealmModel realm,
UserModel user,
boolean offline) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getOfflineUserSessionByBrokerUserId, getOfflineUserSessions, getOfflineUserSessions, getUserSessionByBrokerUserId, getUserSessions, getUserSessions, getUserSessions
protected final KeycloakSession session
protected final org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> sessionCache
protected final org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> offlineSessionCache
protected final org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache
protected final org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> offlineClientSessionCache
protected final org.infinispan.Cache<LoginFailureKey,SessionEntityWrapper<LoginFailureEntity>> loginFailureCache
protected final InfinispanChangelogBasedTransaction<String,UserSessionEntity> sessionTx
protected final InfinispanChangelogBasedTransaction<String,UserSessionEntity> offlineSessionTx
protected final InfinispanChangelogBasedTransaction<UUID,AuthenticatedClientSessionEntity> clientSessionTx
protected final InfinispanChangelogBasedTransaction<UUID,AuthenticatedClientSessionEntity> offlineClientSessionTx
protected final InfinispanChangelogBasedTransaction<LoginFailureKey,LoginFailureEntity> loginFailuresTx
protected final SessionEventsSenderTransaction clusterEventsSenderTx
protected final CrossDCLastSessionRefreshStore lastSessionRefreshStore
protected final CrossDCLastSessionRefreshStore offlineLastSessionRefreshStore
protected final PersisterLastSessionRefreshStore persisterLastSessionRefreshStore
protected final RemoteCacheInvoker remoteCacheInvoker
protected final InfinispanKeyGenerator keyGenerator
public InfinispanUserSessionProvider(KeycloakSession session, RemoteCacheInvoker remoteCacheInvoker, CrossDCLastSessionRefreshStore lastSessionRefreshStore, CrossDCLastSessionRefreshStore offlineLastSessionRefreshStore, PersisterLastSessionRefreshStore persisterLastSessionRefreshStore, InfinispanKeyGenerator keyGenerator, org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> sessionCache, org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> offlineSessionCache, org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> clientSessionCache, org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> offlineClientSessionCache, org.infinispan.Cache<LoginFailureKey,SessionEntityWrapper<LoginFailureEntity>> loginFailureCache)
protected org.infinispan.Cache<String,SessionEntityWrapper<UserSessionEntity>> getCache(boolean offline)
protected InfinispanChangelogBasedTransaction<String,UserSessionEntity> getTransaction(boolean offline)
protected org.infinispan.Cache<UUID,SessionEntityWrapper<AuthenticatedClientSessionEntity>> getClientSessionCache(boolean offline)
protected InfinispanChangelogBasedTransaction<UUID,AuthenticatedClientSessionEntity> getClientSessionTransaction(boolean offline)
protected CrossDCLastSessionRefreshStore getLastSessionRefreshStore()
protected CrossDCLastSessionRefreshStore getOfflineLastSessionRefreshStore()
protected PersisterLastSessionRefreshStore getPersisterLastSessionRefreshStore()
public AuthenticatedClientSessionModel createClientSession(RealmModel realm, ClientModel client, UserSessionModel userSession)
createClientSession
in interface UserSessionProvider
public UserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId)
createUserSession
in interface UserSessionProvider
public 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 UserSessionProvider
public UserSessionModel getUserSession(RealmModel realm, String id)
getUserSession
in interface UserSessionProvider
protected UserSessionAdapter getUserSession(RealmModel realm, String id, boolean offline)
protected Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, Predicate<Map.Entry<String,SessionEntityWrapper<UserSessionEntity>>> predicate, boolean offline)
public AuthenticatedClientSessionAdapter getClientSession(UserSessionModel userSession, ClientModel client, UUID clientSessionId, boolean offline)
getClientSession
in interface UserSessionProvider
public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, UserModel user)
UserSessionProvider
getUserSessionsStream
in interface UserSessionProvider
realm
- a reference to the realm.user
- the user whose sessions are being searched.Stream
of user sessions.public Stream<UserSessionModel> getUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)
UserSessionProvider
brokerUserId
.getUserSessionByBrokerUserIdStream
in interface UserSessionProvider
realm
- a reference to the realm.brokerUserId
- the id of the broker user whose sessions are being searched.Stream
of user sessions.public UserSessionModel getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)
getUserSessionByBrokerSessionId
in interface UserSessionProvider
public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client)
UserSessionProvider
getUserSessionsStream
in interface UserSessionProvider
realm
- a reference to the realm.client
- the client whose user sessions are being searched.Stream
of user sessions.public Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client, int firstResult, int maxResults)
UserSessionProvider
firstResult
and containing
at most maxResults
.getUserSessionsStream
in interface UserSessionProvider
realm
- a reference tot he realm.client
- the client whose user sessions are being searched.firstResult
- first result to return. Ignored if negative.maxResults
- maximum number of results to return. Ignored if negative.Stream
of user sessions.protected Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, ClientModel client, int firstResult, int maxResults, boolean offline)
protected Stream<UserSessionModel> getUserSessionModels(RealmModel realm, int firstResult, int maxResults, boolean offline, UserSessionPredicate predicate)
public UserSessionModel getUserSessionWithPredicate(RealmModel realm, String id, boolean offline, Predicate<UserSessionModel> predicate)
UserSessionProvider
null
.
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 UserSessionProvider
public long getActiveUserSessions(RealmModel realm, ClientModel client)
getActiveUserSessions
in interface UserSessionProvider
public Map<String,Long> getActiveClientSessionStats(RealmModel realm, boolean offline)
UserSessionProvider
getActiveClientSessionStats
in interface UserSessionProvider
protected long getUserSessionsCount(RealmModel realm, ClientModel client, boolean offline)
public void removeUserSession(RealmModel realm, UserSessionModel session)
UserSessionProvider
removeUserSession
in interface UserSessionProvider
public void removeUserSessions(RealmModel realm, UserModel user)
removeUserSessions
in interface UserSessionProvider
protected void removeUserSessions(RealmModel realm, UserModel user, boolean offline)
public void removeExpired(RealmModel realm)
UserSessionProvider
removeExpired
in interface UserSessionProvider
public void removeUserSessions(RealmModel realm)
removeUserSessions
in interface UserSessionProvider
protected void onRemoveUserSessionsEvent(String realmId)
public UserLoginFailureModel getUserLoginFailure(RealmModel realm, String userId)
getUserLoginFailure
in interface UserSessionProvider
public UserLoginFailureModel addUserLoginFailure(RealmModel realm, String userId)
addUserLoginFailure
in interface UserSessionProvider
public void removeUserLoginFailure(RealmModel realm, String userId)
removeUserLoginFailure
in interface UserSessionProvider
public void removeAllUserLoginFailures(RealmModel realm)
removeAllUserLoginFailures
in interface UserSessionProvider
protected void onRemoveAllUserLoginFailuresEvent(String realmId)
public void onRealmRemoved(RealmModel realm)
onRealmRemoved
in interface UserSessionProvider
protected void onRealmRemovedEvent(String realmId)
public void onClientRemoved(RealmModel realm, ClientModel client)
onClientRemoved
in interface UserSessionProvider
protected void onUserRemoved(RealmModel realm, UserModel user)
public void close()
close
in interface UserSessionProvider
close
in interface Provider
protected void removeUserSession(UserSessionEntity sessionEntity, boolean offline)
public UserSessionModel createOfflineUserSession(UserSessionModel userSession)
UserSessionProvider
createOfflineUserSession
in interface UserSessionProvider
public UserSessionAdapter getOfflineUserSession(RealmModel realm, String userSessionId)
getOfflineUserSession
in interface UserSessionProvider
public UserSessionModel getOfflineUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId)
getOfflineUserSessionByBrokerSessionId
in interface UserSessionProvider
public Stream<UserSessionModel> getOfflineUserSessionByBrokerUserIdStream(RealmModel realm, String brokerUserId)
UserSessionProvider
brokerUserId
.getOfflineUserSessionByBrokerUserIdStream
in interface UserSessionProvider
realm
- a reference to the realm.brokerUserId
- the id of the broker user whose sessions are being searched.Stream
of offline user sessions.public void removeOfflineUserSession(RealmModel realm, UserSessionModel userSession)
UserSessionProvider
removeOfflineUserSession
in interface UserSessionProvider
public AuthenticatedClientSessionModel createOfflineClientSession(AuthenticatedClientSessionModel clientSession, UserSessionModel offlineUserSession)
UserSessionProvider
createOfflineClientSession
in interface UserSessionProvider
public Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, UserModel user)
UserSessionProvider
getOfflineUserSessionsStream
in interface UserSessionProvider
realm
- a reference to the realm.user
- the user whose offline sessions are being searched.Stream
of offline user sessions.public long getOfflineSessionsCount(RealmModel realm, ClientModel client)
getOfflineSessionsCount
in interface UserSessionProvider
public Stream<UserSessionModel> getOfflineUserSessionsStream(RealmModel realm, ClientModel client, int first, int max)
UserSessionProvider
firstResult
and
containing at most maxResults
.getOfflineUserSessionsStream
in interface UserSessionProvider
realm
- a reference tot he realm.client
- the client whose user sessions are being searched.first
- first result to return. Ignored if negative.max
- maximum number of results to return. Ignored if negative.Stream
of offline user sessions.public void importUserSessions(Collection<UserSessionModel> persistentUserSessions, boolean offline)
UserSessionProvider
importUserSessions
in interface UserSessionProvider
protected UserSessionAdapter importUserSession(UserSessionModel userSession, boolean offline)
Copyright © 2020 JBoss by Red Hat. All rights reserved.