1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2007 Andreas Hartmetz <ahartmetz@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "ksslcertificatebox.h"
9
10#include "ui_certificateparty.h"
11
12#include <QSslCertificate>
13
14class KSslCertificateBoxPrivate
15{
16public:
17 Ui::CertificateParty ui;
18};
19
20KSslCertificateBox::KSslCertificateBox(QWidget *parent)
21 : QWidget(parent)
22 , d(new KSslCertificateBoxPrivate())
23{
24 d->ui.setupUi(this);
25 // No fooling us with html tags
26 const QList<QLabel *> labels = findChildren<QLabel *>();
27 for (QLabel *label : labels) {
28 label->setTextFormat(Qt::PlainText);
29 }
30}
31
32KSslCertificateBox::~KSslCertificateBox() = default;
33
34void KSslCertificateBox::setCertificate(const QSslCertificate &cert, CertificateParty party)
35{
36 if (party == Subject) {
37 d->ui.commonName->setText(cert.subjectInfo(info: QSslCertificate::CommonName).join(sep: QLatin1String(", ")));
38 d->ui.organization->setText(cert.subjectInfo(info: QSslCertificate::Organization).join(sep: QLatin1String(", ")));
39 d->ui.organizationalUnit->setText(cert.subjectInfo(info: QSslCertificate::OrganizationalUnitName).join(sep: QLatin1String(", ")));
40 d->ui.country->setText(cert.subjectInfo(info: QSslCertificate::CountryName).join(sep: QLatin1String(", ")));
41 d->ui.state->setText(cert.subjectInfo(info: QSslCertificate::StateOrProvinceName).join(sep: QLatin1String(", ")));
42 d->ui.city->setText(cert.subjectInfo(info: QSslCertificate::LocalityName).join(sep: QLatin1String(", ")));
43 } else if (party == Issuer) {
44 d->ui.commonName->setText(cert.issuerInfo(info: QSslCertificate::CommonName).join(sep: QLatin1String(", ")));
45 d->ui.organization->setText(cert.issuerInfo(info: QSslCertificate::Organization).join(sep: QLatin1String(", ")));
46 d->ui.organizationalUnit->setText(cert.issuerInfo(info: QSslCertificate::OrganizationalUnitName).join(sep: QLatin1String(", ")));
47 d->ui.country->setText(cert.issuerInfo(info: QSslCertificate::CountryName).join(sep: QLatin1String(", ")));
48 d->ui.state->setText(cert.issuerInfo(info: QSslCertificate::StateOrProvinceName).join(sep: QLatin1String(", ")));
49 d->ui.city->setText(cert.issuerInfo(info: QSslCertificate::LocalityName).join(sep: QLatin1String(", ")));
50 }
51}
52
53void KSslCertificateBox::clear()
54{
55 d->ui.commonName->clear();
56 d->ui.organization->clear();
57 d->ui.organizationalUnit->clear();
58 d->ui.country->clear();
59 d->ui.state->clear();
60 d->ui.city->clear();
61}
62
63#include "moc_ksslcertificatebox.cpp"
64

source code of kio/src/widgets/ksslcertificatebox.cpp