Class JwksFetchServiceClient
- All Implemented Interfaces:
Closeable, AutoCloseable
Used during expedited key refresh: when a broker encounters an unknown JWT kid,
it calls the regional JWKS Fetch Service to retrieve the latest key set directly,
bypassing the normal rbac-extractor propagation pipeline.
fetchJwks(String) is non-blocking by construction: it runs the blocking HTTP
exchange on an owned, bounded thread pool and returns a CompletableFuture. The calling
(e.g. authentication) thread is never blocked on the network, regardless of caller discipline.
SVID rotation is handled automatically by the SPIRE-backed SSLContext's
underlying KeyManager/TrustManager.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhy a fetch did not produce a key set.static final recordOutcome of afetchJwks(String)call: exactly one ofkeySet(success) orfailureReason(failure) is non-null. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static Optional<JwksFetchServiceClient> create(Map<String, ?> configs, SSLContext sslContext) Creates a client from broker config, orOptional.empty()if no fetch-service URL is configured.Fetches a JWKS from the regional JWKS Fetch Service.
-
Method Details
-
create
Creates a client from broker config, orOptional.empty()if no fetch-service URL is configured. The URL, request timeout, and fetch-thread pool size are read fromConfluentConfigshere so callers pass a config map rather than a positional parameter list; their defaults live inConfluentConfigs. ThesslContextis supplied separately because it comes from SPIRE wiring, not the config.An empty/blank URL means expedited refresh has nowhere to fetch from, so no client (and no thread pool) is built; the caller treats the empty result as "fetch service not configured".
- Parameters:
configs- the broker config map (already validated against the brokerConfigDef)sslContext- the SPIRE-backed mTLS context for the fetch-service connection
-
fetchJwks
Fetches a JWKS from the regional JWKS Fetch Service. The blocking HTTP exchange runs on the client's owned thread pool, so the calling thread is never blocked.- Parameters:
jwksUri- the upstream JWKS URI to fetch (will be URL-encoded as a query parameter)- Returns:
- a future that always completes (never completes exceptionally) with a
JwksFetchServiceClient.FetchOutcomecarrying the parsedJsonWebKeySeton success, or aJwksFetchServiceClient.FetchFailureReasonon any error; nevernull
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-