Mercurial > trustbridge
annotate ui/createcertlistdialog.h @ 1287:d3d66d43365f
Merged
author | Emanuel Schuetze <emanuel@intevation.de> |
---|---|
date | Mon, 29 Sep 2014 13:02:41 +0200 |
parents | 2a1aa9df8f11 |
children | d009da9cfa10 |
rev | line source |
---|---|
404 | 1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 #ifndef CREATECERTLISTDIALOG_H |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 #define CREATECERTLISTDIALOG_H |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 #include <QDialog> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 #include <QMainWindow> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 #include <QLineEdit> |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
14 |
466
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
15 #include "certificate.h" |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
16 |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
17 #include <polarssl/pk.h> |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 /** |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 * @file createinstallerdialog.h |
1255
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
20 * @brief The dialog to select the signing certificate and create a certificate list. |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 */ |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 class QListWidget; |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
24 class AdministratorWindow; |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 |
1255
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
26 /** @brief The dialog to select the signing certificate and create a certificate list.*/ |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 class CreateCertListDialog : public QDialog |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 { |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 Q_OBJECT |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 public: |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 /** @brief Create a dialog showing settings for the create certificate list |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 * process |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 * */ |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
34 CreateCertListDialog(AdministratorWindow *parent); |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
35 ~CreateCertListDialog(); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 |
466
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
37 /** @brief write a signed certificate list. |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
38 * |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
39 * @param [in] certs The certificates to include in the list |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
40 * @param [in] filePath The path where the list should be written to |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
41 * @param [in] listDate The date to write in the list |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
42 * @param [in] pk The private key to sign with. |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
43 * |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
44 * @returns true on success false on error. |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
45 */ |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
46 static bool writeList(const QList<Certificate>& certs, |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
47 const QString& filePath, const QDateTime& listDate, pk_context *pk); |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
48 |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
49 |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 private: |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 void setupGUI(); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
53 QLineEdit *mKeyFile; |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
54 QLineEdit *mSaveDir; |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
55 AdministratorWindow *mAdminWindow; |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
56 |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
57 pk_context *mPk; |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
59 /** @brief show an error message with QMessageBox |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
60 * |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
61 * @param [in] msg The message to show |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
62 */ |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
63 void showErrorMessage(const QString &msg); |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
64 |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
65 /** @brief load a file into mPk |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
66 * |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
67 * If the file is not a valid key or an error |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
68 * occurs mPk will be NULL after a call to this function. |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
69 * |
1053
78798d3af8f0
Fixed doxygen build warnings.
Emanuel Schuetze <emanuel@intevation.de>
parents:
466
diff
changeset
|
70 * @param [in] fileName the file to load |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
71 */ |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
72 void loadKeyFile(const QString& fileName); |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
73 |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 private slots: |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
75 /** @brief Open the certificate selection dialog and parse the certificate |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
76 * |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
77 * If the certificate can be parsed mPk is replaced by the new key |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
78 * otherwise an error message is shown to the user. |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
79 */ |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 void openCertificateSelect(); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 void openSaveLocation(); |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
82 /** @brief create a valid certificate list file |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
83 * |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
84 * The contents of the certificate list are the certificates |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
85 * shown in the adminWindow. It is signed with the currently |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
86 * loaded certificate in mPk. On errors the user is |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
87 * informed with showErrorMessage */ |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 void createList(); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 }; |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
90 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
91 #endif // CREATECERTLISTDIALOG_H |