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 class BadKeyException : public Exception
33 /** Ctor taking message.
34 * Use \ref ZYPP_THROW to throw exceptions.
37 : Exception( "Bad Key Exception" )
40 Pathname keyFile() const
43 /** Ctor taking message.
44 * Use \ref ZYPP_THROW to throw exceptions.
46 BadKeyException( const std::string & msg_r, const Pathname &keyfile = Pathname() )
47 : Exception( msg_r ), _keyfile(keyfile)
50 virtual ~BadKeyException() throw() {};
56 ///////////////////////////////////////////////////////////////////
58 // CLASS NAME : PublicKey
60 /** Class that represent a GPG Public Key
64 friend std::ostream & operator<<( std::ostream & str, const PublicKey & obj );
73 * \throws when data does not make a key
75 PublicKey(const Pathname &file);
80 { return ( ! id().empty() && ! fingerprint().empty() && !path().empty() ); }
82 std::string asString() const;
83 std::string armoredData() const;
84 std::string id() const;
85 std::string name() const;
86 std::string fingerprint() const;
87 Pathname path() const;
89 bool operator==( PublicKey b )
90 { return (b.id() == id()) && (b.fingerprint() == fingerprint() ); }
92 bool operator==( std::string sid )
93 { return sid == id(); }
96 /** Pointer to implementation */
97 RWCOW_pointer<Impl> _pimpl;
99 ///////////////////////////////////////////////////////////////////
101 /** \relates PublicKey Stream output */
102 inline std::ostream & operator<<( std::ostream & str, const PublicKey & obj )
103 { return str << obj.asString(); }
105 /////////////////////////////////////////////////////////////////
107 ///////////////////////////////////////////////////////////////////
108 #endif // ZYPP_PUBLICKEY_H