diff --git a/integration/admin-client/pom.xml b/integration/admin-client/pom.xml
index 23d2d23e89..4163d27ffa 100755
--- a/integration/admin-client/pom.xml
+++ b/integration/admin-client/pom.xml
@@ -30,18 +30,50 @@
Keycloak Admin REST Client
+
+ 3.9.1.Final
+
+
org.keycloak
keycloak-core
+
+
+ *
+ *
+
+
+
+
+ org.keycloak
+ keycloak-common
+
+
+ *
+ *
+
+
+
+
+ org.jboss.resteasy
+ resteasy-client
+ ${resteasy.versions}
org.jboss.resteasy
resteasy-multipart-provider
+ ${resteasy.versions}
org.jboss.resteasy
resteasy-jackson2-provider
+ ${resteasy.versions}
+
+
+ org.jboss.resteasy
+ resteasy-jaxb-provider
+ ${resteasy.versions}
diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/ClientBuilderWrapper.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/ClientBuilderWrapper.java
new file mode 100644
index 0000000000..77497c4668
--- /dev/null
+++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/ClientBuilderWrapper.java
@@ -0,0 +1,28 @@
+package org.keycloak.admin.client;
+
+import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
+
+public class ClientBuilderWrapper {
+
+ static Class clazz;
+ static {
+ try {
+ clazz = Class.forName("org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl");
+ } catch (ClassNotFoundException e) {
+ try {
+ clazz = Class.forName("org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder");
+ } catch (ClassNotFoundException ex) {
+ throw new RuntimeException("RestEasy 3 or 4 not found on classpath");
+ }
+ }
+ }
+
+ public static ResteasyClientBuilder create() {
+ try {
+ return (ResteasyClientBuilder) clazz.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/Keycloak.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/Keycloak.java
index 3372e057d0..0a59ae3e72 100755
--- a/integration/admin-client/src/main/java/org/keycloak/admin/client/Keycloak.java
+++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/Keycloak.java
@@ -30,6 +30,7 @@ import org.keycloak.admin.client.token.TokenManager;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
+import javax.ws.rs.client.Client;
import java.net.URI;
@@ -50,7 +51,8 @@ public class Keycloak implements AutoCloseable {
private final TokenManager tokenManager;
private final String authToken;
private final ResteasyWebTarget target;
- private final ResteasyClient client;
+ private final Client client;
+ private boolean closed = false;
Keycloak(String serverUrl, String realm, String username, String password, String clientId, String clientSecret, String grantType, ResteasyClient resteasyClient, String authtoken) {
config = new Config(serverUrl, realm, username, password, clientId, clientSecret, grantType);
@@ -58,7 +60,7 @@ public class Keycloak implements AutoCloseable {
authToken = authtoken;
tokenManager = authtoken == null ? new TokenManager(config, client) : null;
- target = client.target(config.getServerUrl());
+ target = (ResteasyWebTarget) client.target(config.getServerUrl());
target.register(newAuthFilter());
}
@@ -67,7 +69,7 @@ public class Keycloak implements AutoCloseable {
}
private static ResteasyClient newRestEasyClient(ResteasyJackson2Provider customJacksonProvider, SSLContext sslContext, boolean disableTrustManager) {
- ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder()
+ ResteasyClientBuilder clientBuilder = ClientBuilderWrapper.create()
.sslContext(sslContext)
.connectionPoolSize(10);
@@ -141,7 +143,7 @@ public class Keycloak implements AutoCloseable {
* @return
*/
public T proxy(Class proxyClass, URI absoluteURI) {
- return client.target(absoluteURI).register(newAuthFilter()).proxy(proxyClass);
+ return ((ResteasyWebTarget) client.target(absoluteURI)).register(newAuthFilter()).proxy(proxyClass);
}
/**
@@ -149,6 +151,7 @@ public class Keycloak implements AutoCloseable {
*/
@Override
public void close() {
+ closed = true;
client.close();
}
@@ -156,6 +159,6 @@ public class Keycloak implements AutoCloseable {
* @return true if the underlying client is closed.
*/
public boolean isClosed() {
- return client.isClosed();
+ return closed;
}
}
diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java
index 5246c99fd4..bd231c89db 100644
--- a/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java
+++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java
@@ -25,6 +25,7 @@ import org.keycloak.common.util.Time;
import org.keycloak.representations.AccessTokenResponse;
import javax.ws.rs.BadRequestException;
+import javax.ws.rs.client.Client;
import javax.ws.rs.core.Form;
import static org.keycloak.OAuth2Constants.CLIENT_CREDENTIALS;
@@ -46,9 +47,9 @@ public class TokenManager {
private final TokenService tokenService;
private final String accessTokenGrantType;
- public TokenManager(Config config, ResteasyClient client) {
+ public TokenManager(Config config, Client client) {
this.config = config;
- ResteasyWebTarget target = client.target(config.getServerUrl());
+ ResteasyWebTarget target = (ResteasyWebTarget) client.target(config.getServerUrl());
if (!config.isPublicClient()) {
target.register(new BasicAuthFilter(config.getClientId(), config.getClientSecret()));
}