annotate ui/certificate.h @ 205:a3f542bf38f7

Added header for mainwindow.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 26 Mar 2014 15:21:34 +0100
parents 2551ad24d3c2
children 9f0865dc8b14
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>
186
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
10 #include <QMap>
21
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11 #include <QString>
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13 #ifdef Q_OS_WIN
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 #include <windows.h>
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 #include <wincrypt.h>
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 #endif
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 class Certificate
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 {
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 public:
94
f1ebab8639dc Do not save the x509 cert as a member variable
Andre Heinecke <aheinecke@intevation.de>
parents: 83
diff changeset
21
83
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
22 /** @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
23 *
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
24 * 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
25 * the command. I: or R:
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
26 *
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
27 * @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
28 **/
94
f1ebab8639dc Do not save the x509 cert as a member variable
Andre Heinecke <aheinecke@intevation.de>
parents: 83
diff changeset
29 Certificate(const QString& b64Line = QString());
21
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 /** @brief check if this certificate could be parsed */
78
2f5db8c70bc2 Constify
Andre Heinecke <aheinecke@intevation.de>
parents: 21
diff changeset
32 bool isValid() const {return mValid;}
21
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 /** @brief get a short description of the certificate
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 *
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 * This description should be used as a short overview
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 * for this certificate
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 **/
186
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
40 QString shortDescription() const;
83
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
41
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
42 /** @brief get details for the certificate
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
43 *
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
44 * Get the X509 information that is returned by x509_crt_info
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
45 *
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
46 **/
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
47 const QString& details() const {return mDetails;}
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
48
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
49 /** @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
50 *
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
51 * 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
52 *
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
53 * I:BASE64ENCODEDATA...
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& base64Line() const {return mBaseLine;}
21
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57
186
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
58 /** @brief get a single attribute of the subject
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
59 *
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
60 * Returns a single attribute of the subject such as the
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
61 * common name.
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
62 *
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
63 * @param[in] attr the Attribute name. to get e.g. "CN"
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
64 *
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
65 * @returns the value of the attribute or a null string
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
66 **/
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
67 QString getSubjectAttr(const QString& attr) const;
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
68
21
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69 private:
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
70 bool mValid;
83
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
71
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
72 QString mDetails;
ba8a548ff252 Expand certificate class to make raw data accessible
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
73 QString mBaseLine;
186
2551ad24d3c2 Get subject from the certificate and parse it's attributes
Andre Heinecke <andre.heinecke@intevation.de>
parents: 94
diff changeset
74 QMap <QString, QString> mSubjectAttrs;
21
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
75 };
dc1e1e9e62ce Add certificate class and use it
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
76 #endif

http://wald.intevation.org/projects/trustbridge/