Class EncryptedProperties

All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class EncryptedProperties extends Properties
Encrypted Properties.
If a value starts with a ~ (tilde), the remainder of the string is considered to be encrypted by the application-specific Cryptor. If an unencrypted value starts with a ~, it must be escaped with a backslash.
See Also:
  • Constructor Details

    • EncryptedProperties

      public EncryptedProperties()
      Creates an empty property list with no default values.
    • EncryptedProperties

      public EncryptedProperties(int initialCapacity)
      Creates an empty property list with no default values, and with an initial size accommodating the specified number of elements without the need to dynamically resize.
      Parameters:
      initialCapacity - the EncryptedProperties will be sized to accommodate this many elements
      Throws:
      IllegalArgumentException - if the initial capacity is less than zero.
    • EncryptedProperties

      public EncryptedProperties(Properties defaults)
      Creates an empty property list with the specified defaults.
      Parameters:
      defaults - the defaults.
  • Method Details

    • clone

      public EncryptedProperties clone()
      Overrides:
      clone in class Properties
    • getProperty

      public String getProperty(String key)
      Searches for the property with the specified key in this property list.
      If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

      If the property is encrypted, it will be returned decrypted.

      Overrides:
      getProperty in class Properties
      Parameters:
      key - the property key
      Returns:
      the value in this property list with the specified key value
      See Also:
    • getPropertyBlunt

      public String getPropertyBlunt(String key)
      Gets the original value of the property.
      If the value is encrypted, the encrypted value will be returned.
      Parameters:
      key - the property key
      Returns:
      the value, null if no such key
    • getPropertyAsChars

      public char[] getPropertyAsChars(String key)
      Gets the property as a character array.
      Same as getProperty(String), but returns an array. In case the value was encrypted, the decrypted array can be erased by the application after use.
      Parameters:
      key - the property key
      Returns:
      the value as a character array or null if no such key
    • getPropertyAsChars

      public char[] getPropertyAsChars(String key, char[] defaults)
      Gets the property as a character array with a default value.
      Parameters:
      key - the property key
      defaults - the default value
      Returns:
      the value as a character array or null if no such key
    • setEncryptedProperty

      public void setEncryptedProperty(String key, String value)
      Sets the property string and stores it encrypted, if a Cryptor is available.
      Parameters:
      key - the property key
      value - the unencrypted value
    • setEncryptedProperty

      public void setEncryptedProperty(String key, char[] value)
      Sets the property char array and stores it encrypted, if a Cryptor is available.
      Parameters:
      key - the property key
      value - the unencrypted value