Exemplo n.º 1
0
 function run()
 {
     $ks = KeyStore::getInstance();
     $pr = PathResolver::getInstance();
     $ks_user = $pr->getPath("{USER}/user.cks");
     $ks_system = $pr->getPath("{SYSTEM}/system.cks");
     if (file_exists($ks_user)) {
         $key = getenv("KEYSTORE_USERKEY");
         if ($key) {
             $ks->attachFile($ks_user, $key);
             putenv("KEYSTORE_USERKEY");
         } else {
             $this->debug("Info: To auto-mount the user KeyStore, define the KEYSTORE_USERKEY envvar.");
         }
     } else {
         $this->debug("Keystore {$ks_user} not found.");
     }
     if (file_exists($ks_system)) {
         $key = getenv("KEYSTORE_SYSTEMKEY");
         if ($key) {
             $ks->attachFile($ks_system, $key);
             putenv("KEYSTORE_SYSTEMKEY");
         } else {
             $this->debug("Info: To auto-mount the system KeyStore, define the KEYSTORE_SYSTEMKEY envvar.");
         }
     } else {
         $this->debug("Keystore {$ks_system} not found.");
     }
     return $this->main();
 }
Exemplo n.º 2
0
 public function freeze()
 {
     $key = KeyStore::getInstance()->queryCredentials('opaquetoken.key');
     $data = serialize($this->getArrayCopy());
     $data = gzcompress($data);
     $crypt = Crypto::tripledes($key)->encrypt($data);
     return base64_encode($crypt);
 }
Exemplo n.º 3
0
 private function getKeystorePassword($type, $username, $host, $database)
 {
     // Try to get from keystore
     $ks = \Cherry\Crypto\KeyStore::getInstance();
     try {
         $curi = "{$type}://{$username}@{$host}/{$database}";
         $password = $ks->queryCredentials($curi);
     } catch (Exception $e) {
         $this->debug("Unable to access credentials for connection {$curi}");
     }
     if (!$password) {
         try {
             $curi = "{$type}://{$username}@{$host}";
             $password = $ks->queryCredentials($curi);
         } catch (Exception $e) {
             $this->debug("Unable to access credentials for connection {$curi}");
         }
     }
     return $password;
 }