Class WildcardOptionsUtil

java.lang.Object
org.keycloak.config.WildcardOptionsUtil

public class WildcardOptionsUtil extends Object
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 Details

    • WILDCARD_START

      public static final String WILDCARD_START
      Marker indicating the start of a wildcard segment in a configuration key.
      See Also:
    • WILDCARD_END

      public static final String WILDCARD_END
      Marker indicating the end of a wildcard segment in a configuration key.
      See Also:
  • Constructor Details

    • WildcardOptionsUtil

      public WildcardOptionsUtil()
  • Method Details

    • isWildcardOption

      public static boolean isWildcardOption(String key)
      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:
      true if the key represents a wildcard option
    • getWildcardPrefix

      public static String getWildcardPrefix(String wildcardKey)
      Extracts the prefix part of a wildcard key. You should always check the presence of the wildcard via the isWildcardOption(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

      public static String getWildcardNamedKey(String wildcardKey, String value)
      Generates a concrete configuration key by replacing the wildcard placeholder with a specific value. You should always check the presence of the wildcard via the isWildcardOption(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 segment
      value - the value to replace the wildcard with
      Returns:
      the resolved key, otherwise null
    • getWildcardValue

      public static String getWildcardValue(Option<?> option, String namedKey)
      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 key
      namedKey - the fully qualified (resolved) configuration key
      Returns:
      the part of namedKey that replaces the wildcard in option.getKey(), otherwise null