|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.owasp.esapi.reference.crypto.DefaultEncryptedProperties
public class DefaultEncryptedProperties
Reference implementation of the 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
.
A very simple main program is provided that can be used to create an encrypted properties file. A better approach would be to allow unencrypted properties in the file and to encrypt them the first time the file is accessed.
EncryptedProperties
Constructor Summary | |
---|---|
DefaultEncryptedProperties()
Instantiates a new encrypted properties. |
Method Summary | |
---|---|
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.util.Set |
keySet()
Returns a Set view of properties. |
void |
load(java.io.InputStream in)
Reads a property list (key and element pairs) from the input stream. |
static void |
main(java.lang.String[] args)
Deprecated. Use EncryptedPropertiesUtils instead, which allows creating, reading,
and writing encrypted properties. |
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. |
void |
store(java.io.OutputStream out,
java.lang.String comments)
Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultEncryptedProperties()
Method Detail |
---|
public java.lang.String getProperty(java.lang.String key) throws EncryptionException
getProperty
in interface EncryptedProperties
key
- the name of the property to get
EncryptionException
- if the property could not be decryptedpublic java.lang.String setProperty(java.lang.String key, java.lang.String value) throws EncryptionException
setProperty
in interface EncryptedProperties
key
- the name of the property to setvalue
- the value of the property to set
null
if it did not have one.
EncryptionException
- if the property could not be encryptedpublic java.util.Set keySet()
keySet
in interface EncryptedProperties
public void load(java.io.InputStream in) throws java.io.IOException
load
in interface EncryptedProperties
in
- the input stream that contains the properties file
java.io.IOException
- Signals that an I/O exception has occurred.public void store(java.io.OutputStream out, java.lang.String comments) throws java.io.IOException
store
in interface EncryptedProperties
out
- the output stream that contains the properties filecomments
- a description of the property list (ex. "Encrypted Properties File").
java.io.IOException
- Signals that an I/O exception has occurred.public static void main(java.lang.String[] args) throws java.lang.Exception
EncryptedPropertiesUtils
instead, which allows creating, reading,
and writing encrypted properties.
args
- the location of the properties file to load and write to
java.lang.Exception
- Any exception thrown
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |