com.h3c.util.security

## Class EncryptedProperties

- java.lang.Object
- - java.util.Dictionary<K,V>
  - - java.util.Hashtable<Object,Object>
    - - java.util.Properties
      - - com.h3c.util.security.EncryptedProperties

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

      public class EncryptedProperties
      extends Properties

  A `Properties` class that can handle encrypted property values in the form of

      "ENC(<encoded text>)"

  . Non-encrypted values do not have the

      "ENC()"

  magic mark.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class java.util.Properties

      `defaults`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EncryptedProperties(String password)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getProperty(String key)` This also decrypts any property value that has been encrypted.
    `boolean` | `isEncrypted(String key)` Check if the value with the given key is encrypted or not.
    `static void` | `main(String[] argv)` A simple driver for changing the master key used for encryption (and the corresponding properties files that have encryption).
    `Object` | `setEncryptedProperty(String key, String value)` Force set a property value to be encrypted.
    `Object` | `setProperty(String key, String value)` This also encrypts the value of any property key that was original encrypted.

    - ### Methods inherited from class java.util.Properties

      `getProperty, list, list, load, load, loadFromXML, propertyNames, save, store, store, storeToXML, storeToXML, stringPropertyNames`

    - ### Methods inherited from class java.util.Hashtable

      `clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### EncryptedProperties

          public EncryptedProperties(String password)
                              throws EncryptionException

      Constructor.
      Parameters:
        `password` - password to use for encryption/decryption
      Throws:
        `EncryptionException` - something is wrong, Houston!

  - ### Method Detail

    - #### getProperty

          public String getProperty(String key)

      This also decrypts any property value that has been encrypted.
      Overrides:
        `getProperty` in class `Properties`

    - #### setProperty

          public Object setProperty(String key,
                           String value)

      This also encrypts the value of any property key that was original encrypted.
      Overrides:
        `setProperty` in class `Properties`

    - #### setEncryptedProperty

          public Object setEncryptedProperty(String key,
                                    String value)

      Force set a property value to be encrypted.
      Parameters:
        `key` - property key
        `value` - property value
      Returns:
        the previous value of the specified key in this property list, or null if it did not have one.

    - #### isEncrypted

          public boolean isEncrypted(String key)

      Check if the value with the given key is encrypted or not.
      Parameters:
        `key` - key with value to check
      Returns:
        true if encrypted, false otherwise

    - #### main

          public static void main(String[] argv)
                           throws FileNotFoundException,
                                  IOException

      A simple driver for changing the master key used for encryption (and the corresponding properties files that have encryption). OR, simply decrypt a given properties file or encrypt a given properties.
      Parameters:
        `argv` - command arguments [newPass]
      Throws:
        `FileNotFoundException` - file location not found
        `IOException` - file IO exception

Copyright © 2014. All Rights Reserved.