File indexing completed on 2023-09-24 08:55:09

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (C) 2007, 2008, 2010 Andreas Hartmetz <ahartmetz@gmail.com>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef _INCLUDE_KSSLCERTIFICATEMANAGER_H
0022 #define _INCLUDE_KSSLCERTIFICATEMANAGER_H
0023 
0024 #include "ktcpsocket.h"
0025 
0026 #include <QtNetwork/QSslCertificate>
0027 #include <QtNetwork/QSslError>
0028 #include <QtCore/QString>
0029 #include <QtCore/QStringList>
0030 #include <QtCore/QDate>
0031 
0032 class QSslCertificate;
0033 class KSslCertificateRulePrivate;
0034 class KSslCertificateManagerPrivate;
0035 
0036 //### document this... :/
0037 class KDECORE_EXPORT KSslCertificateRule
0038 {
0039 public:
0040     KSslCertificateRule(const QSslCertificate &cert = QSslCertificate(),
0041                         const QString &hostName = QString());
0042     KSslCertificateRule(const KSslCertificateRule &other);
0043     ~KSslCertificateRule();
0044     KSslCertificateRule &operator=(const KSslCertificateRule &other);
0045 
0046     QSslCertificate certificate() const;
0047     QString hostName() const;
0048     void setExpiryDateTime(const QDateTime &dateTime);
0049     QDateTime expiryDateTime() const;
0050     void setRejected(bool rejected);
0051     bool isRejected() const;
0052     bool isErrorIgnored(KSslError::Error error) const;
0053     void setIgnoredErrors(const QList<KSslError::Error> &errors);
0054     void setIgnoredErrors(const QList<KSslError> &errors);
0055     QList<KSslError::Error> ignoredErrors() const;
0056     QList<KSslError::Error> filterErrors(const QList<KSslError::Error> &errors) const;
0057     QList<KSslError> filterErrors(const QList<KSslError> &errors) const;
0058 private:
0059     KSslCertificateRulePrivate *const d;
0060 };
0061 
0062 
0063 //### document this too... :/
0064 class KDECORE_EXPORT KSslCertificateManager
0065 {
0066 public:
0067     static KSslCertificateManager *self();
0068     void setRule(const KSslCertificateRule &rule);
0069     void clearRule(const KSslCertificateRule &rule);
0070     void clearRule(const QSslCertificate &cert, const QString &hostName);
0071     KSslCertificateRule rule(const QSslCertificate &cert, const QString &hostName) const;
0072 
0073     // do not use, it does nothing!
0074 #ifndef KDE_NO_DEPRECATED
0075     KDE_DEPRECATED void setRootCertificates(const QList<QSslCertificate> &rootCertificates)
0076         { Q_UNUSED(rootCertificates) }
0077 #endif
0078     // use caCertificates() instead
0079 #ifndef KDE_NO_DEPRECATED
0080     KDE_DEPRECATED QList<QSslCertificate> rootCertificates() const
0081         { return caCertificates(); }
0082 #endif
0083 
0084     QList<QSslCertificate> caCertificates() const;
0085 
0086     static QList<KSslError> nonIgnorableErrors(const QList<KSslError> &);
0087     static QList<KSslError::Error> nonIgnorableErrors(const QList<KSslError::Error> &);
0088 
0089 private:
0090     friend class KSslCertificateManagerContainer;
0091     friend class KSslCertificateManagerPrivate;
0092     KSslCertificateManager();
0093     ~KSslCertificateManager();
0094 
0095     KSslCertificateManagerPrivate *const d;
0096 };
0097 
0098 
0099 #endif