Package io.strimzi.kafka.oauth.common
Class Config
java.lang.Object
io.strimzi.kafka.oauth.common.Config
- Direct Known Subclasses:
GlobalConfig
Configuration handling class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of 'oauth.access.token.is.jwt' config optionstatic final StringThe name of 'oauth.audience' config optionstatic final StringThe name of 'oauth.client.id' config optionstatic final StringThe name of 'oauth.client.secret' config optionstatic final StringThe name of 'oauth.config.id' config optionstatic final StringThe name of 'oauth.connect.timeout.seconds' config optionstatic final StringThe name of 'oauth.enable.metrics' config optionstatic final StringThe name of 'oauth.fallback.username.claim' config optionstatic final StringThe name of 'oauth.fallback.username.prefix' config optionstatic final StringThe name of 'oauth.http.retries' config optionstatic final StringThe name of 'oauth.http.retry.pause.millis' config optionstatic final StringWhether http requests should include "application/json" when being sent to the upstream OIDC server.static final StringThe name of 'oauth.read.timeout.seconds' config optionstatic final StringThe name of 'oauth.scope' config optionstatic final StringThe name of 'oauth.ssl.endpoint.identification.algorithm' config optionstatic final StringThe name of 'oauth.ssl.secure.random.implementation' config optionstatic final StringThe name of 'oauth.ssl.truststore.certificates' config optionstatic final StringThe name of 'oauth.ssl.truststore.location' config optionstatic final StringThe name of 'oauth.ssl.truststore.password' config optionstatic final StringThe name of 'oauth.ssl.truststore.type' config optionstatic final StringDeprecated.static final StringThe name of 'oauth.username.claim' config optionstatic final StringThe name of 'oauth.username.prefix' config option -
Constructor Summary
ConstructorsConstructorDescriptionConfig()Use this construtor if you only want to lookup configuration in system properties and env without any default configuration.Use this constructor if you want to wrap another Config object and override some functionalityUse this constructor to provide default values in case some configuration is not set through system properties or ENV.Config(Properties p) Use this constructor to provide default values in case some configuration is not set through system properties or ENV. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringGet value for property key or null if not foundGet value for property key, returning fallback value if configuration for key is not found.final booleangetValueAsBoolean(String key, boolean fallback) Get value for property key as boolean or fallback value if not foundfinal intgetValueAsInt(String key, int fallback) Get value for property key as int or fallback value if not foundfinal longgetValueAsLong(String key, long fallback) Get value for property key as long or fallback value if not foundfinal URIgetValueAsURI(String key) Get value for property key as a URIstatic booleanHelper method the test if some boolean config option is set to 'true' or 'false'static StringConvert property key to env key.voidvalidate()Validate configuration by checking for unknown or missing properties.
-
Field Details
-
OAUTH_CLIENT_ID
The name of 'oauth.client.id' config option- See Also:
-
OAUTH_CLIENT_SECRET
The name of 'oauth.client.secret' config option- See Also:
-
OAUTH_SCOPE
The name of 'oauth.scope' config option- See Also:
-
OAUTH_AUDIENCE
The name of 'oauth.audience' config option- See Also:
-
OAUTH_USERNAME_CLAIM
The name of 'oauth.username.claim' config option- See Also:
-
OAUTH_USERNAME_PREFIX
The name of 'oauth.username.prefix' config option- See Also:
-
OAUTH_FALLBACK_USERNAME_CLAIM
The name of 'oauth.fallback.username.claim' config option- See Also:
-
OAUTH_FALLBACK_USERNAME_PREFIX
The name of 'oauth.fallback.username.prefix' config option- See Also:
-
OAUTH_SSL_TRUSTSTORE_LOCATION
The name of 'oauth.ssl.truststore.location' config option- See Also:
-
OAUTH_SSL_TRUSTSTORE_CERTIFICATES
The name of 'oauth.ssl.truststore.certificates' config option- See Also:
-
OAUTH_SSL_TRUSTSTORE_PASSWORD
The name of 'oauth.ssl.truststore.password' config option- See Also:
-
OAUTH_SSL_TRUSTSTORE_TYPE
The name of 'oauth.ssl.truststore.type' config option- See Also:
-
OAUTH_SSL_SECURE_RANDOM_IMPLEMENTATION
The name of 'oauth.ssl.secure.random.implementation' config option- See Also:
-
OAUTH_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM
The name of 'oauth.ssl.endpoint.identification.algorithm' config option- See Also:
-
OAUTH_ACCESS_TOKEN_IS_JWT
The name of 'oauth.access.token.is.jwt' config option- See Also:
-
OAUTH_CONNECT_TIMEOUT_SECONDS
The name of 'oauth.connect.timeout.seconds' config option- See Also:
-
OAUTH_READ_TIMEOUT_SECONDS
The name of 'oauth.read.timeout.seconds' config option- See Also:
-
OAUTH_HTTP_RETRIES
The name of 'oauth.http.retries' config option- See Also:
-
OAUTH_HTTP_RETRY_PAUSE_MILLIS
The name of 'oauth.http.retry.pause.millis' config option- See Also:
-
OAUTH_CONFIG_ID
The name of 'oauth.config.id' config option- See Also:
-
OAUTH_ENABLE_METRICS
The name of 'oauth.enable.metrics' config option- See Also:
-
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.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
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
Use this constructor if you want to wrap another Config object and override some functionalityYou only need to override
getValue(String, String)in your extending class.- Parameters:
delegate- The Config object to delegate to
-
Config
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
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 keyfallback- Fallback value- Returns:
- Configuration value for specified key
-
getValue
Get value for property key or null if not found- Parameters:
key- Config key- Returns:
- Config value
-
getValueAsInt
Get value for property key as int or fallback value if not found- Parameters:
key- Config keyfallback- Fallback value- Returns:
- Config value
-
getValueAsLong
Get value for property key as long or fallback value if not found- Parameters:
key- Config keyfallback- Fallback value- Returns:
- Config value
-
getValueAsBoolean
Get value for property key as boolean or fallback value if not foundValid values are: "true", "false", "yes", "no", "y", "n", "1", "0"
- Parameters:
key- Config keyfallback- Fallback value- Returns:
- Config value
-
getValueAsURI
Get value for property key as a URI- Parameters:
key- Config key- Returns:
- Config value
-
isTrue
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
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
-