[java-oidc-common] 01/04: JCOMOIDC-195 - Inefficient caching behaviour in RemoteJWKSetCache

Codeberg noreply at shibboleth.net
Fri Nov 27 12:20:47 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch maint-3.4
in repository java-oidc-common.

View the commit online:
https://codeberg.org/Shibboleth/java-oidc-common/commit/9c2a95dfb99a7198c63dd30447bbff3a7dd86665

commit 9c2a95dfb99a7198c63dd30447bbff3a7dd86665
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Nov 27 10:56:09 2026 +0000

    JCOMOIDC-195 - Inefficient caching behaviour in RemoteJWKSetCache
    
     - Add refresh cooldown records to the storage service with fixed expiry
     - Check refresh cooldown storage record when attempting to fetch new
    JWKSet documents
     - Only overwrite a previous cache entry if the fetch for a new one is
    successful
    
    https://shibboleth.atlassian.net/browse/JCOMOIDC-195
---
 .../net/shibboleth/oidc/jwk/RemoteJwkSetCache.java | 128 +++++++++++--
 .../shibboleth/oidc/jwk/RemoteJwkSetCacheTest.java | 208 +++++++++++++++++----
 2 files changed, 292 insertions(+), 44 deletions(-)

diff --git a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwk/RemoteJwkSetCache.java b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwk/RemoteJwkSetCache.java
index 93aa811c..72eba4a5 100644
--- a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwk/RemoteJwkSetCache.java
+++ b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwk/RemoteJwkSetCache.java
@@ -16,6 +16,7 @@ package net.shibboleth.oidc.jwk;
 
 import java.io.IOException;
 import java.net.URI;
+import java.time.Duration;
 import java.time.Instant;
 
 import javax.annotation.Nonnull;
@@ -45,6 +46,9 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
 
     /** The context name in the {@link StorageService}. */
     public static final String CONTEXT_NAME = "oidcRemoteJwkSetContents";
+    
+    /** The context name in the {@link StorageService} to store records about when keysets were forced refreshed. */
+    public static final String FORCED_REFRESH_CONTEXT_NAME = "oidcRemoteJwkSetForcedRefresh";
 
     /** Logger. */
     private final Logger log = LoggerFactory.getLogger(RemoteJwkSetCache.class);
@@ -57,6 +61,19 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
     
     /** HTTP client security parameters. */
     @Nullable private HttpClientSecurityParameters httpClientSecurityParameters;
+    
+    /**
+     * The forced refresh cooldown period. If a JWKS has been forcibly refreshed within this period, another forced
+     * refresh will not be attempted. A duration of {@link Duration#ZERO} disables the cooldown period. 
+     * Disabled by default.
+     */
+    @Nonnull private Duration forcedRefreshCooldown;
+    
+    /** Constructor.*/
+    public RemoteJwkSetCache(){
+    	// Disable the refresh cooldown
+    	forcedRefreshCooldown = Duration.ZERO;
+    }
 
     /**
      * Get the backing store for the remote JWK set contents.
@@ -74,7 +91,7 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
      * @param storageService backing store to use
      */
     public void setStorage(@Nonnull final StorageService storageService) {
-        ifInitializedThrowUnmodifiabledComponentException();
+        checkSetterPreconditions();
 
         storage = Constraint.isNotNull(storageService, "StorageService cannot be null");
         final StorageCapabilities caps = storage.getCapabilities();
@@ -87,8 +104,7 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
      * @param client client to use
      */
     public void setHttpClient(@Nonnull final HttpClient client) {
-        ifInitializedThrowUnmodifiabledComponentException();
-        ifDestroyedThrowDestroyedComponentException();
+    	checkSetterPreconditions();
 
         httpClient = Constraint.isNotNull(client, "HttpClient cannot be null");
     }
@@ -99,11 +115,24 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
      * @param params the new client security parameters
      */
     public void setHttpClientSecurityParameters(@Nullable final HttpClientSecurityParameters params) {
-        ifInitializedThrowUnmodifiabledComponentException();
-        ifDestroyedThrowDestroyedComponentException();
+    	checkSetterPreconditions();
 
         httpClientSecurityParameters = params;
     }
+    
+    /** 
+     * Set the forced refresh cooldown period. If a keyset has been refreshed within that period, a new 
+     * refresh (fetching) of that keyset will not be attempted. A duration of {@link Duration#ZERO} disables the 
+     * cooldown period.
+     * 
+     * @param cooldown the duration of the cooldown period.
+     */
+    public void setForcedRefreshCooldown(@Nonnull final Duration cooldown) {
+    	checkSetterPreconditions();
+    	Constraint.isNotNull(cooldown, "Refresh cooldown can not be null");    	
+		Constraint.isFalse(cooldown.isNegative(), "Refresh cooldown must be zero (disabled) or positive");
+		forcedRefreshCooldown =  cooldown;
+	}
 
     /** {@inheritDoc} */
     @Override
@@ -169,7 +198,7 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
             final StorageRecord<?> entry = storage.read(context, key);
             if (entry == null) {
                 log.debug("JWK set '{}' was not in the cache, fetching it", key);
-                return fetchAndStore(context, key, uri, expires);
+                return fetchAndStore(context, key, uri, expires, false);
             } else {
                 final JWKSet cachedSet = JWKSet.parse(entry.getValue());
                 log.debug("Cached JWK set '{}' found and will be returned, expires at {}", key, entry.getExpiration());
@@ -185,23 +214,40 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
     /**
      * Fetches the remote JWK set from the given URI and stores it in the storage service. 
      * 
+     * <p>If overwriteCache is true, if a new JWKSet is fetched successfully, the cache entry is deleted before 
+     * being recreated. The delete is best effort, in that if it fails, we still try to cache a new entry. </p>
+     * 
+     * <p>There is no explicit locking on this method, the worst case would be extra requests to fetch
+     * the JWKSet.</p>
+     * 
      * @param context a context label to subdivide the cache
      * @param cacheKey the key to store the JWK set under in the storage service
      * @param uri value to fetch the JWK set from
      * @param expires time (in milliseconds since beginning of epoch) for disposal of value from cache
+     * @param overwriteCache if true, the cache entry will be deleted before recreated.
+     * 
      * @return the JWK set document if fetched successfully, {@code null} otherwise. 
      * 
      * @since 2.2.0
      */
     @Nullable private JWKSet fetchAndStore(@Nonnull @NotEmpty final String context, @Nonnull final String cacheKey, 
-            @Nonnull final URI uri, @Nonnull final Instant expires) {
+            @Nonnull final URI uri, @Nonnull final Instant expires, final boolean overwriteCache) {
         try {            
             final JWKSet remoteJwkSet = RemoteJwkUtils.fetchRemoteJwkSet("RemoteJwkSetCache", uri, httpClient, 
                     httpClientSecurityParameters);
             if (remoteJwkSet != null && remoteJwkSet.getKeys() != null && !remoteJwkSet.getKeys().isEmpty()) {
                 final String value = remoteJwkSet.toString();
                 assert value != null;
-                storage.create(context, cacheKey, value, expires.toEpochMilli());
+                if (overwriteCache) {
+                	// This is best effort, we ignore the result
+                	storage.delete(context, cacheKey);
+                }
+                final boolean created = storage.create(context, cacheKey, value, expires.toEpochMilli());
+                if (!created) {
+                	log.debug("JWKSet '{}' was not cached", cacheKey);
+                } else {
+                	log.debug("JWKSet '{}' was cached", cacheKey);
+                }
                 return remoteJwkSet;
             } else {
                 log.warn("Could not find any remote keys from {}", cacheKey);
@@ -218,6 +264,10 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
      * from the cache, checks it contains the JWK keyId input, if not it re-fetches the JWK set even if the set has not 
      * expired. This allows keys to be returned when the JWK Set has been updated but has not yet expired e.g. 
      * during key rotation.
+     *
+     * <p>If a forced refresh due to a missing key identifier has been performed recently, the next forced
+     * refresh may be rejected based on the configured forced refresh cooldown period. If so, the cached
+     * JWK set is returned even if it does not contain the requested key identifier.</p>
      * 
      * @param context a context label to subdivide the cache
      * @param uri value to check
@@ -243,20 +293,28 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
             final StorageRecord<?> entry = storage.read(context, key);
             if (entry == null) {
                 log.debug("JWK set '{}' was not in the cache, fetching it", key);
-                return fetchAndStore(context, key, uri, expires);
+                return fetchAndStore(context, key, uri, expires, false);
             } else {
                 final JWKSet cachedSet = JWKSet.parse(entry.getValue());
                 
                 if (cachedSet.getKeyByKeyId(keyId) == null) {
+                	if (recentlyRefreshed(key)) {
+                	    log.debug("Cached JWK set '{}' does not contain keyId '{}', but the forced refresh cooldown is "
+                	            + "active; returning the cached keyset", key, keyId);
+                		return cachedSet;
+                	}
                     // Cached set does not contain the keyId so re-fetch the document and return (does not re-evaluate 
                     // if the key is contained in the fetched document as the document is the latest and nothing else
                     // can be done).
                     log.debug("Cached JWK set does not contain the keyId '{}', ignoring expiry and re-fetching", keyId);
-                    storage.delete(context, key);
-                    return fetchAndStore(context, key, uri, expires);
+                    final JWKSet freshJwkSet = fetchAndStore(context, key, uri, expires, true);
+                     // Record the attempt regardless of whether fetching succeeds, preventing repeated
+                     // requests for an unknown key identifier from bypassing the cooldown.
+                    markForcedRefresh(key);
+                    return freshJwkSet;
                     
                 } else {                
-                    log.debug("Cached JWK set '{}' found and will be returned, expires at {}", key, 
+                    log.debug("Returning cached JWK set for '{}', expires at {}", key, 
                             entry.getExpiration());
                     return cachedSet;
                 }
@@ -268,4 +326,50 @@ public class RemoteJwkSetCache extends AbstractIdentifiableInitializableComponen
         return null;
     }
     
+    /**
+     * Add an entry to the storage service to record a forced keyset refresh has occurred for the given jwksUri.
+     * 
+     * <p>The entry will expire based on the {@code #forcedRefreshCooldown} period, after which a forced refresh 
+     * would be allowed.</p>
+     * 
+     * @param jwksUri the storage key to use, based on the jwks_uri.
+     */
+    private void markForcedRefresh(@Nonnull final String jwksUri) { 
+    	if (forcedRefreshCooldown.isZero()) {
+    	    return;
+    	}
+    	try {
+    		log.trace("Recording forced refresh cooldown for jwks_uri '{}'", jwksUri);
+    		// storageKey is also used for the content
+			storage.create(FORCED_REFRESH_CONTEXT_NAME, jwksUri, jwksUri, 
+					Instant.now().plus(forcedRefreshCooldown).toEpochMilli());
+		} catch (final IOException e) {
+			// Ignore a failure, just means we may attempt refetch more often.
+		}
+    }
+    
+    /**
+     * Check if a refresh was recently forced for a particular jwks_uri. 
+     * 
+     * @param jwksUri the storage key based on the jwks_uri
+     * 
+     * @return true if the jwksUri was force refreshed inside the cooldown period. False otherwise.
+     */
+    private boolean recentlyRefreshed(@Nonnull final String jwksUri) { 
+    	if (forcedRefreshCooldown.isZero()) {
+    	    return false;
+    	}
+		try {
+			final StorageRecord<?> forcedEntry = storage.read(FORCED_REFRESH_CONTEXT_NAME, jwksUri);
+			// If it exists, it has not expired, then we are within the previous window of forced refresh.
+	    	if (forcedEntry != null) {
+	    		return true;
+	    	}
+		} catch (final IOException e) {
+			// Default position is to allow a refresh.
+		}
+		return  false;
+    	
+    }
+    
 }
\ No newline at end of file
diff --git a/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwk/RemoteJwkSetCacheTest.java b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwk/RemoteJwkSetCacheTest.java
index 4631bde3..33ec7768 100644
--- a/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwk/RemoteJwkSetCacheTest.java
+++ b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwk/RemoteJwkSetCacheTest.java
@@ -17,6 +17,7 @@ package net.shibboleth.oidc.jwk;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.time.Duration;
 import java.time.Instant;
 
 import org.apache.hc.client5.http.ClientProtocolException;
@@ -51,6 +52,7 @@ public class RemoteJwkSetCacheTest {
     @BeforeMethod
     public void setup() throws InitializationException, ComponentInitializationException {
         jwkSetCache = new RemoteJwkSetCache();
+        jwkSetCache.setForcedRefreshCooldown(Duration.ZERO);
         storageService = buildStorageService();
     }
     
@@ -107,6 +109,79 @@ public class RemoteJwkSetCacheTest {
         Assert.assertTrue(jwkSet.getKeyByKeyId("key-not-in-keyset") == null);       
     }
     
+    /* A test to check that the original cache persists if an unknown kid triggers a fetch that fails.*/
+    @Test
+    public void testInvalidJwkID_FetchFails_CacheNotEvicted() throws Exception {
+        jwkSetCache.setStorage(storageService);
+        jwkSetCache.setHttpClient(createMockHttpClientWithFailure(validJwkSet()));
+        jwkSetCache.setHttpClientSecurityParameters(null);
+        jwkSetCache.initialize();
+        final String uri = "http://example.org";
+        
+        // Initial lookup to cache keyset
+        jwkSetCache.fetch(new URI(uri), Instant.now().plusSeconds(5000));
+
+        // Now lookup key that is not in the cached set. Fails to refetch IOException. Cache should not be removed
+        JWKSet jwkSet = jwkSetCache.fetch(new URI(uri), "key-not-in-keyset", Instant.now().plusSeconds(500));
+        assert jwkSet == null;
+        Assert.assertNull(jwkSet);        
+        
+        // Fetch a known key from the cache, this should work because the cache was not deleted.
+        jwkSet = jwkSetCache.fetch(new URI(uri), "08d3245c62f86b6362afcbbffe1d069826dd1dc1", 
+        		Instant.now().plusSeconds(500));
+        Assert.assertNotNull(jwkSet);
+        Assert.assertNotNull(jwkSet.getKeyByKeyId("08d3245c62f86b6362afcbbffe1d069826dd1dc1"));
+        
+        // Another lookup key that is not in the cached set. Fails to refetch IOException. Cache should not be removed
+        jwkSet = jwkSetCache.fetch(new URI(uri), "key-not-in-keyset-two", Instant.now().plusSeconds(500));
+        Assert.assertNull(jwkSet);
+        
+    }
+    
+    /*
+     * TestsL
+     *  <ul>
+	 *   <li>Initial fetch caches key set A.</li>
+	 *   <li>An unknown key identifier triggers a refresh to key set B.</li>
+	 *   <li>A subsequent unknown key identifier during the cooldown period returns
+	 *       the cached key set B without refreshing.</li>
+	 *   <li>After the cooldown period expires, another refresh returns key set C.</li>
+	 * </ul>
+	*/
+    @Test
+    public void testInvalidJwkID_RefetchNotAttemptedWithinCooldown() throws Exception {
+        jwkSetCache.setStorage(storageService);
+        jwkSetCache.setHttpClient(
+        		createMockHttpClientWithAdditionalKeysets(validJwkSet(), validJwkSetB(), validJwkSetC()));
+        jwkSetCache.setHttpClientSecurityParameters(null);
+        jwkSetCache.setForcedRefreshCooldown(Duration.ofSeconds(2));
+        jwkSetCache.initialize();
+        final String uri = "http://example.org";
+        
+        // Initial lookup to cache keyset A
+        jwkSetCache.fetch(new URI(uri), Instant.now().plusSeconds(5000));
+        
+        // should trigger a refresh, which gets back key-b which contains the key
+        JWKSet jwkSet = jwkSetCache.fetch(new URI(uri), "key-in-keyset-b", Instant.now().plusSeconds(500));
+        Assert.assertNotNull(jwkSet);
+        Assert.assertNotNull(jwkSet.getKeyByKeyId("key-in-keyset-b"));
+        
+        // should not trigger a refresh as in the refresh cooldown window, used cached, which does not contain key-c
+        jwkSet = jwkSetCache.fetch(new URI(uri), "key-in-keyset-c", Instant.now().plusSeconds(500));
+        Assert.assertNotNull(jwkSet);
+        // check old key exists in the cache response
+        Assert.assertNotNull(jwkSet.getKeyByKeyId("key-in-keyset-b"));
+        // check no new key in cache response
+        Assert.assertNull(jwkSet.getKeyByKeyId("key-in-keyset-c"));
+        
+        // Wait past the point the refresh cooldown has expired, refetch key-c from keySetC
+        Thread.sleep(3000);
+        jwkSet = jwkSetCache.fetch(new URI(uri), "key-in-keyset-c", Instant.now().plusSeconds(500));
+        Assert.assertNotNull(jwkSet);
+        Assert.assertNotNull(jwkSet.getKeyByKeyId("key-in-keyset-c"));
+        
+    }
+    
     @Test
     public void testKeyIdNotInCachedSet_Refetch() throws Exception{
         jwkSetCache.setStorage(storageService);
@@ -150,42 +225,111 @@ public class RemoteJwkSetCacheTest {
         return httpClient;
     }
     
+    protected HttpClient createMockHttpClientWithFailure(final String output) 
+    			throws ClientProtocolException, IOException {
+        final HttpClient httpClient = Mockito.mock(HttpClient.class);
+        final ClassicHttpResponse httpResponse = Mockito.mock(ClassicHttpResponse.class);
+        Mockito.when(httpResponse.getEntity()).thenReturn(new StringEntity(output));
+        Mockito.when(httpClient.executeOpen(Mockito.any(), (ClassicHttpRequest) Mockito.any(), 
+                (HttpContext) Mockito.any())).thenReturn(httpResponse)
+        		.thenThrow(new IOException("Failure"));
+        return httpClient;
+    }
+    
+    protected HttpClient createMockHttpClientWithAdditionalKeysets(final String keySetA, final String KeySetB, 
+    		final String keySetC) 
+			throws ClientProtocolException, IOException {
+    	final HttpClient httpClient = Mockito.mock(HttpClient.class);
+
+        final ClassicHttpResponse responseA = Mockito.mock(ClassicHttpResponse.class);
+        Mockito.when(responseA.getEntity()).thenReturn(new StringEntity(keySetA));
+
+        final ClassicHttpResponse responseB = Mockito.mock(ClassicHttpResponse.class);
+        Mockito.when(responseB.getEntity()).thenReturn(new StringEntity(KeySetB));
+
+        final ClassicHttpResponse responseC = Mockito.mock(ClassicHttpResponse.class);
+        Mockito.when(responseC.getEntity()).thenReturn(new StringEntity(keySetC));
+
+        Mockito.when(httpClient.executeOpen(
+                Mockito.any(),
+                (ClassicHttpRequest) Mockito.any(),
+                (HttpContext) Mockito.any()))
+            .thenReturn(responseA)
+            .thenReturn(responseB)
+            .thenReturn(responseC);
+	    return httpClient;
+    }
+    
     protected String validJwkSet() {
-        return "{\n" + 
-                "  \"keys\": [\n" + 
-                "    {\n" + 
-                "      \"kid\": \"08d3245c62f86b6362afcbbffe1d069826dd1dc1\",\n" + 
-                "      \"e\": \"AQAB\",\n" + 
-                "      \"kty\": \"RSA\",\n" + 
-                "      \"alg\": \"RS256\",\n" + 
-                "      \"n\": \"mSLCSG1hK28xrzcSfgbvRinkIRjecBlwsQggynHppHiiT6I80waivIqTJBSFYyVuRCAHXi6apSsL5FUWKd42GOhVUayIyzvuz1CqTuh5a9ACXaJjEVLUFO39QfXxWrxhpSJCTN9aMkdtoV1QJqfAd3IF9MYwfojsoEn3d5XX5TX4RxqZ9-HGbgSLsRuAzFIg9NxxfTYhbECBskhhR4RIcam-1T52FafmK2LMiuIEDPiVg6LvAqWi8gdMRd8WhiP_ZIRJTCH4C0NFKmw1PZyKadVxvwg97vwPTF8qkFdwJ_kjQAMmq77PxankluAkfWjFqbD4JepO4HH3aJvU8Sl_Ow\",\n" + 
-                "      \"use\": \"sig\"\n" + 
-                "    },\n" + 
-                "    {\n" + 
-                "      \"alg\": \"RS256\",\n" + 
-                "      \"n\": \"uS9Iep_r83oLpfnMXLnB5a8IVUP7ZRreM1rxNWYnaqEQr1NfRisyIi4cYG7KbWiuLCmRQOD7ybhpdHCcN9ty5evz4irWT5hIa98Jr3a2BISTskBbPmBgUR3_TuQ_fvxeQYCCETJUcho5gXK-yeDWJwcD2iwqpVzIZHz8BBe5AYFUlJMzwgzYMe9aqoOEWVv__Gd7Z_kaz5pa0lOsWUUPNFmeW4e4rtNvosx7ItyyyghIyG2KX-0phOgbfzG6Ub6qA9upBYK9KBtjcoe1ciV-Yn_3HaS5PlugYTo1zYnng1mW7UP5A_QT_HgDqD1clcz0WIEL6usVMRay87ECEmOhrw\",\n" + 
-                "      \"use\": \"sig\",\n" + 
-                "      \"kid\": \"b15a2b8f7a6b3f6bc08bc1c56a88410e146d01fd\",\n" + 
-                "      \"e\": \"AQAB\",\n" + 
-                "      \"kty\": \"RSA\"\n" + 
-                "    }\n" + 
-                "  ]\n" + 
-                "}";
+        return """
+			{
+			  "keys": [
+			    {
+			      "kid": "08d3245c62f86b6362afcbbffe1d069826dd1dc1",
+			      "e": "AQAB",
+			      "kty": "RSA",
+			      "alg": "RS256",
+			      "n": "mSLCSG1hK28xrzcSfgbvRinkIRjecBlwsQggynHppHiiT6I80waivIqTJBSFYyVuRCAHXi6apSsL5FUWKd42GOhVUayIyzvuz1CqTuh5a9ACXaJjEVLUFO39QfXxWrxhpSJCTN9aMkdtoV1QJqfAd3IF9MYwfojsoEn3d5XX5TX4RxqZ9-HGbgSLsRuAzFIg9NxxfTYhbECBskhhR4RIcam-1T52FafmK2LMiuIEDPiVg6LvAqWi8gdMRd8WhiP_ZIRJTCH4C0NFKmw1PZyKadVxvwg97vwPTF8qkFdwJ_kjQAMmq77PxankluAkfWjFqbD4JepO4HH3aJvU8Sl_Ow",
+			      "use": "sig"
+			    },
+			    {
+			      "alg": "RS256",
+			      "n": "uS9Iep_r83oLpfnMXLnB5a8IVUP7ZRreM1rxNWYnaqEQr1NfRisyIi4cYG7KbWiuLCmRQOD7ybhpdHCcN9ty5evz4irWT5hIa98Jr3a2BISTskBbPmBgUR3_TuQ_fvxeQYCCETJUcho5gXK-yeDWJwcD2iwqpVzIZHz8BBe5AYFUlJMzwgzYMe9aqoOEWVv__Gd7Z_kaz5pa0lOsWUUPNFmeW4e4rtNvosx7ItyyyghIyG2KX-0phOgbfzG6Ub6qA9upBYK9KBtjcoe1ciV-Yn_3HaS5PlugYTo1zYnng1mW7UP5A_QT_HgDqD1clcz0WIEL6usVMRay87ECEmOhrw",
+			      "use": "sig",
+			      "kid": "b15a2b8f7a6b3f6bc08bc1c56a88410e146d01fd",
+			      "e": "AQAB",
+			      "kty": "RSA"
+			    }
+			  ]
+			}""";
+    }
+    
+    protected String validJwkSetB() {
+        return """
+			{
+			  "keys": [
+			    {
+			      "kid": "key-in-keyset-b",
+			      "e": "AQAB",
+			      "kty": "RSA",
+			      "alg": "RS256",
+			      "n": "mSLCSG1hK28xrzcSfgbvRinkIRjecBlwsQggynHppHiiT6I80waivIqTJBSFYyVuRCAHXi6apSsL5FUWKd42GOhVUayIyzvuz1CqTuh5a9ACXaJjEVLUFO39QfXxWrxhpSJCTN9aMkdtoV1QJqfAd3IF9MYwfojsoEn3d5XX5TX4RxqZ9-HGbgSLsRuAzFIg9NxxfTYhbECBskhhR4RIcam-1T52FafmK2LMiuIEDPiVg6LvAqWi8gdMRd8WhiP_ZIRJTCH4C0NFKmw1PZyKadVxvwg97vwPTF8qkFdwJ_kjQAMmq77PxankluAkfWjFqbD4JepO4HH3aJvU8Sl_Ow",
+			      "use": "sig"
+			    }			    
+			  ]
+			}""";
+    }
+    
+    protected String validJwkSetC() {
+        return """
+			{
+			  "keys": [
+			    {
+			      "kid": "key-in-keyset-c",
+			      "e": "AQAB",
+			      "kty": "RSA",
+			      "alg": "RS256",
+			      "n": "mSLCSG1hK28xrzcSfgbvRinkIRjecBlwsQggynHppHiiT6I80waivIqTJBSFYyVuRCAHXi6apSsL5FUWKd42GOhVUayIyzvuz1CqTuh5a9ACXaJjEVLUFO39QfXxWrxhpSJCTN9aMkdtoV1QJqfAd3IF9MYwfojsoEn3d5XX5TX4RxqZ9-HGbgSLsRuAzFIg9NxxfTYhbECBskhhR4RIcam-1T52FafmK2LMiuIEDPiVg6LvAqWi8gdMRd8WhiP_ZIRJTCH4C0NFKmw1PZyKadVxvwg97vwPTF8qkFdwJ_kjQAMmq77PxankluAkfWjFqbD4JepO4HH3aJvU8Sl_Ow",
+			      "use": "sig"
+			    }
+			  ]
+			}""";
     }
     
     protected String rotatedValidJwkSet() {
-        return "{\n" + 
-                "  \"keys\": [\n" + 
-                "    {\n" + 
-                "      \"kid\": \"key-in-rotated-keyset\",\n" + 
-                "      \"e\": \"AQAB\",\n" + 
-                "      \"kty\": \"RSA\",\n" + 
-                "      \"alg\": \"RS256\",\n" + 
-                "      \"n\": \"mSLCSG1hK28xrzcSfgbvRinkIRjecBlwsQggynHppHiiT6I80waivIqTJBSFYyVuRCAHXi6apSsL5FUWKd42GOhVUayIyzvuz1CqTuh5a9ACXaJjEVLUFO39QfXxWrxhpSJCTN9aMkdtoV1QJqfAd3IF9MYwfojsoEn3d5XX5TX4RxqZ9-HGbgSLsRuAzFIg9NxxfTYhbECBskhhR4RIcam-1T52FafmK2LMiuIEDPiVg6LvAqWi8gdMRd8WhiP_ZIRJTCH4C0NFKmw1PZyKadVxvwg97vwPTF8qkFdwJ_kjQAMmq77PxankluAkfWjFqbD4JepO4HH3aJvU8Sl_Ow\",\n" + 
-                "      \"use\": \"sig\"\n" + 
-                "    }" +
-                "  ]\n" + 
-                "}";
+        return """
+			{
+			  "keys": [
+			    {
+			      "kid": "key-in-rotated-keyset",
+			      "e": "AQAB",
+			      "kty": "RSA",
+			      "alg": "RS256",
+			      "n": "mSLCSG1hK28xrzcSfgbvRinkIRjecBlwsQggynHppHiiT6I80waivIqTJBSFYyVuRCAHXi6apSsL5FUWKd42GOhVUayIyzvuz1CqTuh5a9ACXaJjEVLUFO39QfXxWrxhpSJCTN9aMkdtoV1QJqfAd3IF9MYwfojsoEn3d5XX5TX4RxqZ9-HGbgSLsRuAzFIg9NxxfTYhbECBskhhR4RIcam-1T52FafmK2LMiuIEDPiVg6LvAqWi8gdMRd8WhiP_ZIRJTCH4C0NFKmw1PZyKadVxvwg97vwPTF8qkFdwJ_kjQAMmq77PxankluAkfWjFqbD4JepO4HH3aJvU8Sl_Ow",
+			      "use": "sig"
+			    }\
+			  ]
+			}""";
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list