public class SecureProperties extends Properties
Properties that allows storing and reading encrypted values by given encryption
algorithm. For recognition whether value is encrypted or not, default or given suffix is added to the end of
encrypted value.defaults| Constructor and Description |
|---|
SecureProperties(EncryptionAlgorithm encryptionAlgorithm)
Creates a new properties that will use given encryption algorithm.
|
SecureProperties(EncryptionAlgorithm encryptionAlgorithm,
String encryptedPropertySuffix)
Creates a new properties that will use given encryption algorithm and given suffix will be used for recognition
whether value is encrypted or not.
|
SecureProperties(Properties defaults,
EncryptionAlgorithm encryptionAlgorithm)
Creates a new properties that will use given encryption algorithm.
|
SecureProperties(Properties defaults,
EncryptionAlgorithm encryptionAlgorithm,
String encryptedPropertySuffix)
Creates a new properties that will use given encryption algorithm and given suffix will be used for recognition
whether value is encrypted or not.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getOriginalProperty(String key)
Gets original property value under given key.
|
String |
getProperty(String key) |
String |
getProperty(String key,
String defaultValue) |
boolean |
isEncrypted(String key)
Checks whether property under given key is encrypted.
|
Object |
setEncryptedProperty(String key,
String value)
Have the same functionality as
Properties.setProperty(String, String) but the value gets encrypted before it gets
stored within properties. |
boolean |
validateValue(String key,
String expectedValue)
Validates whether given expected value is equal to the value in the properties under given key.
|
list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNamesclear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, valuespublic SecureProperties(EncryptionAlgorithm encryptionAlgorithm)
DEFAULT_ENCRYPTED_SUFFIX suffix will be used for recognition whether value is encrypted or not.encryptionAlgorithm - algorithm used for encryptionpublic SecureProperties(Properties defaults, EncryptionAlgorithm encryptionAlgorithm)
DEFAULT_ENCRYPTED_SUFFIX suffix will be used for recognition whether value is encrypted or not.defaults - initial values for propertiesencryptionAlgorithm - algorithm used for encryptionpublic SecureProperties(EncryptionAlgorithm encryptionAlgorithm, String encryptedPropertySuffix)
encryptionAlgorithm - algorithm used for encryptionencryptedPropertySuffix - suffix used for recognition of encrypted values (will be trimmed)public SecureProperties(Properties defaults, EncryptionAlgorithm encryptionAlgorithm, String encryptedPropertySuffix)
defaults - initial values for propertiesencryptionAlgorithm - algorithm used for encryptionencryptedPropertySuffix - suffix used for recognition of encrypted values (will be trimmed)IllegalArgumentException - possible exception if given suffix is null or 0-lengthpublic Object setEncryptedProperty(String key, String value)
Properties.setProperty(String, String) but the value gets encrypted before it gets
stored within properties. The value gets automatically decrypted when getProperty(String) or
getProperty(String, String) is called.key - key of the property to be setvalue - value to be encrypted and setpublic String getOriginalProperty(String key)
getProperty(String) or
getProperty(String, String) instead.key - key of the property to be readpublic String getProperty(String key)
If the property ends with given suffix (specified in constructor or default), it gets decrypted by defined
encryption algorithm. Note that EncryptionException can be thrown if encrypted property cannot be
decrypted by given algorithm.
getProperty in class Propertieskey - key of the property to be readpublic String getProperty(String key, String defaultValue)
If the property ends with given suffix (specified in constructor or default), it gets decrypted by defined
encryption algorithm. Note that EncryptionException can be thrown if encrypted property cannot be
decrypted by given algorithm.
getProperty in class Propertieskey - key of the property to be readdefaultValue - default value if property is not setpublic boolean isEncrypted(String key)
key - key of property to be checkedpublic boolean validateValue(String key, String expectedValue)
key - key of propertyexpectedValue - expected value of propertyCopyright © 2014. All rights reserved.