Red Hat SSO 7.3.0.GA 的 Keycloak API 调用依赖项
Posted
技术标签:
【中文标题】Red Hat SSO 7.3.0.GA 的 Keycloak API 调用依赖项【英文标题】:Keycloak API call dependency for Red Hat SSO 7.3.0.GA 【发布时间】:2021-01-16 14:38:47 【问题描述】:我正在使用以下代码在我的项目中调用 keycloak api。它在 Keylcloak 7.0.1 中工作。但是,它不工作 RedHat SSO 7.3.0.GA
Keycloak kc = KeycloakBuilder.builder()
.realm(MASTERREALM)
.username(USERNAME)
.password(PASSWORD)
.serverUrl(SERVER_URL).clientId(CLIENT_ID)
.resteasyClient(new ResteasyClientBuilder().connectionPoolSize(10).build()).build();
UsersResource usersResource = kc.realm(REALM).users();
使用以下依赖项连接到 Keycloak 7.0.1 时可以正常工作
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-common</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.7.0.Final</version>
</dependency>
<!-- Keycloak api dependencies -->
List<UserRepresentation> listUserResource = usersResource.search(strUserName);
我的问题:-
1) 当我尝试连接 Red Hat SSO 7.3.0.GA 时,我必须使用哪些依赖项。
I have tried use below dependency. it is throwing maven build error of dependencies are not available in central repository. Since, This artifact is located at Redhat GA repository.
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>7.0.0.redhat-00002</version>
</dependency>
2) 如何在 pom.xml 文件中定义 Redhat GA 仓库
提前致谢
【问题讨论】:
【参考方案1】:从RedHat docs,在您的~/.m2/settings.xml
文件中包含以下内容:
<!-- Configure the JBoss Enterprise Maven repository -->
<profile>
<id>jboss-enterprise-maven-repository</id>
<repositories>
<repository>
<id>jboss-enterprise-maven-repository</id>
<url>https://maven.repository.redhat.com/ga/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-enterprise-maven-repository</id>
<url>https://maven.repository.redhat.com/ga/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
假设您可以访问 JBoss EAP Maven 存储库。您需要在命令行中使用mvn -Pjboss-enterprise-maven-repository <target>
启用jboss-enterprise-maven-repository
配置文件,或者添加:
<activeProfiles>
<activeProfile>jboss-enterprise-maven-repository</activeProfile>
</activeProfiles>
到您的~/.m2/settings.xml
文件。
【讨论】:
以上是关于Red Hat SSO 7.3.0.GA 的 Keycloak API 调用依赖项的主要内容,如果未能解决你的问题,请参考以下文章
red hat 6&red hat 7 Apache网站搭建虚拟主机
基于RHEL(centos/red hat)的8个YUM/DNF第三方库
red hat 6.5 红帽企业Linux.6.5 yum This system is not registered to Red Hat Subscription Management. You