don't throw exceptions with string
authorChuck Hagenbuch <chuck@horde.org>
Fri, 27 Mar 2009 20:48:43 +0000 (16:48 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Fri, 27 Mar 2009 20:48:43 +0000 (16:48 -0400)
imp/lib/Crypt/Pgp.php
imp/lib/Crypt/Smime.php

index 106b0c6..caa81ff 100644 (file)
@@ -114,7 +114,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
         /* Make sure the key is valid. */
         $key_info = $this->pgpPacketInformation($public_key);
         if (!isset($key_info['signature'])) {
-            throw new Horde_Exception(_("Not a valid public key."), 'horde.error');
+            throw new Horde_Exception(_("Not a valid public key."));
         }
 
         /* Remove the '_SIGNATURE' entry. */
@@ -297,7 +297,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
         global $conf;
 
         if (empty($conf['utils']['gnupg_keyserver'])) {
-            throw new Horde_Exception(_("Public PGP keyserver support has been disabled."), 'horde.warning');
+            throw new Horde_Exception(_("Public PGP keyserver support has been disabled."));
         }
 
         $timeout = (empty($conf['utils']['gnupg_timeout'])) ? PGP_KEYSERVER_TIMEOUT : $conf['utils']['gnupg_timeout'];
index c9764de..7901787 100644 (file)
@@ -107,13 +107,13 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
         /* Make sure the certificate is valid. */
         $key_info = openssl_x509_parse($cert);
         if (!is_array($key_info) || !isset($key_info['subject'])) {
-            throw new Horde_Exception(_("Not a valid public key."), 'horde.error');
+            throw new Horde_Exception(_("Not a valid public key."));
         }
 
         /* Add key to the user's address book. */
         $email = $this->getEmailFromKey($cert);
         if (is_null($email)) {
-            throw new Horde_Exception(_("No email information located in the public key."), 'horde.error');
+            throw new Horde_Exception(_("No email information located in the public key."));
         }
 
         /* Get the name corresponding to this key. */
@@ -122,12 +122,12 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
         } elseif (isset($key_info['subject']['OU'])) {
             $name = $key_info['subject']['OU'];
         } else {
-            throw new Horde_Exception(_("Not a valid public key."), 'horde.error');
+            throw new Horde_Exception(_("Not a valid public key."));
         }
 
-        $res = $GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source')));
-        if (is_a($res, 'PEAR_Error')) {
-            throw new Horde_Exception($res);
+        $result = $GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source')));
+        if (is_a($result, 'PEAR_Error')) {
+            throw new Horde_Exception($result);
         }
     }
 
@@ -197,12 +197,12 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
         if (empty($params['sources'])) {
             return array();
         }
-        $res = $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
-        if (is_a($res, 'PEAR_Error')) {
-            throw new Horde_Exception($res);
+        $result = $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
+        if (is_a($result, 'PEAR_Error')) {
+            throw new Horde_Exception($result);
         }
 
-        return $res;
+        return $result;
     }
 
     /**
@@ -215,9 +215,9 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
     public function deletePublicKey($email)
     {
         $params = IMP_Compose::getAddressSearchParams();
-        $res = $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
-        if (is_a($res, 'PEAR_Error')) {
-            throw new Horde_Exception($res);
+        $result = $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
+        if (is_a($result, 'PEAR_Error')) {
+            throw new Horde_Exception($result);
         }
     }
 
@@ -284,11 +284,11 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
         } elseif (isset($_SESSION['imp']['smime']['null_passphrase'])) {
             return ($_SESSION['imp']['smime']['null_passphrase']) ? null : false;
         } else {
-            $res = $this->verifyPassphrase($private_key, null);
+            $result = $this->verifyPassphrase($private_key, null);
             if (!isset($_SESSION['imp']['smime'])) {
                 $_SESSION['imp']['smime'] = array();
             }
-            $_SESSION['imp']['smime']['null_passphrase'] = ($res) ? null : false;
+            $_SESSION['imp']['smime']['null_passphrase'] = ($result) ? null : false;
             return $_SESSION['imp']['smime']['null_passphrase'];
         }
     }
@@ -402,10 +402,10 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
             $params['newpassword'] = $pkpass;
         }
 
-        $res = $this->parsePKCS12Data($pkcs12, $params);
-        $this->addPersonalPrivateKey($res->private);
-        $this->addPersonalPublicKey($res->public);
-        $this->addAdditionalCert($res->certs);
+        $result = $this->parsePKCS12Data($pkcs12, $params);
+        $this->addPersonalPrivateKey($result->private);
+        $this->addPersonalPublicKey($result->public);
+        $this->addAdditionalCert($result->certs);
     }
 
     /**