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 00033 class BadKeyException : public Exception 00034 { 00035 public: 00039 BadKeyException() 00040 : Exception( "Bad Key Exception" ) 00041 {} 00042 00043 Pathname keyFile() const 00044 { return _keyfile; } 00045 00049 BadKeyException( const std::string & msg_r, const Pathname &keyfile = Pathname() ) 00050 : Exception( msg_r ), _keyfile(keyfile) 00051 {} 00053 virtual ~BadKeyException() throw() {}; 00054 private: 00055 Pathname _keyfile; 00056 }; 00057 00058 00060 // 00061 // CLASS NAME : PublicKey 00062 // 00066 class PublicKey 00067 { 00068 friend std::ostream & operator<<( std::ostream & str, const PublicKey & obj ); 00069 00070 public: 00072 class Impl; 00073 00074 public: 00075 PublicKey(); 00079 PublicKey(const Pathname &file); 00080 00081 ~PublicKey(); 00082 00083 bool isValid() const 00084 { return ( ! id().empty() && ! fingerprint().empty() && !path().empty() ); } 00085 00086 std::string asString() const; 00087 std::string armoredData() const; 00088 std::string id() const; 00089 std::string name() const; 00090 std::string fingerprint() const; 00091 Pathname path() const; 00092 00093 bool operator==( PublicKey b ) const; 00094 bool operator==( std::string sid ) const; 00095 00096 private: 00098 RWCOW_pointer<Impl> _pimpl; 00099 }; 00101 00103 inline std::ostream & operator<<( std::ostream & str, const PublicKey & obj ) 00104 { return str << obj.asString(); } 00105 00107 } // namespace zypp 00109 #endif // ZYPP_PUBLICKEY_H
1.5.3