validation and expiration splitted
This commit is contained in:
parent
1d02c93aae
commit
16bae0aa70
|
@ -1,8 +1,8 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
|
|
|
@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
|
||||
|
||||
## [v1.0.0] - 2022-06-06
|
||||
## [v1.0.0-SNAPSHOT] - 2022-06-06
|
||||
|
||||
- First Release
|
||||
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.common.security</groupId>
|
||||
<artifactId>gcube-secrets</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>gcube secrets</name>
|
||||
|
||||
<scm>
|
||||
|
|
|
@ -77,9 +77,14 @@ public class AccessTokenSecret extends Secret {
|
|||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
if (this.umaTokenSecret.isExpired())
|
||||
if (isExpired())
|
||||
refreshAccessToken();
|
||||
return this.umaTokenSecret.isValid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
return this.umaTokenSecret.isExpired();
|
||||
}
|
||||
|
||||
}
|
|
@ -57,6 +57,11 @@ public class CredentialSecret extends Secret {
|
|||
return this.accessTokenSecret.getHTTPAuthorizationHeaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
return this.accessTokenSecret.isExpired();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.accessTokenSecret.isValid();
|
||||
|
|
|
@ -72,4 +72,9 @@ public class GCubeSecret extends Secret {
|
|||
return gcubeToken != null && !gcubeToken.isEmpty() && Pattern.matches(GCUBE_TOKEN_REGEX, gcubeToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -97,11 +97,13 @@ public class UmaTokenSecret extends Secret {
|
|||
try {
|
||||
KeycloakClient client = KeycloakClientFactory.newInstance();
|
||||
PublishedRealmRepresentation realmInfo = client.getRealmInfo(client.getRealmBaseURL(context));
|
||||
return ModelUtils.isValid(encodedUmaToken, realmInfo.getPublicKey());
|
||||
return ModelUtils.isValid(encodedUmaToken, realmInfo.getPublicKey(), false);
|
||||
} catch (Exception e) {
|
||||
log.error("Error contacting keycloak, is not possible to check token validity", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue