问题描述
我尝试从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/topic/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导入领域“创建"从Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!