Esempio n. 1
0
  public boolean removeClient(RealmModel realm, ClientModel client) {
    if (realm.removeClient(client.getId())) {
      UserSessionProvider sessions = realmManager.getSession().sessions();
      if (sessions != null) {
        sessions.onClientRemoved(realm, client);
      }

      UserSessionPersisterProvider sessionsPersister =
          realmManager.getSession().getProvider(UserSessionPersisterProvider.class);
      if (sessionsPersister != null) {
        sessionsPersister.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;
    }
  }
Esempio n. 2
0
  public static void dettachClientSession(
      UserSessionProvider sessions, RealmModel realm, ClientSessionModel clientSession) {
    UserSessionModel userSession = clientSession.getUserSession();
    if (userSession == null) {
      return;
    }

    clientSession.setUserSession(null);
    clientSession.setRoles(null);
    clientSession.setProtocolMappers(null);

    if (userSession.getClientSessions().isEmpty()) {
      sessions.removeUserSession(realm, userSession);
    }
  }