Class JavaPropertiesFile


  • public class JavaPropertiesFile
    extends BasePropertiesFile
    In-memory representation of a Java properties file that can contain protected properties with encrypted values. This class reads and writes valid Java properties. When writing the order of the properties and the user comments are kept. Only the changed properties are stored in the output file.
    Since:
    7.1
    See Also:
    PropertiesFile
    • Constructor Detail

      • JavaPropertiesFile

        public JavaPropertiesFile​(java.lang.String path)
                           throws java.lang.Exception
        Constructs Java properties file without any encryption/decryption of properties.
        Parameters:
        path - path to properties files
        Throws:
        java.lang.Exception
      • JavaPropertiesFile

        public JavaPropertiesFile​(java.lang.String path,
                                  java.lang.String keyStoreProp,
                                  java.lang.String keyStoreTypeProp,
                                  java.lang.String keyStoreAliasProp,
                                  java.lang.String transformationProp,
                                  java.lang.String stashFileProp)
                           throws java.lang.Exception
        Constructs Java properties file, obtain keystore and key passwords from the stash file and encrypt/decrypt protected properties.
        Parameters:
        path - path to properties files
        keyStoreProp - keystore password property name
        keyStoreTypeProp - keystore type property name
        keyStoreAliasProp - alias property name
        transformationProp - transformation property name
        stashFileProp - stash file property name
        Throws:
        java.lang.Exception
    • Method Detail

      • store

        public void store​(java.lang.String path)
                   throws java.lang.Exception
        Write the contents of this properties file to disk. The order of the properties order and all user comments are kept. Only the modified properties are overwritten in the file.
        Specified by:
        store in class BasePropertiesFile
        Parameters:
        path - a file, whether the contents will be saved
        Throws:
        java.lang.Exception - error while writing the file or error while encrypting the file
      • asProperties

        public java.util.Properties asProperties()
                                          throws java.lang.Exception
        Returns:
        Properties object representing the contents of this properties file
        Throws:
        java.lang.Exception - if not able to decrypt some property value