QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
23 #ifndef QT_NO_OPENSSL
24 #include <QtCrypto>
25 #include <QSslCertificate>
26 #endif
27 
28 #include <QDialog>
29 #include <QWidget>
30 #include "ui_qgsauthcertificateinfo.h"
31 #include "qgsauthcertutils.h"
32 
36 class GUI_EXPORT QgsAuthCertInfo : public QWidget, private Ui::QgsAuthCertInfo
37 {
38  Q_OBJECT
39 
40  public:
41  explicit QgsAuthCertInfo( const QSslCertificate& cert,
42  bool manageCertTrust = false,
43  QWidget *parent = nullptr,
44  const QList<QSslCertificate>& connectionCAs = QList<QSslCertificate>() );
45  ~QgsAuthCertInfo();
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 on_btnSaveTrust_clicked();
57 
58  void currentPolicyIndexChanged( int indx );
59 
60  void decorateCertTreeItem( const QSslCertificate& cert,
62  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 ,
98  const QColor& color = QColor() );
99 
100  void populateInfoGeneralSection();
101 
102  void populateInfoDetailsSection();
103 
104  void populateInfoPemTextSection();
105 
106  QCA::Certificate mCert;
107  QList<QSslCertificate> mConnectionCAs;
109  QCA::CertificateCollection mCaCerts;
110  QCA::CertificateChain mACertChain;
111  QList<QSslCertificate> mQCertChain;
112  QSslCertificate mCurrentQCert;
113  QCA::Certificate mCurrentACert;
114 
115  QBrush mDefaultItemForeground;
116 
117  bool mManageTrust;
118  bool mTrustCacheRebuilt;
119  QgsAuthCertUtils::CertTrustPolicy mDefaultTrustPolicy;
120  QgsAuthCertUtils::CertTrustPolicy mCurrentTrustPolicy;
121 
122  QTreeWidgetItem *mSecGeneral;
123  QTreeWidgetItem *mSecDetails;
124  QTreeWidgetItem *mSecPemText;
125  QTreeWidgetItem *mGrpSubj;
126  QTreeWidgetItem *mGrpIssu;
127  QTreeWidgetItem *mGrpCert;
128  QTreeWidgetItem *mGrpPkey;
129  QTreeWidgetItem *mGrpExts;
130 
131  QVBoxLayout *mAuthNotifyLayout;
132  QLabel *mAuthNotify;
133 };
134 
136 
140 class GUI_EXPORT QgsAuthCertInfoDialog : public QDialog
141 {
142  Q_OBJECT
143 
144  public:
152  explicit QgsAuthCertInfoDialog( const QSslCertificate& cert,
153  bool manageCertTrust,
154  QWidget *parent = nullptr,
155  const QList<QSslCertificate>& connectionCAs = QList<QSslCertificate>() );
157 
159  QgsAuthCertInfo *certInfoWidget() { return mCertInfoWdgt; }
160 
164  bool trustCacheRebuilt() { return mCertInfoWdgt->trustCacheRebuilt(); }
165 
166  private:
167  QgsAuthCertInfo *mCertInfoWdgt;
168 };
169 
170 #endif // QGSAUTHCERTIFICATEINFO_H
QgsAuthCertInfo * certInfoWidget()
Get access to embedded info widget.
Widget for viewing detailed info on a certificate and its hierarchical trust chain.
bool trustCacheRebuilt()
Whether the trust cache has been rebuilt.
Dialog wrapper for widget displaying detailed info on a certificate and its hierarchical trust chain...
CertTrustPolicy
Type of certificate trust policy.