Class VaultSession


  • public final class VaultSession
    extends Object
    Non-interactive session for VaultTool
    Author:
    Peter Skopek
    • Constructor Detail

      • VaultSession

        public VaultSession​(String keystoreURL,
                            String keystorePassword,
                            String encryptionDirectory,
                            String salt,
                            int iterationCount)
                     throws Exception
        Constructor to create VaultSession.
        Parameters:
        keystoreURL -
        keystorePassword -
        encryptionDirectory -
        salt -
        iterationCount -
        Throws:
        Exception
    • Method Detail

      • validateKeystoreURL

        protected void validateKeystoreURL()
                                    throws Exception
        Throws:
        Exception
      • validateKeystorePassword

        protected void validateKeystorePassword()
                                         throws Exception
        Throws:
        Exception
      • validateEncryptionDirectory

        protected void validateEncryptionDirectory()
                                            throws Exception
        Throws:
        Exception
      • validateIterationCount

        protected void validateIterationCount()
                                       throws Exception
        Throws:
        Exception
      • startVaultSession

        public void startVaultSession​(String vaultAlias)
                               throws Exception
        Start the vault with given alias.
        Parameters:
        vaultAlias -
        Throws:
        Exception
      • addSecuredAttribute

        public void addSecuredAttribute​(String vaultBlock,
                                        String attributeName,
                                        char[] attributeValue)
                                 throws Exception
        Add secured attribute to specified vault block. This method can be called only after successful startVaultSession() call.
        Parameters:
        vaultBlock -
        attributeName -
        attributeValue -
        Throws:
        Exception
      • checkSecuredAttribute

        public boolean checkSecuredAttribute​(String vaultBlock,
                                             String attributeName)
                                      throws Exception
        Check whether secured attribute is already set for given vault block and attribute name. This method can be called only after successful startVaultSession() call.
        Parameters:
        vaultBlock -
        attributeName -
        Returns:
        true is password already exists for given vault block and attribute name.
        Throws:
        Exception
      • removeSecuredAttribute

        public void removeSecuredAttribute​(String vaultBlock,
                                           String attributeName)
                                    throws Exception
        Remove secured attribute with given vault block and attribute name. This method can be called only after successful startVaultSession() call.
        Parameters:
        vaultBlock -
        attributeName -
        Throws:
        Exception
      • encryptValueWithCRYPT

        public void encryptValueWithCRYPT​(String encryptionPassword,
                                          String valueToEncrypt)
                                   throws Exception
        Encrypt a value using the CRYPT feature.
        Parameters:
        encryptionPassword - Encryption password; could be stored in the vault
        valueToEncrypt -
        Throws:
        Exception - if there is an issue retrieving the encryptionPassword from the vault.
      • vaultConfigurationDisplay

        public void vaultConfigurationDisplay()
        Display info about vault itself in form of AS7 configuration file.
      • outputConfig

        public void outputConfig​(PrintStream out)
        Print AS7 configuration file to stream.
        Parameters:
        out - stream to print config.