libzypp
17.14.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
21
#include "
zypp/base/ReferenceCounted.h
"
22
#include "
zypp/base/Flags.h
"
23
#include "
zypp/Callback.h
"
24
#include "
zypp/base/PtrTypes.h
"
25
#include "
zypp/Locale.h
"
26
#include "
zypp/PublicKey.h
"
27
#include "
zypp/KeyContext.h
"
28
30
namespace
zypp
31
{
32
33
DEFINE_PTR_TYPE
(KeyRing);
34
44
struct
KeyRingReport
:
public
callback::ReportBase
45
{
51
enum
KeyTrust
52
{
56
KEY_DONT_TRUST
= 0,
61
KEY_TRUST_TEMPORARILY
,
70
KEY_TRUST_AND_IMPORT
71
};
72
77
virtual
KeyTrust
askUserToAcceptKey
(
const
PublicKey
&key,
const
KeyContext
&keycontext =
KeyContext
() );
78
80
virtual
void
infoVerify
(
const
std::string & file_r,
const
PublicKeyData
& keyData_r,
const
KeyContext
&keycontext =
KeyContext
() );
81
82
virtual
bool
askUserToAcceptUnsignedFile
(
const
std::string &file,
const
KeyContext
&keycontext =
KeyContext
() );
83
90
virtual
bool
askUserToAcceptUnknownKey
(
const
std::string &file,
const
std::string &
id
,
const
KeyContext
&keycontext =
KeyContext
() );
91
97
virtual
bool
askUserToAcceptVerificationFailed
(
const
std::string &file,
const
PublicKey
&key,
const
KeyContext
&keycontext =
KeyContext
() );
98
115
bool
askUserToAcceptPackageKey
(
const
PublicKey
&key_r,
const
KeyContext
&keycontext_r =
KeyContext
() );
117
constexpr
static
const
char
*
ACCEPT_PACKAGE_KEY_REQUEST
=
"KeyRingReport/AcceptPackageKey"
;
118
128
void
reportNonImportedKeys
(
const
std::set<Edition> &keys_r );
130
constexpr
static
const
char
*
KEYS_NOT_IMPORTED_REPORT
=
"KeyRingReport/KeysNotImported"
;
131
132
};
133
134
struct
KeyRingSignals
:
public
callback::ReportBase
135
{
136
virtual
void
trustedKeyAdded
(
const
PublicKey
&
/*key*/
)
137
{}
138
virtual
void
trustedKeyRemoved
(
const
PublicKey
&
/*key*/
)
139
{}
140
};
141
142
class
KeyRingException
:
public
Exception
143
{
144
public
:
148
KeyRingException
()
149
:
Exception
(
"Bad Key Exception"
)
150
{}
154
KeyRingException
(
const
std::string & msg_r )
155
:
Exception
( msg_r )
156
{}
158
virtual
~KeyRingException
() throw() {};
159
};
160
162
//
163
// CLASS NAME : KeyRing
164
//
168
class
KeyRing
:
public
base::ReferenceCounted
,
private
base::NonCopyable
169
{
170
friend
std::ostream &
operator<<
( std::ostream & str,
const
KeyRing
& obj );
171
172
public
:
184
enum
DefaultAcceptBits
185
{
186
ACCEPT_NOTHING
= 0x0000,
187
ACCEPT_UNSIGNED_FILE
= 0x0001,
188
ACCEPT_UNKNOWNKEY
= 0x0002,
189
TRUST_KEY_TEMPORARILY
= 0x0004,
190
TRUST_AND_IMPORT_KEY
= 0x0008,
191
ACCEPT_VERIFICATION_FAILED
= 0x0010,
192
};
193
ZYPP_DECLARE_FLAGS
( DefaultAccept,
DefaultAcceptBits
);
194
196
static
DefaultAccept
defaultAccept
();
197
199
static
void
setDefaultAccept
( DefaultAccept value_r );
201
202
public
:
204
struct
Impl
;
205
206
public
:
208
KeyRing
(
const
Pathname &baseTmpDir);
209
214
void
importKey
(
const
PublicKey
&key,
bool
trusted =
false
);
215
217
void
multiKeyImport
(
const
Pathname & keyfile_r,
bool
trusted_r =
false
);
218
219
void
dumpTrustedPublicKey
(
const
std::string &
id
, std::ostream &stream )
220
{
dumpPublicKey
(
id
,
true
, stream); }
221
222
void
dumpUntrustedPublicKey
(
const
std::string &
id
, std::ostream &stream )
223
{
dumpPublicKey
(
id
,
false
, stream); }
224
225
void
dumpPublicKey
(
const
std::string &
id
,
bool
trusted, std::ostream &stream );
226
228
PublicKey
exportPublicKey
(
const
PublicKeyData
& keyData );
229
231
PublicKey
exportTrustedPublicKey
(
const
PublicKeyData
& keyData );
232
236
std::string
readSignatureKeyId
(
const
Pathname &signature );
237
241
bool
isKeyTrusted
(
const
std::string &
id
);
242
247
bool
isKeyKnown
(
const
std::string &
id
);
248
253
void
deleteKey
(
const
std::string &
id
,
bool
trusted =
false
);
254
258
std::list<PublicKey>
publicKeys
();
259
263
std::list<PublicKey>
trustedPublicKeys
();
264
268
std::list<PublicKeyData>
publicKeyData
();
269
273
std::list<PublicKeyData>
trustedPublicKeyData
();
274
278
PublicKeyData
trustedPublicKeyData
(
const
std::string &
id
);
279
310
bool
verifyFileSignatureWorkflow
(
const
Pathname &file,
const
std::string &filedesc,
const
Pathname &signature,
bool
& sigValid_r,
const
KeyContext
&keycontext =
KeyContext
());
312
bool
verifyFileSignatureWorkflow
(
const
Pathname &file,
const
std::string filedesc,
const
Pathname &signature,
const
KeyContext
&keycontext =
KeyContext
());
313
320
bool
verifyFileSignature
(
const
Pathname &file,
const
Pathname &signature );
321
322
bool
verifyFileTrustedSignature
(
const
Pathname &file,
const
Pathname &signature );
323
328
bool
provideAndImportKeyFromRepositoryWorkflow
(
const
std::string &
id
,
const
RepoInfo
&info );
329
331
~KeyRing
();
332
333
private
:
335
RW_pointer<Impl>
_pimpl
;
336
};
338
340
inline
std::ostream &
operator<<
( std::ostream & str,
const
KeyRing
&
/*obj*/
)
341
{
342
//return str << obj.asString();
343
return
str;
344
}
345
347
ZYPP_DECLARE_OPERATORS_FOR_FLAGS
( KeyRing::DefaultAccept );
348
350
351
namespace
target
352
{
353
namespace
rpm
354
{
356
struct
KeyRingSignals
:
public
::zypp::KeyRingSignals
357
{};
358
}
359
}
360
362
}
// namespace zypp
364
#endif // ZYPP_KEYRING_H
zypp
KeyRing.h
Generated by
1.8.2