Esempio n. 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $plainTextFilePath = $input->getArgument('plainTextFilePath');
     $encryptedFilePath = $input->getArgument('encryptedFilePath');
     $vault = new Vault();
     $vault->encryptFile($plainTextFilePath, $encryptedFilePath);
     $output->writeln("File written: {$encryptedFilePath}");
 }
Esempio n. 2
0
 protected function loadFromConfig()
 {
     if (!is_file('profiles.yml')) {
         if (is_file('profiles.yml.encrypted')) {
             if (class_exists('\\Vault\\Vault')) {
                 try {
                     $configYaml = \Vault\Vault::open('profiles.yml.encrypted');
                 } catch (\Exception $e) {
                     throw new \Exception('Error decrypting profiles.yml.encrypted', 0, $e);
                 }
             } else {
                 throw new \Exception('Please install aoepeople/vault');
             }
         } else {
             throw new \Exception('Could not find profiles.yml or profiles.yml.encrypted');
         }
     } else {
         $configYaml = file_get_contents('profiles.yml');
     }
     $config = \Symfony\Component\Yaml\Yaml::parse($configYaml);
     if (!isset($config['profiles'])) {
         throw new \Exception('Could not find "profiles" key');
     }
     if (!is_array($config['profiles']) || count($config['profiles']) == 0) {
         throw new \Exception('Could not find any profiles "profiles"');
     }
     return $config['profiles'];
 }
Esempio n. 3
0
 protected function __construct($privateKeyFile)
 {
     if (is_file($privateKeyFile)) {
         $this->privateKeyFile = $privateKeyFile;
     } else {
         $encryptedPrivateKeyFile = $privateKeyFile . '.encrypted';
         $this->privateKeyFile = $privateKeyFile . '.unlocked';
         if (is_file($encryptedPrivateKeyFile)) {
             if (class_exists('\\Vault\\Vault')) {
                 $vault = new Vault();
                 $vault->decryptFile($encryptedPrivateKeyFile, $this->privateKeyFile);
                 chmod($this->privateKeyFile, 0600);
                 $this->unlocked = true;
             } else {
                 throw new \Exception('Please install aoepeople/vault');
             }
         } else {
             throw new \Exception('Could not find private key file ' . $privateKeyFile);
         }
     }
     $this->privateKeyFile = realpath($this->privateKeyFile);
 }
 protected function getDecryptedFilecontent($encryptedFilename)
 {
     if (!is_file($encryptedFilename)) {
         throw new \Symfony\Component\Filesystem\Exception\FileNotFoundException("Could not find encrypted file {$encryptedFilename}");
     }
     if (!class_exists('\\Vault\\Vault')) {
         throw new \Exception('Please install aoepeople/vault');
     }
     try {
         return \Vault\Vault::open($encryptedFilename);
     } catch (\Exception $e) {
         throw new \Exception('Error decrypting ' . $encryptedFilename, 0, $e);
     }
 }