Mercurial > trustbridge
annotate ui/certificate.h @ 342:fba80767fd7a
Fixed member variables in certificate table model.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 10 Apr 2014 10:05:32 +0200 |
parents | 36c68dfb821d |
children | a49766196a7d b0a274f4f9e2 |
rev | line source |
---|---|
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 #ifndef CERTIFICATE_H |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 #define CERTIFICATE_H |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 /** |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 * @file certificate.h |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 * @brief Class around native certificates. |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 * |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 */ |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 #include <QByteArray> |
338
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
10 #include <QDateTime> |
186
2551ad24d3c2
Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
94
diff
changeset
|
11 #include <QMap> |
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 #include <QString> |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
14 #ifdef Q_OS_WIN |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 #include <windows.h> |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 #include <wincrypt.h> |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 #endif |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 class Certificate |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 { |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 public: |
94
f1ebab8639dc
Do not save the x509 cert as a member variable
Andre Heinecke <aheinecke@intevation.de>
parents:
83
diff
changeset
|
22 |
265
ffd47b045d19
Added certificate status enum and register it as metatype.
Raimund Renkert <rrenkert@intevation.de>
parents:
248
diff
changeset
|
23 enum Status { |
ffd47b045d19
Added certificate status enum and register it as metatype.
Raimund Renkert <rrenkert@intevation.de>
parents:
248
diff
changeset
|
24 InstallNew = 1, |
ffd47b045d19
Added certificate status enum and register it as metatype.
Raimund Renkert <rrenkert@intevation.de>
parents:
248
diff
changeset
|
25 InstallOld, |
ffd47b045d19
Added certificate status enum and register it as metatype.
Raimund Renkert <rrenkert@intevation.de>
parents:
248
diff
changeset
|
26 RemoveNew, |
ffd47b045d19
Added certificate status enum and register it as metatype.
Raimund Renkert <rrenkert@intevation.de>
parents:
248
diff
changeset
|
27 RemoveOld |
ffd47b045d19
Added certificate status enum and register it as metatype.
Raimund Renkert <rrenkert@intevation.de>
parents:
248
diff
changeset
|
28 }; |
ffd47b045d19
Added certificate status enum and register it as metatype.
Raimund Renkert <rrenkert@intevation.de>
parents:
248
diff
changeset
|
29 |
83
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
30 /** @brief construct a certificate from a line of a certificate list. |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
31 * |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
32 * The first two characters of the string are expected to be |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
33 * the command. I: or R: |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
34 * |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
35 * @param[in] b64Line The line from the certificate list. |
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 **/ |
94
f1ebab8639dc
Do not save the x509 cert as a member variable
Andre Heinecke <aheinecke@intevation.de>
parents:
83
diff
changeset
|
37 Certificate(const QString& b64Line = QString()); |
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
39 /** @brief check if this certificate could be parsed */ |
78 | 40 bool isValid() const {return mValid;} |
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 /** @brief get a short description of the certificate |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 * |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
44 * This description should be used as a short overview |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 * for this certificate |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 * |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 **/ |
186
2551ad24d3c2
Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents:
94
diff
changeset
|
48 QString shortDescription() const; |
83
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
49 |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
50 /** @brief get details for the certificate |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
51 * |
338
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
52 * Get a formatted details string usable for user visible |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
53 * certificate details. |
83
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
54 * |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
55 **/ |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
56 const QString& details() const {return mDetails;} |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
57 |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
58 /** @brief get the line from which this certificate was constructed |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
59 * |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
60 * The resulting line includes the instruction e.g. |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
61 * |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
62 * I:BASE64ENCODEDATA... |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
63 * |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
64 **/ |
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
65 const QString& base64Line() const {return mBaseLine;} |
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
66 |
248
9f0865dc8b14
Add accessor to check if the certificate should be installed
Andre Heinecke <aheinecke@intevation.de>
parents:
186
diff
changeset
|
67 /** @brief Check if this certificate has the install instruction. |
9f0865dc8b14
Add accessor to check if the certificate should be installed
Andre Heinecke <aheinecke@intevation.de>
parents:
186
diff
changeset
|
68 * |
9f0865dc8b14
Add accessor to check if the certificate should be installed
Andre Heinecke <aheinecke@intevation.de>
parents:
186
diff
changeset
|
69 * This is shorthand for baseLine.startsWith("I:"); |
9f0865dc8b14
Add accessor to check if the certificate should be installed
Andre Heinecke <aheinecke@intevation.de>
parents:
186
diff
changeset
|
70 **/ |
9f0865dc8b14
Add accessor to check if the certificate should be installed
Andre Heinecke <aheinecke@intevation.de>
parents:
186
diff
changeset
|
71 bool isInstallCert() const {return mBaseLine.startsWith("I:");} |
9f0865dc8b14
Add accessor to check if the certificate should be installed
Andre Heinecke <aheinecke@intevation.de>
parents:
186
diff
changeset
|
72 |
341
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
73 /** @brief get the subject OU from the certificate */ |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
74 QString subjectOU() const {return mSubjectOU;} |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
75 |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
76 /** @brief get the subject CN from the certificate */ |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
77 QString subjectCN() const {return mSubjectCN;} |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
78 |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
79 /** @brief get the subject O from the certificate */ |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
80 QString subjectO() const {return mSubjectO;} |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
81 |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
82 /** @brief get the subject SN from the certificate */ |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
83 QString subjectSN() const {return mSubjectSN;} |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
84 |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
85 /** @brief get the date the certificate was issued */ |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
86 QDateTime validFrom() const {return mValidFrom;} |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
87 |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
88 /** @brief get the date the certificate expires */ |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
89 QDateTime validTo() const {return mValidTo;} |
36c68dfb821d
Added accessors for certificate details.
Raimund Renkert <rrenkert@intevation.de>
parents:
338
diff
changeset
|
90 |
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
91 private: |
338
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
92 /** @brief Helper function to parse the details of a certificate **/ |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
93 void parseDetails(const QByteArray& cert); |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
94 |
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
95 bool mValid; |
248
9f0865dc8b14
Add accessor to check if the certificate should be installed
Andre Heinecke <aheinecke@intevation.de>
parents:
186
diff
changeset
|
96 bool mInstCert; |
83
ba8a548ff252
Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents:
82
diff
changeset
|
97 |
338
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
98 QString mSubjectOU, |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
99 mSubjectCN, |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
100 mSubjectO, |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
101 mSubjectSN, |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
102 mDetails, |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
103 mBaseLine; |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
104 |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
105 QDateTime mValidFrom, |
64e38886f903
Use certhelp for certificate parsing and add some dummy info
Andre Heinecke <aheinecke@intevation.de>
parents:
265
diff
changeset
|
106 mValidTo; |
21
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
107 }; |
dc1e1e9e62ce
Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
108 #endif |