KeyStoreJwkKeyResolver implements SigningKeyResolver { public KeyStoreJwkKeyResolver(KeyStore keyStore, String url, SSLContext sslContext) { if (LOG.isDebugEnabled()) { LOG.debug("KeyStoreJwkKeyResolver:JWK URL: " + url); } this.keyStore = keyStore; this.jwksResolver = new JwtsSigningKeyResolver(url, sslContext, true); } KeyStoreJwkKeyResolver(KeyStore keyStore, String url, SSLContext sslContext); @Override @SuppressWarnings("rawtypes") Key resolveSigningKey(JwsHeader header, Claims claims); @Override @SuppressWarnings("rawtypes") Key resolveSigningKey(JwsHeader header, String plaintext);  }
@Test public void testKeyStoreJwkKeyResolver() throws MalformedURLException { KeyStoreJwkKeyResolver resolver = null; BiFunction<Field, KeyStoreJwkKeyResolver, Object> getFieldValue = (f, object) -> { try { f.setAccessible(true); return f.get(object); } catch (IllegalArgumentException | IllegalAccessException e) { throw new RuntimeException(e); } }; resolver = new KeyStoreJwkKeyResolver(null, null, null); assertNotNull(resolver); for (Field f : resolver.getClass().getDeclaredFields()) { switch (f.getName()) { case "keyStore": assertNull(getFieldValue.apply(f, resolver)); break; case "jwksResolver": assertNotNull(getFieldValue.apply(f, resolver)); break; } } resolver = new KeyStoreJwkKeyResolver(null, "file: assertNotNull(resolver); for (Field f : resolver.getClass().getDeclaredFields()) { switch (f.getName()) { case "keyStore": assertNull(getFieldValue.apply(f, resolver)); break; case "jwksResolver": assertNotNull(getFieldValue.apply(f, resolver)); break; } } resolver = new KeyStoreJwkKeyResolver(baseKeyStore, "file: assertNotNull(resolver); for (Field f : resolver.getClass().getDeclaredFields()) { switch (f.getName()) { case "keyStore": assertSame(getFieldValue.apply(f, resolver), baseKeyStore); break; case "jwksResolver": assertNotNull(getFieldValue.apply(f, resolver)); break; } } }