PublicKey.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_PUBLICKEY_H
00013 #define ZYPP_PUBLICKEY_H
00014 
00015 #include <iosfwd>
00016 #include <map>
00017 #include <list>
00018 #include <set>
00019 #include <string>
00020 
00021 #include "zypp/base/PtrTypes.h"
00022 #include "zypp/base/Exception.h"
00023 #include "zypp/Pathname.h"
00024 
00026 namespace zypp
00027 { 
00028   
00029   
00030   class BadKeyException : public Exception
00031   {
00032     public:
00036       BadKeyException()
00037       : Exception( "Bad Key Exception" )
00038       {}
00039       
00040       Pathname keyFile() const
00041       { return _keyfile; }
00042       
00046       BadKeyException( const std::string & msg_r, const Pathname &keyfile = Pathname() )
00047       : Exception( msg_r ), _keyfile(keyfile)
00048       {}
00050       virtual ~BadKeyException() throw() {};
00051     private:
00052       Pathname _keyfile;
00053   };
00054   
00055   
00057   //
00058   //    CLASS NAME : PublicKey
00059   //
00062   class PublicKey
00063   {
00064     friend std::ostream & operator<<( std::ostream & str, const PublicKey & obj );
00065 
00066   public:
00068     class Impl;
00069 
00070   public:
00071     PublicKey();
00075     PublicKey(const Pathname &file);
00076     
00077     ~PublicKey();
00078    
00079     bool isValid() const
00080     { return ( ! id().empty() && ! fingerprint().empty() && !path().empty() ); }
00081     
00082     std::string asString() const;
00083     std::string armoredData() const;
00084     std::string id() const;
00085     std::string name() const;
00086     std::string fingerprint() const;
00087     Pathname path() const; 
00088     
00089     bool operator==( PublicKey b )
00090     { return (b.id() == id()) && (b.fingerprint() == fingerprint() ); }
00091     
00092     bool operator==( std::string sid )
00093     { return sid == id(); }
00094     
00095   private:
00097     RWCOW_pointer<Impl> _pimpl;
00098   };
00100 
00102   inline std::ostream & operator<<( std::ostream & str, const PublicKey & obj )
00103   { return str << obj.asString(); }
00104 
00106 } // namespace zypp
00108 #endif // ZYPP_PUBLICKEY_H

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