File indexing completed on 2024-04-21 03:55:50

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2000-2003 George Staikos <staikos@kde.org>
0004     SPDX-FileCopyrightText: 2000 Malte Starostik <malte@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef _KSSLINFODIALOG_H
0010 #define _KSSLINFODIALOG_H
0011 
0012 #include <QDialog>
0013 #include <QSslError>
0014 
0015 #include "kiowidgets_export.h"
0016 
0017 #include <memory>
0018 
0019 /**
0020  * KDE SSL Information Dialog
0021  *
0022  * This class creates a dialog that can be used to display information about
0023  * an SSL session.
0024  *
0025  * There are NO GUARANTEES that KSslInfoDialog will remain binary compatible/
0026  * Contact staikos@kde.org for details if needed.
0027  *
0028  * @author George Staikos <staikos@kde.org>
0029  * @see KSSL
0030  * @short KDE SSL Information Dialog
0031  */
0032 class KIOWIDGETS_EXPORT KSslInfoDialog : public QDialog
0033 {
0034     Q_OBJECT
0035 public:
0036     /**
0037      *  Construct a KSSL Information Dialog
0038      *
0039      *  @param parent the parent widget
0040      */
0041     explicit KSslInfoDialog(QWidget *parent = nullptr);
0042 
0043     /**
0044      *  Destroy this dialog
0045      */
0046     ~KSslInfoDialog() override;
0047 
0048     /**
0049      *  Set information to display about the SSL connection.
0050      *
0051      *  @param certificateChain the certificate chain leading from the certificate
0052      *         authority to the peer.
0053      *  @param ip the ip of the remote host
0054      *  @param host the remote hostname
0055      *  @param sslProtocol the version of SSL in use (SSLv2, SSLv3, TLSv1)
0056      *  @param cipher the cipher in use
0057      *  @param usedBits the used bits of the key
0058      *  @param bits the key size of the cipher in use
0059      *  @param validationErrors errors validating the certificates, if any
0060      *  @since 5.64
0061      */
0062     void setSslInfo(const QList<QSslCertificate> &certificateChain,
0063                     const QString &ip,
0064                     const QString &host,
0065                     const QString &sslProtocol,
0066                     const QString &cipher,
0067                     int usedBits,
0068                     int bits,
0069                     const QList<QList<QSslError::SslError>> &validationErrors);
0070 
0071     void setMainPartEncrypted(bool);
0072     void setAuxiliaryPartsEncrypted(bool);
0073 
0074     /**
0075      * Converts certificate errors as provided in the "ssl_cert_errors" meta data
0076      * to a list of QSslError::SslError values per certificate in the certificate chain.
0077      * @since 5.65
0078      */
0079     static QList<QList<QSslError::SslError>> certificateErrorsFromString(const QString &errorsString);
0080 
0081 private:
0082     KIOWIDGETS_NO_EXPORT void updateWhichPartsEncrypted();
0083 
0084     class KSslInfoDialogPrivate;
0085     std::unique_ptr<KSslInfoDialogPrivate> const d;
0086 
0087 private Q_SLOTS:
0088     KIOWIDGETS_NO_EXPORT void displayFromChain(int);
0089 };
0090 
0091 #endif