Package com.priint.pubserver.util
Class PropertyPlaceholderResolver
java.lang.Object
com.priint.pubserver.util.PropertyPlaceholderResolver
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 usingConfigProvider.getConfig()andgetOptionalValue(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 #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 Summary
-
Method Details
-
resolve
Resolves an input string that may be a MicroProfile Config placeholder in the${key}form.If
rawValueis 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 benull. Leading/trailing whitespace is ignored for placeholder detection.fieldDescription- optional human-readable context used only for logging (e.g. "MinIO password"); may benullor blank.- Returns:
- the resolved secret value when a placeholder is detected and the key exists in MicroProfile Config;
otherwise the original
rawValue(including whenrawValueisnull).
-