QGIS API Documentation 3.99.0-Master (752b475928d)
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:
51 explicit QgsAuthSslConfigWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QSslCertificate &cert = QSslCertificate(), const QString &hostport = QString(), const QList<QSslCertificate> &connectionCAs = QList<QSslCertificate>() );
52
54 QGroupBox *certificateGroupBox();
56 QGroupBox *sslConfigGroupBox();
57
60
62 const QSslCertificate sslCertificate();
63
65 const QString sslHost();
66
68 QSsl::SslProtocol sslProtocol();
69
71 const QList<QSslError::SslError> sslIgnoreErrorEnums();
72
74 QSslSocket::PeerVerifyMode sslPeerVerifyMode();
75
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
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
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 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 = nullptr;
167 QComboBox *mProtocolCmbBx = nullptr;
168 QTreeWidgetItem *mIgnoreErrorsItem = nullptr;
169 QTreeWidgetItem *mVerifyModeItem = nullptr;
170 QComboBox *mVerifyPeerCmbBx = nullptr;
171 QTreeWidgetItem *mVerifyDepthItem = nullptr;
172 QSpinBox *mVerifyDepthSpnBx = nullptr;
173
174 bool mCanSave = false;
175
176 bool mDisabled = false;
177 QVBoxLayout *mAuthNotifyLayout = nullptr;
178 QLabel *mAuthNotify = nullptr;
179};
180
182
187class GUI_EXPORT QgsAuthSslConfigDialog : public QDialog
188{
189 Q_OBJECT
190
191 public:
198 explicit QgsAuthSslConfigDialog( QWidget *parent = nullptr, const QSslCertificate &cert = QSslCertificate(), const QString &hostport = QString() );
199
201 QgsAuthSslConfigWidget *sslCustomConfigWidget() { return mSslConfigWdgt; }
202
203 public slots:
204 void accept() override;
205
206 private slots:
207 void checkCanSave( bool cansave );
208
209 private:
210 QgsAuthSslConfigWidget *mSslConfigWdgt = nullptr;
211 QPushButton *mSaveButton = nullptr;
212};
213
214#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:53