| | |
| | | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
| | | |
| | | /** |
| | | * Crypt_GPG is a package to use GPG from PHP |
| | | * Crypt_GPG is a package to use GnuPG from PHP |
| | | * |
| | | * This file contains an object that handles GPG's status output for the |
| | | * This file contains an object that handles GnuPG's status output for the |
| | | * decrypt operation. |
| | | * |
| | | * PHP version 5 |
| | |
| | | * @category Encryption |
| | | * @package Crypt_GPG |
| | | * @author Michael Gauthier <mike@silverorange.com> |
| | | * @copyright 2008-2009 silverorange |
| | | * @copyright 2008-2013 silverorange |
| | | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 |
| | | * @version CVS: $Id: DecryptStatusHandler.php 302814 2010-08-26 15:43:07Z gauthierm $ |
| | | * @version CVS: $Id$ |
| | | * @link http://pear.php.net/package/Crypt_GPG |
| | | * @link http://www.gnupg.org/ |
| | | */ |
| | |
| | | require_once 'Crypt/GPG.php'; |
| | | |
| | | /** |
| | | * GPG exception classes |
| | | * Crypt_GPG exception classes |
| | | */ |
| | | require_once 'Crypt/GPG/Exceptions.php'; |
| | | |
| | |
| | | * |
| | | * This class is responsible for sending the passphrase commands when required |
| | | * by the {@link Crypt_GPG::decrypt()} method. See <b>doc/DETAILS</b> in the |
| | | * {@link http://www.gnupg.org/download/ GPG distribution} for detailed |
| | | * information on GPG's status output for the decrypt operation. |
| | | * {@link http://www.gnupg.org/download/ GnuPG distribution} for detailed |
| | | * information on GnuPG's status output for the decrypt operation. |
| | | * |
| | | * This class is also responsible for parsing error status and throwing a |
| | | * meaningful exception in the event that decryption fails. |
| | |
| | | * @category Encryption |
| | | * @package Crypt_GPG |
| | | * @author Michael Gauthier <mike@silverorange.com> |
| | | * @copyright 2008 silverorange |
| | | * @copyright 2008-2013 silverorange |
| | | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 |
| | | * @link http://pear.php.net/package/Crypt_GPG |
| | | * @link http://www.gnupg.org/ |
| | |
| | | throw new Crypt_GPG_KeyNotFoundException( |
| | | 'Cannot decrypt data. No suitable private key is in the ' . |
| | | 'keyring. Import a suitable private key before trying to ' . |
| | | 'decrypt this data.', $code, $keyId); |
| | | |
| | | 'decrypt this data.', |
| | | $code, |
| | | $keyId |
| | | ); |
| | | case Crypt_GPG::ERROR_BAD_PASSPHRASE: |
| | | $badPassphrases = array_diff_key( |
| | | $this->badPassphrases, |
| | |
| | | implode('", "', $badPassphrases) . '".'; |
| | | } |
| | | |
| | | throw new Crypt_GPG_BadPassphraseException($message, $code, |
| | | $badPassphrases, $missingPassphrases); |
| | | |
| | | throw new Crypt_GPG_BadPassphraseException( |
| | | $message, |
| | | $code, |
| | | $badPassphrases, |
| | | $missingPassphrases |
| | | ); |
| | | case Crypt_GPG::ERROR_NO_DATA: |
| | | throw new Crypt_GPG_NoDataException( |
| | | 'Cannot decrypt data. No PGP encrypted data was found in '. |
| | | 'the provided data.', $code); |
| | | |
| | | 'the provided data.', |
| | | $code |
| | | ); |
| | | default: |
| | | throw new Crypt_GPG_Exception( |
| | | 'Unknown error decrypting data.', $code); |
| | | 'Unknown error decrypting data.', |
| | | $code |
| | | ); |
| | | } |
| | | } |
| | | |