简体   繁体   English

Keycloak导入领域是否可以通过Java创建?

[英]Keycloak Import Realm “Create” From Java?

I've tried to import a realm from java application, but the server always return: 我尝试从Java应用程序导入领域,但是服务器始终返回:

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)

and this is my code: 这是我的代码:

     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?? 拜托,有人可以帮我导入领域吗?

You are not telling us which Keycloak version you are using. 您没有告诉我们您正在使用哪个Keycloak版本。 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或更高版本,我建议使用“ admin-cli”而不是“ security-admin-console”连接到Keycloak。

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) 请参阅用户指南http://www.keycloak.org/docs/latest/server_admin/topics/MigrationFromOlderVersions.html中的“迁移到1.7.0.CR1”部分(在此页面上搜索1.7.0)

尝试放置org.apache.httpcomponents版本“ 4.3.6”的导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM