Removed OIDC Client credential

This commit is contained in:
Luca Frosini 2022-03-30 15:03:50 +02:00
parent 67a851a5d1
commit dab0deea20
2 changed files with 3 additions and 15 deletions

View File

@ -6,7 +6,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Refactored code to be integrated in Smartgears [#22871]
- Fixed getRoles for JWTSecret [#22754]
- Added OIDC Client credential [#23089]
## [v1.0.0]

View File

@ -2,19 +2,18 @@ package org.gcube.common.authorization.utils.clientid;
import org.gcube.common.authorization.utils.secret.JWTSecret;
import org.gcube.common.authorization.utils.secret.Secret;
import org.gcube.common.keycloak.KeycloakClientException;
import org.gcube.common.keycloak.KeycloakClientFactory;
import org.gcube.common.keycloak.model.TokenResponse;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class ClienIDManager implements RenewalProvider {
public class ClientIDManager implements RenewalProvider {
protected final String clientID;
protected final String clientSecret;
public ClienIDManager(String clientID, String clientSecret) {
public ClientIDManager(String clientID, String clientSecret) {
this.clientID = clientID;
this.clientSecret = clientSecret;
}
@ -40,20 +39,10 @@ public class ClienIDManager implements RenewalProvider {
return jwtSecret;
}
public Secret getOIDCSecret() throws KeycloakClientException {
TokenResponse tokenResponse = KeycloakClientFactory.newInstance().queryOIDCToken(clientID, clientSecret);
JWTSecret jwtSecret = new JWTSecret(tokenResponse.getAccessToken());
jwtSecret.setRenewalProvider(this);
jwtSecret.setTokenResponse(tokenResponse);
return jwtSecret;
}
@Override
public Secret renew() throws Exception {
return getSecret();
}
}