QGIS API Documentation 3.39.0-Master (f549811d78c)
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 <QFile>
22#include "qgis_sip.h"
23
24#ifndef QT_NO_SSL
25#include <QtCrypto>
26#include <QSslCertificate>
27#endif
28
29#include <QDialog>
30#include <QWidget>
31#include "ui_qgsauthcertificateinfo.h"
32#include "qgsauthcertutils.h"
33#include "qgis_gui.h"
34
39class GUI_EXPORT QgsAuthCertInfo : public QWidget, private Ui::QgsAuthCertInfo
40{
41 Q_OBJECT
42
43 public:
44
46 explicit QgsAuthCertInfo( const QSslCertificate &cert,
47 bool manageCertTrust = false,
48 QWidget *parent SIP_TRANSFERTHIS = nullptr,
49 const QList<QSslCertificate> &connectionCAs = QList<QSslCertificate>() );
50
51 bool trustCacheRebuilt() { return mTrustCacheRebuilt; }
52
53 private slots:
54 void setupError( const QString &msg );
55
56 void currentCertItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *previous );
57
58 void updateCurrentCert( QTreeWidgetItem *item );
59
60 void btnSaveTrust_clicked();
61
62 void currentPolicyIndexChanged( int indx );
63
64 void decorateCertTreeItem( const QSslCertificate &cert,
66 QTreeWidgetItem *item = nullptr );
67
68 private:
69 enum DetailsType
70 {
71 DetailsSection = 1000,
72 DetailsGroup = 1001,
73 DetailsField = 1002,
74 };
75
76 enum FieldWidget
77 {
78 NoWidget = 0,
79 LineEdit = 1,
80 TextEdit = 2,
81 };
82
83 void setUpCertDetailsTree();
84
85 void populateTrustBox();
86
87 bool populateQcaCertCollection();
88
89 bool setQcaCertificate( const QSslCertificate &cert );
90
91 bool populateCertChain();
92
93 void setCertHierarchy();
94
95 void updateCurrentCertInfo( int chainindx );
96
97 void populateCertInfo();
98
99 QTreeWidgetItem *addGroupItem( QTreeWidgetItem *parent, const QString &group );
100
101 void addFieldItem( QTreeWidgetItem *parent, const QString &field, const QString &value, FieldWidget wdgt = NoWidget,
102 const QColor &color = QColor() );
103
104 void populateInfoGeneralSection();
105
106 void populateInfoDetailsSection();
107
108 void populateInfoPemTextSection();
109
110 QCA::Certificate mCert;
111 QList<QSslCertificate> mConnectionCAs;
112 QMap<QString, QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate> > mCaCertsCache;
113 QCA::CertificateCollection mCaCerts;
114 QCA::CertificateChain mACertChain;
115 QList<QSslCertificate> mQCertChain;
116 QSslCertificate mCurrentQCert;
117 QCA::Certificate mCurrentACert;
118
119 QBrush mDefaultItemForeground;
120
121 bool mManageTrust;
122 bool mTrustCacheRebuilt;
123 QgsAuthCertUtils::CertTrustPolicy mDefaultTrustPolicy;
124 QgsAuthCertUtils::CertTrustPolicy mCurrentTrustPolicy;
125
126 QTreeWidgetItem *mSecGeneral = nullptr;
127 QTreeWidgetItem *mSecDetails = nullptr;
128 QTreeWidgetItem *mSecPemText = nullptr;
129 QTreeWidgetItem *mGrpSubj = nullptr;
130 QTreeWidgetItem *mGrpIssu = nullptr;
131 QTreeWidgetItem *mGrpCert = nullptr;
132 QTreeWidgetItem *mGrpPkey = nullptr;
133 QTreeWidgetItem *mGrpExts = nullptr;
134
135 QVBoxLayout *mAuthNotifyLayout = nullptr;
136 QLabel *mAuthNotify = nullptr;
137};
138
140
145class GUI_EXPORT QgsAuthCertInfoDialog : public QDialog
146{
147 Q_OBJECT
148
149 public:
150
158 explicit QgsAuthCertInfoDialog( const QSslCertificate &cert,
159 bool manageCertTrust,
160 QWidget *parent SIP_TRANSFERTHIS = nullptr,
161 const QList<QSslCertificate> &connectionCAs = QList<QSslCertificate>() );
162
164 QgsAuthCertInfo *certInfoWidget() { return mCertInfoWdgt; }
165
170 bool trustCacheRebuilt() { return mCertInfoWdgt->trustCacheRebuilt(); }
171
172 private:
173 QgsAuthCertInfo *mCertInfoWdgt = nullptr;
174};
175
176#endif // QGSAUTHCERTIFICATEINFO_H
Dialog wrapper for widget displaying detailed info on a certificate and its hierarchical trust chain.
QgsAuthCertInfo * certInfoWidget()
Gets access to embedded info widget.
bool trustCacheRebuilt()
Whether the trust cache has been rebuilt.
Widget for viewing detailed info on a certificate and its hierarchical trust chain.
CertTrustPolicy
Type of certificate trust policy.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53