home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ksslcertificatecache.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.8 KB  |  108 lines

  1. /* This file is part of the KDE project
  2.  *
  3.  * Copyright (C) 2000, 2001 George Staikos <staikos@kde.org>
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public License
  16.  * along with this library; see the file COPYING.LIB.  If not, write to
  17.  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.  * Boston, MA 02110-1301, USA.
  19.  */
  20.  
  21. #ifndef _INCLUDE_KSSLCCACHE_H
  22. #define _INCLUDE_KSSLCCACHE_H
  23.  
  24. class KSSLCertificate;
  25. #include <qstring.h>
  26. #include <qstringlist.h>
  27. #include <qdatetime.h>
  28.  
  29. #include <kdelibs_export.h>
  30.  
  31. class KIO_EXPORT KSSLCertificateCache {
  32. public:
  33.  
  34. enum KSSLCertificatePolicy { Unknown, Reject, Accept, Prompt, Ambiguous };
  35. // Unknown: no policy has been set for this record
  36. // Reject: user has requested to not accept data from this site
  37. // Accept: user has requested to always accept data from this site
  38. // Prompt: user wishes to be prompted before accepting this certificate
  39. //         You may need to set a [non-]permanent policy on this record after
  40. //         the user is prompted.
  41. // Ambiguous: The state cannot be uniquely determined.  Hopefully this
  42. //            doesn't happen.
  43.  
  44.   KSSLCertificateCache();
  45.   ~KSSLCertificateCache();
  46.  
  47.   void addCertificate(KSSLCertificate& cert, KSSLCertificatePolicy policy, 
  48.                                                      bool permanent = true);
  49.  
  50.   // WARNING!  This is not a "secure" method.  You need to actually
  51.   //           do a getPolicyByCertificate to be cryptographically sure
  52.   //           that this is an accepted certificate/site pair.
  53.   //           (note that the site (CN) is encoded in the certificate
  54.   //            so you should only accept certificates whose CN matches
  55.   //            the exact FQDN of the site presenting it)
  56.   //           If you're just doing an OpenSSL connection, I believe it
  57.   //           tests this for you, but don't take my word for it.
  58.   KSSLCertificatePolicy getPolicyByCN(QString& cn);
  59.  
  60.   KSSLCertificatePolicy getPolicyByCertificate(KSSLCertificate& cert);
  61.  
  62.   bool seenCN(QString& cn);
  63.   bool seenCertificate(KSSLCertificate& cert);
  64.  
  65.   bool removeByCN(QString& cn);
  66.   bool removeByCertificate(KSSLCertificate& cert);
  67.  
  68.   bool isPermanent(KSSLCertificate& cert);
  69.  
  70.   bool modifyByCN(QString& cn,
  71.                   KSSLCertificateCache::KSSLCertificatePolicy policy,
  72.                   bool permanent,
  73.                   QDateTime& expires);
  74.  
  75.   bool modifyByCertificate(KSSLCertificate& cert,
  76.                            KSSLCertificateCache::KSSLCertificatePolicy policy,
  77.                            bool permanent,
  78.                            QDateTime& expires);
  79.  
  80.   QStringList getHostList(KSSLCertificate& cert);
  81.   bool addHost(KSSLCertificate& cert, QString& host);
  82.   bool removeHost(KSSLCertificate& cert, QString& host);
  83.  
  84.   // SMIME
  85.   QStringList getKDEKeyByEmail(const QString &email);
  86.   KSSLCertificate *getCertByMD5Digest(const QString &key);
  87.  
  88.   void reload();
  89.  
  90.   // You shouldn't need to call this but in some weird circumstances
  91.   // it might be necessary.
  92.   void saveToDisk();
  93.  
  94. private:
  95.   class KSSLCertificateCachePrivate;
  96.   KSSLCertificateCachePrivate *d;
  97.  
  98.   void loadDefaultPolicies();
  99.   void clearList();
  100.  
  101. };
  102.  
  103.  
  104. KIO_EXPORT QDataStream& operator<<(QDataStream& s, const KSSLCertificateCache::KSSLCertificatePolicy& p);
  105. KIO_EXPORT QDataStream& operator>>(QDataStream& s, KSSLCertificateCache::KSSLCertificatePolicy& p);
  106.  
  107. #endif
  108.