QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsauthsslconfigwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsauthsslconfigwidget.h
3  ---------------------
4  begin : May 17, 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 #ifndef QGSAUTHSSLCONFIGWIDGET_H
18 #define QGSAUTHSSLCONFIGWIDGET_H
19 
20 #include <QDialog>
21 #include <QWidget>
22 #include "ui_qgsauthsslconfigwidget.h"
23 
24 #include <QSslCertificate>
25 #include <QSslConfiguration>
26 
27 #include "qgsauthconfig.h"
28 
29 class QComboBox;
30 class QGroupBox;
31 class QSpinBox;
32 
36 class GUI_EXPORT QgsAuthSslConfigWidget : public QWidget, private Ui::QgsAuthSslConfigWidget
37 {
38  Q_OBJECT
39 
40  public:
48  explicit QgsAuthSslConfigWidget( QWidget *parent = nullptr,
49  const QSslCertificate &cert = QSslCertificate(),
50  const QString &hostport = QString(),
51  const QList<QSslCertificate>& connectionCAs = QList<QSslCertificate>() );
53 
55  QGroupBox *certificateGroupBox();
57  QGroupBox *sslConfigGroupBox();
58 
60  const QgsAuthConfigSslServer sslCustomConfig();
61 
63  const QSslCertificate sslCertificate();
64 
66  const QString sslHost();
67 
69  QSsl::SslProtocol sslProtocol();
70 
72  const QList<QSslError::SslError> sslIgnoreErrorEnums();
73 
75  QSslSocket::PeerVerifyMode sslPeerVerifyMode();
76 
80  int sslPeerVerifyDepth();
81 
82  public slots:
84  void enableSslCustomOptions( bool enable );
85 
86  // may also load existing config, if found
88  void setSslCertificate( const QSslCertificate& cert, const QString &hostport = QString() );
89 
91  void loadSslCustomConfig( const QgsAuthConfigSslServer& config = QgsAuthConfigSslServer() );
92 
94  void saveSslCertConfig();
95 
97  void resetSslCertConfig();
98 
100  void setSslProtocol( QSsl::SslProtocol protocol );
101 
103  void resetSslProtocol();
104 
106  void appendSslIgnoreErrors( const QList<QSslError>& errors );
107 
109  void setSslIgnoreErrorEnums( const QList<QSslError::SslError>& errorenums );
110 
112  void setSslIgnoreErrors( const QList<QSslError>& errors );
113 
115  void resetSslIgnoreErrors();
116 
118  void setSslPeerVerify( QSslSocket::PeerVerifyMode mode, int modedepth );
119 
121  void resetSslPeerVerify();
122 
124  void setSslHost( const QString& host );
125 
127  void setConfigCheckable( bool checkable );
128 
130  void validateHostPortText( const QString &txt );
131 
133  bool readyToSave();
134 
135  signals:
137  void configEnabledChanged( bool enabled );
138 
140  void certFoundInAuthDatabase( bool found );
141 
143  void hostPortValidityChanged( bool valid );
144 
146  void readyToSaveChanged( bool cansave );
147 
148  private slots:
149  void on_btnCertInfo_clicked();
150 
151  private:
152  enum ConfigType
153  {
154  ConfigParent = 1000,
155  ConfigItem = 1001,
156  };
157 
158  bool validateHostPort( const QString &txt );
159 
160  void setUpSslConfigTree();
161  QTreeWidgetItem* addRootItem( const QString& label );
162 
163  QSslCertificate mCert;
164  QList<QSslCertificate> mConnectionCAs;
165 
166  QTreeWidgetItem *mProtocolItem;
167  QComboBox *mProtocolCmbBx;
168  QTreeWidgetItem *mIgnoreErrorsItem;
169  QTreeWidgetItem *mVerifyModeItem;
170  QComboBox *mVerifyPeerCmbBx;
171  QTreeWidgetItem *mVerifyDepthItem;
172  QSpinBox *mVerifyDepthSpnBx;
173 
174  bool mCanSave;
175 
176  bool mDisabled;
177  QVBoxLayout *mAuthNotifyLayout;
178  QLabel *mAuthNotify;
179 };
180 
182 
186 class GUI_EXPORT QgsAuthSslConfigDialog : public QDialog
187 {
188  Q_OBJECT
189 
190  public:
197  explicit QgsAuthSslConfigDialog( QWidget *parent = nullptr,
198  const QSslCertificate& cert = QSslCertificate(),
199  const QString &hostport = QString() );
201 
203  QgsAuthSslConfigWidget *sslCustomConfigWidget() { return mSslConfigWdgt; }
204 
205  public slots:
207  void accept() override;
208 
209  private slots:
210  void checkCanSave( bool cansave );
211 
212  private:
213  QgsAuthSslConfigWidget *mSslConfigWdgt;
214  QPushButton *mSaveButton;
215 };
216 
217 #endif // QGSAUTHSSLCONFIGWIDGET_H
Configuration container for SSL server connection exceptions or overrides.
Widget for editing an SSL server configuration.
virtual void accept()
Dialog wrapper of widget for editing an SSL server configuration.
QgsAuthSslConfigWidget * sslCustomConfigWidget()
Access the embedded SSL server configuration widget.