QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsauthcertificateinfo.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsauthcertificateinfo.h
3 ---------------------
4 begin : April 29, 2015
5 copyright : (C) 2015 by Boundless Spatial, Inc. USA
6 author : Larry Shaffer
7 email : lshaffer at boundlessgeo dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17
18#ifndef QGSAUTHCERTIFICATEINFO_H
19#define QGSAUTHCERTIFICATEINFO_H
20
21#include "qgis_sip.h"
22
23#include <QFile>
24
25#ifndef QT_NO_SSL
26#include <QtCrypto>
27#include <QSslCertificate>
28#endif
29
30#include <QDialog>
31#include <QWidget>
32#include "ui_qgsauthcertificateinfo.h"
33#include "qgsauthcertutils.h"
34#include "qgis_gui.h"
35
40class GUI_EXPORT QgsAuthCertInfo : public QWidget, private Ui::QgsAuthCertInfo
41{
42 Q_OBJECT
43
44 public:
46 explicit QgsAuthCertInfo( const QSslCertificate &cert, bool manageCertTrust = false, QWidget *parent SIP_TRANSFERTHIS = nullptr, const QList<QSslCertificate> &connectionCAs = QList<QSslCertificate>() );
47
49 bool trustCacheRebuilt() const { return mTrustCacheRebuilt; }
50
51 private slots:
52 void setupError( const QString &msg );
53
54 void currentCertItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *previous );
55
56 void updateCurrentCert( QTreeWidgetItem *item );
57
58 void btnSaveTrust_clicked();
59
60 void currentPolicyIndexChanged( int indx );
61
62 void decorateCertTreeItem( const QSslCertificate &cert, QgsAuthCertUtils::CertTrustPolicy trustpolicy, QTreeWidgetItem *item = nullptr );
63
64 private:
65 enum DetailsType
66 {
67 DetailsSection = 1000,
68 DetailsGroup = 1001,
69 DetailsField = 1002,
70 };
71
72 enum FieldWidget
73 {
74 NoWidget = 0,
75 LineEdit = 1,
76 TextEdit = 2,
77 };
78
79 void setUpCertDetailsTree();
80
81 void populateTrustBox();
82
83 bool populateQcaCertCollection();
84
85 bool setQcaCertificate( const QSslCertificate &cert );
86
87 bool populateCertChain();
88
89 void setCertHierarchy();
90
91 void updateCurrentCertInfo( int chainindx );
92
93 void populateCertInfo();
94
95 QTreeWidgetItem *addGroupItem( QTreeWidgetItem *parent, const QString &group );
96
97 void addFieldItem( QTreeWidgetItem *parent, const QString &field, const QString &value, FieldWidget wdgt = NoWidget, const QColor &color = QColor() );
98
99 void populateInfoGeneralSection();
100
101 void populateInfoDetailsSection();
102
103 void populateInfoPemTextSection();
104
105 QCA::Certificate mCert;
106 QList<QSslCertificate> mConnectionCAs;
107 QMap<QString, QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate>> mCaCertsCache;
108 QCA::CertificateCollection mCaCerts;
109 QCA::CertificateChain mACertChain;
110 QList<QSslCertificate> mQCertChain;
111 QSslCertificate mCurrentQCert;
112 QCA::Certificate mCurrentACert;
113
114 QBrush mDefaultItemForeground;
115
116 bool mManageTrust;
117 bool mTrustCacheRebuilt = false;
120
121 QTreeWidgetItem *mSecGeneral = nullptr;
122 QTreeWidgetItem *mSecDetails = nullptr;
123 QTreeWidgetItem *mSecPemText = nullptr;
124 QTreeWidgetItem *mGrpSubj = nullptr;
125 QTreeWidgetItem *mGrpIssu = nullptr;
126 QTreeWidgetItem *mGrpCert = nullptr;
127 QTreeWidgetItem *mGrpPkey = nullptr;
128 QTreeWidgetItem *mGrpExts = nullptr;
129
130 QVBoxLayout *mAuthNotifyLayout = nullptr;
131 QLabel *mAuthNotify = nullptr;
132};
133
135
140class GUI_EXPORT QgsAuthCertInfoDialog : public QDialog
141{
142 Q_OBJECT
143
144 public:
152 explicit QgsAuthCertInfoDialog( const QSslCertificate &cert, bool manageCertTrust, QWidget *parent SIP_TRANSFERTHIS = nullptr, const QList<QSslCertificate> &connectionCAs = QList<QSslCertificate>() );
153
155 QgsAuthCertInfo *certInfoWidget() { return mCertInfoWdgt; }
156
161 bool trustCacheRebuilt() const { return mCertInfoWdgt->trustCacheRebuilt(); }
162
163 private:
164 QgsAuthCertInfo *mCertInfoWdgt = nullptr;
165};
166
167#endif // QGSAUTHCERTIFICATEINFO_H
QgsAuthCertInfo * certInfoWidget()
Gets access to embedded info widget.
QgsAuthCertInfoDialog(const QSslCertificate &cert, bool manageCertTrust, QWidget *parent=nullptr, const QList< QSslCertificate > &connectionCAs=QList< QSslCertificate >())
Construct a dialog displaying detailed info on a certificate and its hierarchical trust chain.
bool trustCacheRebuilt() const
Whether the trust cache has been rebuilt.
Widget for viewing detailed info on a certificate and its hierarchical trust chain.
QgsAuthCertInfo(const QSslCertificate &cert, bool manageCertTrust=false, QWidget *parent=nullptr, const QList< QSslCertificate > &connectionCAs=QList< QSslCertificate >())
Constructor for QgsAuthCertInfo.
bool trustCacheRebuilt() const
Returns whether the cache of trust chain has been rebuilt.
CertTrustPolicy
Type of certificate trust policy.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53