Search in sources :

Example 1 with RemoveUserSessionsEvent

use of org.keycloak.models.sessions.infinispan.events.RemoveUserSessionsEvent in project keycloak by keycloak.

the class InfinispanUserSessionProviderFactory method registerClusterListeners.

protected void registerClusterListeners(KeycloakSession session) {
    KeycloakSessionFactory sessionFactory = session.getKeycloakSessionFactory();
    ClusterProvider cluster = session.getProvider(ClusterProvider.class);
    cluster.registerListener(REALM_REMOVED_SESSION_EVENT, new AbstractUserSessionClusterListener<RealmRemovedSessionEvent, UserSessionProvider>(sessionFactory, UserSessionProvider.class) {

        @Override
        protected void eventReceived(KeycloakSession session, UserSessionProvider provider, RealmRemovedSessionEvent sessionEvent) {
            if (provider instanceof InfinispanUserSessionProvider) {
                ((InfinispanUserSessionProvider) provider).onRealmRemovedEvent(sessionEvent.getRealmId());
            }
        }
    });
    cluster.registerListener(CLIENT_REMOVED_SESSION_EVENT, new AbstractUserSessionClusterListener<ClientRemovedSessionEvent, UserSessionProvider>(sessionFactory, UserSessionProvider.class) {

        @Override
        protected void eventReceived(KeycloakSession session, UserSessionProvider provider, ClientRemovedSessionEvent sessionEvent) {
            if (provider instanceof InfinispanUserSessionProvider) {
                ((InfinispanUserSessionProvider) provider).onClientRemovedEvent(sessionEvent.getRealmId(), sessionEvent.getClientUuid());
            }
        }
    });
    cluster.registerListener(REMOVE_USER_SESSIONS_EVENT, new AbstractUserSessionClusterListener<RemoveUserSessionsEvent, UserSessionProvider>(sessionFactory, UserSessionProvider.class) {

        @Override
        protected void eventReceived(KeycloakSession session, UserSessionProvider provider, RemoveUserSessionsEvent sessionEvent) {
            if (provider instanceof InfinispanUserSessionProvider) {
                ((InfinispanUserSessionProvider) provider).onRemoveUserSessionsEvent(sessionEvent.getRealmId());
            }
        }
    });
    log.debug("Registered cluster listeners");
}
Also used : UserSessionProvider(org.keycloak.models.UserSessionProvider) ClusterProvider(org.keycloak.cluster.ClusterProvider) KeycloakSession(org.keycloak.models.KeycloakSession) RemoveUserSessionsEvent(org.keycloak.models.sessions.infinispan.events.RemoveUserSessionsEvent) ClientRemovedSessionEvent(org.keycloak.models.sessions.infinispan.events.ClientRemovedSessionEvent) KeycloakSessionFactory(org.keycloak.models.KeycloakSessionFactory) RealmRemovedSessionEvent(org.keycloak.models.sessions.infinispan.events.RealmRemovedSessionEvent)

Aggregations

ClusterProvider (org.keycloak.cluster.ClusterProvider)1 KeycloakSession (org.keycloak.models.KeycloakSession)1 KeycloakSessionFactory (org.keycloak.models.KeycloakSessionFactory)1 UserSessionProvider (org.keycloak.models.UserSessionProvider)1 ClientRemovedSessionEvent (org.keycloak.models.sessions.infinispan.events.ClientRemovedSessionEvent)1 RealmRemovedSessionEvent (org.keycloak.models.sessions.infinispan.events.RealmRemovedSessionEvent)1 RemoveUserSessionsEvent (org.keycloak.models.sessions.infinispan.events.RemoveUserSessionsEvent)1