summaryrefslogtreecommitdiffstats
path: root/kio/kssl/ksslcertificatecache.cc
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kio/kssl/ksslcertificatecache.cc
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kio/kssl/ksslcertificatecache.cc')
-rw-r--r--kio/kssl/ksslcertificatecache.cc399
1 files changed, 399 insertions, 0 deletions
diff --git a/kio/kssl/ksslcertificatecache.cc b/kio/kssl/ksslcertificatecache.cc
new file mode 100644
index 000000000..3a784ed14
--- /dev/null
+++ b/kio/kssl/ksslcertificatecache.cc
@@ -0,0 +1,399 @@
+/* This file is part of the KDE project
+ *
+ * Copyright (C) 2000, 2001 George Staikos <staikos@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#include "ksslcertificatecache.h"
+#include "ksslcertchain.h"
+#include "ksslcertificate.h"
+
+#include <stdlib.h>
+#include <kdebug.h>
+#include <dcopclient.h>
+#include <kdatastream.h>
+
+
+class KSSLCertificateCache::KSSLCertificateCachePrivate {
+ public:
+ DCOPClient *dcc;
+
+ KSSLCertificateCachePrivate() { dcc = new DCOPClient; dcc->attach(); }
+ ~KSSLCertificateCachePrivate() { delete dcc;}
+
+};
+
+
+
+KSSLCertificateCache::KSSLCertificateCache() {
+ d = new KSSLCertificateCachePrivate;
+}
+
+
+KSSLCertificateCache::~KSSLCertificateCache() {
+ delete d;
+}
+
+
+void KSSLCertificateCache::saveToDisk() {
+ kdDebug() << "Deprecated function KSSLCertificateCache::saveToDisk() called" << endl;
+}
+
+
+void KSSLCertificateCache::clearList() {
+ kdDebug() << "Deprecated function KSSLCertificateCache::clearList() called" << endl;
+}
+
+
+void KSSLCertificateCache::loadDefaultPolicies() {
+ kdDebug() << "Deprecated function KSSLCertificateCache::loadDefaultPolicies() called" << endl;
+}
+
+
+void KSSLCertificateCache::reload() {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ d->dcc->call("kded", "kssld",
+ "cacheReload()",
+ data, rettype, retval);
+}
+
+
+void KSSLCertificateCache::addCertificate(KSSLCertificate& cert,
+ KSSLCertificatePolicy policy, bool permanent) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert;
+ arg << policy;
+ arg << permanent;
+ d->dcc->call("kded", "kssld",
+ "cacheAddCertificate(KSSLCertificate,KSSLCertificateCache::KSSLCertificatePolicy,bool)",
+ data, rettype, retval);
+}
+
+
+// KDE 4: Make it const QString &
+KSSLCertificateCache::KSSLCertificatePolicy KSSLCertificateCache::getPolicyByCN(QString& cn) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cn;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheGetPolicyByCN(QString)",
+ data, rettype, retval);
+
+ if (rc && rettype == "KSSLCertificateCache::KSSLCertificatePolicy") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ KSSLCertificateCache::KSSLCertificatePolicy drc;
+ retStream >> drc;
+ return drc;
+ }
+return KSSLCertificateCache::Ambiguous;
+}
+
+
+KSSLCertificateCache::KSSLCertificatePolicy KSSLCertificateCache::getPolicyByCertificate(KSSLCertificate& cert) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheGetPolicyByCertificate(KSSLCertificate)",
+ data, rettype, retval);
+
+ if (rc && rettype == "KSSLCertificateCache::KSSLCertificatePolicy") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ KSSLCertificateCache::KSSLCertificatePolicy drc;
+ retStream >> drc;
+ return drc;
+ }
+return KSSLCertificateCache::Ambiguous;
+}
+
+
+// KDE 4: Make it const QString &
+bool KSSLCertificateCache::seenCN(QString& cn) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cn;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheSeenCN(QString)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+bool KSSLCertificateCache::seenCertificate(KSSLCertificate& cert) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheSeenCertificate(KSSLCertificate)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+bool KSSLCertificateCache::isPermanent(KSSLCertificate& cert) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheIsPermanent(KSSLCertificate)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+// KDE 4: Make it const QString &
+bool KSSLCertificateCache::removeByCN(QString& cn) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cn;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheRemoveByCN(QString)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+bool KSSLCertificateCache::removeByCertificate(KSSLCertificate& cert) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheRemoveByCertificate(KSSLCertificate)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+// KDE 4: Make it const QString &
+bool KSSLCertificateCache::modifyByCN(QString& cn,
+ KSSLCertificateCache::KSSLCertificatePolicy policy,
+ bool permanent,
+ QDateTime& expires) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cn << policy << permanent << expires;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheModifyByCN(QString,KSSLCertificateCache::KSSLCertificatePolicy,bool,QDateTime)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+bool KSSLCertificateCache::modifyByCertificate(KSSLCertificate& cert,
+ KSSLCertificateCache::KSSLCertificatePolicy policy,
+ bool permanent,
+ QDateTime& expires) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert << policy << permanent << expires;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheModifyByCertificate(KSSLCertificate,KSSLCertificateCache::KSSLCertificatePolicy,bool,QDateTime)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+QStringList KSSLCertificateCache::getHostList(KSSLCertificate& cert) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheGetHostList(KSSLCertificate)",
+ data, rettype, retval);
+
+ if (rc && rettype == "QStringList") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ QStringList drc;
+ retStream >> drc;
+ return drc;
+ }
+return QStringList();
+}
+
+
+// KDE 4: Make it const QString &
+bool KSSLCertificateCache::addHost(KSSLCertificate& cert, QString& host) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert << host;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheAddHost(KSSLCertificate,QString)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+// KDE 4: Make it const QString &
+bool KSSLCertificateCache::removeHost(KSSLCertificate& cert, QString& host) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << cert << host;
+ bool rc = d->dcc->call("kded", "kssld",
+ "cacheRemoveHost(KSSLCertificate,QString)",
+ data, rettype, retval);
+
+ if (rc && rettype == "bool") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ bool drc;
+ retStream >> drc;
+ return drc;
+ }
+
+return false;
+}
+
+
+QStringList KSSLCertificateCache::getKDEKeyByEmail(const QString &email) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << email;
+ bool rc = d->dcc->call("kded", "kssld",
+ "getKDEKeyByEmail(QString)",
+ data, rettype, retval);
+
+ if (rc && rettype == "QStringList") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ QStringList drc;
+ retStream >> drc;
+ return drc;
+ }
+
+ return QStringList();
+}
+
+
+KSSLCertificate *KSSLCertificateCache::getCertByMD5Digest(const QString &key) {
+ QByteArray data, retval;
+ QCString rettype;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << key;
+ bool rc = d->dcc->call("kded", "kssld",
+ "getCertByMD5Digest(QString)",
+ data, rettype, retval);
+
+ if (rc && rettype == "KSSLCertificate") {
+ QDataStream retStream(retval, IO_ReadOnly);
+ KSSLCertificate *drc = new KSSLCertificate;
+ retStream >> *drc;
+ if (drc->getCert())
+ return drc;
+ delete drc; // should not happen too often if used in conjunction with getKDEKeyByEmail
+ }
+
+ return 0L;
+}
+
+
+QDataStream& operator<<(QDataStream& s, const KSSLCertificateCache::KSSLCertificatePolicy& p) {
+ s << (Q_UINT32)p;
+return s;
+}
+
+
+QDataStream& operator>>(QDataStream& s, KSSLCertificateCache::KSSLCertificatePolicy& p) {
+ Q_UINT32 pd;
+ s >> pd;
+ p = (KSSLCertificateCache::KSSLCertificatePolicy) pd;
+ return s;
+}
+
+
+
+
+