Package org.keycloak.config
Class WildcardOptionsUtil
java.lang.Object
org.keycloak.config.WildcardOptionsUtil
Utility class for working with configuration options that use wildcards.
Wildcard options are configuration keys that contain a variable segment enclosed between WILDCARD_START and WILDCARD_END characters.
Wildcard options in Keycloak always end with the variable segment.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetWildcardNamedKey(String wildcardKey, String value) Generates a concrete configuration key by replacing the wildcard placeholder with a specific value.static StringgetWildcardPrefix(String wildcardKey) Extracts the prefix part of a wildcard key.static StringgetWildcardValue(Option<?> option, String namedKey) Extracts the name that replaces the wildcard placeholder from a fully qualified configuration key.static booleanisWildcardOption(String key) Determines whether the given configuration key represents a wildcard option (contains variable segment)
-
Field Details
-
WILDCARD_START
Marker indicating the start of a wildcard segment in a configuration key.- See Also:
-
WILDCARD_END
Marker indicating the end of a wildcard segment in a configuration key.- See Also:
-
-
Constructor Details
-
WildcardOptionsUtil
public WildcardOptionsUtil()
-
-
Method Details
-
isWildcardOption
Determines whether the given configuration key represents a wildcard option (contains variable segment)Examples:
isWildcardOption("tracing-header-<header>") → "true" isWildcardOption("tracing-header-<headxxx") → "false" isWildcardOption("tracing-header-headxxx>") → "false" isWildcardOption("db-kind-<datasource>") → "true" isWildcardOption("http-port") → "false" isWildcardOption("quarkus.<sth>.end") → "true"- Parameters:
key- the configuration key to check- Returns:
trueif the key represents a wildcard option
-
getWildcardPrefix
Extracts the prefix part of a wildcard key. You should always check the presence of the wildcard via theisWildcardOption(String).Examples:
getWildcardPrefix("tracing-header-<header>") → "tracing-header-" getWildcardPrefix("db-kind-<datasource>") → "db-kind-"- Parameters:
wildcardKey- a configuration key that includes a wildcard segment- Returns:
- the prefix before the wildcard marker, otherwise
null
-
getWildcardNamedKey
Generates a concrete configuration key by replacing the wildcard placeholder with a specific value. You should always check the presence of the wildcard via theisWildcardOption(String).Examples:
getWildcardNamedKey("tracing-header-<header>", "Authorization") → "tracing-header-Authorization" getWildcardNamedKey("db-kind-<datasource>", "user-store") → "db-kind-user-store"- Parameters:
wildcardKey- a configuration key that includes a wildcard segmentvalue- the value to replace the wildcard with- Returns:
- the resolved key, otherwise
null
-
getWildcardValue
Extracts the name that replaces the wildcard placeholder from a fully qualified configuration key.Examples:
getWildcardValue(TracingOptions.TRACING_HEADER, "tracing-header-Authorization") → "Authorization" getWildcardValue(DatabaseOptions.DB_ENABLED_DATASOURCE, "db-enabled-my-store") → "my-store" getWildcardValue(DatabaseOptions.DB_ENABLED_DATASOURCE, "kc.db-enabled-my-store") → "my-store"- Parameters:
option- the option containing a wildcard keynamedKey- the fully qualified (resolved) configuration key- Returns:
- the part of
namedKeythat replaces the wildcard inoption.getKey(), otherwisenull
-