QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
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 "ui_qgsauthsslconfigwidget.h"
21
22#include "qgis_gui.h"
23#include "qgis_sip.h"
24#include "qgsauthconfig.h"
25
26#include <QDialog>
27#include <QSslCertificate>
28#include <QSslConfiguration>
29#include <QWidget>
30
31class QComboBox;
32class QGroupBox;
33class QSpinBox;
34
39class GUI_EXPORT QgsAuthSslConfigWidget : public QWidget, private Ui::QgsAuthSslConfigWidget
40{
41 Q_OBJECT
42
43 public:
52 QWidget *parent SIP_TRANSFERTHIS = nullptr,
53 const QSslCertificate &cert = QSslCertificate(),
54 const QString &hostport = QString(),
55 const QList<QSslCertificate> &connectionCAs = QList<QSslCertificate>()
56 );
57
59 QGroupBox *certificateGroupBox();
61 QGroupBox *sslConfigGroupBox();
62
65
67 const QSslCertificate sslCertificate();
68
70 const QString sslHost();
71
73 QSsl::SslProtocol sslProtocol();
74
76 const QList<QSslError::SslError> sslIgnoreErrorEnums();
77
79 QSslSocket::PeerVerifyMode sslPeerVerifyMode();
80
86
87 public slots:
89 void enableSslCustomOptions( bool enable );
90
91 // may also load existing config, if found
93 void setSslCertificate( const QSslCertificate &cert, const QString &hostport = QString() );
94
97
99 void saveSslCertConfig();
100
102 void resetSslCertConfig();
103
105 void setSslProtocol( QSsl::SslProtocol protocol );
106
108 void resetSslProtocol();
109
111 void appendSslIgnoreErrors( const QList<QSslError> &errors );
112
114 void setSslIgnoreErrorEnums( const QList<QSslError::SslError> &errorenums );
115
117 void setSslIgnoreErrors( const QList<QSslError> &errors );
118
121
123 void setSslPeerVerify( QSslSocket::PeerVerifyMode mode, int modedepth );
124
126 void resetSslPeerVerify();
127
129 void setSslHost( const QString &host );
130
132 void setConfigCheckable( bool checkable );
133
135 void validateHostPortText( const QString &txt );
136
138 bool readyToSave();
139
140 signals:
142 void configEnabledChanged( bool enabled );
143
145 void certFoundInAuthDatabase( bool found );
146
148 void hostPortValidityChanged( bool valid );
149
151 void readyToSaveChanged( bool cansave );
152
153 private slots:
154 void btnCertInfo_clicked();
155
156 private:
157 enum ConfigType
158 {
159 ConfigParent = 1000,
160 ConfigItem = 1001,
161 };
162
163 bool validateHostPort( const QString &txt );
164
165 void setUpSslConfigTree();
166 QTreeWidgetItem *addRootItem( const QString &label );
167
168 QSslCertificate mCert;
169 QList<QSslCertificate> mConnectionCAs;
170
171 QTreeWidgetItem *mProtocolItem = nullptr;
172 QComboBox *mProtocolCmbBx = nullptr;
173 QTreeWidgetItem *mIgnoreErrorsItem = nullptr;
174 QTreeWidgetItem *mVerifyModeItem = nullptr;
175 QComboBox *mVerifyPeerCmbBx = nullptr;
176 QTreeWidgetItem *mVerifyDepthItem = nullptr;
177 QSpinBox *mVerifyDepthSpnBx = nullptr;
178
179 bool mCanSave = false;
180
181 bool mDisabled = false;
182 QVBoxLayout *mAuthNotifyLayout = nullptr;
183 QLabel *mAuthNotify = nullptr;
184};
185
187
192class GUI_EXPORT QgsAuthSslConfigDialog : public QDialog
193{
194 Q_OBJECT
195
196 public:
203 explicit QgsAuthSslConfigDialog( QWidget *parent = nullptr, const QSslCertificate &cert = QSslCertificate(), const QString &hostport = QString() );
204
206 QgsAuthSslConfigWidget *sslCustomConfigWidget() { return mSslConfigWdgt; }
207
208 public slots:
209 void accept() override;
210
211 private slots:
212 void checkCanSave( bool cansave );
213
214 private:
215 QgsAuthSslConfigWidget *mSslConfigWdgt = nullptr;
216 QPushButton *mSaveButton = nullptr;
217};
218
219#endif // QGSAUTHSSLCONFIGWIDGET_H
Configuration container for SSL server connection exceptions or overrides.
QgsAuthSslConfigWidget * sslCustomConfigWidget()
Access the embedded SSL server configuration widget.
QgsAuthSslConfigDialog(QWidget *parent=nullptr, const QSslCertificate &cert=QSslCertificate(), const QString &hostport=QString())
Construct wrapper dialog for the SSL config widget.
Widget for editing an SSL server configuration.
QgsAuthSslConfigWidget(QWidget *parent=nullptr, const QSslCertificate &cert=QSslCertificate(), const QString &hostport=QString(), const QList< QSslCertificate > &connectionCAs=QList< QSslCertificate >())
Construct a widget for editing an SSL server certificate configuration.
const QSslCertificate sslCertificate()
Gets the SSL server certificate.
void validateHostPortText(const QString &txt)
Parse string for host:port.
void setSslPeerVerify(QSslSocket::PeerVerifyMode mode, int modedepth)
Sets the client's peer verify mode for connections.
QSslSocket::PeerVerifyMode sslPeerVerifyMode()
Gets the client's peer verify mode for connections.
QSsl::SslProtocol sslProtocol()
Gets the SSL protocol used for connections.
QGroupBox * sslConfigGroupBox()
Access to the SSL configuration's group box widget.
const QString sslHost()
Gets the host:port to associate with the server certificate.
void resetSslCertConfig()
Clear the current SSL server configuration and disabled it.
void setSslCertificate(const QSslCertificate &cert, const QString &hostport=QString())
Sets SSl certificate and any associated host:port.
void saveSslCertConfig()
Save the current SSL server configuration to the authentication database.
void certFoundInAuthDatabase(bool found)
Emitted when an certificate of same SHA hash is found in authentication database.
void resetSslProtocol()
Reset the SSL protocol to use in connections to the default.
void setSslHost(const QString &host)
Sets the host of the server.
void appendSslIgnoreErrors(const QList< QSslError > &errors)
Add to SSL errors to ignore for the connection.
void hostPortValidityChanged(bool valid)
Emitted when the validity of the host:port changes.
void setSslIgnoreErrorEnums(const QList< QSslError::SslError > &errorenums)
Sets the SSL errors (as enums) to ignore for the connection.
void readyToSaveChanged(bool cansave)
Emitted when the configuration can be saved changes.
void resetSslIgnoreErrors()
Clear the SSL errors to ignore for the connection.
void configEnabledChanged(bool enabled)
Emitted when the enabled state of the configuration changes.
void setSslIgnoreErrors(const QList< QSslError > &errors)
Sets the SSL errors to ignore for the connection.
int sslPeerVerifyDepth()
Gets the client's peer verify depth for connections.
void loadSslCustomConfig(const QgsAuthConfigSslServer &config=QgsAuthConfigSslServer())
Load an existing SSL server configuration.
const QList< QSslError::SslError > sslIgnoreErrorEnums()
Gets list of the SSL errors (as enums) to be ignored for connections.
bool readyToSave()
Verify if the configuration if ready to save.
void setSslProtocol(QSsl::SslProtocol protocol)
Sets the SSL protocol to use in connections.
QGroupBox * certificateGroupBox()
Access to the certificate's group box widget.
void enableSslCustomOptions(bool enable)
Enable or disable the custom options widget.
void resetSslPeerVerify()
Reset the client's peer verify mode for connections to default.
void setConfigCheckable(bool checkable)
Sets whether the config group box is checkable.
const QgsAuthConfigSslServer sslCustomConfig()
Gets the SSL configuration.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52