Package com.auth0.jwk

Interface JwksHttpClient

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface JwksHttpClient
Abstraction for fetching JWKS JSON over HTTP.

Implement this interface to control how the library makes HTTP requests. This allows customization of TLS settings, proxy authentication, HTTP version, and any other transport concern.

This is a functional interface, so a lambda can be used:


 JwksHttpClient client = url -> {
     // Use any HTTP library (OkHttp, Apache HC, Java 11 HttpClient, etc.)
     Request req = new Request.Builder().url(url).build();
     try (Response resp = okHttp.newCall(req).execute()) {
         return new JwksHttpResponse(resp.body().string(), resp.headers().toMultimap());
     }
 };

 JwkProvider provider = new JwkProviderBuilder(domain)
     .httpClient(client)
     .build();
 

If no custom client is provided, the library uses a default implementation based on URLConnection.

  • Method Summary

    Modifier and Type
    Method
    Description
    fetch(URL url)
    Fetch the JWKS JSON from the given URL.
  • Method Details

    • fetch

      JwksHttpResponse fetch(URL url) throws IOException
      Fetch the JWKS JSON from the given URL.

      Implementations should:

      • Make an HTTP GET request to the URL
      • Return the response body and headers wrapped in a JwksHttpResponse
      • Throw IOException on any network or protocol error
      Parameters:
      url - the JWKS endpoint URL
      Returns:
      the HTTP response containing the body and headers
      Throws:
      IOException - on any network or protocol error