KEYCLOAK-1102 Used just one ResteasyClient in admin client

This commit is contained in:
mposolda 2015-03-13 19:55:54 +01:00
parent d28f3ebaf9
commit 9b74393add
2 changed files with 7 additions and 6 deletions

View file

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

View file

@ -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()