diff --git a/src/main/java/org/gcube/common/security/renewal/ClientIDManager.java b/src/main/java/org/gcube/common/security/renewal/ClientIDManager.java index 966f0c2..41490bd 100644 --- a/src/main/java/org/gcube/common/security/renewal/ClientIDManager.java +++ b/src/main/java/org/gcube/common/security/renewal/ClientIDManager.java @@ -1,5 +1,7 @@ package org.gcube.common.security.renewal; +import java.net.URL; + import org.gcube.common.keycloak.KeycloakClientFactory; import org.gcube.common.keycloak.model.TokenResponse; import org.gcube.common.security.secrets.JWTSecret; @@ -12,14 +14,16 @@ public class ClientIDManager implements RenewalProvider { protected final String clientID; protected final String clientSecret; + protected final URL endpoint; - public ClientIDManager(String clientID, String clientSecret) { + public ClientIDManager(String clientID, String clientSecret, URL endpoint) { this.clientID = clientID; this.clientSecret = clientSecret; + this.endpoint = endpoint; } public Secret getSecret() throws Exception { - TokenResponse tokenResponse = KeycloakClientFactory.newInstance().queryUMAToken(clientID, clientSecret, null); + TokenResponse tokenResponse = KeycloakClientFactory.newInstance().queryUMAToken(endpoint, clientID, clientSecret, null); JWTSecret jwtSecret = new JWTSecret(tokenResponse.getAccessToken()); jwtSecret.setRenewalProvider(this); @@ -30,7 +34,7 @@ public class ClientIDManager implements RenewalProvider { } public Secret getSecret(String context) throws Exception { - TokenResponse tokenResponse = KeycloakClientFactory.newInstance().queryUMAToken(clientID, clientSecret, context, null); + TokenResponse tokenResponse = KeycloakClientFactory.newInstance().queryUMAToken(endpoint, clientID, clientSecret, context, null); JWTSecret jwtSecret = new JWTSecret(tokenResponse.getAccessToken()); jwtSecret.setRenewalProvider(this); diff --git a/src/main/java/org/gcube/common/security/secrets/AccessTokenSecret.java b/src/main/java/org/gcube/common/security/secrets/AccessTokenSecret.java index efa25c2..d8f05e0 100644 --- a/src/main/java/org/gcube/common/security/secrets/AccessTokenSecret.java +++ b/src/main/java/org/gcube/common/security/secrets/AccessTokenSecret.java @@ -76,5 +76,5 @@ public class AccessTokenSecret extends Secret { } } - + } diff --git a/src/main/java/org/gcube/common/security/secrets/JWTSecret.java b/src/main/java/org/gcube/common/security/secrets/JWTSecret.java index 88c54c8..a95e75b 100644 --- a/src/main/java/org/gcube/common/security/secrets/JWTSecret.java +++ b/src/main/java/org/gcube/common/security/secrets/JWTSecret.java @@ -6,7 +6,6 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.gcube.com.fasterxml.jackson.databind.ObjectMapper; -import org.gcube.common.keycloak.KeycloakClientFactory; import org.gcube.common.keycloak.model.AccessToken; import org.gcube.common.keycloak.model.ModelUtils; import org.gcube.common.keycloak.model.RefreshToken; @@ -54,7 +53,7 @@ public class JWTSecret extends Secret { expired = true; if(tokenResponse!=null) { try { - KeycloakClientFactory.newInstance().refreshToken(this.getOwner().getId(), tokenResponse); + //KeycloakClientFactory.newInstance().refreshToken(URL, this.getOwner().getId(), tokenResponse); expired = false; }catch (Exception e) { logger.warn("Unable to refresh the token with RefreshToken. Going to try to renew it if possible.", e);