libzypp  10.5.0
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   namespace filesystem
00030   {
00031     class TmpFile;
00032   }
00033 
00038   class BadKeyException : public Exception
00039   {
00040     public:
00044       BadKeyException()
00045       : Exception( "Bad Key Exception" )
00046       {}
00047 
00048       Pathname keyFile() const
00049       { return _keyfile; }
00050 
00054       BadKeyException( const std::string & msg_r, const Pathname &keyfile = Pathname() )
00055       : Exception( msg_r ), _keyfile(keyfile)
00056       {}
00058       virtual ~BadKeyException() throw() {};
00059     private:
00060       Pathname _keyfile;
00061   };
00062 
00063 
00064   // forward declaration of class Date
00065   class Date;
00066 
00068   //
00069   //    CLASS NAME : PublicKey
00070   //
00076   class PublicKey
00077   {
00078     friend std::ostream & operator<<( std::ostream & str, const PublicKey & obj );
00079 
00080   public:
00082     class Impl;
00083 
00084   public:
00086     PublicKey();
00087 
00096     explicit
00097     PublicKey( const Pathname & file );
00098 
00105     explicit
00106     PublicKey( const filesystem::TmpFile & sharedfile );
00107 
00108     ~PublicKey();
00109 
00110     bool isValid() const
00111     { return ( ! id().empty() && ! fingerprint().empty() && !path().empty() ); }
00112 
00113     std::string asString() const;
00114     std::string id() const;
00115     std::string name() const;
00116     std::string fingerprint() const;
00117 
00137     std::string gpgPubkeyVersion() const;
00138 
00143     std::string gpgPubkeyRelease() const;
00144 
00148     Date created() const;
00149 
00154     Date expires() const;
00155 
00169     std::string expiresAsString() const;
00170 
00172     bool expired() const;
00173 
00179     int daysToLive() const;
00180 
00181     Pathname path() const;
00182 
00183     bool operator==( PublicKey b ) const;
00184     bool operator==( std::string sid ) const;
00185 
00186   private:
00188     RWCOW_pointer<Impl> _pimpl;
00189   };
00191 
00193   inline std::ostream & operator<<( std::ostream & str, const PublicKey & obj )
00194   { return str << obj.asString(); }
00195 
00197   std::ostream & dumpOn( std::ostream & str, const PublicKey & obj );
00198 
00200 } // namespace zypp
00202 #endif // ZYPP_PUBLICKEY_H