Search in sources :

Example 1 with Get

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);
    }
}
Also used : Path(java.nio.file.Path) HttpsJwks(org.jose4j.jwk.HttpsJwks) Get(org.jose4j.http.Get) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) URL(java.net.URL) SASL_OAUTHBEARER_JWKS_ENDPOINT_URL(org.apache.kafka.common.config.SaslConfigs.SASL_OAUTHBEARER_JWKS_ENDPOINT_URL)

Aggregations

URL (java.net.URL)1 Path (java.nio.file.Path)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 SASL_OAUTHBEARER_JWKS_ENDPOINT_URL (org.apache.kafka.common.config.SaslConfigs.SASL_OAUTHBEARER_JWKS_ENDPOINT_URL)1 Get (org.jose4j.http.Get)1 HttpsJwks (org.jose4j.jwk.HttpsJwks)1