Class JdkAuthFactory

java.lang.Object
io.apicurio.registry.client.common.auth.JdkAuthFactory

public class JdkAuthFactory extends Object
Factory class for creating authentication-enabled components for JDK HttpClient. Provides OAuth2 client credentials flow and Basic authentication support.
  • Method Details

    • buildBasicAuthHeaderValue

      public static String buildBasicAuthHeaderValue(String username, String password)
      Creates a Basic authentication header value.
      Parameters:
      username - the username
      password - the password
      Returns:
      the Base64-encoded Authorization header value (e.g., "Basic dXNlcjpwYXNz")
    • buildProxyAuthenticator

      public static Authenticator buildProxyAuthenticator(String username, String password)
      Creates an Authenticator for proxy authentication.
      Parameters:
      username - the proxy username
      password - the proxy password
      Returns:
      an Authenticator configured for the proxy credentials
    • buildOAuth2TokenProvider

      public static JdkAuthFactory.TokenProvider buildOAuth2TokenProvider(HttpClient httpClient, String tokenEndpoint, String clientId, String clientSecret, String scope)
      Creates an OAuth2 token provider that handles client credentials flow. The token provider caches tokens and automatically refreshes them before expiry.
      Parameters:
      httpClient - the HttpClient to use for token requests
      tokenEndpoint - the OAuth2 token endpoint URL
      clientId - the OAuth2 client ID
      clientSecret - the OAuth2 client secret
      scope - the OAuth2 scope (optional, can be null)
      Returns:
      a TokenProvider that supplies valid access tokens