* or parameters a subclass might need.
*
* @return Horde_Crypt The newly created concrete instance.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
static public function factory($driver, $params = array())
{
return new $class($params);
}
- throw new Horde_Exception(__CLASS__ . ': Class definition of ' . $driver . ' not found.');
+ throw new Horde_Crypt_Exception(__CLASS__ . ': Class definition of ' . $driver . ' not found.');
}
/**
* @param array $params An array of arguments needed to decrypt the data.
*
* @return array The decrypted data.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function decrypt($data, $params = array())
{
--- /dev/null
+<?php
+/**
+ * Exception handler for the Horde_Crypt package.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Crypt
+ */
+class Horde_Crypt_Exception extends Horde_Exception_Prior
+{
+}
* 'public' => Public Key
* 'private' => Private Key
* </pre>
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function generateKey($realname, $email, $passphrase, $comment = '',
$keylength = 1024)
if (!empty($result->stderr)) {
$msg .= ' ' . _("Returned error message:") . ' ' . $result->stderr;
}
- throw new Horde_Exception($msg);
+ throw new Horde_Crypt_Exception($msg);
}
return array('public' => $public_key, 'private' => $secret_key);
* UID (e.g. revocation signatures and sub keys) will be stored under the
* special keyword '_SIGNATURE'.
*
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function pgpPacketInformation($pgpdata)
{
* @param string $pgpdata The PGP data block.
*
* @return string Tabular information on the PGP key.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function pgpPrettyKey($pgpdata)
{
* created => Signature creation - UNIX timestamp
* micalg => The hash used to create the signature
* </pre>
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function pgpPacketSignature($pgpdata, $email)
{
* @param string $uid_idx The UID index.
*
* @return array See pgpPacketSignature().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function pgpPacketSignatureByUidIndex($pgpdata, $uid_idx)
{
* @param string $text The PGP signed text block.
*
* @return string The key ID of the key used to sign $text.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function getSignersKeyID($text)
{
*
* @return boolean Returns true on valid passphrase, false on invalid
* passphrase.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function verifyPassphrase($public_key, $private_key, $passphrase)
{
/* Get e-mail address of public key. */
$key_info = $this->pgpPacketInformation($public_key);
if (!isset($key_info['signature']['id1']['email'])) {
- throw new Horde_Exception(_("Could not determine the recipient's e-mail address."));
+ throw new Horde_Crypt_Exception(_("Could not determine the recipient's e-mail address."));
}
/* Encrypt a test message. */
try {
$result = $this->encrypt('Test', array('type' => 'message', 'pubkey' => $public_key, 'recips' => array($key_info['signature']['id1']['email'] => $public_key)));
- } catch (Horde_Exception $e) {
+ } catch (Horde_Crypt_Exception $e) {
return false;
}
/* Try to decrypt the message. */
try {
$this->decrypt($result, array('type' => 'message', 'pubkey' => $public_key, 'privkey' => $private_key, 'passphrase' => $passphrase));
- } catch (Horde_Exception $e) {
+ } catch (Horde_Crypt_Exception $e) {
return false;
}
return substr($start, 0, $length);
}
- throw new Horde_Exception(_("Could not obtain public key from the keyserver."));
+ throw new Horde_Crypt_Exception(_("Could not obtain public key from the keyserver."));
}
/**
* @param string $server The keyserver to use.
* @param float $timeout The keyserver timeout.
*
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function putPublicKeyserver($pubkey,
$server = self::KEYSERVER_PUBLIC,
/* See if the public key already exists on the keyserver. */
try {
$this->getPublicKeyserver($info['keyid'], $server, $timeout);
- } catch (Horde_Exception $e) {
- throw new Horde_Exception(_("Key already exists on the public keyserver."));
+ } catch (Horde_Crypt_Exception $e) {
+ throw new Horde_Crypt_Exception(_("Key already exists on the public keyserver."));
}
/* Connect to the public keyserver. _connectKeyserver() */
* @param float $timeout The keyserver timeout.
*
* @return string The PGP key ID.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function getKeyID($address, $server = self::KEYSERVER_PUBLIC,
$timeout = self::KEYSERVER_TIMEOUT)
}
}
- throw new Horde_Exception(_("Could not obtain public key from the keyserver."));
+ throw new Horde_Crypt_Exception(_("Could not obtain public key from the keyserver."));
}
/**
* @param string $pgpdata The PGP data block.
*
* @return array The fingerprints in $pgpdata indexed by key id.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function getFingerprintsFromKey($pgpdata)
{
* @param float $timeout The timeout value.
*
* @return string The text from standard output on success.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _connectKeyserver($method, $server, $resource,
$command, $timeout)
} while (++$connRefuse < self::KEYSERVER_REFUSE);
if ($errno == 0) {
- throw new Horde_Exception(_("Connection refused to the public keyserver."));
+ throw new Horde_Crypt_Exception(_("Connection refused to the public keyserver."));
} else {
- throw new Horde_Exception(sprintf(_("Connection refused to the public keyserver. Reason: %s (%s)"), Horde_String::convertCharset($errstr, $this->_params['external_charset']), $errno));
+ throw new Horde_Crypt_Exception(sprintf(_("Connection refused to the public keyserver. Reason: %s (%s)"), Horde_String::convertCharset($errstr, $this->_params['external_charset']), $errno));
}
}
* parameter requirements.
*
* @return string The encrypted message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function encrypt($text, $params = array())
{
* 'message' - (string) The signature result text.
* 'result' - (boolean) The result of the signature test.
* </pre>
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function decrypt($text, $params = array())
{
* @param string $text The PGP encrypted text.
*
* @return boolean True if the text is symmetricallly encrypted.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function encryptedSymmetrically($text)
{
* (Default) or 'private'
*
* @return string Command line keystring option to use with gpg program.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _putInKeyring($keys = array(), $type = 'public')
{
* </pre>
*
* @return string The encrypted message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _encryptMessage($text, $params)
{
$result = $this->_callGpg($cmdline, 'w', empty($params['symmetric']) ? null : $params['passphrase'], true, true);
if (empty($result->output)) {
$error = preg_replace('/\n.*/', '', $result->stderr);
- throw new Horde_Exception(_("Could not PGP encrypt message: ") . $error);
+ throw new Horde_Crypt_Exception(_("Could not PGP encrypt message: ") . $error);
}
return $result->output;
* </pre>
*
* @return string The signed message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _encryptSignature($text, $params)
{
if (!isset($params['pubkey']) ||
!isset($params['privkey']) ||
!isset($params['passphrase'])) {
- throw new Horde_Exception(_("A public PGP key, private PGP key, and passphrase are required to sign a message."));
+ throw new Horde_Crypt_Exception(_("A public PGP key, private PGP key, and passphrase are required to sign a message."));
}
/* Create temp files for input. */
$result = $this->_callGpg($cmdline, 'w', $params['passphrase'], true, true);
if (empty($result->output)) {
$error = preg_replace('/\n.*/', '', $result->stderr);
- throw new Horde_Exception(_("Could not PGP sign message: ") . $error);
+ throw new Horde_Crypt_Exception(_("Could not PGP sign message: ") . $error);
}
return $result->output;
* 'message' - (string) The signature result text.
* 'result' - (boolean) The result of the signature test.
* </pre>
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _decryptMessage($text, $params)
{
/* Check for required parameters. */
if (!isset($params['passphrase']) && empty($params['no_passphrase'])) {
- throw new Horde_Exception(_("A passphrase is required to decrypt a message."));
+ throw new Horde_Crypt_Exception(_("A passphrase is required to decrypt a message."));
}
/* Create temp files. */
}
if (empty($result->output)) {
$error = preg_replace('/\n.*/', '', $result->stderr);
- throw new Horde_Exception(_("Could not decrypt PGP data: ") . $error);
+ throw new Horde_Crypt_Exception(_("Could not decrypt PGP data: ") . $error);
}
/* Create the return object. */
* 'message' - (string) The signature result text.
* 'result' - (boolean) The result of the signature test.
* </pre>
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _decryptSignature($text, $params)
{
/* Check for required parameters. */
if (!isset($params['pubkey'])) {
- throw new Horde_Exception(_("A public PGP key is required to verify a signed message."));
+ throw new Horde_Crypt_Exception(_("A public PGP key is required to verify a signed message."));
}
if (($params['type'] === 'detached-signature') &&
!isset($params['signature'])) {
- throw new Horde_Exception(_("The detached PGP signature block is required to verify the signed message."));
+ throw new Horde_Crypt_Exception(_("The detached PGP signature block is required to verify the signed message."));
}
$good_sig_flag = 0;
* 'message' - (string) The signature result text.
* 'result' - (boolean) The result of the signature test.
* </pre>
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _checkSignatureResult($result, $message = null)
{
* Bad signature:
* gpg: BAD signature from "blah blah blah (Comment)" */
if (strpos($result, 'gpg: BAD signature') !== false) {
- throw new Horde_Exception($result);
+ throw new Horde_Crypt_Exception($result);
}
$ob = new stdClass;
*
* @return mixed A Horde_Mime_Part object that is signed according to RFC
* 3156.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function signMIMEPart($mime_part, $params = array())
{
*
* @return mixed A Horde_Mime_Part object that is encrypted according to
* RFC 3156.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function encryptMIMEPart($mime_part, $params = array())
{
*
* @return mixed A Horde_Mime_Part object that is signed and encrypted
* according to RFC 3156.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function signAndEncryptMIMEPart($mime_part, $sign_params = array(),
$encrypt_params = array())
* @param boolean $verbose Run GnuPG with verbose flag?
*
* @return stdClass Class with members output, stderr, and stdout.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _callGpg($options, $mode, $input = array(),
$output = false, $stderr = false,
}
}
} else {
- throw new Horde_Exception(_("Error while talking to pgp binary."));
+ throw new Horde_Crypt_Exception(_("Error while talking to pgp binary."));
}
} elseif ($mode == 'r') {
if ($fp = popen($cmdline, 'r')) {
$data->stdout .= fgets($fp, 1024);
}
} else {
- throw new Horde_Exception(_("Error while talking to pgp binary."));
+ throw new Horde_Crypt_Exception(_("Error while talking to pgp binary."));
}
}
pclose($fp);
* @param string $passphrase The passphrase to use for the key.
*
* @return string The revocation certificate.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function generateRevocation($key, $email, $passphrase)
{
/* If the key is empty, something went wrong. */
if (empty($results->output)) {
- throw new Horde_Exception(_("Revocation key not generated successfully."));
+ throw new Horde_Crypt_Exception(_("Revocation key not generated successfully."));
}
return $results->output;
* the parameter requirements.
*
* @return string The encrypted message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function encrypt($text, $params = array())
{
* the parameter requirements.
*
* @return string The decrypted message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function decrypt($text, $params = array())
{
* 'cert' -> The certificate of the signer stored
* in the message (in PEM format).
* 'email' -> The email of the signing person.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function verify($text, $certs)
{
$result = openssl_pkcs7_verify($input, PKCS7_NOVERIFY, $output);
if ($result === true) {
- throw new Horde_Exception(_("Message Verified Successfully but the signer's certificate could not be verified."));
+ throw new Horde_Crypt_Exception(_("Message Verified Successfully but the signer's certificate could not be verified."));
} elseif ($result == -1) {
- throw new Horde_Exception(_("Verification failed - an unknown error has occurred."));
+ throw new Horde_Crypt_Exception(_("Verification failed - an unknown error has occurred."));
} else {
- throw new Horde_Exception(_("Verification failed - this message may have been tampered with."));
+ throw new Horde_Crypt_Exception(_("Verification failed - this message may have been tampered with."));
}
$ob->cert = file_get_contents($output);
* @param string $sslpath The path to the OpenSSL binary.
*
* @return string The contents embedded in the signed data.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function extractSignedContents($data, $sslpath)
{
return $ret;
}
- throw new Horde_Exception(_("OpenSSL error: Could not extract data from signed S/MIME part."));
+ throw new Horde_Crypt_Exception(_("OpenSSL error: Could not extract data from signed S/MIME part."));
}
/**
* @param array $params The parameters required for signing.
*
* @return mixed A Horde_Mime_Part object that is signed.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function signMIMEPart($mime_part, $params)
{
* encryption.
*
* @return mixed A Horde_Mime_Part object that is encrypted.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function encryptMIMEPart($mime_part, $params = array())
{
* </pre>
*
* @return string The encrypted message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _encryptMessage($text, $params)
{
/* Check for required parameters. */
if (!isset($params['pubkey'])) {
- throw new Horde_Exception(_("A public S/MIME key is required to encrypt a message."));
+ throw new Horde_Crypt_Exception(_("A public S/MIME key is required to encrypt a message."));
}
/* Create temp files for input/output. */
}
}
- throw new Horde_Exception(_("Could not S/MIME encrypt message."));
+ throw new Horde_Crypt_Exception(_("Could not S/MIME encrypt message."));
}
/**
* </pre>
*
* @return string The signed message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _encryptSignature($text, $params)
{
if (!isset($params['pubkey']) ||
!isset($params['privkey']) ||
!array_key_exists('passphrase', $params)) {
- throw new Horde_Exception(_("A public S/MIME key, private S/MIME key, and passphrase are required to sign a message."));
+ throw new Horde_Crypt_Exception(_("A public S/MIME key, private S/MIME key, and passphrase are required to sign a message."));
}
/* Create temp files for input/output/certificates. */
}
if (!$res) {
- throw new Horde_Exception(_("Could not S/MIME sign message."));
+ throw new Horde_Crypt_Exception(_("Could not S/MIME sign message."));
}
$data = file_get_contents($output);
* </pre>
*
* @return string The decrypted message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _decryptMessage($text, $params)
{
if (!isset($params['pubkey']) ||
!isset($params['privkey']) ||
!array_key_exists('passphrase', $params)) {
- throw new Horde_Exception(_("A public S/MIME key, private S/MIME key, and passphrase are required to decrypt a message."));
+ throw new Horde_Crypt_Exception(_("A public S/MIME key, private S/MIME key, and passphrase are required to decrypt a message."));
}
/* Create temp files for input/output. */
return file_get_contents($output);
}
- throw new Horde_Exception(_("Could not decrypt S/MIME data."));
+ throw new Horde_Crypt_Exception(_("Could not decrypt S/MIME data."));
}
/**
* @see _encryptMessage().
*
* @return mixed A Horde_Mime_Part object that is signed and encrypted.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function signAndEncryptMIMEPart($mime_part, $sign_params = array(),
$encrypt_params = array())
* @param array $params The parameters needed for verification.
*
* @return string The verification message.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _decryptSignature($text, $params)
{
- throw new Horde_Exception('_decryptSignature() ' . _("not yet implemented"));
+ throw new Horde_Crypt_Exception('_decryptSignature() ' . _("not yet implemented"));
}
/**
* Check for the presence of the OpenSSL extension to PHP.
*
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function checkForOpenSSL()
{
if (!Horde_Util::extensionExists('openssl')) {
- throw new Horde_Exception(_("The openssl module is required for the Horde_Crypt_Smime:: class."));
+ throw new Horde_Crypt_Exception(_("The openssl module is required for the Horde_Crypt_Smime:: class."));
}
}
* 'private' - The private key in PEM format.
* 'public' - The public key in PEM format.
* 'certs' - An array of additional certs.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function parsePKCS12Data($pkcs12, $params)
{
$this->checkForOpenSSL();
if (!isset($params['sslpath'])) {
- throw new Horde_Exception(_("No path to the OpenSSL binary provided. The OpenSSL binary is necessary to work with PKCS 12 data."));
+ throw new Horde_Crypt_Exception(_("No path to the OpenSSL binary provided. The OpenSSL binary is necessary to work with PKCS 12 data."));
}
$sslpath = escapeshellcmd($params['sslpath']);
}
pclose($fd);
} else {
- throw new Horde_Exception(_("Error while talking to smime binary."));
+ throw new Horde_Crypt_Exception(_("Error while talking to smime binary."));
}
$ob->private = trim(file_get_contents($output));
if (empty($ob->private)) {
- throw new Horde_Exception(_("Password incorrect"));
+ throw new Horde_Crypt_Exception(_("Password incorrect"));
}
/* Extract the client public key next. */
fwrite($fd, $params['password'] . "\n");
pclose($fd);
} else {
- throw new Horde_Exception(_("Error while talking to smime binary."));
+ throw new Horde_Crypt_Exception(_("Error while talking to smime binary."));
}
$ob->public = trim(file_get_contents($output));
fwrite($fd, $params['password'] . "\n");
pclose($fd);
} else {
- throw new Horde_Exception(_("Error while talking to smime binary."));
+ throw new Horde_Crypt_Exception(_("Error while talking to smime binary."));
}
$ob->certs = trim(file_get_contents($output));
<api>alpha</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Better error handling for gnupg and openssl command line binaries.
-* Initial Horde 4 package.</notes>
+ <notes>* Add Horde_Crypt_Exception::.
+ * Better error handling for gnupg and openssl command line binaries.
+ * Initial Horde 4 package.</notes>
<contents>
<dir name="/">
<dir name="lib">
<dir name="Horde">
<dir name="Crypt">
+ <file name="Exception.php" role="php" />
<file name="Pgp.php" role="php" />
<file name="Smime.php" role="php" />
</dir> <!-- /lib/Horde/Crypt -->
<min>1.5.0</min>
</pearinstaller>
<package>
+ <name>Exception</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>Mime</name>
<channel>pear.horde.org</channel>
</package>
</dependencies>
<phprelease>
<filelist>
+ <install name="lib/Horde/Crypt/Exception.php" as="Horde/Crypt/Exception.php" />
<install name="lib/Horde/Crypt/Pgp.php" as="Horde/Crypt/Pgp.php" />
<install name="lib/Horde/Crypt/Smime.php" as="Horde/Crypt/Smime.php" />
<install name="lib/Horde/Crypt.php" as="Horde/Crypt.php" />
* @param string $comment See Horde_Crypt_Pgp::
* @param string $keylength See Horde_Crypt_Pgp::
*
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function generatePersonalKeys($name, $email, $passphrase,
$comment = '', $keylength = 1024)
* @param string $public_key An PGP public key.
*
* @return array See Horde_Crypt_Pgp::pgpPacketInformation()
+ * @throws Horde_Crypt_Exception
* @throws Horde_Exception
*/
public function addPublicKey($public_key)
/* 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."));
+ throw new Horde_Crypt_Exception(_("Not a valid public key."));
}
/* Remove the '_SIGNATURE' entry. */
unset($key_info['signature'][$id]);
continue;
}
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Crypt_Exception $e) {}
/* Add key to the user's address book. */
$GLOBALS['registry']->call('contacts/addField', array($sig['email'], $sig['name'], self::PUBKEY_FIELD, $public_key, $GLOBALS['prefs']->getValue('add_source')));
* </pre>
*
* @return string The PGP public key requested.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function getPublicKey($address, $options = array())
{
if ($key) {
return $key;
}
- } catch (Horde_Exception_HookNotSet $e) {
- }
+ } catch (Horde_Exception_HookNotSet $e) {}
/* Try retrieving by e-mail only first. */
$params = IMP::getAddressbookSearchParams();
+ $result = null;
try {
$result = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
- } catch (Horde_Exception $e) {
+ } catch (Horde_Exception $e) {}
+
+ if (is_null($result)) {
/* TODO: Retrieve by ID. */
/* See if the address points to the user's public key. */
if (is_object($cache)) {
$cache->set("PGPpublicKey_" . $address . $keyid, $result, 3600);
}
- } catch (Horde_Exception $e) {
+ } catch (Horde_Crypt_Exception $e) {
/* Return now, if no public key found at all. */
Horde::logMessage('PGPpublicKey: ' . $e->getMessage(), 'DEBUG');
- throw new Horde_Exception(sprintf(_("Could not retrieve public key for %s."), $address));
+ throw new Horde_Crypt_Exception(sprintf(_("Could not retrieve public key for %s."), $address));
}
} else {
$result = '';
* Retrieves all public keys from a user's address book(s).
*
* @return array All PGP public keys available.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function listPublicKeys()
{
*
* @param string $email The e-mail address to delete.
*
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function deletePublicKey($email)
{
* @param string $address The email address of the requested key.
*
* @return string See Horde_Crypt_Pgp::getPublicKeyserver()
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function getFromPublicKeyserver($keyid, $address = null)
{
* @param string $pubkey The PGP public key.
*
* @return string See Horde_Crypt_Pgp::putPublicKeyserver()
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function sendToPublicKeyserver($pubkey)
{
*
* @return string See Horde_Crypt_Pgp::getPublicKeyserver() -or-
* Horde_Crypt_Pgp::putPublicKeyserver().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _keyserverConnect($data, $method, $additional = null)
{
global $conf;
if (empty($conf['gnupg']['keyserver'])) {
- throw new Horde_Exception(_("Public PGP keyserver support has been disabled."));
+ throw new Horde_Crypt_Exception(_("Public PGP keyserver support has been disabled."));
}
$timeout = empty($conf['gnupg']['timeout'])
foreach ($conf['gnupg']['keyserver'] as $server) {
try {
return $this->getPublicKeyserver($data, $server, $timeout, $additional);
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Crypt_Exception $e) {}
}
- throw new Horde_Exception(_("Could not connect to public PGP keyserver"));
+ throw new Horde_Crypt_Exception(_("Could not connect to public PGP keyserver"));
}
/**
* @param string $signature A PGP signature block.
*
* @return stdClass See Horde_Crypt_Pgp::decrypt().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function verifySignature($text, $address, $signature = '')
{
* the passphrase to use.
*
* @return stdClass See Horde_Crypt_Pgp::decrypt().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function decryptMessage($text, $type, $passphrase = null)
{
* encrypting. If null, uses the personal key.
*
* @return array The list of parameters needed by encrypt().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _encryptParameters($addresses, $symmetric)
{
* @param Horde_Mime_Part $mime_part The object to sign.
*
* @return Horde_Mime_Part See Horde_Crypt_Pgp::signMIMEPart().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function impSignMimePart($mime_part)
{
* the personal key.
*
* @return Horde_Mime_Part See Horde_Crypt_Pgp::encryptMimePart().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function impEncryptMimePart($mime_part, $addresses,
$symmetric = null)
* the personal key.
*
* @return Horde_Mime_Part See Horde_Crypt_Pgp::signAndencryptMimePart().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function impSignAndEncryptMimePart($mime_part, $addresses,
$symmetric = null)
{
try {
$key_info = $this->pgpPrettyKey($key);
- } catch (Horde_Exception $e) {
+ } catch (Horde_Crypt_Exception $e) {
Horde::logMessage($e, 'INFO');
$key_info = $e->getMessage();
}
*
* @param string $cert A public certificate to add.
*
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function addPublicKey($cert)
{
/* 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."));
+ throw new Horde_Crypt_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."));
+ throw new Horde_Crypt_Exception(_("No email information located in the public key."));
}
/* Get the name corresponding to this key. */
} elseif (isset($key_info['subject']['OU'])) {
$name = $key_info['subject']['OU'];
} else {
- throw new Horde_Exception(_("Not a valid public key."));
+ throw new Horde_Crypt_Exception(_("Not a valid public key."));
}
$GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source')));
* @param string $address The e-mail address of the recipient.
*
* @return array The list of parameters needed by encrypt().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
protected function _encryptParameters($address)
{
if ($key) {
return $key;
}
- } catch (Horde_Exception_HookNotSet $e) {
- }
+ } catch (Horde_Exception_HookNotSet $e) {}
$params = IMP::getAddressbookSearchParams();
* Retrieves all public keys from a user's address book(s).
*
* @return array All S/MIME public keys available.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function listPublicKeys()
{
*
* @param string $email The e-mail address to delete.
*
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function deletePublicKey($email)
{
* @param string $text The text to verify.
*
* @return stdClass See Horde_Crypt_Smime::verify().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function verifySignature($text)
{
* @param string $text The text to decrypt.
*
* @return string See Horde_Crypt_Smime::decrypt().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function decryptMessage($text)
{
* encryption.
*
* @return MIME_Part See Horde_Crypt_Smime::encryptMIMEPart().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function IMPencryptMIMEPart($mime_part, $to_address)
{
* @param MIME_Part $mime_part The MIME_Part object to sign.
*
* @return MIME_Part See Horde_Crypt_Smime::signMIMEPart().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function IMPsignMIMEPart($mime_part)
{
* encryption.
*
* @return MIME_Part See Horde_Crypt_Smime::signAndencryptMIMEPart().
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function IMPsignAndEncryptMIMEPart($mime_part, $to_address)
{
* @param string $password The password of the PKCS 12 file.
* @param string $pkpass The password to use to encrypt the private key.
*
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function addFromPKCS12($pkcs12, $password, $pkpass = null)
{
* @param string $data The signed S/MIME data.
*
* @return string The contents embedded in the signed data.
- * @throws Horde_Exception
+ * @throws Horde_Crypt_Exception
*/
public function extractSignedContents($data)
{