From d3ec1337bc8562f385d8c011c3e6b294b4a4d170 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 1 Aug 2013 19:37:23 +0200 Subject: [PATCH] Provide additional keys data in case the ASCII armored blob containes multiple keys --- zypp/PublicKey.cc | 13 ++++++++++++- zypp/PublicKey.h | 9 ++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/zypp/PublicKey.cc b/zypp/PublicKey.cc index 7fe3ba4..6996cd1 100644 --- a/zypp/PublicKey.cc +++ b/zypp/PublicKey.cc @@ -311,6 +311,9 @@ namespace zypp Pathname path() const { return _dataFile.path(); } + const std::list & hiddenKeys() const + { return _hiddenKeys; } + protected: void readFromFile() { @@ -354,20 +357,25 @@ namespace zypp case 1: // ok. + _keyData = scanner._keys.back(); + _hiddenKeys.clear(); break; default: WAR << "File " << _dataFile.path().asString() << " contains multiple keys: " << scanner._keys << endl; + _keyData = scanner._keys.back(); + scanner._keys.pop_back(); + _hiddenKeys.swap( scanner._keys ); break; } - _keyData = scanner._keys.back(); MIL << "Read pubkey from " << info.path() << ": " << _keyData << endl; } private: filesystem::TmpFile _dataFile; PublicKeyData _keyData; + std::list _hiddenKeys; public: /** Offer default Impl. */ @@ -413,6 +421,9 @@ namespace zypp Pathname PublicKey::path() const { return _pimpl->path(); } + const std::list & PublicKey::hiddenKeys() const + { return _pimpl->hiddenKeys(); } + std::string PublicKey::id() const { return keyData().id(); } diff --git a/zypp/PublicKey.h b/zypp/PublicKey.h index 036f076..5f81d13 100644 --- a/zypp/PublicKey.h +++ b/zypp/PublicKey.h @@ -197,8 +197,13 @@ namespace zypp /////////////////////////////////////////////////////////////////// /// \class PublicKey /// \brief Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile). + /// /// If you don't need the ASCII armored version of the key stored in /// a tempfile, using \ref PublicKeyData might be sufficient. + /// + /// \note In case the ASCII armored blob actually contains multiple + /// keys, the \b last keys data are made available via the API. The + /// additional keys data are made available via \ref hiddenKeys. /////////////////////////////////////////////////////////////////// class PublicKey { @@ -249,11 +254,13 @@ namespace zypp std::string gpgPubkeyRelease() const; //!< \see \ref PublicKeyData std::string asString() const; //!< \see \ref PublicKeyData - public: /** File containig the ASCII armored key. */ Pathname path() const; + /** Additional keys data in case the ASCII armored blob containes multiple keys. */ + const std::list & hiddenKeys() const; + public: bool operator==( PublicKey rhs ) const; // FIXME: change arg to const& bool operator==( std::string sid ) const; // FIXME: change arg to const& -- 2.7.4