Keycloak API call dependency for Red Hat SSO 7.3.0.GA

252 views Asked by At

I am calling keycloak api in my project using below code. It is working in Keylcloak 7.0.1. But, it is not working 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();

This is working fine when connecting to Keycloak 7.0.1 using below dependencies

<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);

My questions:-

1) when I try to connect Red Hat SSO 7.3.0.GA what dependencies I have to use.

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) How to define Redhat GA repository in pom.xml file

Thanks in advance

1

There are 1 answers

0
stdunbar On

From the RedHat docs, include the following in your ~/.m2/settings.xml file:

<!-- 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>

assuming that you have access to the JBoss EAP Maven repository. You'll need to either enable the jboss-enterprise-maven-repository profile on the command line with mvn -Pjboss-enterprise-maven-repository <target> or by adding:

<activeProfiles>
    <activeProfile>jboss-enterprise-maven-repository</activeProfile>
</activeProfiles>

to your ~/.m2/settings.xml file.