Mercurial > trustbridge
annotate ui/createcertlistdialog.h @ 613:47235ae3fa9a
Remove close / help button and set fixed size
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 18 Jun 2014 15:10:00 +0200 |
parents | 0d71ce440bcc |
children | 78798d3af8f0 |
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 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 * @brief The dialog to show settings and create an installer. |
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 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 class CreateCertListDialog : public QDialog |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 { |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 Q_OBJECT |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 public: |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 /** @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
|
31 * process |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 * */ |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
33 CreateCertListDialog(AdministratorWindow *parent); |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
34 ~CreateCertListDialog(); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 |
466
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
36 /** @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
|
37 * |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
38 * @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
|
39 * @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
|
40 * @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
|
41 * @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
|
42 * |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
43 * @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
|
44 */ |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
45 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
|
46 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
|
47 |
0d71ce440bcc
Factor out list creation to make it more testable
Andre Heinecke <aheinecke@intevation.de>
parents:
465
diff
changeset
|
48 |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 private: |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 void setupGUI(); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
52 QLineEdit *mKeyFile; |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
53 QLineEdit *mSaveDir; |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
54 AdministratorWindow *mAdminWindow; |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
55 |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
56 pk_context *mPk; |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
58 /** @brief show an error message with QMessageBox |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
59 * |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
60 * @param [in] msg The message to show |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
61 */ |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
62 void showErrorMessage(const QString &msg); |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
63 |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
64 /** @brief load a file into mPk |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
65 * |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
66 * If the file is not a valid key or an error |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
67 * occurs mPk will be NULL after a call to this function. |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
68 * |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
69 * @param [in] the file to load |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
70 */ |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
71 void loadKeyFile(const QString& fileName); |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
72 |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 private slots: |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
74 /** @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
|
75 * |
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
76 * 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
|
77 * 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
|
78 */ |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 void openCertificateSelect(); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 void openSaveLocation(); |
454
efd1bd85112f
Save selected certificate in settings and parse it.
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
81 /** @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
|
82 * |
465
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
83 * The contents of the certificate list are the certificates |
88dfe16a0bb9
Implement certificatelist saving
Andre Heinecke <aheinecke@intevation.de>
parents:
454
diff
changeset
|
84 * 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
|
85 * 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
|
86 * informed with showErrorMessage */ |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 void createList(); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 }; |
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 #endif // CREATECERTLISTDIALOG_H |