Class EncryptedPropertiesUtils


  • public class EncryptedPropertiesUtils
    extends java.lang.Object
    Command line utilities for reading, writing and creating encrypted properties files.

    Usage:
    java org.owasp.esapi.reference.crypto.EncryptedPropertiesUtils [--in file] [--out file] [--in-encrypted true|false] [--verbose true|false]

    Command line parameters:

    • --in (Optional) Encrypted or plaintext file to read from. If no input file is specified, a new properties file will be created.
    • --out (Optional) Encrypted file to output to. Default: Overwrite input file
    • --in-encrypted (Optional) True if the input file is encrypted. Default: true
    • --verbose (Optional) If true, output (potentially unencrypted) information to the terminal. Default: false
    Since:
    October 8, 2010
    Author:
    August Detlefsen (augustd at codemagi dot com) CodeMagi, Inc.
    See Also:
    EncryptedProperties
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object addProperty​(java.util.Properties props, java.lang.String key, java.lang.String value)
      Adds a new key-value property to the passed Properties object
      static java.util.Properties loadProperties​(java.lang.String inFile, java.lang.Boolean inFileEncrypted)
      Loads a Properties file from a filename.
      static void main​(java.lang.String[] args)
      Loads encrypted or plaintext properties file based on the location passed in args then prompts the user to input key-value pairs.
      static void storeProperties​(java.lang.String outFile, java.util.Properties props, java.lang.String message)
      Stores a Properties object to a file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EncryptedPropertiesUtils

        public EncryptedPropertiesUtils()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Loads encrypted or plaintext properties file based on the location passed in args then prompts the user to input key-value pairs. When the user enters a null or blank key, the values are stored to the properties file.
        Throws:
        java.lang.Exception - Any exception thrown
      • loadProperties

        public static java.util.Properties loadProperties​(java.lang.String inFile,
                                                          java.lang.Boolean inFileEncrypted)
                                                   throws java.io.IOException
        Loads a Properties file from a filename. If the filename is unspecified or the file could not be found, a new Properties is returned.
        Parameters:
        inFile - Filename to load Properties from.
        inFileEncrypted - If true, the input file is assumed to be already encrypted. Default true.
        Returns:
        Either the loaded Properties object or a new one if the file could not be found.
        Throws:
        java.io.IOException
      • storeProperties

        public static void storeProperties​(java.lang.String outFile,
                                           java.util.Properties props,
                                           java.lang.String message)
                                    throws java.lang.Exception
        Stores a Properties object to a file.
        Parameters:
        outFile - Filename to store to
        props - Properties to store
        message - A message to add to the comments in the stored file
        Throws:
        java.lang.Exception
      • addProperty

        public static java.lang.Object addProperty​(java.util.Properties props,
                                                   java.lang.String key,
                                                   java.lang.String value)
        Adds a new key-value property to the passed Properties object
        Parameters:
        props - The Properties object to add to
        key - The key to add
        value - The value to set
        Returns:
        The previous value of the property, or null if it is newly added.