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 KeyRing &/*keyring*/, const PublicKey &/*key*/ )
00067     {}
00068     virtual void trustedKeyRemoved( const KeyRing &/*keyring*/, 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 
00147     std::list<PublicKey> publicKeys();
00148     std::list<PublicKey> trustedPublicKeys();
00149 
00154     bool verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature);
00155     bool verifyFileSignature( const Pathname &file, const Pathname &signature);
00156     bool verifyFileTrustedSignature( const Pathname &file, const Pathname &signature);
00157 
00159     ~KeyRing();
00160 
00161   public:
00162 
00164     //std::string asString() const
00165     //{}
00166 
00167   private:
00169     RWCOW_pointer<Impl> _pimpl;
00170   };
00172 
00174   inline std::ostream & operator<<( std::ostream & str, const KeyRing & /*obj*/ )
00175   {
00176     //return str << obj.asString();
00177     return str;
00178   }
00179 
00181 } // namespace zypp
00183 #endif // ZYPP_KEYRING_H

Generated on Thu Apr 24 02:24:49 2008 for zypp by  doxygen 1.4.6