Search in sources :

Example 1 with AuthenticationSessionProvider

use of org.keycloak.sessions.AuthenticationSessionProvider in project keycloak by keycloak.

the class RealmManager method removeRealm.

public boolean removeRealm(RealmModel realm) {
    ClientModel masterAdminClient = realm.getMasterAdminClient();
    boolean removed = model.removeRealm(realm.getId());
    if (removed) {
        if (masterAdminClient != null) {
            session.clients().removeClient(getKeycloakAdminstrationRealm(), masterAdminClient.getId());
        }
        UserSessionProvider sessions = session.sessions();
        if (sessions != null) {
            sessions.onRealmRemoved(realm);
        }
        AuthenticationSessionProvider authSessions = session.authenticationSessions();
        if (authSessions != null) {
            authSessions.onRealmRemoved(realm);
        }
        // Refresh periodic sync tasks for configured storageProviders
        UserStorageSyncManager storageSync = new UserStorageSyncManager();
        realm.getUserStorageProvidersStream().forEachOrdered(provider -> storageSync.notifyToRefreshPeriodicSync(session, realm, provider, true));
    }
    return removed;
}
Also used : ClientModel(org.keycloak.models.ClientModel) UserSessionProvider(org.keycloak.models.UserSessionProvider) AuthenticationSessionProvider(org.keycloak.sessions.AuthenticationSessionProvider)

Example 2 with AuthenticationSessionProvider

use of org.keycloak.sessions.AuthenticationSessionProvider in project keycloak by keycloak.

the class ClientManager method removeClient.

public boolean removeClient(RealmModel realm, ClientModel client) {
    if (!isInternalClient(realm.getName(), client.getClientId()) && realm.removeClient(client.getId())) {
        UserSessionProvider sessions = realmManager.getSession().sessions();
        if (sessions != null) {
            sessions.onClientRemoved(realm, client);
        }
        AuthenticationSessionProvider authSessions = realmManager.getSession().authenticationSessions();
        if (authSessions != null) {
            authSessions.onClientRemoved(realm, client);
        }
        UserModel serviceAccountUser = realmManager.getSession().users().getServiceAccount(client);
        if (serviceAccountUser != null) {
            new UserManager(realmManager.getSession()).removeUser(realm, serviceAccountUser);
        }
        return true;
    } else {
        return false;
    }
}
Also used : UserModel(org.keycloak.models.UserModel) UserSessionProvider(org.keycloak.models.UserSessionProvider) UserManager(org.keycloak.models.UserManager) AuthenticationSessionProvider(org.keycloak.sessions.AuthenticationSessionProvider)

Aggregations

UserSessionProvider (org.keycloak.models.UserSessionProvider)2 AuthenticationSessionProvider (org.keycloak.sessions.AuthenticationSessionProvider)2 ClientModel (org.keycloak.models.ClientModel)1 UserManager (org.keycloak.models.UserManager)1 UserModel (org.keycloak.models.UserModel)1