QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
45 explicit QgsAuthCertInfo( const QSslCertificate &cert, bool manageCertTrust = false, QWidget *parent SIP_TRANSFERTHIS = nullptr, const QList<QSslCertificate> &connectionCAs = QList<QSslCertificate>() );
46
47 bool trustCacheRebuilt() { return mTrustCacheRebuilt; }
48
49 private slots:
50 void setupError( const QString &msg );
51
52 void currentCertItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *previous );
53
54 void updateCurrentCert( QTreeWidgetItem *item );
55
56 void btnSaveTrust_clicked();
57
58 void currentPolicyIndexChanged( int indx );
59
60 void decorateCertTreeItem( const QSslCertificate &cert, QgsAuthCertUtils::CertTrustPolicy trustpolicy, QTreeWidgetItem *item = nullptr );
61
62 private:
63 enum DetailsType
64 {
65 DetailsSection = 1000,
66 DetailsGroup = 1001,
67 DetailsField = 1002,
68 };
69
70 enum FieldWidget
71 {
72 NoWidget = 0,
73 LineEdit = 1,
74 TextEdit = 2,
75 };
76
77 void setUpCertDetailsTree();
78
79 void populateTrustBox();
80
81 bool populateQcaCertCollection();
82
83 bool setQcaCertificate( const QSslCertificate &cert );
84
85 bool populateCertChain();
86
87 void setCertHierarchy();
88
89 void updateCurrentCertInfo( int chainindx );
90
91 void populateCertInfo();
92
93 QTreeWidgetItem *addGroupItem( QTreeWidgetItem *parent, const QString &group );
94
95 void addFieldItem( QTreeWidgetItem *parent, const QString &field, const QString &value, FieldWidget wdgt = NoWidget, const QColor &color = QColor() );
96
97 void populateInfoGeneralSection();
98
99 void populateInfoDetailsSection();
100
101 void populateInfoPemTextSection();
102
103 QCA::Certificate mCert;
104 QList<QSslCertificate> mConnectionCAs;
105 QMap<QString, QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate>> mCaCertsCache;
106 QCA::CertificateCollection mCaCerts;
107 QCA::CertificateChain mACertChain;
108 QList<QSslCertificate> mQCertChain;
109 QSslCertificate mCurrentQCert;
110 QCA::Certificate mCurrentACert;
111
112 QBrush mDefaultItemForeground;
113
114 bool mManageTrust;
115 bool mTrustCacheRebuilt;
116 QgsAuthCertUtils::CertTrustPolicy mDefaultTrustPolicy;
117 QgsAuthCertUtils::CertTrustPolicy mCurrentTrustPolicy;
118
119 QTreeWidgetItem *mSecGeneral = nullptr;
120 QTreeWidgetItem *mSecDetails = nullptr;
121 QTreeWidgetItem *mSecPemText = nullptr;
122 QTreeWidgetItem *mGrpSubj = nullptr;
123 QTreeWidgetItem *mGrpIssu = nullptr;
124 QTreeWidgetItem *mGrpCert = nullptr;
125 QTreeWidgetItem *mGrpPkey = nullptr;
126 QTreeWidgetItem *mGrpExts = nullptr;
127
128 QVBoxLayout *mAuthNotifyLayout = nullptr;
129 QLabel *mAuthNotify = nullptr;
130};
131
133
138class GUI_EXPORT QgsAuthCertInfoDialog : public QDialog
139{
140 Q_OBJECT
141
142 public:
150 explicit QgsAuthCertInfoDialog( const QSslCertificate &cert, bool manageCertTrust, QWidget *parent SIP_TRANSFERTHIS = nullptr, const QList<QSslCertificate> &connectionCAs = QList<QSslCertificate>() );
151
153 QgsAuthCertInfo *certInfoWidget() { return mCertInfoWdgt; }
154
159 bool trustCacheRebuilt() { return mCertInfoWdgt->trustCacheRebuilt(); }
160
161 private:
162 QgsAuthCertInfo *mCertInfoWdgt = nullptr;
163};
164
165#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