comparison vendor/pear/crypt_gpg/Crypt/GPG/Exceptions.php @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e000243b222
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Various exception handling classes for Crypt_GPG
7 *
8 * Crypt_GPG provides an object oriented interface to GNU Privacy
9 * Guard (GPG). It requires the GPG executable to be on the system.
10 *
11 * This file contains various exception classes used by the Crypt_GPG package.
12 *
13 * PHP version 5
14 *
15 * LICENSE:
16 *
17 * This library is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU Lesser General Public License as
19 * published by the Free Software Foundation; either version 2.1 of the
20 * License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, see
29 * <http://www.gnu.org/licenses/>
30 *
31 * @category Encryption
32 * @package Crypt_GPG
33 * @author Nathan Fredrickson <nathan@silverorange.com>
34 * @author Michael Gauthier <mike@silverorange.com>
35 * @copyright 2005-2011 silverorange
36 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
37 * @link http://pear.php.net/package/Crypt_GPG
38 */
39
40 /**
41 * PEAR Exception handler and base class
42 */
43 require_once 'PEAR/Exception.php';
44
45 // {{{ class Crypt_GPG_Exception
46
47 /**
48 * An exception thrown by the Crypt_GPG package
49 *
50 * @category Encryption
51 * @package Crypt_GPG
52 * @author Michael Gauthier <mike@silverorange.com>
53 * @copyright 2005 silverorange
54 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
55 * @link http://pear.php.net/package/Crypt_GPG
56 */
57 class Crypt_GPG_Exception extends PEAR_Exception
58 {
59 }
60
61 // }}}
62 // {{{ class Crypt_GPG_FileException
63
64 /**
65 * An exception thrown when a file is used in ways it cannot be used
66 *
67 * For example, if an output file is specified and the file is not writeable, or
68 * if an input file is specified and the file is not readable, this exception
69 * is thrown.
70 *
71 * @category Encryption
72 * @package Crypt_GPG
73 * @author Michael Gauthier <mike@silverorange.com>
74 * @copyright 2007-2008 silverorange
75 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
76 * @link http://pear.php.net/package/Crypt_GPG
77 */
78 class Crypt_GPG_FileException extends Crypt_GPG_Exception
79 {
80 // {{{ private class properties
81
82 /**
83 * The name of the file that caused this exception
84 *
85 * @var string
86 */
87 private $_filename = '';
88
89 // }}}
90 // {{{ __construct()
91
92 /**
93 * Creates a new Crypt_GPG_FileException
94 *
95 * @param string $message an error message.
96 * @param integer $code a user defined error code.
97 * @param string $filename the name of the file that caused this exception.
98 */
99 public function __construct($message, $code = 0, $filename = '')
100 {
101 $this->_filename = $filename;
102 parent::__construct($message, $code);
103 }
104
105 // }}}
106 // {{{ getFilename()
107
108 /**
109 * Returns the filename of the file that caused this exception
110 *
111 * @return string the filename of the file that caused this exception.
112 *
113 * @see Crypt_GPG_FileException::$_filename
114 */
115 public function getFilename()
116 {
117 return $this->_filename;
118 }
119
120 // }}}
121 }
122
123 // }}}
124 // {{{ class Crypt_GPG_OpenSubprocessException
125
126 /**
127 * An exception thrown when the GPG subprocess cannot be opened
128 *
129 * This exception is thrown when the {@link Crypt_GPG_Engine} tries to open a
130 * new subprocess and fails.
131 *
132 * @category Encryption
133 * @package Crypt_GPG
134 * @author Michael Gauthier <mike@silverorange.com>
135 * @copyright 2005 silverorange
136 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
137 * @link http://pear.php.net/package/Crypt_GPG
138 */
139 class Crypt_GPG_OpenSubprocessException extends Crypt_GPG_Exception
140 {
141 // {{{ private class properties
142
143 /**
144 * The command used to try to open the subprocess
145 *
146 * @var string
147 */
148 private $_command = '';
149
150 // }}}
151 // {{{ __construct()
152
153 /**
154 * Creates a new Crypt_GPG_OpenSubprocessException
155 *
156 * @param string $message an error message.
157 * @param integer $code a user defined error code.
158 * @param string $command the command that was called to open the
159 * new subprocess.
160 *
161 * @see Crypt_GPG::_openSubprocess()
162 */
163 public function __construct($message, $code = 0, $command = '')
164 {
165 $this->_command = $command;
166 parent::__construct($message, $code);
167 }
168
169 // }}}
170 // {{{ getCommand()
171
172 /**
173 * Returns the contents of the internal _command property
174 *
175 * @return string the command used to open the subprocess.
176 *
177 * @see Crypt_GPG_OpenSubprocessException::$_command
178 */
179 public function getCommand()
180 {
181 return $this->_command;
182 }
183
184 // }}}
185 }
186
187 // }}}
188 // {{{ class Crypt_GPG_InvalidOperationException
189
190 /**
191 * An exception thrown when an invalid GPG operation is attempted
192 *
193 * @category Encryption
194 * @package Crypt_GPG
195 * @author Michael Gauthier <mike@silverorange.com>
196 * @copyright 2008 silverorange
197 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
198 * @link http://pear.php.net/package/Crypt_GPG
199 */
200 class Crypt_GPG_InvalidOperationException extends Crypt_GPG_Exception
201 {
202 // {{{ private class properties
203
204 /**
205 * The attempted operation
206 *
207 * @var string
208 */
209 private $_operation = '';
210
211 // }}}
212 // {{{ __construct()
213
214 /**
215 * Creates a new Crypt_GPG_OpenSubprocessException
216 *
217 * @param string $message an error message.
218 * @param integer $code a user defined error code.
219 * @param string $operation the operation.
220 */
221 public function __construct($message, $code = 0, $operation = '')
222 {
223 $this->_operation = $operation;
224 parent::__construct($message, $code);
225 }
226
227 // }}}
228 // {{{ getOperation()
229
230 /**
231 * Returns the contents of the internal _operation property
232 *
233 * @return string the attempted operation.
234 *
235 * @see Crypt_GPG_InvalidOperationException::$_operation
236 */
237 public function getOperation()
238 {
239 return $this->_operation;
240 }
241
242 // }}}
243 }
244
245 // }}}
246 // {{{ class Crypt_GPG_KeyNotFoundException
247
248 /**
249 * An exception thrown when Crypt_GPG fails to find the key for various
250 * operations
251 *
252 * @category Encryption
253 * @package Crypt_GPG
254 * @author Michael Gauthier <mike@silverorange.com>
255 * @copyright 2005 silverorange
256 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
257 * @link http://pear.php.net/package/Crypt_GPG
258 */
259 class Crypt_GPG_KeyNotFoundException extends Crypt_GPG_Exception
260 {
261 // {{{ private class properties
262
263 /**
264 * The key identifier that was searched for
265 *
266 * @var string
267 */
268 private $_keyId = '';
269
270 // }}}
271 // {{{ __construct()
272
273 /**
274 * Creates a new Crypt_GPG_KeyNotFoundException
275 *
276 * @param string $message an error message.
277 * @param integer $code a user defined error code.
278 * @param string $keyId the key identifier of the key.
279 */
280 public function __construct($message, $code = 0, $keyId= '')
281 {
282 $this->_keyId = $keyId;
283 parent::__construct($message, $code);
284 }
285
286 // }}}
287 // {{{ getKeyId()
288
289 /**
290 * Gets the key identifier of the key that was not found
291 *
292 * @return string the key identifier of the key that was not found.
293 */
294 public function getKeyId()
295 {
296 return $this->_keyId;
297 }
298
299 // }}}
300 }
301
302 // }}}
303 // {{{ class Crypt_GPG_NoDataException
304
305 /**
306 * An exception thrown when Crypt_GPG cannot find valid data for various
307 * operations
308 *
309 * @category Encryption
310 * @package Crypt_GPG
311 * @author Michael Gauthier <mike@silverorange.com>
312 * @copyright 2006 silverorange
313 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
314 * @link http://pear.php.net/package/Crypt_GPG
315 */
316 class Crypt_GPG_NoDataException extends Crypt_GPG_Exception
317 {
318 }
319
320 // }}}
321 // {{{ class Crypt_GPG_BadPassphraseException
322
323 /**
324 * An exception thrown when a required passphrase is incorrect or missing
325 *
326 * @category Encryption
327 * @package Crypt_GPG
328 * @author Michael Gauthier <mike@silverorange.com>
329 * @copyright 2006-2008 silverorange
330 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
331 * @link http://pear.php.net/package/Crypt_GPG
332 */
333 class Crypt_GPG_BadPassphraseException extends Crypt_GPG_Exception
334 {
335 // {{{ private class properties
336
337 /**
338 * Keys for which the passhprase is missing
339 *
340 * This contains primary user ids indexed by sub-key id.
341 *
342 * @var array
343 */
344 private $_missingPassphrases = array();
345
346 /**
347 * Keys for which the passhprase is incorrect
348 *
349 * This contains primary user ids indexed by sub-key id.
350 *
351 * @var array
352 */
353 private $_badPassphrases = array();
354
355 // }}}
356 // {{{ __construct()
357
358 /**
359 * Creates a new Crypt_GPG_BadPassphraseException
360 *
361 * @param string $message an error message.
362 * @param integer $code a user defined error code.
363 * @param array $badPassphrases an array containing user ids of keys
364 * for which the passphrase is incorrect.
365 * @param array $missingPassphrases an array containing user ids of keys
366 * for which the passphrase is missing.
367 */
368 public function __construct($message, $code = 0,
369 array $badPassphrases = array(), array $missingPassphrases = array()
370 ) {
371 $this->_badPassphrases = (array) $badPassphrases;
372 $this->_missingPassphrases = (array) $missingPassphrases;
373
374 parent::__construct($message, $code);
375 }
376
377 // }}}
378 // {{{ getBadPassphrases()
379
380 /**
381 * Gets keys for which the passhprase is incorrect
382 *
383 * @return array an array of keys for which the passphrase is incorrect.
384 * The array contains primary user ids indexed by the sub-key
385 * id.
386 */
387 public function getBadPassphrases()
388 {
389 return $this->_badPassphrases;
390 }
391
392 // }}}
393 // {{{ getMissingPassphrases()
394
395 /**
396 * Gets keys for which the passhprase is missing
397 *
398 * @return array an array of keys for which the passphrase is missing.
399 * The array contains primary user ids indexed by the sub-key
400 * id.
401 */
402 public function getMissingPassphrases()
403 {
404 return $this->_missingPassphrases;
405 }
406
407 // }}}
408 }
409
410 // }}}
411 // {{{ class Crypt_GPG_DeletePrivateKeyException
412
413 /**
414 * An exception thrown when an attempt is made to delete public key that has an
415 * associated private key on the keyring
416 *
417 * @category Encryption
418 * @package Crypt_GPG
419 * @author Michael Gauthier <mike@silverorange.com>
420 * @copyright 2008 silverorange
421 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
422 * @link http://pear.php.net/package/Crypt_GPG
423 */
424 class Crypt_GPG_DeletePrivateKeyException extends Crypt_GPG_Exception
425 {
426 // {{{ private class properties
427
428 /**
429 * The key identifier the deletion attempt was made upon
430 *
431 * @var string
432 */
433 private $_keyId = '';
434
435 // }}}
436 // {{{ __construct()
437
438 /**
439 * Creates a new Crypt_GPG_DeletePrivateKeyException
440 *
441 * @param string $message an error message.
442 * @param integer $code a user defined error code.
443 * @param string $keyId the key identifier of the public key that was
444 * attempted to delete.
445 *
446 * @see Crypt_GPG::deletePublicKey()
447 */
448 public function __construct($message, $code = 0, $keyId = '')
449 {
450 $this->_keyId = $keyId;
451 parent::__construct($message, $code);
452 }
453
454 // }}}
455 // {{{ getKeyId()
456
457 /**
458 * Gets the key identifier of the key that was not found
459 *
460 * @return string the key identifier of the key that was not found.
461 */
462 public function getKeyId()
463 {
464 return $this->_keyId;
465 }
466
467 // }}}
468 }
469
470 // }}}
471 // {{{ class Crypt_GPG_KeyNotCreatedException
472
473 /**
474 * An exception thrown when an attempt is made to generate a key and the
475 * attempt fails
476 *
477 * @category Encryption
478 * @package Crypt_GPG
479 * @author Michael Gauthier <mike@silverorange.com>
480 * @copyright 2011 silverorange
481 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
482 * @link http://pear.php.net/package/Crypt_GPG
483 */
484 class Crypt_GPG_KeyNotCreatedException extends Crypt_GPG_Exception
485 {
486 }
487
488 // }}}
489 // {{{ class Crypt_GPG_InvalidKeyParamsException
490
491 /**
492 * An exception thrown when an attempt is made to generate a key and the
493 * key parameters set on the key generator are invalid
494 *
495 * @category Encryption
496 * @package Crypt_GPG
497 * @author Michael Gauthier <mike@silverorange.com>
498 * @copyright 2011 silverorange
499 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
500 * @link http://pear.php.net/package/Crypt_GPG
501 */
502 class Crypt_GPG_InvalidKeyParamsException extends Crypt_GPG_Exception
503 {
504 // {{{ private class properties
505
506 /**
507 * The key algorithm
508 *
509 * @var integer
510 */
511 private $_algorithm = 0;
512
513 /**
514 * The key size
515 *
516 * @var integer
517 */
518 private $_size = 0;
519
520 /**
521 * The key usage
522 *
523 * @var integer
524 */
525 private $_usage = 0;
526
527 // }}}
528 // {{{ __construct()
529
530 /**
531 * Creates a new Crypt_GPG_InvalidKeyParamsException
532 *
533 * @param string $message an error message.
534 * @param integer $code a user defined error code.
535 * @param string $algorithm the key algorithm.
536 * @param string $size the key size.
537 * @param string $usage the key usage.
538 */
539 public function __construct(
540 $message,
541 $code = 0,
542 $algorithm = 0,
543 $size = 0,
544 $usage = 0
545 ) {
546 parent::__construct($message, $code);
547
548 $this->_algorithm = $algorithm;
549 $this->_size = $size;
550 $this->_usage = $usage;
551 }
552
553 // }}}
554 // {{{ getAlgorithm()
555
556 /**
557 * Gets the key algorithm
558 *
559 * @return integer the key algorithm.
560 */
561 public function getAlgorithm()
562 {
563 return $this->_algorithm;
564 }
565
566 // }}}
567 // {{{ getSize()
568
569 /**
570 * Gets the key size
571 *
572 * @return integer the key size.
573 */
574 public function getSize()
575 {
576 return $this->_size;
577 }
578
579 // }}}
580 // {{{ getUsage()
581
582 /**
583 * Gets the key usage
584 *
585 * @return integer the key usage.
586 */
587 public function getUsage()
588 {
589 return $this->_usage;
590 }
591
592 // }}}
593 }
594
595 // }}}
596
597 ?>