aheinecke@404: /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
aheinecke@404:  * Software engineering by Intevation GmbH
aheinecke@404:  *
aheinecke@404:  * This file is Free Software under the GNU GPL (v>=2)
aheinecke@404:  * and comes with ABSOLUTELY NO WARRANTY!
aheinecke@404:  * See LICENSE.txt for details.
aheinecke@404:  */
rrenkert@367: #ifndef CREATECERTLISTDIALOG_H
rrenkert@367: #define CREATECERTLISTDIALOG_H
rrenkert@367: 
rrenkert@367: #include <QDialog>
rrenkert@367: #include <QMainWindow>
rrenkert@367: #include <QLineEdit>
aheinecke@454: 
aheinecke@466: #include "certificate.h"
aheinecke@466: 
aheinecke@454: #include <polarssl/pk.h>
rrenkert@367: /**
rrenkert@367:  * @file createinstallerdialog.h
rrenkert@367:  * @brief The dialog to show settings and create an installer.
rrenkert@367:  */
rrenkert@367: 
rrenkert@367: class QListWidget;
aheinecke@454: class AdministratorWindow;
rrenkert@367: 
rrenkert@367: class CreateCertListDialog : public QDialog
rrenkert@367: {
rrenkert@367:     Q_OBJECT
rrenkert@367: public:
rrenkert@367:     /** @brief Create a dialog showing settings for the create certificate list
rrenkert@367:      * process
rrenkert@367:      * */
aheinecke@454:     CreateCertListDialog(AdministratorWindow *parent);
aheinecke@465:     ~CreateCertListDialog();
rrenkert@367: 
aheinecke@466:     /** @brief write a signed certificate list.
aheinecke@466:      *
aheinecke@466:      * @param [in] certs The certificates to include in the list
aheinecke@466:      * @param [in] filePath The path where the list should be written to
aheinecke@466:      * @param [in] listDate The date to write in the list
aheinecke@466:      * @param [in] pk The private key to sign with.
aheinecke@466:      *
aheinecke@466:      * @returns true on success false on error.
aheinecke@466:      */
aheinecke@466:     static bool writeList(const QList<Certificate>& certs,
aheinecke@466:             const QString& filePath, const QDateTime& listDate, pk_context *pk);
aheinecke@466: 
aheinecke@466: 
rrenkert@367: private:
rrenkert@367:     void setupGUI();
rrenkert@367: 
aheinecke@465:     QLineEdit *mKeyFile;
aheinecke@465:     QLineEdit *mSaveDir;
aheinecke@454:     AdministratorWindow *mAdminWindow;
aheinecke@454: 
aheinecke@454:     pk_context *mPk;
rrenkert@367: 
aheinecke@465:     /** @brief show an error message with QMessageBox
aheinecke@465:      *
aheinecke@465:      * @param [in] msg The message to show
aheinecke@465:      */
aheinecke@465:     void showErrorMessage(const QString &msg);
aheinecke@465: 
aheinecke@465:     /** @brief load a file into mPk
aheinecke@465:      *
aheinecke@465:      * If the file is not a valid key or an error
aheinecke@465:      * occurs mPk will be NULL after a call to this function.
aheinecke@465:      *
aheinecke@465:      * @param [in] the file to load
aheinecke@465:      */
aheinecke@465:     void loadKeyFile(const QString& fileName);
aheinecke@465: 
rrenkert@367: private slots:
aheinecke@454:     /** @brief Open the certificate selection dialog and parse the certificate
aheinecke@454:      *
aheinecke@454:      * If the certificate can be parsed mPk is replaced by the new key
aheinecke@454:      * otherwise an error message is shown to the user.
aheinecke@454:      */
rrenkert@367:     void openCertificateSelect();
rrenkert@367:     void openSaveLocation();
aheinecke@454:     /** @brief create a valid certificate list file
aheinecke@454:      *
aheinecke@465:      * The contents of the certificate list are the certificates
aheinecke@465:      * shown in the adminWindow. It is signed with the currently
aheinecke@454:      * loaded certificate in mPk. On errors the user is
aheinecke@454:      * informed with showErrorMessage */
rrenkert@367:     void createList();
rrenkert@367: };
rrenkert@367: 
rrenkert@367: #endif // CREATECERTLISTDIALOG_H