Search in sources :

Example 1 with ClientRemovedSessionEvent

use of org.keycloak.models.sessions.infinispan.events.ClientRemovedSessionEvent 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)

Example 2 with ClientRemovedSessionEvent

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

the class InfinispanAuthenticationSessionProviderFactory method registerClusterListeners.

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

        @Override
        protected void eventReceived(KeycloakSession session, InfinispanAuthenticationSessionProvider provider, RealmRemovedSessionEvent sessionEvent) {
            provider.onRealmRemovedEvent(sessionEvent.getRealmId());
        }
    });
    cluster.registerListener(CLIENT_REMOVED_AUTHSESSION_EVENT, new AbstractAuthSessionClusterListener<ClientRemovedSessionEvent>(sessionFactory) {

        @Override
        protected void eventReceived(KeycloakSession session, InfinispanAuthenticationSessionProvider provider, ClientRemovedSessionEvent sessionEvent) {
            provider.onClientRemovedEvent(sessionEvent.getRealmId(), sessionEvent.getClientUuid());
        }
    });
    log.debug("Registered cluster listeners");
}
Also used : ClusterProvider(org.keycloak.cluster.ClusterProvider) KeycloakSession(org.keycloak.models.KeycloakSession) 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)2 KeycloakSession (org.keycloak.models.KeycloakSession)2 KeycloakSessionFactory (org.keycloak.models.KeycloakSessionFactory)2 ClientRemovedSessionEvent (org.keycloak.models.sessions.infinispan.events.ClientRemovedSessionEvent)2 RealmRemovedSessionEvent (org.keycloak.models.sessions.infinispan.events.RealmRemovedSessionEvent)2 UserSessionProvider (org.keycloak.models.UserSessionProvider)1 RemoveUserSessionsEvent (org.keycloak.models.sessions.infinispan.events.RemoveUserSessionsEvent)1