Class DefaultJwtRetriever

java.lang.Object
org.apache.kafka.common.security.oauthbearer.DefaultJwtRetriever
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.security.oauthbearer.internals.secured.OAuthBearerConfigurable, JwtRetriever

public class DefaultJwtRetriever extends Object implements JwtRetriever
DefaultJwtRetriever instantiates and delegates JwtRetriever API calls to an embedded implementation based on configuration:
  • If the value of sasl.oauthbearer.token.endpoint.url is set to a value that starts with the file protocol (e.g. file:/tmp/path/to/a/static-jwt.json), an instance of FileJwtRetriever will be used as the underlying JwtRetriever. Otherwise, the URL is assumed to be an HTTP/HTTPS-based URL, and an instance of ClientCredentialsRequestFormatter will be created and used.
The configuration required by the individual JwtRetriever classes will likely differ. Please refer to the official Apache Kafka documentation for more information on these, and related configuration.
  • Constructor Details

    • DefaultJwtRetriever

      public DefaultJwtRetriever()
  • Method Details

    • configure

      public void configure(Map<String,?> configs, String saslMechanism, List<AppConfigurationEntry> jaasConfigEntries)
      Specified by:
      configure in interface org.apache.kafka.common.security.oauthbearer.internals.secured.OAuthBearerConfigurable
    • retrieve

      public String retrieve() throws JwtRetrieverException
      Description copied from interface: JwtRetriever
      Retrieves a JWT access token in its serialized three-part form. The implementation is free to determine how it should be retrieved but should not perform validation on the result. Note: This is a blocking function and callers should be aware that the implementation may be communicating over a network, with the file system, coordinating threads, etc. The facility in the LoginModule from which this is ultimately called does not provide an asynchronous approach.
      Specified by:
      retrieve in interface JwtRetriever
      Returns:
      Non-null JWT access token string
      Throws:
      JwtRetrieverException - Thrown on errors related to IO during retrieval
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.kafka.common.security.oauthbearer.internals.secured.OAuthBearerConfigurable
      Throws:
      IOException