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 ///////////////////////////////////////////////////////////////////
61 // CLASS NAME : PublicKey
64 * Class that represent a GPG Public Key
68 friend std::ostream & operator<<( std::ostream & str, const PublicKey & obj );
77 * \throws when data does not make a key
79 PublicKey(const Pathname &file);
84 { return ( ! id().empty() && ! fingerprint().empty() && !path().empty() ); }
86 std::string asString() const;
87 std::string armoredData() const;
88 std::string id() const;
89 std::string name() const;
90 std::string fingerprint() const;
91 Pathname path() const;
93 bool operator==( PublicKey b ) const;
94 bool operator==( std::string sid ) const;
97 /** Pointer to implementation */
98 RWCOW_pointer<Impl> _pimpl;
100 ///////////////////////////////////////////////////////////////////
102 /** \relates PublicKey Stream output */
103 inline std::ostream & operator<<( std::ostream & str, const PublicKey & obj )
104 { return str << obj.asString(); }
106 /////////////////////////////////////////////////////////////////
108 ///////////////////////////////////////////////////////////////////
109 #endif // ZYPP_PUBLICKEY_H