123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- module SecureMailing::PGP::Tool::Error
- def self.exception(code)
- {
- 'NODATA' => SecureMailing::PGP::Tool::Error::NoData,
- 'NO_SECKEY' => SecureMailing::PGP::Tool::Error::NoSecretKey,
- 'NO_PUBKEY' => SecureMailing::PGP::Tool::Error::NoPublicKey,
- 'KEYEXPIRED' => SecureMailing::PGP::Tool::Error::ExpiredKey,
- 'KEYREVOKED' => SecureMailing::PGP::Tool::Error::RevokedKey,
- 'EXPSIG' => SecureMailing::PGP::Tool::Error::ExpiredSignature,
- 'BADSIG' => SecureMailing::PGP::Tool::Error::BadSignature,
- 'EXPKEYSIG' => SecureMailing::PGP::Tool::Error::ExpiredKeySignature,
- 'REVKEYSIG' => SecureMailing::PGP::Tool::Error::RevokedKeySignature,
- 'INV_RECP' => SecureMailing::PGP::Tool::Error::InvalidRecipient,
- 'INV_SGNR' => SecureMailing::PGP::Tool::Error::InvalidSigner,
- 'NO_RECP' => SecureMailing::PGP::Tool::Error::NoRecipient,
- 'NO_SGNR' => SecureMailing::PGP::Tool::Error::NoSigner,
- }[code]
- end
- class SecureMailing::PGP::Tool::Error::NoData < StandardError
- def initialize(info)
- msg = __('There was no valid OpenPGP data found.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::NoSecretKey < StandardError
- def initialize(info)
- msg = __('There was no secret PGP key found.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::NoPublicKey < StandardError
- def initialize(info)
- msg = __('There was no public PGP key found.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::ExpiredKey < StandardError
- def initialize(info)
- msg = __('The PGP key has expired.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::RevokedKey < StandardError
- def initialize(info)
- msg = __('The PGP key has been revoked.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::ExpiredSignature < StandardError
- def initialize(info)
- msg = __('The PGP signature has expired.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::BadSignature < StandardError
- def initialize(info)
- msg = __('The PGP signature is invalid.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::ExpiredKeySignature < StandardError
- def initialize(info)
- msg = __('The signature PGP key has expired.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::RevokedKeySignature < StandardError
- def initialize(info)
- msg = __('The PGP signature key has been revoked.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::InvalidRecipient < StandardError
- def initialize(info)
- msg = __('The PGP email recipient is invalid.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::InvalidSigner < StandardError
- def initialize(info)
- msg = __('The PGP email signer is invalid.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::NoRecipient < StandardError
- def initialize(info)
- msg = __('There is no valid PGP email recipient.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::NoSigner < StandardError
- def initialize(info)
- msg = __('There is no valid PGP email signer.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::BadPassphrase < StandardError
- def initialize(info)
- msg = __('The PGP passphrase is invalid.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::NoPassphrase < StandardError
- def initialize(info)
- msg = __('The required PGP passphrase is missing.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- class SecureMailing::PGP::Tool::Error::UnknownError < StandardError
- def initialize(info)
- msg = __('There was an unknown PGP error.')
- msg = "#{msg} #{info}" if info.present?
- super(msg)
- end
- end
- end
|