Class Config

java.lang.Object
io.strimzi.kafka.oauth.common.Config
Direct Known Subclasses:
GlobalConfig

public class Config extends Object
Configuration handling class
  • Field Details

    • OAUTH_CLIENT_ID

      public static final String OAUTH_CLIENT_ID
      The name of 'oauth.client.id' config option
      See Also:
    • OAUTH_CLIENT_SECRET

      public static final String OAUTH_CLIENT_SECRET
      The name of 'oauth.client.secret' config option
      See Also:
    • OAUTH_SCOPE

      public static final String OAUTH_SCOPE
      The name of 'oauth.scope' config option
      See Also:
    • OAUTH_AUDIENCE

      public static final String OAUTH_AUDIENCE
      The name of 'oauth.audience' config option
      See Also:
    • OAUTH_USERNAME_CLAIM

      public static final String OAUTH_USERNAME_CLAIM
      The name of 'oauth.username.claim' config option
      See Also:
    • OAUTH_USERNAME_PREFIX

      public static final String OAUTH_USERNAME_PREFIX
      The name of 'oauth.username.prefix' config option
      See Also:
    • OAUTH_FALLBACK_USERNAME_CLAIM

      public static final String OAUTH_FALLBACK_USERNAME_CLAIM
      The name of 'oauth.fallback.username.claim' config option
      See Also:
    • OAUTH_FALLBACK_USERNAME_PREFIX

      public static final String OAUTH_FALLBACK_USERNAME_PREFIX
      The name of 'oauth.fallback.username.prefix' config option
      See Also:
    • OAUTH_SSL_TRUSTSTORE_LOCATION

      public static final String OAUTH_SSL_TRUSTSTORE_LOCATION
      The name of 'oauth.ssl.truststore.location' config option
      See Also:
    • OAUTH_SSL_TRUSTSTORE_CERTIFICATES

      public static final String OAUTH_SSL_TRUSTSTORE_CERTIFICATES
      The name of 'oauth.ssl.truststore.certificates' config option
      See Also:
    • OAUTH_SSL_TRUSTSTORE_PASSWORD

      public static final String OAUTH_SSL_TRUSTSTORE_PASSWORD
      The name of 'oauth.ssl.truststore.password' config option
      See Also:
    • OAUTH_SSL_TRUSTSTORE_TYPE

      public static final String OAUTH_SSL_TRUSTSTORE_TYPE
      The name of 'oauth.ssl.truststore.type' config option
      See Also:
    • OAUTH_SSL_SECURE_RANDOM_IMPLEMENTATION

      public static final String OAUTH_SSL_SECURE_RANDOM_IMPLEMENTATION
      The name of 'oauth.ssl.secure.random.implementation' config option
      See Also:
    • OAUTH_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM

      public static final String OAUTH_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM
      The name of 'oauth.ssl.endpoint.identification.algorithm' config option
      See Also:
    • OAUTH_ACCESS_TOKEN_IS_JWT

      public static final String OAUTH_ACCESS_TOKEN_IS_JWT
      The name of 'oauth.access.token.is.jwt' config option
      See Also:
    • OAUTH_CONNECT_TIMEOUT_SECONDS

      public static final String OAUTH_CONNECT_TIMEOUT_SECONDS
      The name of 'oauth.connect.timeout.seconds' config option
      See Also:
    • OAUTH_READ_TIMEOUT_SECONDS

      public static final String OAUTH_READ_TIMEOUT_SECONDS
      The name of 'oauth.read.timeout.seconds' config option
      See Also:
    • OAUTH_HTTP_RETRIES

      public static final String OAUTH_HTTP_RETRIES
      The name of 'oauth.http.retries' config option
      See Also:
    • OAUTH_HTTP_RETRY_PAUSE_MILLIS

      public static final String OAUTH_HTTP_RETRY_PAUSE_MILLIS
      The name of 'oauth.http.retry.pause.millis' config option
      See Also:
    • OAUTH_CONFIG_ID

      public static final String OAUTH_CONFIG_ID
      The name of 'oauth.config.id' config option
      See Also:
    • OAUTH_ENABLE_METRICS

      public static final String OAUTH_ENABLE_METRICS
      The name of 'oauth.enable.metrics' config option
      See Also:
    • OAUTH_INCLUDE_ACCEPT_HEADER

      public static final String OAUTH_INCLUDE_ACCEPT_HEADER
      Whether http requests should include "application/json" when being sent to the upstream OIDC server.
      See Also:
    • OAUTH_TOKENS_NOT_JWT

      @Deprecated public static final String OAUTH_TOKENS_NOT_JWT
      Deprecated.
      The name of 'oauth.tokens.not.jwt' config option
      See Also:
  • Constructor Details

    • Config

      public Config()
      Use this construtor if you only want to lookup configuration in system properties and env without any default configuration.
    • Config

      public Config(Properties p)
      Use this constructor to provide default values in case some configuration is not set through system properties or ENV.
      Parameters:
      p - Default property values
    • Config

      public Config(Config delegate)
      Use this constructor if you want to wrap another Config object and override some functionality

      You only need to override getValue(String, String) in your extending class.

      Parameters:
      delegate - The Config object to delegate to
    • Config

      public Config(Map<String,?> p)
      Use this constructor to provide default values in case some configuration is not set through system properties or ENV.
      Parameters:
      p - Default property values
  • Method Details

    • validate

      public void validate()
      Validate configuration by checking for unknown or missing properties.

      Override this method to provide custom validation.

      Throws:
      RuntimeException - if validation fails
    • getValue

      public String getValue(String key, String fallback)
      Get value for property key, returning fallback value if configuration for key is not found.

      This method first checks if system property exists for the key. If not, it checks if env variable exists with the name derived from the key:

         key.toUpperCase().replace('-', '_').replace('.', '_');
       
      If not, it checks if env variable with name equal to key exists.

      Ultimately, it checks the defaults passed at Config object construction time.

      If no configuration is found for key, it returns the fallback value.

      Parameters:
      key - Config key
      fallback - Fallback value
      Returns:
      Configuration value for specified key
    • getValue

      public final String getValue(String key)
      Get value for property key or null if not found
      Parameters:
      key - Config key
      Returns:
      Config value
    • getValueAsInt

      public final int getValueAsInt(String key, int fallback)
      Get value for property key as int or fallback value if not found
      Parameters:
      key - Config key
      fallback - Fallback value
      Returns:
      Config value
    • getValueAsLong

      public final long getValueAsLong(String key, long fallback)
      Get value for property key as long or fallback value if not found
      Parameters:
      key - Config key
      fallback - Fallback value
      Returns:
      Config value
    • getValueAsBoolean

      public final boolean getValueAsBoolean(String key, boolean fallback)
      Get value for property key as boolean or fallback value if not found

      Valid values are: "true", "false", "yes", "no", "y", "n", "1", "0"

      Parameters:
      key - Config key
      fallback - Fallback value
      Returns:
      Config value
    • getValueAsURI

      public final URI getValueAsURI(String key)
      Get value for property key as a URI
      Parameters:
      key - Config key
      Returns:
      Config value
    • isTrue

      public static boolean isTrue(String result)
      Helper method the test if some boolean config option is set to 'true' or 'false'
      Parameters:
      result - The configured value of the option as String
      Returns:
      The boolean value of the option
    • toEnvName

      public static String toEnvName(String key)
      Convert property key to env key.

      Property key is converted to all uppercase, then all '.' and '-' characters are converted to '_'

      Parameters:
      key - A key of a property which should be converted to environment variable name
      Returns:
      A name which should be used for environment variable