Keycloak 导入领域"创建"来自爪哇? [英] Keycloak Import Realm "Create" From Java?

查看:81
本文介绍了Keycloak 导入领域"创建"来自爪哇?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从 Java 应用程序导入领域,但服务器总是返回:

I've tried to import a realm from java application, but the server always return:

Exception in thread "main" javax.ws.rs.BadRequestException: HTTP 400 Bad Request
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.handleErrorStatus(ClientInvocation.java:197)
at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.DefaultEntityExtractorFactory$3.extractEntity(DefaultEntityExtractorFactory.java:50)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:104)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:64)
at com.sun.proxy.$Proxy20.create(Unknown Source)
at com.blulogix.core.rest.util.TestKeycloakToken.createRealm(TestKeycloakToken.java:59)
at com.blulogix.core.rest.util.TestKeycloakToken.main(TestKeycloakToken.java:38)

这是我的代码:

     Keycloak kc = Keycloak.getInstance("http://localhost:8080/auth", "master", "admin", "admin", "security-admin-console");
     RealmRepresentation rr = new RealmRepresentation();
     rr.setId("TestRealm2");
     rr.setRealm("TestRealm2");
     rr.setEnabled(true);

用于向任何领域添加新用户的代码有效.

Code for adding a new user to any realm are worked.

   kc.realm("master").users().create(user);

请问,有人可以帮我导入领域吗??

Please, Can anyone help me out with importing realm??

推荐答案

您没有告诉我们您使用的是哪个 Keycloak 版本.假设它是 1.7.0 或更新版本,我建议使用admin-cli"而不是security-admin-console"来连接到 Keycloak.

You are not telling us which Keycloak version you are using. Assuming it is 1.7.0 or newer I suggest using "admin-cli" rather than "security-admin-console" to connect to Keycloak.

请参阅用户指南中的迁移到 1.7.0.CR1"部分http://www.keycloak.org/docs/latest/server_admin/主题/MigrationFromOlderVersions.html(在此页面上搜索 1.7.0)

See the "Migrating to 1.7.0.CR1" section in the user guide http://www.keycloak.org/docs/latest/server_admin/topics/MigrationFromOlderVersions.html (on this page search for 1.7.0)

这篇关于Keycloak 导入领域"创建"来自爪哇?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆