closes #71
parent
7f2e08667b
commit
1769ebfef0
12 changed files with 1067 additions and 620 deletions
@ -0,0 +1,104 @@ |
||||
/*! @file
|
||||
|
||||
@id $Id$ |
||||
*/ |
||||
// 1 2 3 4 5 6 7 8
|
||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
#ifndef CERTIFICATE_HXX |
||||
#define CERTIFICATE_HXX |
||||
|
||||
#include <ui_certificate.h> |
||||
#include <QtCore/QDateTime> |
||||
#include <QtGui/QTreeWidget> |
||||
#include <QtGui/QTreeWidgetItem> |
||||
#include <QtNetwork/QSslCertificate> |
||||
|
||||
class Certificate: public QTreeWidget, protected Ui::Certificate { |
||||
public: |
||||
Certificate(QWidget* p): QTreeWidget(p) { |
||||
setupUi(this); |
||||
} |
||||
Certificate& certificate(const QSslCertificate& cert) { |
||||
_cert->clear(); |
||||
if (!cert.isValid()) return *this; |
||||
_cert->addTopLevelItem |
||||
((new QTreeWidgetItem |
||||
(QStringList()<<tr("Valid Since") |
||||
<<cert.effectiveDate().toString(Qt::SystemLocaleLongDate)))); |
||||
_cert->addTopLevelItem |
||||
((new QTreeWidgetItem |
||||
(QStringList()<<tr("Valid Until") |
||||
<<cert.expiryDate().toString(Qt::SystemLocaleLongDate)))); |
||||
_cert->addTopLevelItem |
||||
((new QTreeWidgetItem |
||||
(QStringList()<<tr("Serial Number") |
||||
<<cert.serialNumber()))); |
||||
_cert->addTopLevelItem |
||||
((new QTreeWidgetItem |
||||
(QStringList()<<tr("Version") |
||||
<<cert.version()))); |
||||
QTreeWidgetItem *it(0); |
||||
_cert->addTopLevelItem |
||||
((it = new QTreeWidgetItem(QStringList()<<tr("Subject Info")<<""))); |
||||
for (QSslCertificate::SubjectInfo |
||||
si(QSslCertificate::StateOrProvinceName); |
||||
si>=QSslCertificate::Organization; |
||||
si=(QSslCertificate::SubjectInfo)((int)si-1)) |
||||
if (!cert.subjectInfo(si).isEmpty()) |
||||
it->addChild |
||||
((new QTreeWidgetItem |
||||
(QStringList()<<subjectInfo(si)<<cert.subjectInfo(si)))); |
||||
QTreeWidgetItem *it2(0); |
||||
it->addChild |
||||
((it2 = new QTreeWidgetItem |
||||
(QStringList()<<tr("Alternate Subject")<<""))); |
||||
QMultiMap<QSsl::AlternateNameEntryType, QString> |
||||
asns(cert.alternateSubjectNames()); |
||||
for (QMultiMap<QSsl::AlternateNameEntryType, QString>::iterator |
||||
asn(asns.begin()); asn!=asns.end(); ++asn) |
||||
it2->addChild |
||||
((new QTreeWidgetItem |
||||
(QStringList()<<alternateName(asn.key())<<asn.value()))); |
||||
_cert->addTopLevelItem |
||||
((it = new QTreeWidgetItem(QStringList()<<tr("Issuer Info")<<""))); |
||||
for (QSslCertificate::SubjectInfo |
||||
si(QSslCertificate::StateOrProvinceName); |
||||
si>=QSslCertificate::Organization; |
||||
si=(QSslCertificate::SubjectInfo)((int)si-1)) |
||||
if (!cert.issuerInfo(si).isEmpty()) |
||||
it->addChild |
||||
((new QTreeWidgetItem |
||||
(QStringList()<<subjectInfo(si)<<cert.issuerInfo(si)))); |
||||
_cert->expandAll(); |
||||
_cert->resizeColumnToContents(0); |
||||
_cert->resizeColumnToContents(1); |
||||
return *this; |
||||
} |
||||
QString alternateName(QSsl::AlternateNameEntryType an) { |
||||
switch (an) { |
||||
case QSsl::EmailEntry: return tr("E-Mail"); |
||||
case QSsl::DnsEntry: return tr("URL"); |
||||
} |
||||
return tr("error", "unknown certificate subject alternate name"); |
||||
} |
||||
QString subjectInfo(QSslCertificate::SubjectInfo si) { |
||||
switch (si) { |
||||
case QSslCertificate::Organization: |
||||
return tr("Organization"); |
||||
case QSslCertificate::CommonName: |
||||
return tr("Common Name"); |
||||
case QSslCertificate::LocalityName: |
||||
return tr("Locality"); |
||||
case QSslCertificate::OrganizationalUnitName: |
||||
return tr("Organizational Unit"); |
||||
case QSslCertificate::CountryName: |
||||
return tr("Country"); |
||||
case QSslCertificate::StateOrProvinceName: |
||||
return tr("State or Province"); |
||||
} |
||||
return tr("error", "unknown certificate subject info"); |
||||
} |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,56 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>Certificate</class> |
||||
<widget class="QWidget" name="Certificate"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>400</width> |
||||
<height>320</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Form</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="0" column="0"> |
||||
<widget class="QTreeWidget" name="_cert"> |
||||
<property name="editTriggers"> |
||||
<set>QAbstractItemView::NoEditTriggers</set> |
||||
</property> |
||||
<property name="alternatingRowColors"> |
||||
<bool>true</bool> |
||||
</property> |
||||
<property name="rootIsDecorated"> |
||||
<bool>true</bool> |
||||
</property> |
||||
<property name="sortingEnabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<property name="wordWrap"> |
||||
<bool>true</bool> |
||||
</property> |
||||
<attribute name="headerCascadingSectionResizes"> |
||||
<bool>true</bool> |
||||
</attribute> |
||||
<attribute name="headerShowSortIndicator" stdset="0"> |
||||
<bool>false</bool> |
||||
</attribute> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Attribute</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</column> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
@ -0,0 +1,83 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>LoginCertificate</class> |
||||
<widget class="QDialog" name="LoginCertificate"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>726</width> |
||||
<height>471</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>User Login Certificate</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="1" column="0"> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Close</set> |
||||
</property> |
||||
<property name="centerButtons"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="0"> |
||||
<widget class="Certificate" name="_cert"> |
||||
<column> |
||||
<property name="text"> |
||||
<string notr="true">1</string> |
||||
</property> |
||||
</column> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<customwidgets> |
||||
<customwidget> |
||||
<class>Certificate</class> |
||||
<extends>QTreeWidget</extends> |
||||
<header>certificate.hxx</header> |
||||
</customwidget> |
||||
</customwidgets> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>LoginCertificate</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>LoginCertificate</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
Loading…
Reference in new issue