Merge pull request #1046 from mposolda/master
KEYCLOAK-1102 Used just one ResteasyClient in admin client
This commit is contained in:
commit
f732332281
2 changed files with 7 additions and 6 deletions
|
@ -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()));
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue