org.keycloak.admin.client.Keycloak.realm()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.keycloak.admin.client.Keycloak.realm()方法的一些代码示例,展示了Keycloak.realm()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keycloak.realm()方法的具体详情如下:
包路径:org.keycloak.admin.client.Keycloak
类名称:Keycloak
方法名:realm

Keycloak.realm介绍

暂无

代码示例

代码示例来源:origin: FundRequest/platform

@Bean
  public RealmResource keycloak() {
    final Keycloak keycloak = Keycloak.getInstance(
        serverUrl,
        realm,
        username,
        password,
        clientId,
        clientSecret);
    return keycloak.realm(realm);
  }
}

代码示例来源:origin: EnMasseProject/enmasse

private RealmResource getRealmResource(Keycloak keycloak, String realmName) {
  List<RealmRepresentation> realms = keycloak.realms().findAll();
  for (RealmRepresentation realm : realms) {
    if (realm.getRealm().equals(realmName)) {
      return keycloak.realm(realmName);
    }
  }
  return null;
}

代码示例来源:origin: EnMasseProject/enmasse

@Override
public void deleteUsers(String namespace) {
  withKeycloak(keycloak -> {
    List<RealmRepresentation> realmReps = keycloak.realms().findAll();
    for (RealmRepresentation realmRep : realmReps) {
      String realmNs = realmRep.getAttributes().get("namespace");
      if (realmNs != null && realmNs.equals(namespace)) {
        String realm = realmRep.getRealm();
        List<UserRepresentation> userReps = keycloak.realm(realm).users().list(0, 100);
        while (!userReps.isEmpty()) {
          for (UserRepresentation userRep : userReps) {
            keycloak.realm(realm).users().delete(userRep.getId());
          }
          userReps = keycloak.realm(realm).users().list(0, 100);
        }
      }
    }
    return null;
  });
}

代码示例来源:origin: EnMasseProject/enmasse

@Override
  public void deleteRealm(String realmName) {
    withKeycloak(kc -> {

      try {
        kc.realm(realmName).remove();
      } finally {
        realmState.remove(realmName);
      }

      return true;
    });
  }
}

代码示例来源:origin: EnMasseProject/enmasse

private UserList queryUsers(final Predicate<RealmRepresentation> realmPredicate, final Predicate<UserRepresentation> userPredicate) {
  return withKeycloak(keycloak -> {
    List<RealmRepresentation> realmReps = keycloak.realms().findAll();
    UserList userList = new UserList();
    for (RealmRepresentation realmRep : realmReps) {
      if (realmPredicate.test(realmRep)) {
        String realm = realmRep.getRealm();
        keycloak.realm(realm).users().list()
                .stream()
                .filter(userPredicate)
                .forEachOrdered(userRep -> {
                  List<GroupRepresentation> groupReps = keycloak.realm(realm).users().get(userRep.getId()).groups();
                  userList.getItems().add(buildUser(userRep, groupReps));
                });
      }
    }
    return userList;
  });
}

代码示例来源:origin: adorsys/xs2a

public boolean registerClient(String psuId, String password, String email) {
  Keycloak keycloak = Keycloak.getInstance(keycloakConfigProperties.getAuthServerUrl(), MASTER_REALM,
    keycloakAdminUsername,
    keycloakAdminPassword,
    ADMIN_CLI);
  try (Response response = keycloak.realm(keycloakConfigProperties.getRealm()).users().create(getUserRepresentation(psuId, password, email))) {
    log.info("Register keycloak client status: {}", response.getStatus());
    return response.getStatus() == 201;
  }
}

代码示例来源:origin: EnMasseProject/enmasse

if (!updated.equals(current)) {
  withKeycloak(kc -> {
    RealmResource realm = kc.realm(realmName);
    if (realm != null) {

相关文章