Interface EncryptedProperties

  • All Known Implementing Classes:
    DefaultEncryptedProperties, ReferenceEncryptedProperties

    public interface EncryptedProperties
    The EncryptedProperties interface represents a properties file where all the data is encrypted before it is added, and decrypted when it retrieved. This interface can be implemented in a number of ways, the simplest being extending Properties and overloading the getProperty and setProperty methods. In all cases, the master encryption key, as given by the Encryptor.MasterKey property in ESAPI.properties file.
    Since:
    June 1, 2007
    Author:
    Jeff Williams (jeff.williams .at. aspectsecurity.com) Aspect Security
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      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()
      Returns a Set view of properties.
      void load​(java.io.InputStream in)
      Reads a property list (key and element pairs) from the input stream.
      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)
      Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method.
    • Method Detail

      • getProperty

        java.lang.String getProperty​(java.lang.String key)
                              throws EncryptionException
        Gets the property value from the encrypted store, decrypts it, and returns the plaintext value to the caller.
        Parameters:
        key - the name of the property to get
        Returns:
        The decrypted property value. null if the key is not set.
        Throws:
        EncryptionException - if the property could not be decrypted
      • setProperty

        java.lang.String setProperty​(java.lang.String key,
                                     java.lang.String value)
                              throws EncryptionException
        Encrypts the plaintext property value and stores the ciphertext value in the encrypted store.
        Parameters:
        key - the name of the property to set
        value - the value of the property to set
        Returns:
        the previously encrypted property value for the specified key, or null if it did not have one.
        Throws:
        EncryptionException - if the property could not be encrypted
      • keySet

        java.util.Set<?> keySet()
        Returns a Set view of properties. The Set is backed by a java.util.Hashtable, so changes to the Hashtable are reflected in the Set, and vice-versa. The Set supports element removal (which removes the corresponding entry from the Hashtable, but not element addition.
        Returns:
        a set view of the properties contained in this map.
      • load

        void load​(java.io.InputStream in)
           throws java.io.IOException
        Reads a property list (key and element pairs) from the input stream.
        Parameters:
        in - the input stream that contains the properties file
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • store

        void store​(java.io.OutputStream out,
                   java.lang.String comments)
            throws java.io.IOException
        Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method.
        Parameters:
        out - the output stream that contains the properties file
        comments - a description of the property list (ex. "Encrypted Properties File").
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.