Added OIDC Client credential [#23089]

This commit is contained in:
Luca Frosini 2022-03-30 14:29:40 +02:00
parent bd7ef7ff1c
commit 67a851a5d1
2 changed files with 13 additions and 0 deletions

View File

@ -6,6 +6,7 @@ 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,6 +2,7 @@ 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;
@ -40,6 +41,17 @@ 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();