Mercurial > trustbridge
annotate ui/createinstallerdialog.h @ 1088:508c96e72f62
(issue124) Switch server URL and remove some RELEASE_BUILD options
As the test server speaks ECDSA we do not need so much
#ifndef RELEASE_BUILD options anymore.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 12 Sep 2014 15:38:42 +0200 |
parents | 78798d3af8f0 |
children | 2a1aa9df8f11 |
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 */ | |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 #ifndef CREATEINSTALLERDIALOG_H |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 #define CREATEINSTALLERDIALOG_H |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 #include <QDialog> |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 #include <QMainWindow> |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 #include <QLineEdit> |
516
3332db04c77d
Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents:
515
diff
changeset
|
14 #include <QProcess> |
3332db04c77d
Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents:
515
diff
changeset
|
15 #include <QProgressDialog> |
571
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
16 #include <QDir> |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 /** |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 * @file createinstallerdialog.h |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 * @brief The dialog to show settings and create an installer. |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 */ |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 class QListWidget; |
571
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
23 class QTemporaryDir; |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 class CreateInstallerDialog : public QDialog |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 { |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 Q_OBJECT |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 public: |
526
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
29 /** @brief Create a dialog showing settings for the create installer |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 * process |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 * */ |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 CreateInstallerDialog(QMainWindow *parent); |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 private: |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 void setupGUI(); |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 QLineEdit *mCertFile; |
515
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
38 QLineEdit *mBinaryFolder; |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 QLineEdit *mSaveFile; |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 |
516
3332db04c77d
Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents:
515
diff
changeset
|
41 QProcess mNSISProc; |
3332db04c77d
Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents:
515
diff
changeset
|
42 QProgressDialog mProgress; |
571
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
43 QString mInstallerPath; |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
44 QTemporaryDir *mCurrentWorkingDir; |
516
3332db04c77d
Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents:
515
diff
changeset
|
45 |
515
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
46 /** @brief show an error message with QMessageBox |
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
47 * |
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
48 * @param [in] msg The message to show |
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
49 */ |
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
50 void showErrorMessage(const QString &msg); |
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
51 |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 private slots: |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 void openCertificateSelect(); |
515
9d3880db6ba7
Improve error handlig and persist user decisions
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
54 void openFolderSelect(); |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 void openSaveLocation(); |
571
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
56 |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
57 /**@brief entry point for installer creation |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
58 * |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
59 * check the selected parameters (certificate / folder etc.) and |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
60 * create the nsis installer. This also creates the signatures. */ |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 void createInstaller(); |
516
3332db04c77d
Call makensis in create installer dialog
Andre Heinecke <aheinecke@intevation.de>
parents:
515
diff
changeset
|
62 |
571
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
63 /**@brief Create tempoary dir with signed binaries from sourcedir |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
64 * |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
65 * Copies all files from the sourceDir to a temporary directory |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
66 * and signs all .exe files in that directory. |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
67 * |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
68 * The caller needs to delete the temporary directory. If an error |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
69 * occurs NULL is returned. |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
70 * |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
71 * @param[in] sourceDir the directory with the binaries to sign |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
72 * @returns a pointer to a temporary dir containing the signed binaries |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
73 * or NULL. |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
74 */ |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
75 QTemporaryDir *codesignBinaries(const QDir& sourceDir); |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
76 |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
77 /**@brief Sign a file with the codesigning certificate from mCertFile |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
78 * |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
79 * Calls osslsigncode to sign the file pointed to in filePath. |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
80 * The signing operation is logged. |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
81 * |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
82 * Sign information (hash algo / publisher / url) can be set at |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
83 * build time or in the settings with the variables: |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
84 * |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
85 * sign_hash # the hash algorithm to use. Values are the same as in singtool |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
86 * sign_publisher # the publisher information |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
87 * sign_url # the product url to use in the signature |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
88 * |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
89 * @param[in] filePath the absolute path to the file. |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
90 * @returns true on success, false on error |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
91 */ |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
92 bool signFile(QString filePath); |
6c4fff146999
Implement codesigning in the administrator tool
Andre Heinecke <aheinecke@intevation.de>
parents:
526
diff
changeset
|
93 |
868
ae571e7ecdc9
Make appendTextSignature public for better testability
Andre Heinecke <andre.heinecke@intevation.de>
parents:
761
diff
changeset
|
94 /* Slots for the creator process */ |
ae571e7ecdc9
Make appendTextSignature public for better testability
Andre Heinecke <andre.heinecke@intevation.de>
parents:
761
diff
changeset
|
95 void processError(QProcess::ProcessError error); |
ae571e7ecdc9
Make appendTextSignature public for better testability
Andre Heinecke <andre.heinecke@intevation.de>
parents:
761
diff
changeset
|
96 void processFinished(int exitCode, QProcess::ExitStatus exitStatus); |
ae571e7ecdc9
Make appendTextSignature public for better testability
Andre Heinecke <andre.heinecke@intevation.de>
parents:
761
diff
changeset
|
97 |
ae571e7ecdc9
Make appendTextSignature public for better testability
Andre Heinecke <andre.heinecke@intevation.de>
parents:
761
diff
changeset
|
98 public slots: |
761
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
99 /**@brief Append a base64 encoded sha256 RSA signature to a file. |
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
100 * |
1053
78798d3af8f0
Fixed doxygen build warnings.
Emanuel Schuetze <emanuel@intevation.de>
parents:
868
diff
changeset
|
101 * The format of the added signature line will be:<BR> |
78798d3af8f0
Fixed doxygen build warnings.
Emanuel Schuetze <emanuel@intevation.de>
parents:
868
diff
changeset
|
102 * S:\<signature\>\\r\\n<BR> |
761
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
103 * For the signature the key in mCertFile is used. |
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
104 * |
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
105 * @param[in] input The absolute path of the file to sign |
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
106 * @param[out] output The absolute path of the file to write |
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
107 * |
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
108 * @returns true on success, false on failure |
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
109 */ |
49168bcb02e2
(Issue55) Sign a linux installer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
571
diff
changeset
|
110 bool appendTextSignatureToFile(const QString& input, const QString& output); |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 }; |
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
112 |
526
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
113 /** @brief The dialog shown after the installer was created. */ |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
114 class FinishedDialog : public QDialog |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
115 { |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
116 Q_OBJECT |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
117 |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
118 public: |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
119 /** @brief constructor for the dialog |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
120 * |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
121 * @param [in] parent the parent window |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
122 * @param [in] msg the message to show |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
123 * @param [in] details verbose information |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
124 * @param [in] isErr if the dialog should be shown as an error*/ |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
125 FinishedDialog(QDialog *parent, |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
126 QString msg, |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
127 QString details, |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
128 bool isErr); |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
129 |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
130 }; |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
131 |
f6371e9c959a
Add a dialog when installer creation is done
Andre Heinecke <aheinecke@intevation.de>
parents:
516
diff
changeset
|
132 |
361
b67dd46cd4a9
Added dialog to create a new, signed installer binary.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
133 #endif // CREATEINSTALLERDIALOG_H |