ksslcertificatecache.cc Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# ksslcertificatecache.cc

    00001 /* This file is part of the KDE project
    00002  *
    00003  * Copyright (C) 2000, 2001 George Staikos <staikos@kde.org>
    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., 59 Temple Place - Suite 330,
    00018  * Boston, MA 02111-1307, USA.
    00019  */
    00020
    00021
    00022 #include "ksslcertificatecache.h"
    00023 #include "ksslcertchain.h"
    00024 #include "ksslcertificate.h"
    00025
    00026 #include <stdlib.h>
    00027 #include <kdebug.h>
    00028 #include <dcopclient.h>
    00029 #include <kdatastream.h>
    00030
    00031
    00032 class KSSLCertificateCache::KSSLCertificateCachePrivate {
    00033   public:
    00034   DCOPClient *dcc;
    00035
    00036   KSSLCertificateCachePrivate()  { dcc = new DCOPClient; dcc->attach(); }
    00037   ~KSSLCertificateCachePrivate() { delete dcc;}
    00038
    00039 };
    00040
    00041
    00042
    00043 KSSLCertificateCache::KSSLCertificateCache() {
    00044   d = new KSSLCertificateCachePrivate;
    00045 }
    00046
    00047
    00048 KSSLCertificateCache::~KSSLCertificateCache() {
    00049   delete d;
    00050 }
    00051
    00052
    00053 void KSSLCertificateCache::saveToDisk() {
    00054    kdDebug() << "Deprecated function KSSLCertificateCache::saveToDisk() called" << endl;
    00055 }
    00056
    00057
    00058 void KSSLCertificateCache::clearList() {
    00059    kdDebug() << "Deprecated function KSSLCertificateCache::clearList() called" << endl;
    00060 }
    00061
    00062
    00063 void KSSLCertificateCache::loadDefaultPolicies() {
    00064    kdDebug() << "Deprecated function KSSLCertificateCache::loadDefaultPolicies() called" << endl;
    00065 }
    00066
    00067
    00068 void KSSLCertificateCache::reload() {
    00069      QByteArray data, retval;
    00070      QCString rettype;
    00071      QDataStream arg(data, IO_WriteOnly);
    00072      d->dcc->call("kded", "kssld",
    00073                   "cacheReload()",
    00074                   data, rettype, retval);
    00075 }
    00076
    00077
    00078 void KSSLCertificateCache::addCertificate(KSSLCertificate& cert,
    00079                        KSSLCertificatePolicy policy, bool permanent) {
    00080      QByteArray data, retval;
    00081      QCString rettype;
    00082      QDataStream arg(data, IO_WriteOnly);
    00083      arg << cert;
    00084      arg << policy;
    00085      arg << permanent;
    00086      d->dcc->call("kded", "kssld",
    00087                   "cacheAddCertificate(KSSLCertificate,KSSLCertificateCache::KSSLCertificatePolicy,bool)",
    00088                   data, rettype, retval);
    00089 }
    00090
    00091
    00092 KSSLCertificateCache::KSSLCertificatePolicy KSSLCertificateCache::getPolicyByCN(QString& cn) {
    00093      QByteArray data, retval;
    00094      QCString rettype;
    00095      QDataStream arg(data, IO_WriteOnly);
    00096      arg << cn;
    00097      bool rc = d->dcc->call("kded", "kssld",
    00098                             "cacheGetPolicyByCN(QString)",
    00099                             data, rettype, retval);
    00100
    00101      if (rc && rettype == "KSSLCertificateCache::KSSLCertificatePolicy") {
    00102         QDataStream retStream(retval, IO_ReadOnly);
    00103         KSSLCertificateCache::KSSLCertificatePolicy drc;
    00104         retStream >> drc;
    00105         return drc;
    00106      }
    00107 return KSSLCertificateCache::Ambiguous;
    00108 }
    00109
    00110
    00111 KSSLCertificateCache::KSSLCertificatePolicy KSSLCertificateCache::getPolicyByCertificate(KSSLCertificate& cert) {
    00112      QByteArray data, retval;
    00113      QCString rettype;
    00114      QDataStream arg(data, IO_WriteOnly);
    00115      arg << cert;
    00116      bool rc = d->dcc->call("kded", "kssld",
    00117                             "cacheGetPolicyByCertificate(KSSLCertificate)",
    00118                             data, rettype, retval);
    00119
    00120      if (rc && rettype == "KSSLCertificateCache::KSSLCertificatePolicy") {
    00121         QDataStream retStream(retval, IO_ReadOnly);
    00122         KSSLCertificateCache::KSSLCertificatePolicy drc;
    00123         retStream >> drc;
    00124         return drc;
    00125      }
    00126 return KSSLCertificateCache::Ambiguous;
    00127 }
    00128
    00129
    00130 bool KSSLCertificateCache::seenCN(QString& cn) {
    00131      QByteArray data, retval;
    00132      QCString rettype;
    00133      QDataStream arg(data, IO_WriteOnly);
    00134      arg << cn;
    00135      bool rc = d->dcc->call("kded", "kssld",
    00136                             "cacheSeenCN(QString)",
    00137                             data, rettype, retval);
    00138
    00139      if (rc && rettype == "bool") {
    00140         QDataStream retStream(retval, IO_ReadOnly);
    00141         bool drc;
    00142         retStream >> drc;
    00143         return drc;
    00144      }
    00145
    00146 return false;
    00147 }
    00148
    00149
    00150 bool KSSLCertificateCache::seenCertificate(KSSLCertificate& cert) {
    00151      QByteArray data, retval;
    00152      QCString rettype;
    00153      QDataStream arg(data, IO_WriteOnly);
    00154      arg << cert;
    00155      bool rc = d->dcc->call("kded", "kssld",
    00156                             "cacheSeenCertificate(KSSLCertificate)",
    00157                             data, rettype, retval);
    00158
    00159      if (rc && rettype == "bool") {
    00160         QDataStream retStream(retval, IO_ReadOnly);
    00161         bool drc;
    00162         retStream >> drc;
    00163         return drc;
    00164      }
    00165
    00166 return false;
    00167 }
    00168
    00169
    00170 bool KSSLCertificateCache::isPermanent(KSSLCertificate& cert) {
    00171      QByteArray data, retval;
    00172      QCString rettype;
    00173      QDataStream arg(data, IO_WriteOnly);
    00174      arg << cert;
    00175      bool rc = d->dcc->call("kded", "kssld",
    00176                             "cacheIsPermanent(KSSLCertificate)",
    00177                             data, rettype, retval);
    00178
    00179      if (rc && rettype == "bool") {
    00180         QDataStream retStream(retval, IO_ReadOnly);
    00181         bool drc;
    00182         retStream >> drc;
    00183         return drc;
    00184      }
    00185
    00186 return false;
    00187 }
    00188
    00189
    00190 bool KSSLCertificateCache::removeByCN(QString& cn) {
    00191      QByteArray data, retval;
    00192      QCString rettype;
    00193      QDataStream arg(data, IO_WriteOnly);
    00194      arg << cn;
    00195      bool rc = d->dcc->call("kded", "kssld",
    00196                             "cacheRemoveByCN(QString)",
    00197                             data, rettype, retval);
    00198
    00199      if (rc && rettype == "bool") {
    00200         QDataStream retStream(retval, IO_ReadOnly);
    00201         bool drc;
    00202         retStream >> drc;
    00203         return drc;
    00204      }
    00205
    00206 return false;
    00207 }
    00208
    00209
    00210 bool KSSLCertificateCache::removeByCertificate(KSSLCertificate& cert) {
    00211      QByteArray data, retval;
    00212      QCString rettype;
    00213      QDataStream arg(data, IO_WriteOnly);
    00214      arg << cert;
    00215      bool rc = d->dcc->call("kded", "kssld",
    00216                             "cacheRemoveByCertificate(KSSLCertificate)",
    00217                             data, rettype, retval);
    00218
    00219      if (rc && rettype == "bool") {
    00220         QDataStream retStream(retval, IO_ReadOnly);
    00221         bool drc;
    00222         retStream >> drc;
    00223         return drc;
    00224      }
    00225
    00226 return false;
    00227 }
    00228
    00229
    00230 bool KSSLCertificateCache::modifyByCN(QString& cn,
    00231                   KSSLCertificateCache::KSSLCertificatePolicy policy,
    00232                   bool permanent,
    00233                   QDateTime& expires) {
    00234      QByteArray data, retval;
    00235      QCString rettype;
    00236      QDataStream arg(data, IO_WriteOnly);
    00237      arg << cn << policy << permanent << expires;
    00238      bool rc = d->dcc->call("kded", "kssld",
    00239                             "cacheModifyByCN(QString,KSSLCertificateCache::KSSLCertificatePolicy,bool,QDateTime)",
    00240                             data, rettype, retval);
    00241
    00242      if (rc && rettype == "bool") {
    00243         QDataStream retStream(retval, IO_ReadOnly);
    00244         bool drc;
    00245         retStream >> drc;
    00246         return drc;
    00247      }
    00248
    00249 return false;
    00250 }
    00251
    00252
    00253 bool KSSLCertificateCache::modifyByCertificate(KSSLCertificate& cert,
    00254                            KSSLCertificateCache::KSSLCertificatePolicy policy,
    00255                            bool permanent,
    00256                            QDateTime& expires) {
    00257      QByteArray data, retval;
    00258      QCString rettype;
    00259      QDataStream arg(data, IO_WriteOnly);
    00260      arg << cert << policy << permanent << expires;
    00261      bool rc = d->dcc->call("kded", "kssld",
    00262                             "cacheModifyByCertificate(KSSLCertificate,KSSLCertificateCache::KSSLCertificatePolicy,bool,QDateTime)",
    00263                             data, rettype, retval);
    00264
    00265      if (rc && rettype == "bool") {
    00266         QDataStream retStream(retval, IO_ReadOnly);
    00267         bool drc;
    00268         retStream >> drc;
    00269         return drc;
    00270      }
    00271
    00272 return false;
    00273 }
    00274
    00275
    00276 QStringList KSSLCertificateCache::getHostList(KSSLCertificate& cert) {
    00277      QByteArray data, retval;
    00278      QCString rettype;
    00279      QDataStream arg(data, IO_WriteOnly);
    00280      arg << cert;
    00281      bool rc = d->dcc->call("kded", "kssld",
    00282                             "cacheGetHostList(KSSLCertificate)",
    00283                             data, rettype, retval);
    00284
    00285      if (rc && rettype == "QStringList") {
    00286         QDataStream retStream(retval, IO_ReadOnly);
    00287         QStringList drc;
    00288         retStream >> drc;
    00289         return drc;
    00290      }
    00291 return QStringList();
    00292 }
    00293
    00294
    00295 bool KSSLCertificateCache::addHost(KSSLCertificate& cert, QString& host) {
    00296      QByteArray data, retval;
    00297      QCString rettype;
    00298      QDataStream arg(data, IO_WriteOnly);
    00299      arg << cert << host;
    00300      bool rc = d->dcc->call("kded", "kssld",
    00301                             "cacheAddHost(KSSLCertificate,QString)",
    00302                             data, rettype, retval);
    00303
    00304      if (rc && rettype == "bool") {
    00305         QDataStream retStream(retval, IO_ReadOnly);
    00306         bool drc;
    00307         retStream >> drc;
    00308         return drc;
    00309      }
    00310
    00311 return false;
    00312 }
    00313
    00314
    00315 bool KSSLCertificateCache::removeHost(KSSLCertificate& cert, QString& host) {
    00316      QByteArray data, retval;
    00317      QCString rettype;
    00318      QDataStream arg(data, IO_WriteOnly);
    00319      arg << cert << host;
    00320      bool rc = d->dcc->call("kded", "kssld",
    00321                             "cacheRemoveHost(KSSLCertificate,QString)",
    00322                             data, rettype, retval);
    00323
    00324      if (rc && rettype == "bool") {
    00325         QDataStream retStream(retval, IO_ReadOnly);
    00326         bool drc;
    00327         retStream >> drc;
    00328         return drc;
    00329      }
    00330
    00331 return false;
    00332 }
    00333
    00334
    00335 QDataStream& operator<<(QDataStream& s, const KSSLCertificateCache::KSSLCertificatePolicy& p) {
    00336   s << (Q_UINT32)p;
    00337 return s;
    00338 }
    00339
    00340
    00341 QDataStream& operator>>(QDataStream& s, KSSLCertificateCache::KSSLCertificatePolicy& p) {
    00342   Q_UINT32 pd;
    00343   s >> pd;
    00344   p = (KSSLCertificateCache::KSSLCertificatePolicy) pd;
    00345   return s;
    00346 }
    00347
    00348
    00349
    00350
    00351

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:14:24 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001