KeyRing.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_KEYRING_H
00013 #define ZYPP_KEYRING_H
00014 
00015 #include <iosfwd>
00016 #include <map>
00017 #include <list>
00018 #include <set>
00019 #include <string>
00020 
00021 #include "zypp/base/ReferenceCounted.h"
00022 #include "zypp/Callback.h"
00023 #include "zypp/base/PtrTypes.h"
00024 #include "zypp/Locale.h"
00025 #include "zypp/PublicKey.h"
00026 
00028 namespace zypp
00029 { 
00030 
00031   DEFINE_PTR_TYPE(KeyRing);
00032 
00033   struct KeyRingReport : public callback::ReportBase
00034   {
00035 
00036     virtual bool askUserToAcceptUnsignedFile( const std::string &file );
00037 
00043     virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id );
00044 
00049     virtual bool askUserToTrustKey( const PublicKey &key);
00050 
00051 
00060     virtual bool askUserToImportKey( const PublicKey &key);
00061     virtual bool askUserToAcceptVerificationFailed( const std::string &file, const PublicKey &key );
00062   };
00063 
00064   struct KeyRingSignals : public callback::ReportBase
00065   {
00066     virtual void trustedKeyAdded( const PublicKey &/*key*/ )
00067     {}
00068     virtual void trustedKeyRemoved( const PublicKey &/*key*/ )
00069     {}
00070   };
00071 
00072   class KeyRingException : public Exception
00073    {
00074      public:
00078        KeyRingException()
00079        : Exception( "Bad Key Exception" )
00080        {}
00084        KeyRingException( const std::string & msg_r )
00085        : Exception( msg_r )
00086        {}
00088        virtual ~KeyRingException() throw() {};
00089    };
00090 
00092   //
00093   //    CLASS NAME : KeyRing
00094   //
00097   class KeyRing  : public base::ReferenceCounted, private base::NonCopyable
00098   {
00099     friend std::ostream & operator<<( std::ostream & str, const KeyRing & obj );
00100 
00101   public:
00103     class Impl;
00104 
00105   public:
00107     KeyRing(const Pathname &baseTmpDir);
00108     //explicit
00109     //KeyRing(const Pathname &general_kr, const Pathname &trusted_kr);
00110 
00115     void importKey( const PublicKey &key, bool trusted = false);
00116 
00117     void dumpTrustedPublicKey( const std::string &id, std::ostream &stream )
00118     { dumpPublicKey(id, true, stream); }
00119 
00120     void dumpUntrustedPublicKey( const std::string &id, std::ostream &stream )
00121     { dumpPublicKey(id, false, stream); }
00122 
00123     void dumpPublicKey( const std::string &id, bool trusted, std::ostream &stream );
00124 
00128     std::string readSignatureKeyId( const Pathname &signature );
00129 
00133     bool isKeyTrusted( const std::string &id);
00134 
00139     bool isKeyKnown( const std::string &id );
00140 
00145     void deleteKey( const std::string &id, bool trusted =  false);
00146 
00150     std::list<PublicKey> publicKeys();
00151 
00155     std::list<PublicKey> trustedPublicKeys();
00156 
00160     std::list<std::string> publicKeyIds();
00161 
00165     std::list<std::string> trustedPublicKeyIds();
00166 
00171     bool verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature);
00172     bool verifyFileSignature( const Pathname &file, const Pathname &signature);
00173     bool verifyFileTrustedSignature( const Pathname &file, const Pathname &signature);
00174 
00176     ~KeyRing();
00177 
00178   public:
00179 
00181     //std::string asString() const
00182     //{}
00183 
00184   private:
00186     RWCOW_pointer<Impl> _pimpl;
00187   };
00189 
00191   inline std::ostream & operator<<( std::ostream & str, const KeyRing & /*obj*/ )
00192   {
00193     //return str << obj.asString();
00194     return str;
00195   }
00196 
00198 
00199   namespace target
00200   {
00201     namespace rpm
00202     {
00204       struct KeyRingSignals : public ::zypp::KeyRingSignals
00205       {};
00206     }
00207   }
00208 
00210 } // namespace zypp
00212 #endif // ZYPP_KEYRING_H

Generated on Tue Sep 25 19:23:01 2007 for libzypp by  doxygen 1.5.3