• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kio

ksslcertificatecache.cc

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, 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 // KDE 4: Make it const QString &
00093 KSSLCertificateCache::KSSLCertificatePolicy KSSLCertificateCache::getPolicyByCN(QString& cn) {
00094      QByteArray data, retval;
00095      QCString rettype;
00096      QDataStream arg(data, IO_WriteOnly);
00097      arg << cn;
00098      bool rc = d->dcc->call("kded", "kssld",
00099                             "cacheGetPolicyByCN(QString)",
00100                             data, rettype, retval);
00101 
00102      if (rc && rettype == "KSSLCertificateCache::KSSLCertificatePolicy") {
00103         QDataStream retStream(retval, IO_ReadOnly);
00104         KSSLCertificateCache::KSSLCertificatePolicy drc;
00105         retStream >> drc;
00106     return drc;
00107      }
00108 return KSSLCertificateCache::Ambiguous;
00109 }
00110 
00111 
00112 KSSLCertificateCache::KSSLCertificatePolicy KSSLCertificateCache::getPolicyByCertificate(KSSLCertificate& cert) {
00113      QByteArray data, retval;
00114      QCString rettype;
00115      QDataStream arg(data, IO_WriteOnly);
00116      arg << cert;
00117      bool rc = d->dcc->call("kded", "kssld",
00118                             "cacheGetPolicyByCertificate(KSSLCertificate)",
00119                             data, rettype, retval);
00120 
00121      if (rc && rettype == "KSSLCertificateCache::KSSLCertificatePolicy") {
00122         QDataStream retStream(retval, IO_ReadOnly);
00123         KSSLCertificateCache::KSSLCertificatePolicy drc;
00124         retStream >> drc;
00125     return drc;
00126      }
00127 return KSSLCertificateCache::Ambiguous;
00128 }
00129 
00130 
00131 // KDE 4: Make it const QString &
00132 bool KSSLCertificateCache::seenCN(QString& cn) {
00133      QByteArray data, retval;
00134      QCString rettype;
00135      QDataStream arg(data, IO_WriteOnly);
00136      arg << cn;
00137      bool rc = d->dcc->call("kded", "kssld",
00138                             "cacheSeenCN(QString)",
00139                             data, rettype, retval);
00140 
00141      if (rc && rettype == "bool") {
00142         QDataStream retStream(retval, IO_ReadOnly);
00143         bool drc;
00144         retStream >> drc;
00145     return drc;
00146      }
00147 
00148 return false;
00149 }
00150 
00151 
00152 bool KSSLCertificateCache::seenCertificate(KSSLCertificate& cert) {
00153      QByteArray data, retval;
00154      QCString rettype;
00155      QDataStream arg(data, IO_WriteOnly);
00156      arg << cert;
00157      bool rc = d->dcc->call("kded", "kssld",
00158                             "cacheSeenCertificate(KSSLCertificate)",
00159                             data, rettype, retval);
00160 
00161      if (rc && rettype == "bool") {
00162         QDataStream retStream(retval, IO_ReadOnly);
00163         bool drc;
00164         retStream >> drc;
00165     return drc;
00166      }
00167 
00168 return false;
00169 }
00170 
00171 
00172 bool KSSLCertificateCache::isPermanent(KSSLCertificate& cert) {
00173      QByteArray data, retval;
00174      QCString rettype;
00175      QDataStream arg(data, IO_WriteOnly);
00176      arg << cert;
00177      bool rc = d->dcc->call("kded", "kssld",
00178                             "cacheIsPermanent(KSSLCertificate)",
00179                             data, rettype, retval);
00180 
00181      if (rc && rettype == "bool") {
00182         QDataStream retStream(retval, IO_ReadOnly);
00183         bool drc;
00184         retStream >> drc;
00185     return drc;
00186      }
00187 
00188 return false;
00189 }
00190 
00191 
00192 // KDE 4: Make it const QString &
00193 bool KSSLCertificateCache::removeByCN(QString& cn) {
00194      QByteArray data, retval;
00195      QCString rettype;
00196      QDataStream arg(data, IO_WriteOnly);
00197      arg << cn;
00198      bool rc = d->dcc->call("kded", "kssld",
00199                             "cacheRemoveByCN(QString)",
00200                             data, rettype, retval);
00201 
00202      if (rc && rettype == "bool") {
00203         QDataStream retStream(retval, IO_ReadOnly);
00204         bool drc;
00205         retStream >> drc;
00206     return drc;
00207      }
00208 
00209 return false;
00210 }
00211 
00212 
00213 bool KSSLCertificateCache::removeByCertificate(KSSLCertificate& cert) {
00214      QByteArray data, retval;
00215      QCString rettype;
00216      QDataStream arg(data, IO_WriteOnly);
00217      arg << cert;
00218      bool rc = d->dcc->call("kded", "kssld",
00219                             "cacheRemoveByCertificate(KSSLCertificate)",
00220                             data, rettype, retval);
00221 
00222      if (rc && rettype == "bool") {
00223         QDataStream retStream(retval, IO_ReadOnly);
00224         bool drc;
00225         retStream >> drc;
00226     return drc;
00227      }
00228 
00229 return false;
00230 }
00231 
00232 
00233 // KDE 4: Make it const QString &
00234 bool KSSLCertificateCache::modifyByCN(QString& cn,
00235                   KSSLCertificateCache::KSSLCertificatePolicy policy,
00236                   bool permanent,
00237                   QDateTime& expires) {
00238      QByteArray data, retval;
00239      QCString rettype;
00240      QDataStream arg(data, IO_WriteOnly);
00241      arg << cn << policy << permanent << expires;
00242      bool rc = d->dcc->call("kded", "kssld",
00243                             "cacheModifyByCN(QString,KSSLCertificateCache::KSSLCertificatePolicy,bool,QDateTime)",
00244                             data, rettype, retval);
00245 
00246      if (rc && rettype == "bool") {
00247         QDataStream retStream(retval, IO_ReadOnly);
00248         bool drc;
00249         retStream >> drc;
00250         return drc;
00251      }
00252 
00253 return false;
00254 }
00255 
00256 
00257 bool KSSLCertificateCache::modifyByCertificate(KSSLCertificate& cert,
00258                            KSSLCertificateCache::KSSLCertificatePolicy policy,
00259                            bool permanent,
00260                            QDateTime& expires) {
00261      QByteArray data, retval;
00262      QCString rettype;
00263      QDataStream arg(data, IO_WriteOnly);
00264      arg << cert << policy << permanent << expires;
00265      bool rc = d->dcc->call("kded", "kssld",
00266                             "cacheModifyByCertificate(KSSLCertificate,KSSLCertificateCache::KSSLCertificatePolicy,bool,QDateTime)",
00267                             data, rettype, retval);
00268 
00269      if (rc && rettype == "bool") {
00270         QDataStream retStream(retval, IO_ReadOnly);
00271         bool drc;
00272         retStream >> drc;
00273         return drc;
00274      }
00275 
00276 return false;
00277 }
00278 
00279 
00280 QStringList KSSLCertificateCache::getHostList(KSSLCertificate& cert) {
00281      QByteArray data, retval;
00282      QCString rettype;
00283      QDataStream arg(data, IO_WriteOnly);
00284      arg << cert;
00285      bool rc = d->dcc->call("kded", "kssld",
00286                             "cacheGetHostList(KSSLCertificate)",
00287                             data, rettype, retval);
00288 
00289      if (rc && rettype == "QStringList") {
00290         QDataStream retStream(retval, IO_ReadOnly);
00291         QStringList drc;
00292         retStream >> drc;
00293     return drc;
00294      }
00295 return QStringList();
00296 }
00297 
00298 
00299 // KDE 4: Make it const QString &
00300 bool KSSLCertificateCache::addHost(KSSLCertificate& cert, QString& host) {
00301      QByteArray data, retval;
00302      QCString rettype;
00303      QDataStream arg(data, IO_WriteOnly);
00304      arg << cert << host;
00305      bool rc = d->dcc->call("kded", "kssld",
00306                             "cacheAddHost(KSSLCertificate,QString)",
00307                             data, rettype, retval);
00308 
00309      if (rc && rettype == "bool") {
00310         QDataStream retStream(retval, IO_ReadOnly);
00311         bool drc;
00312         retStream >> drc;
00313         return drc;
00314      }
00315 
00316 return false;
00317 }
00318 
00319 
00320 // KDE 4: Make it const QString &
00321 bool KSSLCertificateCache::removeHost(KSSLCertificate& cert, QString& host) {
00322      QByteArray data, retval;
00323      QCString rettype;
00324      QDataStream arg(data, IO_WriteOnly);
00325      arg << cert << host;
00326      bool rc = d->dcc->call("kded", "kssld",
00327                             "cacheRemoveHost(KSSLCertificate,QString)",
00328                             data, rettype, retval);
00329 
00330      if (rc && rettype == "bool") {
00331         QDataStream retStream(retval, IO_ReadOnly);
00332         bool drc;
00333         retStream >> drc;
00334         return drc;
00335      }
00336 
00337 return false;
00338 }
00339 
00340 
00341 QStringList KSSLCertificateCache::getKDEKeyByEmail(const QString &email) {
00342      QByteArray data, retval;
00343      QCString rettype;
00344      QDataStream arg(data, IO_WriteOnly);
00345      arg << email;
00346      bool rc = d->dcc->call("kded", "kssld",
00347                             "getKDEKeyByEmail(QString)",
00348                             data, rettype, retval);
00349 
00350      if (rc && rettype == "QStringList") {
00351         QDataStream retStream(retval, IO_ReadOnly);
00352         QStringList drc;
00353         retStream >> drc;
00354         return drc;
00355      }
00356 
00357      return QStringList();
00358 }     
00359 
00360 
00361 KSSLCertificate *KSSLCertificateCache::getCertByMD5Digest(const QString &key) {
00362      QByteArray data, retval;
00363      QCString rettype;
00364      QDataStream arg(data, IO_WriteOnly);
00365      arg << key;
00366      bool rc = d->dcc->call("kded", "kssld",
00367                             "getCertByMD5Digest(QString)",
00368                             data, rettype, retval);
00369 
00370      if (rc && rettype == "KSSLCertificate") {
00371         QDataStream retStream(retval, IO_ReadOnly);
00372         KSSLCertificate *drc = new KSSLCertificate;
00373         retStream >> *drc;
00374     if (drc->getCert())
00375              return drc; 
00376     delete drc; // should not happen too often if used in conjunction with getKDEKeyByEmail
00377      }
00378 
00379      return 0L;
00380 }     
00381 
00382 
00383 QDataStream& operator<<(QDataStream& s, const KSSLCertificateCache::KSSLCertificatePolicy& p) {
00384   s << (Q_UINT32)p;
00385 return s;
00386 }
00387 
00388 
00389 QDataStream& operator>>(QDataStream& s, KSSLCertificateCache::KSSLCertificatePolicy& p) {
00390   Q_UINT32 pd;
00391   s >> pd;
00392   p = (KSSLCertificateCache::KSSLCertificatePolicy) pd;
00393   return s;
00394 }
00395 
00396 
00397 
00398 
00399 

kio

Skip menu "kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal