KDECore
ksslcertificatemanager_p.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2010 Andreas Hartmetz <ahartmetz@gmail.com> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include <QMutex> 00022 00023 struct KSslCaCertificate 00024 { 00025 enum Store { 00026 SystemStore = 0, 00027 UserStore 00028 }; 00029 00030 // TODO see if we can get rid of the .toHex() for storage and comparison; requires 00031 // several changes in KSslCertificateManager and CaCertificatesPage! 00032 KSslCaCertificate(const QSslCertificate &c, Store s, bool _isBlacklisted) 00033 : cert(c), 00034 certHash(c.digest().toHex()), 00035 store(s), 00036 isBlacklisted(_isBlacklisted) { } 00037 const QSslCertificate cert; 00038 const QByteArray certHash; 00039 const Store store; 00040 bool isBlacklisted; 00041 // the synthesized version without the const_casts doesn't compile 00042 const KSslCaCertificate &operator=(const KSslCaCertificate &other) 00043 { 00044 const_cast<QSslCertificate &>(cert) = other.cert; 00045 const_cast<QByteArray &>(certHash) = other.certHash; 00046 const_cast<Store &>(store) = other.store; 00047 isBlacklisted = other.isBlacklisted; 00048 return *this; 00049 } 00050 }; 00051 00052 class OrgKdeKSSLDInterface; // aka org::kde::KSSLDInterface 00053 namespace org { namespace kde { 00054 typedef ::OrgKdeKSSLDInterface KSSLDInterface; 00055 }} 00056 00057 class KSslCertificateManagerPrivate 00058 { 00059 public: 00060 KSslCertificateManagerPrivate(); 00061 ~KSslCertificateManagerPrivate(); 00062 00063 static KSslCertificateManagerPrivate *get(KSslCertificateManager *q) 00064 { return q->d; } 00065 00066 void loadDefaultCaCertificates(); 00067 00068 // helpers for setAllCertificates() 00069 bool addCertificate(const KSslCaCertificate &in); 00070 bool removeCertificate(const KSslCaCertificate &old); 00071 bool updateCertificateBlacklisted(const KSslCaCertificate &cert); 00072 bool setCertificateBlacklisted(const QByteArray &certHash, bool isBlacklisted); 00073 00074 void setAllCertificates(const QList<KSslCaCertificate> &certsIn); 00075 QList<KSslCaCertificate> allCertificates() const; 00076 00077 KConfig config; 00078 org::kde::KSSLDInterface *iface; 00079 QHash<QString, KSslError::Error> stringToSslError; 00080 QHash<KSslError::Error, QString> sslErrorToString; 00081 00082 QList<QSslCertificate> defaultCaCertificates; 00083 00084 // for use in setAllCertificates() only 00085 QSet<QByteArray> knownCerts; 00086 QMutex certListMutex; 00087 bool isCertListLoaded; 00088 QString userCertDir; 00089 }; 00090 00091 // don't export KSslCertificateManagerPrivate to avoid unnecessary symbols in libkdecore 00092 KDECORE_EXPORT QList<KSslCaCertificate> _allKsslCaCertificates(KSslCertificateManager *cm); 00093 KDECORE_EXPORT void _setAllKsslCaCertificates(KSslCertificateManager *cm, 00094 const QList<KSslCaCertificate> &certsIn);
KDE 4.6 API Reference