X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=zypp%2FKeyRing.cc;h=7cea27d30dbd5b8afc3fad47db49b366e5ae3eff;hb=4960f0a558c8a7de86f690cc2119bb23c715168e;hp=51ebcd00469b63c83215d47e8dd549002b4984fb;hpb=7a54bd4a7ce3bce21539e82b66d642cca137dfb5;p=platform%2Fupstream%2Flibzypp.git diff --git a/zypp/KeyRing.cc b/zypp/KeyRing.cc index 51ebcd0..7cea27d 100644 --- a/zypp/KeyRing.cc +++ b/zypp/KeyRing.cc @@ -162,14 +162,8 @@ namespace zypp const std::list & getData( const Pathname & keyring_r, Cache & cache_r ) const { if ( cache_r.hasChanged() ) { - shared_ptr ctx = KeyManagerCtx::createForOpenPGP(); - if (ctx) { - if (ctx->setHomedir(keyring_r)) { - std::list foundKeys = ctx->listKeys(); - cache_r._data.swap(foundKeys); - } - } - MIL << "Found keys: " << cache_r._data << endl; + cache_r._data = KeyManagerCtx::createForOpenPGP( keyring_r ).listKeys(); + MIL << "Found keys: " << cache_r._data << endl; } return cache_r._data; } @@ -392,10 +386,7 @@ namespace zypp void KeyRing::Impl::dumpPublicKey( const std::string & id, const Pathname & keyring, std::ostream & stream ) { - KeyManagerCtx::Ptr ctx = KeyManagerCtx::createForOpenPGP(); - if (!ctx || !ctx->setHomedir(keyring)) - return; - ctx->exportKey(id, stream); + KeyManagerCtx::createForOpenPGP( keyring ).exportKey(id, stream); } filesystem::TmpFile KeyRing::Impl::dumpPublicKeyToTmp( const std::string & id, const Pathname & keyring ) @@ -600,31 +591,16 @@ namespace zypp % keyfile.asString() % keyring.asString() )); - KeyManagerCtx::Ptr ctx = KeyManagerCtx::createForOpenPGP(); - if(!ctx || !ctx->setHomedir(keyring)) - ZYPP_THROW(KeyRingException(_("Failed to import key."))); - cachedPublicKeyData.setDirty( keyring ); - if(!ctx->importKey(keyfile)) + if ( ! KeyManagerCtx::createForOpenPGP( keyring ).importKey( keyfile ) ) ZYPP_THROW(KeyRingException(_("Failed to import key."))); } void KeyRing::Impl::deleteKey( const std::string & id, const Pathname & keyring ) { - KeyManagerCtx::Ptr ctx = KeyManagerCtx::createForOpenPGP(); - if(!ctx) { - ZYPP_THROW(KeyRingException(_("Failed to delete key."))); - } - - if(!ctx->setHomedir(keyring)) { - ZYPP_THROW(KeyRingException(_("Failed to delete key."))); - } - - if(!ctx->deleteKey(id)){ - ZYPP_THROW(KeyRingException(_("Failed to delete key."))); - } - cachedPublicKeyData.setDirty( keyring ); + if ( ! KeyManagerCtx::createForOpenPGP( keyring ).deleteKey( id ) ) + ZYPP_THROW(KeyRingException(_("Failed to delete key."))); } std::string KeyRing::Impl::readSignatureKeyId( const Pathname & signature ) @@ -634,13 +610,8 @@ namespace zypp MIL << "Determining key id of signature " << signature << endl; - KeyManagerCtx::Ptr ctx = KeyManagerCtx::createForOpenPGP(); - if(!ctx) { - return std::string(); - } - - std::list fprs = ctx->readSignatureFingerprints(signature); - if (fprs.size()) { + std::list fprs = KeyManagerCtx::createForOpenPGP().readSignatureFingerprints( signature ); + if ( ! fprs.empty() ) { std::string &id = fprs.back(); MIL << "Determined key id [" << id << "] for signature " << signature << endl; return id; @@ -650,11 +621,7 @@ namespace zypp bool KeyRing::Impl::verifyFile( const Pathname & file, const Pathname & signature, const Pathname & keyring ) { - KeyManagerCtx::Ptr ctx = KeyManagerCtx::createForOpenPGP(); - if (!ctx || !ctx->setHomedir(keyring)) - return false; - - return ctx->verify(file, signature); + return KeyManagerCtx::createForOpenPGP( keyring ).verify( file, signature ); } ///////////////////////////////////////////////////////////////////