[java-oidc-common] 02/02: JOIDC-38 Refactor fetching of remote JWK sets
Henri Mikkonen
henri.mikkonen at iki.fi
Thu Mar 11 15:48:06 UTC 2021
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-oidc-common.
View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=86edff46be7720c45f90bb5d91dc1718e64c72e0
commit 86edff46be7720c45f90bb5d91dc1718e64c72e0
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Thu Mar 11 17:47:19 2021 +0200
JOIDC-38 Refactor fetching of remote JWK sets
https://issues.shibboleth.net/jira/browse/JOIDC-38
The client information resolvers no longer fetches keys (via RemoteJwkSetCache)
---
.../impl/FilesystemClientInformationResolver.java | 44 --------------------
.../StorageServiceClientInformationResolver.java | 47 ----------------------
2 files changed, 91 deletions(-)
diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/FilesystemClientInformationResolver.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/FilesystemClientInformationResolver.java
index 31eb5ad..5d69a65 100644
--- a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/FilesystemClientInformationResolver.java
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/FilesystemClientInformationResolver.java
@@ -18,8 +18,6 @@
package net.shibboleth.oidc.metadata.impl;
import java.io.IOException;
-import java.time.Duration;
-import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -41,13 +39,10 @@ import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformation;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
-import net.shibboleth.oidc.jwk.RemoteJwkSetCache;
import net.shibboleth.oidc.metadata.RefreshableClientInformationResolver;
import net.shibboleth.oidc.metadata.criterion.ClientIDCriterion;
-import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
@@ -60,13 +55,6 @@ public class FilesystemClientInformationResolver extends AbstractFileOIDCEntityR
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(FilesystemClientInformationResolver.class);
- /** The cache for remote JWK key sets. */
- private RemoteJwkSetCache remoteJwkSetCache;
-
- /** The remote key refresh interval. Default value: 30 minutes. */
- @Positive
- private Duration keyFetchInterval = Duration.ofMinutes(30);
-
/**
* Constructor.
*
@@ -94,33 +82,6 @@ public class FilesystemClientInformationResolver extends AbstractFileOIDCEntityR
/** {@inheritDoc} */
@Override protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
- if (remoteJwkSetCache == null) {
- log.warn("The RemoteJwkSetCache is not defined, the remote keys are not fetched automatically");
- }
- }
-
- /**
- * Set the cache for remote JWK key sets.
- *
- * @param jwkSetCache What to set.
- */
- public void setRemoteJwkSetCache(final RemoteJwkSetCache jwkSetCache) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- remoteJwkSetCache = Constraint.isNotNull(jwkSetCache, "The remote JWK set cache cannot be null");
- }
-
- /**
- * Set the remote key refresh interval.
- *
- * @param interval What to set.
- */
- public void setKeyFetchInterval(@Positive final Duration interval) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
-
- Constraint.isFalse(interval == null || interval.isNegative(), "Remote key refresh must be greater than 0");
- keyFetchInterval = interval;
}
/** {@inheritDoc} */
@@ -149,11 +110,6 @@ public class FilesystemClientInformationResolver extends AbstractFileOIDCEntityR
protected List<OIDCClientInformation> updateKeys(final List<OIDCClientInformation> clientInformations) {
final List<OIDCClientInformation> result = new ArrayList<>();
for (final OIDCClientInformation clientInformation : clientInformations) {
- if (clientInformation.getOIDCMetadata().getJWKSetURI() != null && remoteJwkSetCache != null) {
- clientInformation.getOIDCMetadata().setJWKSet(
- remoteJwkSetCache.fetch(clientInformation.getOIDCMetadata().getJWKSetURI(),
- Instant.now().plus(keyFetchInterval)));
- }
result.add(clientInformation);
}
return result;
diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/StorageServiceClientInformationResolver.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/StorageServiceClientInformationResolver.java
index 09935c4..a6298f3 100644
--- a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/StorageServiceClientInformationResolver.java
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/metadata/impl/StorageServiceClientInformationResolver.java
@@ -18,8 +18,6 @@
package net.shibboleth.oidc.metadata.impl;
import java.io.IOException;
-import java.time.Duration;
-import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -37,14 +35,10 @@ import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.oauth2.sdk.util.JSONObjectUtils;
import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformation;
-import net.shibboleth.oidc.jwk.RemoteJwkSetCache;
import net.shibboleth.oidc.metadata.ClientInformationResolver;
import net.shibboleth.oidc.metadata.criterion.ClientIDCriterion;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
@@ -57,45 +51,9 @@ public class StorageServiceClientInformationResolver extends BaseStorageServiceC
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(StorageServiceClientInformationResolver.class);
- /** The cache for remote JWK key sets. */
- @NonnullAfterInit private RemoteJwkSetCache remoteJwkSetCache;
-
- /** The remote key refresh interval in milliseconds. Default value: 30 minutes. */
- @Positive private Duration keyFetchInterval = Duration.ofMinutes(30);
-
/** {@inheritDoc} */
@Override protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
-
- if (remoteJwkSetCache == null) {
- log.warn("The RemoteJwkSetCache is not defined, the remote keys are not fetched automatically");
- }
- }
-
- /**
- * Set the cache for remote JWK key sets.
- *
- * @param jwkSetCache What to set.
- */
- public void setRemoteJwkSetCache(@Nonnull final RemoteJwkSetCache jwkSetCache) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
-
- remoteJwkSetCache = Constraint.isNotNull(jwkSetCache, "The remote JWK set cache cannot be null");
- }
-
- /**
- * Set the remote key refresh interval.
- *
- * @param interval What to set.
- */
- public void setKeyFetchInterval(@Positive final Duration interval) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
-
- Constraint.isFalse(interval == null || interval.isNegative(), "Remote key refresh must be greater than 0");
-
- keyFetchInterval = interval;
}
/** {@inheritDoc} */
@@ -121,11 +79,6 @@ public class StorageServiceClientInformationResolver extends BaseStorageServiceC
final OIDCClientInformation clientInformation =
OIDCClientInformation.parse(JSONObjectUtils.parse(record.getValue()));
log.debug("Found a record with clientId {}", clientId);
- if (clientInformation.getOIDCMetadata().getJWKSetURI() != null && remoteJwkSetCache != null) {
- clientInformation.getOIDCMetadata().setJWKSet(remoteJwkSetCache
- .fetch(clientInformation.getOIDCMetadata().getJWKSetURI(),
- Instant.now().plus(keyFetchInterval)));
- }
result.add(clientInformation);
}
} catch (final IOException | ParseException e) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list