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     virtual bool askUserToAcceptUnsignedFile( const std::string &file );
00036     virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id );
00037     virtual bool askUserToTrustKey( const PublicKey &key);
00038     virtual bool askUserToImportKey( const PublicKey &key);
00039     virtual bool askUserToAcceptVerificationFailed( const std::string &file, const PublicKey &key );
00040   };
00041   
00042   struct KeyRingSignals : public callback::ReportBase
00043   {
00044     virtual void trustedKeyAdded( const KeyRing &/*keyring*/, const PublicKey &/*key*/ )
00045     {}
00046     virtual void trustedKeyRemoved( const KeyRing &/*keyring*/, const PublicKey &/*key*/ )
00047     {}
00048   };
00049 
00050   class KeyRingException : public Exception
00051    {
00052      public:
00056        KeyRingException()
00057        : Exception( "Bad Key Exception" )
00058        {}
00062        KeyRingException( const std::string & msg_r )
00063        : Exception( msg_r )
00064        {}
00066        virtual ~KeyRingException() throw() {};
00067    };
00068   
00070   //
00071   //    CLASS NAME : KeyRing
00072   //
00075   class KeyRing  : public base::ReferenceCounted, private base::NonCopyable
00076   {
00077     friend std::ostream & operator<<( std::ostream & str, const KeyRing & obj );
00078 
00079   public:
00081     class Impl;
00082 
00083   public:
00085     KeyRing(const Pathname &baseTmpDir);
00086     //explicit
00087     //KeyRing(const Pathname &general_kr, const Pathname &trusted_kr);
00088 
00093     void importKey( const PublicKey &key, bool trusted = false);
00094     
00095     void dumpTrustedPublicKey( const std::string &id, std::ostream &stream )
00096     { dumpPublicKey(id, true, stream); }
00097     
00098     void dumpUntrustedPublicKey( const std::string &id, std::ostream &stream )
00099     { dumpPublicKey(id, false, stream); }
00100     
00101     void dumpPublicKey( const std::string &id, bool trusted, std::ostream &stream );
00102     
00106     std::string readSignatureKeyId( const Pathname &signature );
00107     
00112     void deleteKey( const std::string &id, bool trusted =  false);
00113 
00114     std::list<PublicKey> publicKeys();
00115     std::list<PublicKey> trustedPublicKeys();
00116 
00121     bool verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature);
00122     bool verifyFileSignature( const Pathname &file, const Pathname &signature);
00123     bool verifyFileTrustedSignature( const Pathname &file, const Pathname &signature);
00124 
00126     ~KeyRing();
00127 
00128   public:
00129 
00131     //std::string asString() const
00132     //{}
00133 
00134   private:
00136     RWCOW_pointer<Impl> _pimpl;
00137   };
00139 
00141   inline std::ostream & operator<<( std::ostream & str, const KeyRing & /*obj*/ )
00142   {
00143     //return str << obj.asString();
00144     return str;
00145   }
00146 
00148 } // namespace zypp
00150 #endif // ZYPP_KEYRING_H

Generated on Tue Nov 28 16:49:29 2006 for zypp by  doxygen 1.5.0