Class InfinispanAuthenticationSessionProvider
- java.lang.Object
-
- org.keycloak.models.sessions.infinispan.InfinispanAuthenticationSessionProvider
-
- All Implemented Interfaces:
Provider
,AuthenticationSessionProvider
public class InfinispanAuthenticationSessionProvider extends Object implements AuthenticationSessionProvider
- Author:
- Marek Posolda
-
-
Field Summary
Fields Modifier and Type Field Description protected SessionEventsSenderTransaction
clusterEventsSenderTx
protected InfinispanKeycloakTransaction
tx
-
Constructor Summary
Constructors Constructor Description InfinispanAuthenticationSessionProvider(KeycloakSession session, InfinispanKeyGenerator keyGenerator, org.infinispan.Cache<String,RootAuthenticationSessionEntity> cache, int authSessionsLimit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
RootAuthenticationSessionModel
createRootAuthenticationSession(RealmModel realm)
Creates and registers a new authentication session with random ID.RootAuthenticationSessionModel
createRootAuthenticationSession(RealmModel realm, String id)
Creates a new root authentication session specified by the provided realm and id.protected String
generateTabId()
org.infinispan.Cache<String,RootAuthenticationSessionEntity>
getCache()
RootAuthenticationSessionModel
getRootAuthenticationSession(RealmModel realm, String authenticationSessionId)
Returns the root authentication session specified by the provided realm and id.void
onClientRemoved(RealmModel realm, ClientModel client)
Removes all associated root authentication sessions to the given realm and client which was removed.protected void
onClientRemovedEvent(String realmId, String clientUuid)
void
onRealmRemoved(RealmModel realm)
Removes all associated root authentication sessions to the given realm which was removed.protected void
onRealmRemovedEvent(String realmId)
void
removeAllExpired()
Remove expired authentication sessions in all the realmsvoid
removeExpired(RealmModel realm)
Removes all expired root authentication sessions for the given realm.void
removeRootAuthenticationSession(RealmModel realm, RootAuthenticationSessionModel authenticationSession)
Removes provided root authentication session.void
updateNonlocalSessionAuthNotes(AuthenticationSessionCompoundId compoundId, Map<String,String> authNotesFragment)
Requests update of authNotes of a root authentication session that is not owned by this instance but might exist somewhere in the cluster.
-
-
-
Field Detail
-
tx
protected final InfinispanKeycloakTransaction tx
-
clusterEventsSenderTx
protected final SessionEventsSenderTransaction clusterEventsSenderTx
-
-
Constructor Detail
-
InfinispanAuthenticationSessionProvider
public InfinispanAuthenticationSessionProvider(KeycloakSession session, InfinispanKeyGenerator keyGenerator, org.infinispan.Cache<String,RootAuthenticationSessionEntity> cache, int authSessionsLimit)
-
-
Method Detail
-
createRootAuthenticationSession
public RootAuthenticationSessionModel createRootAuthenticationSession(RealmModel realm)
Description copied from interface:AuthenticationSessionProvider
Creates and registers a new authentication session with random ID. Authentication session entity will be prefilled with current timestamp, the given realm and client.- Specified by:
createRootAuthenticationSession
in interfaceAuthenticationSessionProvider
- Parameters:
realm
-RealmModel
Can't benull
.- Returns:
- Returns created
RootAuthenticationSessionModel
. Never returnsnull
.
-
createRootAuthenticationSession
public RootAuthenticationSessionModel createRootAuthenticationSession(RealmModel realm, String id)
Description copied from interface:AuthenticationSessionProvider
Creates a new root authentication session specified by the provided realm and id.- Specified by:
createRootAuthenticationSession
in interfaceAuthenticationSessionProvider
- Parameters:
realm
-RealmModel
Can't benull
.id
-String
Id of newly created root authentication session. Ifnull
a random id will be generated.- Returns:
- Returns created
RootAuthenticationSessionModel
. Never returnsnull
.
-
removeAllExpired
public void removeAllExpired()
Description copied from interface:AuthenticationSessionProvider
Remove expired authentication sessions in all the realms- Specified by:
removeAllExpired
in interfaceAuthenticationSessionProvider
-
removeExpired
public void removeExpired(RealmModel realm)
Description copied from interface:AuthenticationSessionProvider
Removes all expired root authentication sessions for the given realm.- Specified by:
removeExpired
in interfaceAuthenticationSessionProvider
- Parameters:
realm
-RealmModel
Can't benull
.
-
onRealmRemoved
public void onRealmRemoved(RealmModel realm)
Description copied from interface:AuthenticationSessionProvider
Removes all associated root authentication sessions to the given realm which was removed.- Specified by:
onRealmRemoved
in interfaceAuthenticationSessionProvider
- Parameters:
realm
-RealmModel
Can't benull
.
-
onRealmRemovedEvent
protected void onRealmRemovedEvent(String realmId)
-
onClientRemoved
public void onClientRemoved(RealmModel realm, ClientModel client)
Description copied from interface:AuthenticationSessionProvider
Removes all associated root authentication sessions to the given realm and client which was removed.- Specified by:
onClientRemoved
in interfaceAuthenticationSessionProvider
- Parameters:
realm
-RealmModel
Can't benull
.client
-ClientModel
Can't benull
.
-
updateNonlocalSessionAuthNotes
public void updateNonlocalSessionAuthNotes(AuthenticationSessionCompoundId compoundId, Map<String,String> authNotesFragment)
Description copied from interface:AuthenticationSessionProvider
Requests update of authNotes of a root authentication session that is not owned by this instance but might exist somewhere in the cluster.- Specified by:
updateNonlocalSessionAuthNotes
in interfaceAuthenticationSessionProvider
- Parameters:
compoundId
-AuthenticationSessionCompoundId
The method has no effect ifnull
.authNotesFragment
-Map<String, String>
Map with authNote values. Auth note is removed if the corresponding value in the map isnull
. Map itself can't benull
.
-
getRootAuthenticationSession
public RootAuthenticationSessionModel getRootAuthenticationSession(RealmModel realm, String authenticationSessionId)
Description copied from interface:AuthenticationSessionProvider
Returns the root authentication session specified by the provided realm and id.- Specified by:
getRootAuthenticationSession
in interfaceAuthenticationSessionProvider
- Parameters:
realm
-RealmModel
Can't benull
.authenticationSessionId
-RootAuthenticationSessionModel
Ifnull
thennull
will be returned.- Returns:
- Returns found
RootAuthenticationSessionModel
ornull
if no root authentication session is found.
-
removeRootAuthenticationSession
public void removeRootAuthenticationSession(RealmModel realm, RootAuthenticationSessionModel authenticationSession)
Description copied from interface:AuthenticationSessionProvider
Removes provided root authentication session.- Specified by:
removeRootAuthenticationSession
in interfaceAuthenticationSessionProvider
- Parameters:
realm
-RealmModel
Associated realm to the given root authentication session.authenticationSession
-RootAuthenticationSessionModel
Can't benull
.
-
getCache
public org.infinispan.Cache<String,RootAuthenticationSessionEntity> getCache()
-
generateTabId
protected String generateTabId()
-
-