com.mindbright.util
Class EncryptedProperties

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byjava.util.Properties
              extended bycom.mindbright.util.EncryptedProperties
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class EncryptedProperties
extends java.util.Properties

Handles an encrypted properties file.

See Also:
Serialized Form

Field Summary
static java.lang.String CIPHER_KEY
          Property holding the name of the encryption algorithm used
static java.lang.String CONTENTS_KEY
          Property holding the encrypted content
static java.lang.String HASH_KEY
          Property holding a hash of the encrypted data
static java.lang.String PROPS_HEADER
          Property identifying the file
static java.lang.String SIZE_KEY
          Property holding the size of the encrypted content
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
EncryptedProperties()
          Create a new instance of EncryptedProperties without any default values.
EncryptedProperties(java.util.Properties defaultProperties)
          Create a new instance of EncryptedProperties with the given default values.
 
Method Summary
 boolean isNormalPropsFile()
          Checks if the underlying properties file was encrypted or not
 void load(java.io.InputStream in, java.lang.String password)
          Load and decrypt properties
 java.lang.Object remove(java.lang.Object key)
           
 void save(java.io.OutputStream out, java.lang.String header, java.lang.String password, java.lang.String cipherName)
          Save the properties to an encrypted file.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HASH_KEY

public static final java.lang.String HASH_KEY
Property holding a hash of the encrypted data

See Also:
Constant Field Values

CIPHER_KEY

public static final java.lang.String CIPHER_KEY
Property holding the name of the encryption algorithm used

See Also:
Constant Field Values

CONTENTS_KEY

public static final java.lang.String CONTENTS_KEY
Property holding the encrypted content

See Also:
Constant Field Values

SIZE_KEY

public static final java.lang.String SIZE_KEY
Property holding the size of the encrypted content

See Also:
Constant Field Values

PROPS_HEADER

public static final java.lang.String PROPS_HEADER
Property identifying the file

See Also:
Constant Field Values
Constructor Detail

EncryptedProperties

public EncryptedProperties()
Create a new instance of EncryptedProperties without any default values.


EncryptedProperties

public EncryptedProperties(java.util.Properties defaultProperties)
Create a new instance of EncryptedProperties with the given default values.

Method Detail

isNormalPropsFile

public boolean isNormalPropsFile()
Checks if the underlying properties file was encrypted or not

Returns:
true if the file was no encrypted

save

public void save(java.io.OutputStream out,
                 java.lang.String header,
                 java.lang.String password,
                 java.lang.String cipherName)
          throws java.io.IOException
Save the properties to an encrypted file.

Parameters:
out - strean to save to
header - header string which is saved before properties
password - encryption key
cipherName - name of cipher to use. Currentl the valued algorithms are: Blowfish, DES, DES3 and IDEA.
Throws:
java.io.IOException

load

public void load(java.io.InputStream in,
                 java.lang.String password)
          throws java.io.IOException,
                 SSHAccessDeniedException
Load and decrypt properties

Parameters:
in - stream to load properties from
password - decryptiopn key
Throws:
java.io.IOException
SSHAccessDeniedException

remove

public java.lang.Object remove(java.lang.Object key)