1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/PublicKey.h
12 #ifndef ZYPP_PUBLICKEY_H
13 #define ZYPP_PUBLICKEY_H
21 #include "zypp/base/PtrTypes.h"
22 #include "zypp/base/Exception.h"
23 #include "zypp/Pathname.h"
25 ///////////////////////////////////////////////////////////////////
27 { /////////////////////////////////////////////////////////////////
30 * Exception thrown when the supplied key is
33 class BadKeyException : public Exception
36 /** Ctor taking message.
37 * Use \ref ZYPP_THROW to throw exceptions.
40 : Exception( "Bad Key Exception" )
43 Pathname keyFile() const
46 /** Ctor taking message.
47 * Use \ref ZYPP_THROW to throw exceptions.
49 BadKeyException( const std::string & msg_r, const Pathname &keyfile = Pathname() )
50 : Exception( msg_r ), _keyfile(keyfile)
53 virtual ~BadKeyException() throw() {};
59 // forward declaration of class Date
62 ///////////////////////////////////////////////////////////////////
64 // CLASS NAME : PublicKey
67 * Class that represent a GPG Public Key
71 friend std::ostream & operator<<( std::ostream & str, const PublicKey & obj );
80 * \throws when data does not make a key
82 PublicKey(const Pathname &file);
87 { return ( ! id().empty() && ! fingerprint().empty() && !path().empty() ); }
89 std::string asString() const;
90 std::string armoredData() const;
91 std::string id() const;
92 std::string name() const;
93 std::string fingerprint() const;
96 * Date when the key was created (time is 00:00:00)
101 * Date when the key expires (time is 00:00:00)
102 * If the key never expires the date is Date() (i.e. 0 seconds since the epoch (1.1.1970))
104 Date expires() const;
106 Pathname path() const;
108 bool operator==( PublicKey b ) const;
109 bool operator==( std::string sid ) const;
112 /** Pointer to implementation */
113 RWCOW_pointer<Impl> _pimpl;
115 ///////////////////////////////////////////////////////////////////
117 /** \relates PublicKey Stream output */
118 inline std::ostream & operator<<( std::ostream & str, const PublicKey & obj )
119 { return str << obj.asString(); }
121 /** \relates PublicKey Detailed stream output */
122 std::ostream & dumpOn( std::ostream & str, const PublicKey & obj );
124 /////////////////////////////////////////////////////////////////
126 ///////////////////////////////////////////////////////////////////
127 #endif // ZYPP_PUBLICKEY_H