/** * Initialise a new passphrase file. * * @return void * * @since 12.3 */ protected function initPassphraseFile() { $keychain = new JKeychain(); $passphraseFile = $this->input->get('passphrase', '', 'raw'); $privateKeyFile = $this->input->get('private-key', '', 'raw'); if (!strlen($passphraseFile)) { $this->out('A passphrase file must be specified with --passphrase'); exit(1); } if (!file_exists($privateKeyFile)) { $this->out("protected key file specified doesn't exist: {$privateKeyFile}"); exit(1); } $this->out('Please enter the new passphrase:'); $passphrase = $this->in(); $this->out('Please enter the passphrase for the protected key:'); $privateKeyPassphrase = $this->in(); $keychain->createPassphraseFile($passphrase, $passphraseFile, $privateKeyFile, $privateKeyPassphrase); }
/** * Delete a value from the keychain * * @depends testSaveKeychain * * @return void * * @since 12.3 */ public function testDeleteValue() { $keychainFile = __DIR__ . '/data/web-keychain.dat'; $publicKeyFile = __DIR__ . '/data/publickey.pem'; $passphraseFile = __DIR__ . '/data/web-passphrase.dat'; $keychain = new JKeychain(); $keychain->loadKeychain($keychainFile, $passphraseFile, $publicKeyFile); $this->assertEquals('liao', $keychain->get('dennis')); $keychain->deleteValue('dennis'); $this->assertFalse($keychain->exists('dennis')); $keychain->saveKeychain($keychainFile, $passphraseFile, $publicKeyFile); $keychain = new JKeychain(); $keychain->loadKeychain($keychainFile, $passphraseFile, $publicKeyFile); $this->assertFalse($keychain->exists('dennis')); }