QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsauthsslimportdialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsauthsslimportdialog.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 /****************************************************************************
18 **
19 ** Portions of this code were derived from the following...
20 **
21 ** qt-everywhere-opensource-src-4.8.6/examples/network/
22 ** securesocketclient/certificateinfo.h (and .cpp)
23 **
24 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
25 ** Contact: http://www.qt-project.org/legal
26 **
27 ** This file is part of the examples of the Qt Toolkit.
28 **
29 ** $QT_BEGIN_LICENSE:BSD$
30 ** You may use this file under the terms of the BSD license as follows:
31 **
32 ** "Redistribution and use in source and binary forms, with or without
33 ** modification, are permitted provided that the following conditions are
34 ** met:
35 ** * Redistributions of source code must retain the above copyright
36 ** notice, this list of conditions and the following disclaimer.
37 ** * Redistributions in binary form must reproduce the above copyright
38 ** notice, this list of conditions and the following disclaimer in
39 ** the documentation and/or other materials provided with the
40 ** distribution.
41 ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
42 ** of its contributors may be used to endorse or promote products derived
43 ** from this software without specific prior written permission.
44 **
45 **
46 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
47 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
48 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
49 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
50 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
53 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
54 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
57 **
58 ** $QT_END_LICENSE$
59 **
60 ****************************************************************************/
61 
62 #ifndef QGSAUTHSSLIMPORTDIALOG_H
63 #define QGSAUTHSSLIMPORTDIALOG_H
64 
65 #include "ui_qgsauthsslimportdialog.h"
66 #include "qgis.h"
67 
68 #include <QDialog>
69 #include <QAbstractSocket>
70 #include <QSslSocket>
71 #include "qgis_gui.h"
72 
73 class QPushButton;
74 class QSslSocket;
75 class QTimer;
76 
77 
82 class GUI_EXPORT QgsAuthSslImportDialog : public QDialog, private Ui::QgsAuthSslTestDialog
83 {
84  Q_OBJECT
85  public:
86 
91  QgsAuthSslImportDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr );
92 
93  public slots:
94  void accept() override;
95 
96  private slots:
97  void updateEnabledState();
98  void secureConnect();
99  void socketStateChanged( QAbstractSocket::SocketState state );
100  void socketConnected();
101  void socketDisconnected();
102  void socketEncrypted();
103  void socketError( QAbstractSocket::SocketError err );
104  void socketReadyRead();
105  void destroySocket();
106  void sslErrors( const QList<QSslError> &errors );
107  void showCertificateInfo();
108 
109  void widgetReadyToSaveChanged( bool cansave );
110  void checkCanSave();
111 
112  void radioServerImportToggled( bool checked );
113  void radioFileImportToggled( bool checked );
114 
115  void btnCertPath_clicked();
116  void clearCertificateConfig();
117  void clearStatusCertificateConfig();
118 
119  private:
120  void loadCertFromFile();
121 
122  void appendString( const QString &line );
123 
124  QPushButton *saveButton();
125  QPushButton *closeButton();
126  QString getOpenFileName( const QString &title, const QString &extfilter );
127 
128  QSslSocket *mSocket = nullptr;
129  bool mExecErrorsDialog = false;
130  QTimer *mTimer = nullptr;
131  QList<QSslError> mSslErrors;
132  QList<QSslCertificate> mTrustedCAs;
133 
134  QVBoxLayout *mAuthNotifyLayout = nullptr;
135  QLabel *mAuthNotify = nullptr;
136 };
137 
138 #endif // QGSAUTHSSLIMPORTDIALOG_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Widget for importing an SSL server certificate exception into the authentication database.