use of org.jose4j.http.Get in project kafka by apache.
the class VerificationKeyResolverFactory method create.
public static CloseableVerificationKeyResolver create(Map<String, ?> configs, String saslMechanism, Map<String, Object> jaasConfig) {
ConfigurationUtils cu = new ConfigurationUtils(configs, saslMechanism);
URL jwksEndpointUrl = cu.validateUrl(SASL_OAUTHBEARER_JWKS_ENDPOINT_URL);
if (jwksEndpointUrl.getProtocol().toLowerCase(Locale.ROOT).equals("file")) {
Path p = cu.validateFile(SASL_OAUTHBEARER_JWKS_ENDPOINT_URL);
return new JwksFileVerificationKeyResolver(p);
} else {
long refreshIntervalMs = cu.validateLong(SASL_OAUTHBEARER_JWKS_ENDPOINT_REFRESH_MS, true, 0L);
JaasOptionsUtils jou = new JaasOptionsUtils(jaasConfig);
SSLSocketFactory sslSocketFactory = null;
if (jou.shouldCreateSSLSocketFactory(jwksEndpointUrl))
sslSocketFactory = jou.createSSLSocketFactory();
HttpsJwks httpsJwks = new HttpsJwks(jwksEndpointUrl.toString());
httpsJwks.setDefaultCacheDuration(refreshIntervalMs);
if (sslSocketFactory != null) {
Get get = new Get();
get.setSslSocketFactory(sslSocketFactory);
httpsJwks.setSimpleHttpGet(get);
}
RefreshingHttpsJwks refreshingHttpsJwks = new RefreshingHttpsJwks(Time.SYSTEM, httpsJwks, refreshIntervalMs, cu.validateLong(SASL_OAUTHBEARER_JWKS_ENDPOINT_RETRY_BACKOFF_MS), cu.validateLong(SASL_OAUTHBEARER_JWKS_ENDPOINT_RETRY_BACKOFF_MAX_MS));
return new RefreshingHttpsJwksVerificationKeyResolver(refreshingHttpsJwks);
}
}
Aggregations