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 Flux application, ensure the appropriate key is present, e.g.:
export ENCRYPTION_KEY=ChaCha20|mYbAse64ENcodedKeY==
- See Also:
-
Field Summary
Fields inherited from interface io.fluxcapacitor.common.application.PropertySource
substitutionPattern
-
Constructor Summary
ConstructorsConstructorDescriptionDecryptingPropertySource
(PropertySource delegate) Constructs aDecryptingPropertySource
using a delegate and automatically resolves the encryption key from system or environment variables.DecryptingPropertySource
(PropertySource delegate, Encryption encryption) Constructs aDecryptingPropertySource
using an explicitEncryption
strategy.DecryptingPropertySource
(PropertySource delegate, String encryptionKey) Constructs aDecryptingPropertySource
using the given encryption key. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.common.application.PropertySource
andThen, containsProperty, get, getBoolean, getBoolean, require, substituteProperties
-
Constructor Details
-
DecryptingPropertySource
Constructs aDecryptingPropertySource
using a delegate and automatically resolves the encryption key from system or environment variables.It looks for the
ENCRYPTION_KEY
orencryption_key
in 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 aDecryptingPropertySource
using 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 aDecryptingPropertySource
using an explicitEncryption
strategy.- 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 configuredEncryption
implementation. Otherwise, the raw value is returned unchanged.Values are cached after the first decryption attempt for efficiency.
- Specified by:
get
in interfacePropertySource
- Parameters:
name
- the property key- Returns:
- the decrypted or original property value, or
null
if not found
-