org.owasp.esapi
Class EncryptedProperties

java.lang.Object
  extended byorg.owasp.esapi.EncryptedProperties
All Implemented Interfaces:
IEncryptedProperties

public class EncryptedProperties
extends java.lang.Object
implements IEncryptedProperties

Reference implementation of the IEncryptedProperties interface. This implementation wraps a normal properties file, and creates surrogates for the getProperty and setProperty methods that perform encryption and decryption based on the 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.

Since:
June 1, 2007
Author:
Jeff Williams (jeff.williams .at. aspectsecurity.com) Aspect Security
See Also:
IEncryptedProperties

Constructor Summary
EncryptedProperties()
          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()
          Key set.
 void load(java.io.InputStream in)
          Load.
static void main(java.lang.String[] args)
          The main method.
 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)
          Store.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncryptedProperties

public EncryptedProperties()
Instantiates a new encrypted properties.

Method Detail

getProperty

public java.lang.String getProperty(java.lang.String key)
                             throws EncryptionException
Description copied from interface: IEncryptedProperties
Gets the property value from the encrypted store, decrypts it, and returns the plaintext value to the caller.

Specified by:
getProperty in interface IEncryptedProperties
Parameters:
key - the key
Returns:
the property
Throws:
EncryptionException - the encryption exception

setProperty

public java.lang.String setProperty(java.lang.String key,
                                    java.lang.String value)
                             throws EncryptionException
Description copied from interface: IEncryptedProperties
Encrypts the plaintext property value and stores the ciphertext value in the encrypted store.

Specified by:
setProperty in interface IEncryptedProperties
Parameters:
key - the key
value - the value
Returns:
the object
Throws:
EncryptionException - the encryption exception

keySet

public java.util.Set keySet()
Key set.

Returns:
the set

load

public void load(java.io.InputStream in)
          throws java.io.IOException
Load.

Parameters:
in - the in
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

store

public void store(java.io.OutputStream out,
                  java.lang.String comments)
           throws java.io.IOException
Store.

Parameters:
out - the out
comments - the comments
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
The main method.

Parameters:
args - the arguments
Throws:
java.lang.Exception - the exception