KIO

ksslcertificatebox.cpp
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(QSslCertificate::CommonName).join(QLatin1String(", ")));
38 d->ui.organization->setText(cert.subjectInfo(QSslCertificate::Organization).join(QLatin1String(", ")));
39 d->ui.organizationalUnit->setText(cert.subjectInfo(QSslCertificate::OrganizationalUnitName).join(QLatin1String(", ")));
40 d->ui.country->setText(cert.subjectInfo(QSslCertificate::CountryName).join(QLatin1String(", ")));
41 d->ui.state->setText(cert.subjectInfo(QSslCertificate::StateOrProvinceName).join(QLatin1String(", ")));
42 d->ui.city->setText(cert.subjectInfo(QSslCertificate::LocalityName).join(QLatin1String(", ")));
43 } else if (party == Issuer) {
44 d->ui.commonName->setText(cert.issuerInfo(QSslCertificate::CommonName).join(QLatin1String(", ")));
45 d->ui.organization->setText(cert.issuerInfo(QSslCertificate::Organization).join(QLatin1String(", ")));
46 d->ui.organizationalUnit->setText(cert.issuerInfo(QSslCertificate::OrganizationalUnitName).join(QLatin1String(", ")));
47 d->ui.country->setText(cert.issuerInfo(QSslCertificate::CountryName).join(QLatin1String(", ")));
48 d->ui.state->setText(cert.issuerInfo(QSslCertificate::StateOrProvinceName).join(QLatin1String(", ")));
49 d->ui.city->setText(cert.issuerInfo(QSslCertificate::LocalityName).join(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"
QString label(StandardShortcut id)
QStringList issuerInfo(SubjectInfo subject) const const
QStringList subjectInfo(SubjectInfo subject) const const
QString join(QChar separator) const const
PlainText
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.