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 using the ENCRYPTION_KEY environment variable or system property.
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 aDecryptingPropertySourceusing a delegate and automatically resolves the encryption key from system or environment variables.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, require, substituteProperties, substituteProperties
-
Constructor Details
-
DecryptingPropertySource
Constructs aDecryptingPropertySourceusing a delegate and automatically resolves the encryption key from system or environment variables.It looks for the
ENCRYPTION_KEYorencryption_keyin the following order:- Environment variable
ENCRYPTION_KEY - Environment variable
encryption_key - System property
ENCRYPTION_KEY - System property
encryption_key
If no key is found, a no-op encryption fallback is used.
- Parameters:
delegate- the property source to wrap
- Environment variable
-
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
-