libzypp 17.37.17
KeyRing.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_KEYRING_H
13#define ZYPP_KEYRING_H
14
15#include <iosfwd>
16#include <map>
17#include <list>
18#include <set>
19#include <string>
20
22#include <zypp/base/Flags.h>
23#include <zypp/Callback.h>
24#include <zypp/base/PtrTypes.h>
25#include <zypp/Locale.h>
27
28#include <zypp-common/PublicKey.h>
29#include <zypp-common/KeyRingException.h>
30
32namespace zypp
33{
34
36
47 {
74
79 virtual KeyTrust askUserToAcceptKey( const PublicKey &key, const KeyContext &keycontext = KeyContext() );
80
82 virtual void infoVerify( const std::string & file_r, const PublicKeyData & keyData_r, const KeyContext &keycontext = KeyContext() );
83
84 virtual bool askUserToAcceptUnsignedFile( const std::string &file, const KeyContext &keycontext = KeyContext() );
85
92 virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id, const KeyContext &keycontext = KeyContext() );
93
99 virtual bool askUserToAcceptVerificationFailed( const std::string &file, const PublicKey &key, const KeyContext &keycontext = KeyContext() );
100
117 bool askUserToAcceptPackageKey( const PublicKey &key_r, const KeyContext &keycontext_r = KeyContext() );
119 constexpr static const char * ACCEPT_PACKAGE_KEY_REQUEST = "KeyRingReport/AcceptPackageKey";
120
130 void reportNonImportedKeys( const std::set<Edition> &keys_r );
132 constexpr static const char *KEYS_NOT_IMPORTED_REPORT = "KeyRingReport/KeysNotImported";
133
134
147 void reportAutoImportKey( const std::list<PublicKeyData> & keyDataList_r,
148 const PublicKeyData & keySigning_r,
149 const KeyContext &keyContext_r );
151 constexpr static const char *REPORT_AUTO_IMPORT_KEY = "KeyRingReport/reportAutoImportKey";
152 };
153
155 {
156 virtual void trustedKeyAdded( const PublicKey &/*key*/ )
157 {}
158 virtual void trustedKeyRemoved( const PublicKey &/*key*/ )
159 {}
160 };
161
163 //
164 // CLASS NAME : KeyRing
165 //
170 {
171 friend std::ostream & operator<<( std::ostream & str, const KeyRing & obj );
172
173 public:
178
195
197 static DefaultAccept defaultAccept();
198
200 static void setDefaultAccept( DefaultAccept value_r );
202
203 public:
205 struct Impl;
206
207 public:
209 KeyRing(const Pathname &baseTmpDir);
210
215 void importKey( const PublicKey &key, bool trusted = false);
216
218 void multiKeyImport( const Pathname & keyfile_r, bool trusted_r = false );
219
220 void dumpTrustedPublicKey( const std::string &id, std::ostream &stream )
221 { dumpPublicKey(id, true, stream); }
222
223 void dumpUntrustedPublicKey( const std::string &id, std::ostream &stream )
224 { dumpPublicKey(id, false, stream); }
225
226 void dumpPublicKey( const std::string &id, bool trusted, std::ostream &stream );
227
229 PublicKey exportPublicKey( const PublicKeyData & keyData );
230
232 PublicKey exportTrustedPublicKey( const PublicKeyData & keyData );
233
237 std::string readSignatureKeyId( const Pathname &signature );
238
242 bool isKeyTrusted( const std::string &id );
243
248 bool isKeyKnown( const std::string &id );
249
254 void deleteKey( const std::string &id, bool trusted = false );
255
259 std::list<PublicKey> publicKeys();
260
264 std::list<PublicKey> trustedPublicKeys();
265
269 std::list<PublicKeyData> publicKeyData();
270
274 std::list<PublicKeyData> trustedPublicKeyData();
275
279 PublicKeyData publicKeyData( const std::string &id );
280
284 PublicKeyData trustedPublicKeyData( const std::string &id );
285
292 bool verifyFileSignature( const Pathname &file, const Pathname &signature ) ZYPP_API;
293
294 bool verifyFileTrustedSignature( const Pathname &file, const Pathname &signature ) ZYPP_API;
295
297 ~KeyRing() override;
298
300 KeyRing::Impl &pimpl();
301
302 public:
304 void allowPreload( bool yesno_r );
305
306 private:
309 };
310
311
313 inline std::ostream & operator<<( std::ostream & str, const KeyRing & /*obj*/ )
314 {
315 //return str << obj.asString();
316 return str;
317 }
318
320 ZYPP_DECLARE_OPERATORS_FOR_FLAGS( KeyRing::DefaultAccept );
321
323
324 namespace target
325 {
326 namespace rpm
327 {
330 {};
331 }
332 }
333
335} // namespace zypp
337#endif // ZYPP_KEYRING_H
Gpg key handling.
Definition KeyRing.h:170
std::ostream & operator<<(std::ostream &str, const KeyRing &)
Stream output.
Definition KeyRing.h:313
ZYPP_DECLARE_FLAGS(DefaultAccept, DefaultAcceptBits)
static DefaultAccept defaultAccept()
Get the active accept bits.
Definition KeyRing.cc:53
void dumpTrustedPublicKey(const std::string &id, std::ostream &stream)
Definition KeyRing.h:220
void dumpPublicKey(const std::string &id, bool trusted, std::ostream &stream)
Definition KeyRing.cc:224
friend std::ostream & operator<<(std::ostream &str, const KeyRing &obj)
void multiKeyImport(const Pathname &keyfile_r, bool trusted_r=false)
Initial import from RpmDb.
Definition KeyRing.cc:192
KeyRing(const Pathname &baseTmpDir)
Default ctor.
Definition KeyRing.cc:173
void dumpUntrustedPublicKey(const std::string &id, std::ostream &stream)
Definition KeyRing.h:223
void importKey(const PublicKey &key, bool trusted=false)
imports a key from a file.
Definition KeyRing.cc:189
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition KeyRing.h:308
static void setDefaultAccept(DefaultAccept value_r)
Set the active accept bits.
Definition KeyRing.cc:56
DefaultAcceptBits
DefaultAccept flags (
Definition KeyRing.h:186
@ TRUST_KEY_TEMPORARILY
Definition KeyRing.h:190
@ ACCEPT_VERIFICATION_FAILED
Definition KeyRing.h:192
@ ACCEPT_UNKNOWNKEY
Definition KeyRing.h:189
@ TRUST_AND_IMPORT_KEY
Definition KeyRing.h:191
@ ACCEPT_UNSIGNED_FILE
Definition KeyRing.h:188
Base class for reference counted objects.
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
Easy-to use interface to the ZYPP dependency resolver.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
Callbacks from signature verification workflow.
Definition KeyRing.h:47
void reportNonImportedKeys(const std::set< Edition > &keys_r)
Notify the user about keys that were not imported from the rpm key database into zypp keyring.
Definition KeyRing.cc:96
KeyTrust
User reply options for the askUserToTrustKey callback.
Definition KeyRing.h:54
@ KEY_TRUST_AND_IMPORT
Import the key.
Definition KeyRing.h:72
@ KEY_DONT_TRUST
User has chosen not to trust the key.
Definition KeyRing.h:58
@ KEY_TRUST_TEMPORARILY
This basically means, we knew the key, but it was not trusted.
Definition KeyRing.h:63
static constexpr const char * REPORT_AUTO_IMPORT_KEY
generic reports UserData::type
Definition KeyRing.h:151
static constexpr const char * ACCEPT_PACKAGE_KEY_REQUEST
generic reports UserData::type
Definition KeyRing.h:119
static constexpr const char * KEYS_NOT_IMPORTED_REPORT
generic reports UserData::type
Definition KeyRing.h:132
void reportAutoImportKey(const std::list< PublicKeyData > &keyDataList_r, const PublicKeyData &keySigning_r, const KeyContext &keyContext_r)
Notify that a repository auto imported new package signing keys.
Definition KeyRing.cc:103
virtual void trustedKeyAdded(const PublicKey &)
Definition KeyRing.h:156
virtual void trustedKeyRemoved(const PublicKey &)
Definition KeyRing.h:158
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
Internal connection to rpm database.
Definition KeyRing.h:330
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639