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 
00027 namespace zypp
00028 { 
00029 
00030   DEFINE_PTR_TYPE(KeyRing);
00031 
00032   struct KeyRingReport : public callback::ReportBase
00033   {
00034     virtual bool askUserToAcceptUnsignedFile( const std::string &file );
00035     virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &keyid, const std::string &keyname, const std::string &fingerprint );
00036     virtual bool askUserToTrustKey( const std::string &keyid, const std::string &keyname, const std::string &fingerprint);
00037     virtual bool askUserToAcceptVerificationFailed( const std::string &file, const std::string &keyid, const std::string &keyname, const std::string &fingerprint );
00038   };
00039   
00040   struct KeyRingSignals : public callback::ReportBase
00041   {
00042     virtual void trustedKeyAdded( const KeyRing &keyring, const std::string &keyid, const std::string &keyname, const std::string &fingerprint )
00043     {}
00044     virtual void trustedKeyRemoved( const KeyRing &keyring, const std::string &keyid, const std::string &keyname, const std::string &fingerprint )
00045     {}
00046   };
00047   
00048   struct PublicKey
00049   {
00050     bool operator==(PublicKey b)
00051     { return (b.id == id) && (b.fingerprint == fingerprint); }
00052     
00053     bool operator==(std::string sid)
00054     { return sid == id; }
00055     
00056     std::string id;
00057     std::string name;
00058     std::string fingerprint;
00059   };
00060 
00062   //
00063   //    CLASS NAME : KeyRing
00064   //
00067   class KeyRing  : public base::ReferenceCounted, private base::NonCopyable
00068   {
00069     friend std::ostream & operator<<( std::ostream & str, const KeyRing & obj );
00070 
00071   public:
00073     class Impl;
00074 
00075   public:
00077     KeyRing(const Pathname &baseTmpDir);
00078     //explicit
00079     //KeyRing(const Pathname &general_kr, const Pathname &trusted_kr);
00080 
00085     void importKey( const Pathname &keyfile, bool trusted = false);
00086     PublicKey readPublicKey( const Pathname &keyfile );
00087     
00088     void dumpTrustedPublicKey( const std::string &id, std::ostream &stream )
00089     { dumpPublicKey(id, true, stream); }
00090     
00091     void dumpUntrustedPublicKey( const std::string &id, std::ostream &stream )
00092     { dumpPublicKey(id, false, stream); }
00093     
00094     void dumpPublicKey( const std::string &id, bool trusted, std::ostream &stream );
00095     
00099     std::string readSignatureKeyId( const Pathname &signature );
00100     
00105     void deleteKey( const std::string &id, bool trusted =  false);
00106 
00107     std::list<PublicKey> publicKeys();
00108     std::list<PublicKey> trustedPublicKeys();
00109 
00114     bool verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature);
00115     
00116     bool verifyFileSignature( const Pathname &file, const Pathname &signature);
00117     bool verifyFileTrustedSignature( const Pathname &file, const Pathname &signature);
00118 
00120     ~KeyRing();
00121 
00122   public:
00123 
00125     //std::string asString() const
00126     //{}
00127 
00128   private:
00130     RWCOW_pointer<Impl> _pimpl;
00131   };
00133 
00135   inline std::ostream & operator<<( std::ostream & str, const KeyRing & obj )
00136   {
00137     //return str << obj.asString();
00138     return str;
00139   }
00140 
00142 } // namespace zypp
00144 #endif // ZYPP_KEYRING_H

Generated on Thu Jul 6 00:07:21 2006 for zypp by  doxygen 1.4.6