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 1488d38f3c..20914e5de0 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 @@ -20,9 +20,10 @@ public class Keycloak { private Keycloak(String serverUrl, String realm, String username, String password, String clientId, String clientSecret){ config = new Config(serverUrl, realm, username, password, clientId, clientSecret); - tokenManager = new TokenManager(config); - client = new ResteasyClientBuilder().build(); + + tokenManager = new TokenManager(config, client); + target = client.target(config.getServerUrl()); target.register(new BearerAuthFilter(tokenManager.getAccessTokenString())); 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 3e3d923ea2..f5a796dd24 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 @@ -18,10 +18,12 @@ public class TokenManager { private AccessTokenResponse currentToken; private Date expirationTime; - private Config config; + private final Config config; + private final ResteasyClient client; - public TokenManager(Config config){ + public TokenManager(Config config, ResteasyClient client){ this.config = config; + this.client = client; } public String getAccessTokenString(){ @@ -38,7 +40,6 @@ public class TokenManager { } public AccessTokenResponse grantToken(){ - ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(config.getServerUrl()); Form form = new Form() @@ -60,7 +61,6 @@ public class TokenManager { } public AccessTokenResponse refreshToken(){ - ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target(config.getServerUrl()); Form form = new Form()