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   class Date;
00034 
00035 
00040   class BadKeyException : public Exception
00041   {
00042     public:
00046       BadKeyException()
00047       : Exception( "Bad Key Exception" )
00048       {}
00049 
00050       Pathname keyFile() const
00051       { return _keyfile; }
00052 
00056       BadKeyException( const std::string & msg_r, const Pathname &keyfile = Pathname() )
00057       : Exception( msg_r ), _keyfile(keyfile)
00058       {}
00060       virtual ~BadKeyException() throw() {};
00061     private:
00062       Pathname _keyfile;
00063   };
00064 
00065 
00072   class PublicKey
00073   {
00074     friend std::ostream & operator<<( std::ostream & str, const PublicKey & obj );
00075 
00076   public:
00078     class Impl;
00079 
00080   public:
00082     PublicKey();
00083 
00092     explicit
00093     PublicKey( const Pathname & file );
00094 
00101     explicit
00102     PublicKey( const filesystem::TmpFile & sharedfile );
00103 
00104     ~PublicKey();
00105 
00106     bool isValid() const
00107     { return ( ! id().empty() && ! fingerprint().empty() && !path().empty() ); }
00108 
00109     std::string asString() const;
00110     std::string armoredData() const; 
00111     std::string id() const;
00112     std::string name() const;
00113     std::string fingerprint() const;
00114 
00134     std::string gpgPubkeyVersion() const;
00135 
00140     std::string gpgPubkeyRelease() const;
00141 
00145     Date created() const;
00146 
00151     Date expires() const;
00152 
00166     std::string expiresAsString() const;
00167 
00169     bool expired() const;
00170 
00176     int daysToLive() const;
00177 
00178     Pathname path() const;
00179 
00180     bool operator==( PublicKey b ) const;
00181     bool operator==( std::string sid ) const;
00182 
00183   private:
00185     RWCOW_pointer<Impl> _pimpl;
00186   };
00188 
00190   inline std::ostream & operator<<( std::ostream & str, const PublicKey & obj )
00191   { return str << obj.asString(); }
00192 
00194   std::ostream & dumpOn( std::ostream & str, const PublicKey & obj );
00195 
00197 } // namespace zypp
00199 #endif // ZYPP_PUBLICKEY_H

doxygen