-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathConf.cpp
More file actions
381 lines (318 loc) · 8.42 KB
/
Conf.cpp
File metadata and controls
381 lines (318 loc) · 8.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
/*
* libdigidocpp
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "Conf.h"
#include "crypto/Digest.h"
#include "crypto/X509Cert.h"
#include "tslcerts.h"
#include "util/File.h"
#include "util/log.h"
#include <map>
using namespace digidoc;
using namespace digidoc::util;
using namespace std;
Conf* Conf::INSTANCE = nullptr;
/**
* @typedef digidoc::ConfCurrent
* Reference to latest ConfV5 class.
*/
/**
* @class digidoc::Conf
* @brief Configuration class which can reimplemented and virtual methods overloaded.
*
* @deprecated Use digidoc::ConfV5
* @see @ref parameters
*/
/**
* Configuration parameters
*/
Conf::Conf() = default;
Conf::~Conf() = default;
/**
* Return global config instance object
*/
Conf* Conf::instance() { return INSTANCE; }
/**
* Init global Conf with conf
*/
void Conf::init(Conf *conf)
{
delete INSTANCE;
INSTANCE = conf;
}
/**
* Returns libdigidoc library configuration file's (digidoc.ini) file location
* @deprecated Unused
*/
string Conf::libdigidocConf() const { return {}; }
/**
* Returns log level.
* 0 = Error
* 1 = Warn
* 2 = Info
* 3 = Debug
*/
int Conf::logLevel() const {
#ifdef NDEBUG
return Log::InfoType;
#else
return Log::DebugType;
#endif
}
/**
* Gets log file location. Default log goes to standard out stream
*/
string Conf::logFile() const { return {}; }
/**
* Return default digest type as URI
*/
string Conf::digestUri() const { return URI_SHA256; }
/**
* Gets XSD schema files path
*/
string Conf::xsdPath() const { return File::path(File::confPath(), "schema"); }
/**
* Returns PKCS11 driver file path
*/
string Conf::PKCS11Driver() const { return PKCS11_MODULE; }
/**
* Return OCSP request URL
* @param issuer OCSP issuer.
*/
string Conf::ocsp(const string &/*issuer*/) const
{
return {};
}
/**
* Gets Certificate store location.
* @deprecated Unused
*/
string Conf::certsPath() const { return {}; }
/**
* Gets proxy host address.
*/
string Conf::proxyHost() const { return {}; }
/**
* Gets proxy port number.
*/
string Conf::proxyPort() const { return {}; }
/**
* Gets proxy user name.
*/
string Conf::proxyUser() const { return {}; }
/**
* Gets proxy login password.
*/
string Conf::proxyPass() const { return {}; }
/**
* Gets PKCS12 certificate file location.
*
* Used for signing OCSP request
*/
string Conf::PKCS12Cert() const { return {}; }
/**
* Gets PKCS12 password.
* @see digidoc::Conf::PKCS12Cert
*/
string Conf::PKCS12Pass() const { return {}; }
/**
* Gets PKCS12 usage.
* @see digidoc::Conf::PKCS12Cert
*/
bool Conf::PKCS12Disable() const { return false; }
/**
* Returns default time-stamp server URL
*/
string Conf::TSUrl() const { return TSA_URL; }
/**
* Download new TSL list when it is expired or invalid
*/
bool Conf::TSLAutoUpdate() const { return true; }
/**
* TSL cache path in local file system
*/
string Conf::TSLCache() const
{
return File::path(File::digidocppPath(), "tsl");
}
/**
* TSL master list's (LOTL) URL
*/
string Conf::TSLUrl() const { return TSL_URL; }
/**
* Allow expired TSL lists
*/
bool Conf::TSLAllowExpired() const { return false; }
/**
* TSL master list's (LOTL) signing certificates
*/
vector<X509Cert> Conf::TSLCerts() const { return tslcerts; }
/**
* Compare local TSL digest with digest published online to check for newer version
*/
bool Conf::TSLOnlineDigest() const { return true; }
/**
* Gets TSL downloading connection's current timeout value
*/
int Conf::TSLTimeOut() const { return 10; }
/**
* Redirect SSL traffic over proxy server
* Default: false
*/
bool Conf::proxyForceSSL() const { return false; }
/**
* Tunnel SSL traffic over proxy server
* Default: false
*/
bool Conf::proxyTunnelSSL() const { return true; }
/**
* Gets signature digest URI
*/
string Conf::signatureDigestUri() const { return digestUri(); }
/**
* Gets verify service URI
*/
string Conf::verifyServiceUri() const { return SIVA_URL; }
/**
* @class digidoc::ConfV2
* @brief Verison 2 of configuration class to add additonial parameters.
*
* Conf contains virtual members and is not leaf class we need create
* subclasses to keep binary compatibility
* https://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Adding_new_virtual_functions_to_leaf_classes
* @see digidoc::Conf
* @deprecated Use digidoc::ConfV5
* @see @ref parameters
*/
/**
* Version 2 config with new parameters
*/
ConfV2::ConfV2() = default;
ConfV2::~ConfV2() = default;
/**
* @copydoc digidoc::Conf::instance()
*/
ConfV2* ConfV2::instance() { return dynamic_cast<ConfV2*>(Conf::instance()); }
/**
* Gets verify service Cert
*/
X509Cert ConfV2::verifyServiceCert() const { return X509Cert(); }
/**
* @class digidoc::ConfV3
* @brief Verison 3 of configuration class to add additonial parameters.
*
* Conf contains virtual members and is not leaf class we need create
* subclasses to keep binary compatibility
* https://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Adding_new_virtual_functions_to_leaf_classes
* @see digidoc::ConfV2
* @deprecated Use digidoc::ConfV5
* @see @ref parameters
*/
/**
* Version 3 config with new parameters
*/
ConfV3::ConfV3() = default;
ConfV3::~ConfV3() = default;
/**
* @copydoc digidoc::Conf::instance()
*/
ConfV3* ConfV3::instance() { return dynamic_cast<ConfV3*>(Conf::instance()); }
/**
* Gets OCSP TM Profile OID-s
*
* OCSP responder certificate policies that are used to identify if OCSP response is given with TM profile
*/
set<string> ConfV3::OCSPTMProfiles() const { return { "1.3.6.1.4.1.10015.4.1.2" }; }
/**
* @class digidoc::ConfV4
* @brief Verison 4 of configuration class to add additonial parameters.
*
* Conf contains virtual members and is not leaf class we need create
* subclasses to keep binary compatibility
* https://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Adding_new_virtual_functions_to_leaf_classes
* @see digidoc::ConfV3
* @deprecated Use digidoc::ConfV5
* @see @ref parameters
*/
/**
* Version 4 config with new parameters
*/
ConfV4::ConfV4() = default;
ConfV4::~ConfV4() = default;
/**
* @copydoc digidoc::Conf::instance()
*/
ConfV4* ConfV4::instance() { return dynamic_cast<ConfV4*>(Conf::instance()); }
/**
* Gets verify service Certs
*/
vector<X509Cert> ConfV4::verifyServiceCerts() const
{
if(X509Cert cert = verifyServiceCert())
return { std::move(cert) };
return {};
}
/**
* @class digidoc::ConfV5
* @brief Verison 5 of configuration class to add additonial parameters.
*
* Conf contains virtual members and is not leaf class we need create
* subclasses to keep binary compatibility
* https://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Adding_new_virtual_functions_to_leaf_classes
* @see digidoc::ConfV4
* @see @ref parameters
*/
/**
* Version 5 config with new parameters
*/
ConfV5::ConfV5() = default;
ConfV5::~ConfV5() = default;
/**
* @copydoc digidoc::Conf::instance()
*/
ConfV5* ConfV5::instance() { return dynamic_cast<ConfV5*>(Conf::instance()); }
/**
* Gets verify service Certs
*/
vector<X509Cert> ConfV5::TSCerts() const
{
return {};
}
/**
* @class digidoc::ConfV6
* @brief Verison 6 of configuration class to add additonial parameters.
*
* Conf contains virtual members and is not leaf class we need create
* subclasses to keep binary compatibility
* https://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Adding_new_virtual_functions_to_leaf_classes
* @see digidoc::ConfV5
* @see @ref parameters
*/
/**
* Version 6 config with new parameters
*/
ConfV6::ConfV6() = default;
ConfV6::~ConfV6() = default;
/**
* @copydoc digidoc::Conf::instance()
*/
ConfV6* ConfV6::instance() { return dynamic_cast<ConfV6*>(Conf::instance()); }
/**
* Gets signing certificate ignoring parameter
*/
bool ConfV6::validateSigningCert() const { return true; }