diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-12 17:22:43 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-12 17:22:43 +0200 |
| commit | 4f8f8fc2a9450982078f18d49ddfa9036023bc29 (patch) | |
| tree | 6c0452651d4954c65a1542d46aaaebeef47da64d /src/certificatemanagementdialog.cpp | |
| parent | 79e62a80579c5669542c65d1e9e7b31dc3872137 (diff) | |
| download | kristall-4f8f8fc2a9450982078f18d49ddfa9036023bc29.tar.gz | |
Adds certificate manager, removes client certificate window.
Diffstat (limited to 'src/certificatemanagementdialog.cpp')
| -rw-r--r-- | src/certificatemanagementdialog.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/certificatemanagementdialog.cpp b/src/certificatemanagementdialog.cpp new file mode 100644 index 0000000..defa3cc --- /dev/null +++ b/src/certificatemanagementdialog.cpp @@ -0,0 +1,70 @@ +#include "certificatemanagementdialog.hpp" +#include "ui_certificatemanagementdialog.h" + +#include "kristall.hpp" + +#include <QCryptographicHash> + +CertificateManagementDialog::CertificateManagementDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CertificateManagementDialog), + selected_identity { nullptr } +{ + ui->setupUi(this); + + this->ui->certificates->setModel(&global_identities); + this->ui->certificates->expandAll(); + + on_certificates_clicked(QModelIndex { }); +} + +CertificateManagementDialog::~CertificateManagementDialog() +{ + delete ui; +} + +void CertificateManagementDialog::on_certificates_clicked(const QModelIndex &index) +{ + selected_identity = global_identities.getMutableIdentity(index); + + this->ui->delete_cert_button->setEnabled(selected_identity != nullptr); + this->ui->export_cert_button->setEnabled(selected_identity != nullptr); + + if(selected_identity != nullptr) + { + auto & cert = *selected_identity; + this->ui->groupBox->setEnabled(true); + this->ui->cert_display_name->setText(cert.display_name); + this->ui->cert_common_name->setText(cert.certificate.subjectInfo(QSslCertificate::CommonName).join(", ")); + this->ui->cert_expiration_date->setDateTime(cert.certificate.expiryDate()); + this->ui->cert_livetime->setText(QString("%1 days").arg(QDateTime::currentDateTime().daysTo(cert.certificate.expiryDate()))); + this->ui->cert_fingerprint->setPlainText( + QCryptographicHash::hash(cert.certificate.toDer(), QCryptographicHash::Sha256).toHex(':') + ); + this->ui->cert_notes->setPlainText(cert.user_notes); + + } + else + { + this->ui->groupBox->setEnabled(false); + this->ui->cert_display_name->setText(""); + this->ui->cert_common_name->setText(""); + this->ui->cert_expiration_date->setDateTime(QDateTime { }); + this->ui->cert_livetime->setText(""); + this->ui->cert_fingerprint->setPlainText(""); + } +} + +void CertificateManagementDialog::on_cert_notes_textChanged() +{ + if(this->selected_identity != nullptr) { + this->selected_identity->user_notes = this->ui->cert_notes->toPlainText(); + } +} + +void CertificateManagementDialog::on_cert_display_name_textChanged(const QString &arg1) +{ + if(this->selected_identity != nullptr) { + this->selected_identity->display_name = this->ui->cert_display_name->text(); + } +} |
