QGIS API Documentation  2.12.0-Lyon
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 #ifndef QT_NO_OPENSSL
22 #include <QtCrypto>
23 #include <QSslCertificate>
24 #endif
25 
26 #include <QDialog>
27 #include <QWidget>
28 #include "ui_qgsauthcertificateinfo.h"
29 #include "qgsauthcertutils.h"
30 
34 class GUI_EXPORT QgsAuthCertInfo : public QWidget, private Ui::QgsAuthCertInfo
35 {
36  Q_OBJECT
37 
38  public:
39  explicit QgsAuthCertInfo( const QSslCertificate& cert,
40  bool manageCertTrust = false,
41  QWidget *parent = 0,
42  const QList<QSslCertificate>& connectionCAs = QList<QSslCertificate>() );
43  ~QgsAuthCertInfo();
44 
45  bool trustCacheRebuilt() { return mTrustCacheRebuilt; }
46 
47  private slots:
48  void setupError( const QString& msg );
49 
50  void currentCertItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *previous );
51 
52  void updateCurrentCert( QTreeWidgetItem *item );
53 
54  void on_btnSaveTrust_clicked();
55 
56  void currentPolicyIndexChanged( int indx );
57 
58  void decorateCertTreeItem( const QSslCertificate& cert,
60  QTreeWidgetItem * item = 0 );
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 ,
96  const QColor& color = QColor() );
97 
98  void populateInfoGeneralSection();
99 
100  void populateInfoDetailsSection();
101 
102  void populateInfoPemTextSection();
103 
104  QCA::Certificate mCert;
105  QList<QSslCertificate> mConnectionCAs;
107  QCA::CertificateCollection mCaCerts;
108  QCA::CertificateChain mACertChain;
109  QList<QSslCertificate> mQCertChain;
110  QSslCertificate mCurrentQCert;
111  QCA::Certificate mCurrentACert;
112 
113  QBrush mDefaultItemForeground;
114 
115  bool mManageTrust;
116  bool mTrustCacheRebuilt;
117  QgsAuthCertUtils::CertTrustPolicy mDefaultTrustPolicy;
118  QgsAuthCertUtils::CertTrustPolicy mCurrentTrustPolicy;
119 
120  QTreeWidgetItem *mSecGeneral;
121  QTreeWidgetItem *mSecDetails;
122  QTreeWidgetItem *mSecPemText;
123  QTreeWidgetItem *mGrpSubj;
124  QTreeWidgetItem *mGrpIssu;
125  QTreeWidgetItem *mGrpCert;
126  QTreeWidgetItem *mGrpPkey;
127  QTreeWidgetItem *mGrpExts;
128 
129  QVBoxLayout *mAuthNotifyLayout;
130  QLabel *mAuthNotify;
131 };
132 
134 
138 class GUI_EXPORT QgsAuthCertInfoDialog : public QDialog
139 {
140  Q_OBJECT
141 
142  public:
150  explicit QgsAuthCertInfoDialog( const QSslCertificate& cert,
151  bool manageCertTrust,
152  QWidget *parent = 0,
153  const QList<QSslCertificate>& connectionCAs = QList<QSslCertificate>() );
155 
157  QgsAuthCertInfo *certInfoWidget() { return mCertInfoWdgt; }
158 
162  bool trustCacheRebuilt() { return mCertInfoWdgt->trustCacheRebuilt(); }
163 
164  private:
165  QgsAuthCertInfo *mCertInfoWdgt;
166 };
167 
168 #endif // QGSAUTHCERTIFICATEINFO_H
QgsAuthCertInfo * certInfoWidget()
Get access to embedded info widget.
CertTrustPolicy
Type of certificate trust policy.
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...