qca_keystore.h

Go to the documentation of this file.
00001 /*
00002  * qca_keystore.h - Qt Cryptographic Architecture
00003  * Copyright (C) 2003-2007  Justin Karneges <justin@affinix.com>
00004  * Copyright (C) 2004,2005  Brad Hards <bradh@frogmouth.net>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00019  *
00020  */
00021 
00032 #ifndef QCA_KEYSTORE_H
00033 #define QCA_KEYSTORE_H
00034 
00035 #include "qca_core.h"
00036 #include "qca_cert.h"
00037 
00038 namespace QCA {
00039 
00040 class KeyStoreTracker;
00041 class KeyStoreManagerPrivate;
00042 class KeyStorePrivate;
00043 
00139 class QCA_EXPORT KeyStoreEntry : public Algorithm
00140 {
00141 public:
00145         enum Type
00146         {
00147                 TypeKeyBundle,
00148                 TypeCertificate,
00149                 TypeCRL,
00150                 TypePGPSecretKey,
00151                 TypePGPPublicKey
00152         };
00153 
00157         KeyStoreEntry();
00158 
00167         KeyStoreEntry(const QString &serialized);
00168 
00174         KeyStoreEntry(const KeyStoreEntry &from);
00175 
00176         ~KeyStoreEntry();
00177 
00183         KeyStoreEntry & operator=(const KeyStoreEntry &from);
00184 
00188         bool isNull() const;
00189 
00199         bool isAvailable() const;
00200 
00216         bool isAccessible() const;
00217 
00221         Type type() const;
00222 
00226         QString name() const;
00227 
00231         QString id() const;
00232 
00236         QString storeName() const;
00237 
00243         QString storeId() const;
00244 
00248         QString toString() const;
00249 
00258         static KeyStoreEntry fromString(const QString &serialized);
00259 
00264         KeyBundle keyBundle() const;
00265 
00270         Certificate certificate() const;
00271 
00276         CRL crl() const;
00277 
00282         PGPKey pgpSecretKey() const;
00283 
00289         PGPKey pgpPublicKey() const;
00290 
00309         bool ensureAvailable();
00310 
00321         bool ensureAccess();
00322 
00323 private:
00324         class Private;
00325         Private *d;
00326 
00327         friend class KeyStoreTracker;
00328 };
00329 
00349 class QCA_EXPORT KeyStoreEntryWatcher : public QObject
00350 {
00351         Q_OBJECT
00352 public:
00363         explicit KeyStoreEntryWatcher(const KeyStoreEntry &e, QObject *parent = 0);
00364 
00365         ~KeyStoreEntryWatcher();
00366 
00370         KeyStoreEntry entry() const;
00371 
00372 Q_SIGNALS:
00377         void available();
00378 
00383         void unavailable();
00384 
00385 private:
00386         Q_DISABLE_COPY(KeyStoreEntryWatcher)
00387 
00388         class Private;
00389         friend class Private;
00390         Private *d;
00391 };
00392 
00415 class QCA_EXPORT KeyStore : public QObject, public Algorithm
00416 {
00417         Q_OBJECT
00418 public:
00422         enum Type
00423         {
00424                 System,      
00425                 User,        
00426                 Application, 
00427                 SmartCard,   
00428                 PGPKeyring   
00429         };
00430 
00437         KeyStore(const QString &id, KeyStoreManager *keyStoreManager);
00438 
00439         ~KeyStore();
00440 
00446         bool isValid() const;
00447 
00451         Type type() const;
00452 
00456         QString name() const;
00457 
00461         QString id() const;
00462 
00468         bool isReadOnly() const;
00469 
00483         void startAsynchronousMode();
00484 
00494         QList<KeyStoreEntry> entryList() const;
00495 
00499         bool holdsTrustedCertificates() const;
00500 
00504         bool holdsIdentities() const;
00505 
00509         bool holdsPGPPublicKeys() const;
00510 
00525         QString writeEntry(const KeyBundle &kb);
00526 
00532         QString writeEntry(const Certificate &cert);
00533 
00539         QString writeEntry(const CRL &crl);
00540 
00548         QString writeEntry(const PGPKey &key);
00549 
00561         bool removeEntry(const QString &id);
00562 
00563 Q_SIGNALS:
00570         void updated();
00571 
00575         void unavailable();
00576 
00584         void entryWritten(const QString &entryId);
00585 
00592         void entryRemoved(bool success);
00593 
00594 private:
00595         Q_DISABLE_COPY(KeyStore)
00596 
00597         friend class KeyStorePrivate;
00598         KeyStorePrivate *d;
00599 
00600         friend class KeyStoreManagerPrivate;
00601 };
00602 
00622 class QCA_EXPORT KeyStoreInfo
00623 {
00624 public:
00632         KeyStoreInfo();
00633 
00644         KeyStoreInfo(KeyStore::Type type, const QString &id, const QString &name);
00645 
00651         KeyStoreInfo(const KeyStoreInfo &from);
00652 
00653         ~KeyStoreInfo();
00654 
00660         KeyStoreInfo & operator=(const KeyStoreInfo &from);
00661 
00667         bool isNull() const;
00668 
00673         KeyStore::Type type() const;
00674 
00679         QString id() const;
00680 
00685         QString name() const;
00686 
00687 private:
00688         class Private;
00689         QSharedDataPointer<Private> d;
00690 };
00691 
00708 class QCA_EXPORT KeyStoreManager : public QObject
00709 {
00710         Q_OBJECT
00711 public:
00717         KeyStoreManager(QObject *parent = 0);
00718         ~KeyStoreManager();
00719 
00723         static void start();
00724 
00730         static void start(const QString &provider);
00731 
00735         bool isBusy() const;
00736 
00740         void waitForBusyFinished();
00741 
00745         QStringList keyStores() const;
00746 
00751         static QString diagnosticText();
00752 
00756         static void clearDiagnosticText();
00757 
00762         void sync();
00763 
00764 Q_SIGNALS:
00768         void busyStarted();
00769 
00773         void busyFinished();
00774 
00780         void keyStoreAvailable(const QString &id);
00781 
00782 private:
00783         Q_DISABLE_COPY(KeyStoreManager)
00784 
00785         friend class KeyStoreManagerPrivate;
00786         KeyStoreManagerPrivate *d;
00787 
00788         friend class Global;
00789         friend class KeyStorePrivate;
00790 
00791         static void scan();
00792         static void shutdown();
00793 };
00794 
00795 }
00796 
00797 #endif

Generated on Thu Sep 6 19:13:35 2007 for Qt Cryptographic Architecture by  doxygen 1.5.2