3
#include<qtextbrowser.h>
6
#include<qpushbutton.h>
10
#include"iconwidget.h"
12
static void setLabelStatus(QLabel *l, bool ok)
15
l->setPaletteForegroundColor(QColor("#2A993B"));
17
l->setPaletteForegroundColor(QColor("#810000"));
20
static QString getPropValue(const QCA::CertProperties &list, const QString &var)
23
for(QCA::CertProperties::ConstIterator it = list.begin(); it != list.end(); ++it) {
33
static QString makePropEntry(const QString &var, const QString &name, const QCA::CertProperties &list)
35
QString val = getPropValue(list, var);
39
return QString("<tr><td><nobr><b>") + name + "</b></nobr></td><td>" + val + "</td></tr>";
42
QString SSLCertDlg::makePropTable(const QString &heading, const QCA::CertProperties &list)
45
str += "<tr><td><i>" + heading + "</i><br>";
47
str += makePropEntry("O", tr("Organization:"), list);
48
str += makePropEntry("OU", tr("Organizational unit:"), list);
49
str += makePropEntry("L", tr("Locality:"), list);
50
str += makePropEntry("ST", tr("State:"), list);
51
str += makePropEntry("C", tr("Country:"), list);
52
str += makePropEntry("CN", tr("Common name:"), list);
53
str += makePropEntry("Email", tr("Email:"), list);
54
str += "</table></td></tr>";
58
SSLCertDlg::SSLCertDlg(QWidget *parent, const char *name)
59
:SSLCertUI(parent, name, true)
61
setCaption(CAP(caption()));
63
connect(pb_close, SIGNAL(clicked()), SLOT(close()));
64
pb_close->setDefault(true);
68
void SSLCertDlg::setCert(const QCA::Cert &cert, int result)
73
if(result == QCA::TLS::Valid) {
74
lb_valid->setText(tr("The certificate is valid."));
75
setLabelStatus(lb_valid, true);
78
lb_valid->setText(tr("The certificate is NOT valid!"));
79
setLabelStatus(lb_valid, false);
82
QDateTime now = QDateTime::currentDateTime();
83
QDateTime notBefore = cert.notBefore();
84
QDateTime notAfter = cert.notAfter();
85
lb_notBefore->setText(cert.notBefore().toString());
86
setLabelStatus(lb_notBefore, now > notBefore);
87
lb_notAfter->setText(cert.notAfter().toString());
88
setLabelStatus(lb_notAfter, now < notAfter);
90
lb_sn->setText(cert.serialNumber());
94
str += makePropTable(tr("Subject Details:"), cert.subject());
95
str += makePropTable(tr("Issuer Details:"), cert.issuer());
97
tb_cert->setText(str);
100
void SSLCertDlg::showCert(const QCA::Cert &cert, int result)
102
SSLCertDlg *w = new SSLCertDlg(0);
103
w->setCert(cert, result);