QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
67 #include <QDialog>
68 #include <QAbstractSocket>
69 #include <QSslSocket>
70 
71 class QPushButton;
72 class QSslSocket;
73 class QTimer;
74 
75 
79 class GUI_EXPORT QgsAuthSslImportDialog : public QDialog, private Ui::QgsAuthSslTestDialog
80 {
81  Q_OBJECT
82  public:
87  QgsAuthSslImportDialog( QWidget *parent = nullptr );
89 
90  public slots:
92  void accept() override;
93 
94  private slots:
95  void updateEnabledState();
96  void secureConnect();
97  void socketStateChanged( QAbstractSocket::SocketState state );
98  void socketConnected();
99  void socketDisconnected();
100  void socketEncrypted();
101  void socketError( QAbstractSocket::SocketError err );
102  void socketReadyRead();
103  void destroySocket();
104  void sslErrors( const QList<QSslError> &errors );
105  void showCertificateInfo();
106 
107  void widgetReadyToSaveChanged( bool cansave );
108  void checkCanSave();
109 
110  void radioServerImportToggled( bool checked );
111  void radioFileImportToggled( bool checked );
112 
113  void on_btnCertPath_clicked();
114  void clearCertificateConfig();
115  void clearStatusCertificateConfig();
116 
117  private:
118  void loadCertFromFile();
119 
120  void appendString( const QString &line );
121 
122  QPushButton* saveButton();
123  QPushButton* closeButton();
124  QString getOpenFileName( const QString& title, const QString& extfilter );
125 
126  QSslSocket *mSocket;
127  bool mExecErrorsDialog;
128  QTimer *mTimer;
129  QList<QSslError> mSslErrors;
130  QList<QSslCertificate> mTrustedCAs;
131 
132  QVBoxLayout *mAuthNotifyLayout;
133  QLabel *mAuthNotify;
134 };
135 
136 #endif // QGSAUTHSSLIMPORTDIALOG_H
virtual void accept()
Widget for importing an SSL server certificate exception into the authentication database.