Closed adFrej closed 1 year ago
Thanks @adFrej, we will look into this this week.
We should be able to just unwrap the ExecutionException
in the GuavaCachedJwkProvider
:
@Override
public Jwk get(final String keyId) throws JwkException {
try {
String cacheKey = keyId == null ? NULL_KID_KEY : keyId;
return cache.get(cacheKey, () -> provider.get(keyId));
} catch (ExecutionException e) {
if (e.getCause() instanceof JwkException) {
throw (JwkException) e.getCause();
}
throw new JwkException("Unable to obtain key with kid " + keyId, e);
}
}
I'll get a PR up shortly.
Describe the problem
As per: examples we should be able to catch NetworkException when getting JWK using cached JwkProviderBuilder. But in here that error is caught and replaced with SigningKeyNotFoundException (as ExecutionException includes NetworkException):
This basically recreates the issue: #79.
What was the expected behavior?
NetworkException being thrown directly from:
JwkProviderBuilder(URL(...)).cached(...).build().get(...)
method when unable to connect to the url.Reproduction
val provider = JwkProviderBuilder(URL(urlPath)).cached(10, 1, TimeUnit.MINUTES).build()
provider.get(keyId)
Failed to get key with kid ****
java.util.concurrent.ExecutionException: com.auth0.jwk.NetworkException: Cannot obtain jwks from url ****
Environment