Class DecryptingPropertySource
- All Implemented Interfaces:
PropertySource
PropertySource decorator that transparently decrypts encrypted property values.
This implementation wraps a delegate PropertySource and attempts to decrypt any retrieved
property value using a configured Encryption strategy.
Decryption is only applied to values identified as encrypted via Encryption.isEncrypted(String).
Values that are not encrypted are returned as-is.
The encryption strategy is determined through the default Fluxzero property source using the
ENCRYPTION_KEY or encryption_key property. This includes environment variables, system properties,
configured additional locations, application property files, and Fluxzero defaults according to
DefaultPropertySource precedence. If no key is found, a no-op fallback is used, meaning decryption will be
skipped.
To enable encrypted property support in a Fluxzero application, ensure the appropriate key is present, e.g.:
export ENCRYPTION_KEY=ChaCha20|mYbAse64ENcodedKeY==
- See Also:
-
Field Summary
Fields inherited from interface PropertySource
substitutionPattern -
Constructor Summary
ConstructorsConstructorDescriptionDecryptingPropertySource(PropertySource delegate) Constructs aDecryptingPropertySourcewith the specified delegate property source.DecryptingPropertySource(PropertySource delegate, Encryption encryption) Constructs aDecryptingPropertySourceusing an explicitEncryptionstrategy.DecryptingPropertySource(PropertySource delegate, String encryptionKey) Constructs aDecryptingPropertySourceusing the given encryption key. -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertySource
andThen, containsProperty, get, getBoolean, getBoolean, getInteger, getInteger, require, substituteProperties, substituteProperties
-
Constructor Details
-
DecryptingPropertySource
Constructs aDecryptingPropertySourcewith the specified delegate property source. By default, the encryption key is fetched from theDefaultPropertySourceusing the keysENCRYPTION_KEYorencryption_key.- Parameters:
delegate- the property source to wrap and decrypt values from
-
DecryptingPropertySource
Constructs aDecryptingPropertySourceusing the given encryption key.If the provided key is invalid or unrecognized, a no-op encryption fallback is used.
- Parameters:
delegate- the property source to wrapencryptionKey- the Base64-encoded encryption key in the formalgorithm|key
-
DecryptingPropertySource
Constructs aDecryptingPropertySourceusing an explicitEncryptionstrategy.- Parameters:
delegate- the property source to wrapencryption- the encryption strategy to apply to values
-
-
Method Details
-
get
Returns the decrypted value of the given property name.If the underlying property is encrypted (i.e.,
Encryption.isEncrypted(String)istrue), it is decrypted using the configuredEncryptionimplementation. Otherwise, the raw value is returned unchanged.Values are cached after the first decryption attempt for efficiency.
- Specified by:
getin interfacePropertySource- Parameters:
name- the property key- Returns:
- the decrypted or original property value, or
nullif not found
-