public class ReferenceEncryptedProperties extends java.util.Properties implements EncryptedProperties
EncryptedProperties interface. This
implementation wraps a normal properties file, and creates surrogates for the
getProperty and setProperty methods that perform encryption
and decryption based on Encryptor.
This implementation differs from DefaultEncryptedProperties in that
it actually extends from java.util.Properties for applications that need an
instance of that class. In order to do so, the getProperty and
setProperty methods were modified to throw EncryptionRuntimeException
instead of EncryptionException.
EncryptedProperties,
DefaultEncryptedProperties,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String[] |
GET_ERROR_MESSAGES |
private Logger |
logger
The logger.
|
private static long |
serialVersionUID
serverVersionUID; use format of YYYYMMDD.
|
private static java.lang.String[] |
SET_ERROR_MESSAGES |
| Constructor and Description |
|---|
ReferenceEncryptedProperties()
Instantiates a new encrypted properties.
|
ReferenceEncryptedProperties(java.util.Properties defaults) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Enumeration |
elements()
This method has been overridden to throw an
UnsupportedOperationException |
java.util.Set |
entrySet()
This method has been overridden to throw an
UnsupportedOperationException |
java.lang.String |
getProperty(java.lang.String key)
Gets the property value from the encrypted store, decrypts it, and
returns the plaintext value to the caller.
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue) |
void |
list(java.io.PrintStream out)
This method has been overridden to throw an
UnsupportedOperationException |
void |
list(java.io.PrintWriter out)
This method has been overridden to throw an
UnsupportedOperationException |
void |
load(java.io.InputStream in)
Reads a property list (key and element pairs) from the input stream.
|
void |
load(java.io.Reader in)
For JDK 1.5 compatibility, this method has been overridden convert the Reader
into an InputStream and call the superclass constructor.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
This method has been overridden to only accept Strings for key and value, and to encrypt
those Strings before storing them.
|
java.lang.String |
setProperty(java.lang.String key,
java.lang.String value)
Encrypts the plaintext property value and stores the ciphertext value
in the encrypted store.
|
java.lang.String |
toString()
This method has been overridden to not print out the keys and values stored in this properties file.
|
java.util.Collection |
values()
This method has been overridden to throw an
UnsupportedOperationException |
loadFromXML, propertyNames, save, store, store, storeToXML, storeToXML, stringPropertyNamesclear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, sizefinalize, getClass, notify, notifyAll, wait, wait, waitkeySet, storeprivate static final long serialVersionUID
private final Logger logger
private static final java.lang.String[] GET_ERROR_MESSAGES
private static final java.lang.String[] SET_ERROR_MESSAGES
public ReferenceEncryptedProperties()
public ReferenceEncryptedProperties(java.util.Properties defaults)
public java.lang.String getProperty(java.lang.String key)
throws EncryptionRuntimeException
getProperty in interface EncryptedPropertiesgetProperty in class java.util.Propertieskey - the name of the property to getEncryptionRuntimeException - Thrown if decryption fails.public java.lang.String getProperty(java.lang.String key,
java.lang.String defaultValue)
throws EncryptionRuntimeException
getProperty in class java.util.PropertiesEncryptionRuntimeException - Thrown if decryption fails.public java.lang.String setProperty(java.lang.String key,
java.lang.String value)
throws EncryptionRuntimeException
setProperty in interface EncryptedPropertiessetProperty in class java.util.Propertieskey - the name of the property to setvalue - the value of the property to setnull if it did not have one.EncryptionRuntimeException - Thrown if encryption fails.public void load(java.io.InputStream in)
throws java.io.IOException
load in interface EncryptedPropertiesload in class java.util.Propertiesin - the input stream that contains the properties filejava.io.IOException - Thrown if input stream invalid or does not
correspond to Java properties file format.public void load(java.io.Reader in)
throws java.io.IOException
load in class java.util.Propertiesjava.io.IOException - Thrown if Reader input stream invalid or does not
correspond to Java properties file format.public void list(java.io.PrintStream out)
UnsupportedOperationExceptionlist in class java.util.Propertiespublic void list(java.io.PrintWriter out)
UnsupportedOperationExceptionlist in class java.util.Propertiespublic java.util.Collection values()
UnsupportedOperationExceptionvalues in interface java.util.Map<java.lang.Object,java.lang.Object>values in class java.util.Hashtable<java.lang.Object,java.lang.Object>public java.util.Set entrySet()
UnsupportedOperationExceptionentrySet in interface java.util.Map<java.lang.Object,java.lang.Object>entrySet in class java.util.Hashtable<java.lang.Object,java.lang.Object>public java.util.Enumeration elements()
UnsupportedOperationExceptionelements in class java.util.Hashtable<java.lang.Object,java.lang.Object>public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
setProperty
to add values to the Properties map. If an outside class does erroneously call this method
with non-String parameters an IllegalArgumentException will be thrown.put in interface java.util.Map<java.lang.Object,java.lang.Object>put in class java.util.Hashtable<java.lang.Object,java.lang.Object>key - A String key to addvalue - A String value to addnull
if the key did not exist.public java.lang.String toString()
toString in class java.util.Hashtable<java.lang.Object,java.lang.Object>