public class Config
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
OAUTH_ACCESS_TOKEN_IS_JWT
The name of 'oauth.access.token.is.jwt' config option
|
static java.lang.String |
OAUTH_AUDIENCE
The name of 'oauth.audience' config option
|
static java.lang.String |
OAUTH_CLIENT_ID
The name of 'oauth.client.id' config option
|
static java.lang.String |
OAUTH_CLIENT_SECRET
The name of 'oauth.client.secret' config option
|
static java.lang.String |
OAUTH_CONFIG_ID
The name of 'oauth.config.id' config option
|
static java.lang.String |
OAUTH_CONNECT_TIMEOUT_SECONDS
The name of 'oauth.connect.timeout.seconds' config option
|
static java.lang.String |
OAUTH_ENABLE_METRICS
The name of 'oauth.enable.metrics' config option
|
static java.lang.String |
OAUTH_FALLBACK_USERNAME_CLAIM
The name of 'oauth.fallback.username.claim' config option
|
static java.lang.String |
OAUTH_FALLBACK_USERNAME_PREFIX
The name of 'oauth.fallback.username.prefix' config option
|
static java.lang.String |
OAUTH_HTTP_RETRIES
The name of 'oauth.http.retries' config option
|
static java.lang.String |
OAUTH_HTTP_RETRY_PAUSE_MILLIS
The name of 'oauth.http.retry.pause.millis' config option
|
static java.lang.String |
OAUTH_INCLUDE_ACCEPT_HEADER
Whether http requests should include "application/json" when being sent to the upstream OIDC server.
|
static java.lang.String |
OAUTH_READ_TIMEOUT_SECONDS
The name of 'oauth.read.timeout.seconds' config option
|
static java.lang.String |
OAUTH_SCOPE
The name of 'oauth.scope' config option
|
static java.lang.String |
OAUTH_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM
The name of 'oauth.ssl.endpoint.identification.algorithm' config option
|
static java.lang.String |
OAUTH_SSL_SECURE_RANDOM_IMPLEMENTATION
The name of 'oauth.ssl.secure.random.implementation' config option
|
static java.lang.String |
OAUTH_SSL_TRUSTSTORE_CERTIFICATES
The name of 'oauth.ssl.truststore.certificates' config option
|
static java.lang.String |
OAUTH_SSL_TRUSTSTORE_LOCATION
The name of 'oauth.ssl.truststore.location' config option
|
static java.lang.String |
OAUTH_SSL_TRUSTSTORE_PASSWORD
The name of 'oauth.ssl.truststore.password' config option
|
static java.lang.String |
OAUTH_SSL_TRUSTSTORE_TYPE
The name of 'oauth.ssl.truststore.type' config option
|
static java.lang.String |
OAUTH_TOKENS_NOT_JWT
Deprecated.
|
static java.lang.String |
OAUTH_USERNAME_CLAIM
The name of 'oauth.username.claim' config option
|
static java.lang.String |
OAUTH_USERNAME_PREFIX
The name of 'oauth.username.prefix' config option
|
| Constructor and Description |
|---|
Config()
Use this construtor if you only want to lookup configuration in system properties and env
without any default configuration.
|
Config(Config delegate)
Use this constructor if you want to wrap another Config object and override some functionality
|
Config(java.util.Map<java.lang.String,?> p)
Use this constructor to provide default values in case some configuration is not set through system properties or ENV.
|
Config(java.util.Properties p)
Use this constructor to provide default values in case some configuration is not set through system properties or ENV.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getValue(java.lang.String key)
Get value for property key or null if not found
|
java.lang.String |
getValue(java.lang.String key,
java.lang.String fallback)
Get value for property key, returning fallback value if configuration for key is not found.
|
boolean |
getValueAsBoolean(java.lang.String key,
boolean fallback)
Get value for property key as boolean or fallback value if not found
|
int |
getValueAsInt(java.lang.String key,
int fallback)
Get value for property key as int or fallback value if not found
|
long |
getValueAsLong(java.lang.String key,
long fallback)
Get value for property key as long or fallback value if not found
|
java.net.URI |
getValueAsURI(java.lang.String key)
Get value for property key as a URI
|
static boolean |
isTrue(java.lang.String result)
Helper method the test if some boolean config option is set to 'true' or 'false'
|
static java.lang.String |
toEnvName(java.lang.String key)
Convert property key to env key.
|
void |
validate()
Validate configuration by checking for unknown or missing properties.
|
public static final java.lang.String OAUTH_CLIENT_ID
public static final java.lang.String OAUTH_CLIENT_SECRET
public static final java.lang.String OAUTH_SCOPE
public static final java.lang.String OAUTH_AUDIENCE
public static final java.lang.String OAUTH_USERNAME_CLAIM
public static final java.lang.String OAUTH_USERNAME_PREFIX
public static final java.lang.String OAUTH_FALLBACK_USERNAME_CLAIM
public static final java.lang.String OAUTH_FALLBACK_USERNAME_PREFIX
public static final java.lang.String OAUTH_SSL_TRUSTSTORE_LOCATION
public static final java.lang.String OAUTH_SSL_TRUSTSTORE_CERTIFICATES
public static final java.lang.String OAUTH_SSL_TRUSTSTORE_PASSWORD
public static final java.lang.String OAUTH_SSL_TRUSTSTORE_TYPE
public static final java.lang.String OAUTH_SSL_SECURE_RANDOM_IMPLEMENTATION
public static final java.lang.String OAUTH_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM
public static final java.lang.String OAUTH_ACCESS_TOKEN_IS_JWT
public static final java.lang.String OAUTH_CONNECT_TIMEOUT_SECONDS
public static final java.lang.String OAUTH_READ_TIMEOUT_SECONDS
public static final java.lang.String OAUTH_HTTP_RETRIES
public static final java.lang.String OAUTH_HTTP_RETRY_PAUSE_MILLIS
public static final java.lang.String OAUTH_CONFIG_ID
public static final java.lang.String OAUTH_ENABLE_METRICS
public static final java.lang.String OAUTH_INCLUDE_ACCEPT_HEADER
@Deprecated public static final java.lang.String OAUTH_TOKENS_NOT_JWT
public Config()
public Config(java.util.Properties p)
p - Default property valuespublic Config(Config delegate)
You only need to override getValue(String, String) in your extending class.
delegate - The Config object to delegate topublic Config(java.util.Map<java.lang.String,?> p)
p - Default property valuespublic void validate()
Override this method to provide custom validation.
java.lang.RuntimeException - if validation failspublic java.lang.String getValue(java.lang.String key,
java.lang.String fallback)
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.
key - Config keyfallback - Fallback valuepublic final java.lang.String getValue(java.lang.String key)
key - Config keypublic final int getValueAsInt(java.lang.String key,
int fallback)
key - Config keyfallback - Fallback valuepublic final long getValueAsLong(java.lang.String key,
long fallback)
key - Config keyfallback - Fallback valuepublic final boolean getValueAsBoolean(java.lang.String key,
boolean fallback)
Valid values are: "true", "false", "yes", "no", "y", "n", "1", "0"
key - Config keyfallback - Fallback valuepublic final java.net.URI getValueAsURI(java.lang.String key)
key - Config keypublic static boolean isTrue(java.lang.String result)
result - The configured value of the option as Stringpublic static java.lang.String toEnvName(java.lang.String key)
Property key is converted to all uppercase, then all '.' and '-' characters are converted to '_'
key - A key of a property which should be converted to environment variable nameCopyright © 2024. All rights reserved.