Skip to content

Commit

Permalink
Cleaner handling of passphrases
Browse files Browse the repository at this point in the history
No need to inform the user that passphrases are "saved in the session",
since that is abstract implementation details
  • Loading branch information
slusarz committed Aug 5, 2014
1 parent 679dc09 commit d0159c9
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions imp/lib/Ajax/Application/Handler/Passphrase.php
Expand Up @@ -39,42 +39,33 @@ public function checkPassphrase()

$result = false;

if (!$this->vars->dialog_input) {
$notification->push(_("No passphrase entered."), 'horde.error');
return $result;
}

try {
Horde::requireSecureConnection();

switch ($this->vars->type) {
case 'pgpPersonal':
$result = $injector->getInstance('IMP_Crypt_Pgp')->storePassphrase('personal', $this->vars->dialog_input);
break;

case 'pgpSymmetric':
if ($this->vars->dialog_input) {
$imp_pgp = $injector->getInstance('IMP_Crypt_Pgp');
if ((($this->vars->type == 'pgpPersonal') &&
$imp_pgp->storePassphrase('personal', $this->vars->dialog_input)) ||
(($this->vars->type == 'pgpSymmetric') &&
$imp_pgp->storePassphrase('symmetric', $this->vars->dialog_input, $this->vars->symmetricid))) {
$result = true;
$notification->push(_("PGP passhprase stored in session."), 'horde.success');
} else {
$notification->push(_("Invalid passphrase entered."), 'horde.error');
}
} else {
$notification->push(_("No passphrase entered."), 'horde.error');
}
$result = $injector->getInstance('IMP_Crypt_Pgp')->storePassphrase('symmetric', $this->vars->dialog_input, $this->vars->symmetricid);
break;

case 'smimePersonal':
if ($this->vars->dialog_input) {
$imp_smime = $injector->getInstance('IMP_Crypt_Smime');
if ($imp_smime->storePassphrase($this->vars->dialog_input)) {
$result = true;
$notification->push(_("S/MIME passphrase stored in session."), 'horde.success');
} else {
$notification->push(_("Invalid passphrase entered."), 'horde.error');
}
} else {
$notification->push(_("No passphrase entered."), 'horde.error');
}
$result = $injector->getInstance('IMP_Crypt_Smime')->storePassphrase($this->vars->dialog_input);
break;
}

if ($result) {
$notification->push(_("Passphrase verified."), 'horde.success');
} else {
$notification->push(_("Invalid passphrase entered."), 'horde.error');
}
} catch (Horde_Exception $e) {
$notification->push($e, 'horde.error');
}
Expand Down

0 comments on commit d0159c9

Please sign in to comment.