Class PropertyPlaceholderResolver

java.lang.Object
com.priint.pubserver.util.PropertyPlaceholderResolver

public final class PropertyPlaceholderResolver extends Object
Resolves sensitive configuration values that may be expressed as MicroProfile Config placeholders.

This utility enables dynamic substitution of secrets in custom XML configuration files (parsed by internal parsers) without storing them in plain text. It supports a minimal placeholder syntax:


 <password>${minio.secret.key}</password>
 

Resolution rules

  • Backward compatible: if the input does not match the ${...} pattern, it is treated as a legacy plain-text value and returned unchanged.
  • MicroProfile Config integration: for values matching ${...}, the key inside braces is resolved using ConfigProvider.getConfig() and getOptionalValue(key, String.class).
  • Fallback behavior: if the key is not present in any MicroProfile Config source (e.g. environment variables, system properties, Payara-integrated secret sources), a warning is logged and the original raw input is returned to preserve existing deployments.
  • No defaults / no recursion: the resolver expects a simple key (e.g. ${a.b}), does not support default values (e.g. ${a.b:default}) and does not perform nested or recursive resolution.
  • Safety: log messages must never include resolved secret values; only the key and an optional field description are logged.

Typical usage is to call

invalid reference
#resolve(String, String)
just before a sensitive value is used (or persisted into runtime configuration objects) inside custom XML parsers.

Example:


 String passwordRaw = readTagText("password");
 String password = PropertyPlaceholderResolver.resolve(passwordRaw, "MinIO password");
 
  • Method Details

    • resolve

      public static String resolve(String rawValue)
      Resolves an input string that may be a MicroProfile Config placeholder in the ${key} form.

      If rawValue is not a placeholder, the method returns it unchanged (legacy behavior). If it is a placeholder, the method attempts to resolve the key using MicroProfile Config. When the key cannot be resolved (missing source or runtime issues), the method logs a warning and returns the original raw value to maintain compatibility with existing installations.

      Parameters:
      rawValue - the value read from configuration (e.g. from an XML element text node); may be null. Leading/trailing whitespace is ignored for placeholder detection.
      Returns:
      the resolved secret value when a placeholder is detected and the key exists in MicroProfile Config; otherwise the original rawValue (including when rawValue is null).