Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jasypt.properties
Class EncryptableProperties

    Object
      java.util.Dictionary<K,V>
          java.util.Hashtable<Object,Object>
              java.util.Properties
                  org.jasypt.properties.EncryptableProperties

All Implemented Interfaces:
  java.io.Serializable, Cloneable, java.util.Map<Object,Object>

    public final class EncryptableProperties

extends java.util.Properties

Subclass of `java.util.Properties` which can make use of a `StringEncryptor` or `TextEncryptor` object to decrypt property values if they are encrypted in the `.properties` file.

A value is considered "encrypted" when it appears surrounded by `ENC(...)`, like:

`my.value=ENC(!"DGAS24FaIO$)`

Decryption is performed on-the-fly when the `getProperty(String)` or `getProperty(String, String)` methods are called, and only these two methods perform decryption (note that neither `get(Object)` nor `Hashtable.toString()` do). Load and store operations are not affected by decryption in any manner.

Encrypted and unencrypted objects can be combined in the same properties file.

Please note that, altough objects of this class are Serializable, they cannot be serialized and then de-serialized in different classloaders or virtual machines. This is so because encryptors are not serializable themselves (they cannot, as they contain sensitive information) and so they remain in memory, and live for as long as the classloader lives.

Since:
  1.4
Author:
  Daniel Fernández
See Also:
  Serialized Form

Field Summary

Fields inherited from class java.util.Properties
`defaults`

Constructor Summary
`EncryptableProperties(java.util.Properties defaults, StringEncryptor stringEncryptor)` Creates an `EncryptableProperties` instance which will use the passed `StringEncryptor` object to decrypt encrypted values, and the passed defaults as default values (may contain encrypted values).
`EncryptableProperties(java.util.Properties defaults, TextEncryptor textEncryptor)` Creates an `EncryptableProperties` instance which will use the passed `TextEncryptor` object to decrypt encrypted values, and the passed defaults as default values (may contain encrypted values).
`EncryptableProperties(StringEncryptor stringEncryptor)` Creates an `EncryptableProperties` instance which will use the passed `StringEncryptor` object to decrypt encrypted values.
`EncryptableProperties(TextEncryptor textEncryptor)` Creates an `EncryptableProperties` instance which will use the passed `TextEncryptor` object to decrypt encrypted values.

Method Summary
`Object` | `get(Object key)` Obtains the property value for the specified key (see `Hashtable#get(Object)`), decrypting it if needed.
`String` | `getProperty(String key)` Obtains the property value for the specified key (see `Properties.getProperty(String)`), decrypting it if needed.
`String` | `getProperty(String key, String defaultValue)` Obtains the property value for the specified key (see `Properties.getProperty(String)`), decrypting it if needed.

Methods inherited from class java.util.Properties
`list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames`

Methods inherited from class java.util.Hashtable
`clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values`

Methods inherited from class Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### EncryptableProperties

    public EncryptableProperties(StringEncryptor stringEncryptor)

  Creates an `EncryptableProperties` instance which will use the passed `StringEncryptor` object to decrypt encrypted values.

  Parameters:
    `stringEncryptor` - the `StringEncryptor` to be used do decrypt values. It can not be null.

### EncryptableProperties

    public EncryptableProperties(TextEncryptor textEncryptor)

  Creates an `EncryptableProperties` instance which will use the passed `TextEncryptor` object to decrypt encrypted values.

  Parameters:
    `textEncryptor` - the `TextEncryptor` to be used do decrypt values. It can not be null.

### EncryptableProperties

    public EncryptableProperties(java.util.Properties defaults,
                                 StringEncryptor stringEncryptor)

  Creates an `EncryptableProperties` instance which will use the passed `StringEncryptor` object to decrypt encrypted values, and the passed defaults as default values (may contain encrypted values).

  Parameters:
    `defaults` - default values for properties (may be encrypted).
    `stringEncryptor` - the `StringEncryptor` to be used do decrypt values. It can not be null.

### EncryptableProperties

    public EncryptableProperties(java.util.Properties defaults,
                                 TextEncryptor textEncryptor)

  Creates an `EncryptableProperties` instance which will use the passed `TextEncryptor` object to decrypt encrypted values, and the passed defaults as default values (may contain encrypted values).

  Parameters:
    `defaults` - default values for properties (may be encrypted).
    `textEncryptor` - the `TextEncryptor` to be used do decrypt values. It can not be null.

Method Detail

### getProperty

    public String getProperty(String key)

  Obtains the property value for the specified key (see `Properties.getProperty(String)`), decrypting it if needed.

  Overrides:
    `getProperty` in class `java.util.Properties`
  Parameters:
    `key` - the property key
  Returns:
    the (decrypted) value

### getProperty

    public String getProperty(String key,
                              String defaultValue)

  Obtains the property value for the specified key (see `Properties.getProperty(String)`), decrypting it if needed.

  If no value is found for the specified key, the default value will be returned (decrypted if needed).

  Overrides:
    `getProperty` in class `java.util.Properties`
  Parameters:
    `key` - the property key
    `defaultValue` - the default value to return
  Returns:
    the (decrypted) value

### get

    public Object get(Object key)

  Obtains the property value for the specified key (see `Hashtable#get(Object)`), decrypting it if needed.

  Specified by:
    `get` in interface `java.util.Map<Object,Object>`
  Overrides:
    `get` in class `java.util.Hashtable<Object,Object>`
  Parameters:
    `key` - the property key
  Returns:
    the (decrypted) value
  Since:
    1.9.0

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2014 The JASYPT team. All Rights Reserved.