00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00137 class QCA_EXPORT KeyStoreEntry : public Algorithm
00138 {
00139 public:
00143 enum Type
00144 {
00145 TypeKeyBundle,
00146 TypeCertificate,
00147 TypeCRL,
00148 TypePGPSecretKey,
00149 TypePGPPublicKey
00150 };
00151
00155 KeyStoreEntry();
00156
00163 KeyStoreEntry(const QString &serialized);
00164
00170 KeyStoreEntry(const KeyStoreEntry &from);
00171
00172 ~KeyStoreEntry();
00173
00179 KeyStoreEntry & operator=(const KeyStoreEntry &from);
00180
00184 bool isNull() const;
00185
00195 bool isAvailable() const;
00196
00212 bool isAccessible() const;
00213
00217 Type type() const;
00218
00222 QString name() const;
00223
00227 QString id() const;
00228
00232 QString storeName() const;
00233
00239 QString storeId() const;
00240
00244 QString toString() const;
00245
00252 static KeyStoreEntry fromString(const QString &serialized);
00253
00258 KeyBundle keyBundle() const;
00259
00264 Certificate certificate() const;
00265
00270 CRL crl() const;
00271
00276 PGPKey pgpSecretKey() const;
00277
00283 PGPKey pgpPublicKey() const;
00284
00303 bool ensureAvailable();
00304
00315 bool ensureAccess();
00316
00317 private:
00318 class Private;
00319 Private *d;
00320
00321 friend class KeyStoreTracker;
00322 };
00323
00339 class QCA_EXPORT KeyStoreEntryWatcher : public QObject
00340 {
00341 Q_OBJECT
00342 public:
00353 explicit KeyStoreEntryWatcher(const KeyStoreEntry &e, QObject *parent = 0);
00354
00355 ~KeyStoreEntryWatcher();
00356
00360 KeyStoreEntry entry() const;
00361
00362 Q_SIGNALS:
00367 void available();
00368
00373 void unavailable();
00374
00375 private:
00376 Q_DISABLE_COPY(KeyStoreEntryWatcher)
00377
00378 class Private;
00379 friend class Private;
00380 Private *d;
00381 };
00382
00403 class QCA_EXPORT KeyStore : public QObject, public Algorithm
00404 {
00405 Q_OBJECT
00406 public:
00410 enum Type
00411 {
00412 System,
00413 User,
00414 Application,
00415 SmartCard,
00416 PGPKeyring
00417 };
00418
00425 KeyStore(const QString &id, KeyStoreManager *keyStoreManager);
00426
00427 ~KeyStore();
00428
00434 bool isValid() const;
00435
00439 Type type() const;
00440
00444 QString name() const;
00445
00449 QString id() const;
00450
00456 bool isReadOnly() const;
00457
00471 void startAsynchronousMode();
00472
00482 QList<KeyStoreEntry> entryList() const;
00483
00487 bool holdsTrustedCertificates() const;
00488
00492 bool holdsIdentities() const;
00493
00497 bool holdsPGPPublicKeys() const;
00498
00513 QString writeEntry(const KeyBundle &kb);
00514
00520 QString writeEntry(const Certificate &cert);
00521
00527 QString writeEntry(const CRL &crl);
00528
00536 QString writeEntry(const PGPKey &key);
00537
00549 bool removeEntry(const QString &id);
00550
00551 Q_SIGNALS:
00558 void updated();
00559
00563 void unavailable();
00564
00570 void entryWritten(const QString &entryId);
00571
00576 void entryRemoved(bool success);
00577
00578 private:
00579 Q_DISABLE_COPY(KeyStore)
00580
00581 friend class KeyStorePrivate;
00582 KeyStorePrivate *d;
00583
00584 friend class KeyStoreManagerPrivate;
00585 };
00586
00602 class QCA_EXPORT KeyStoreInfo
00603 {
00604 public:
00612 KeyStoreInfo();
00613
00624 KeyStoreInfo(KeyStore::Type type, const QString &id, const QString &name);
00625
00631 KeyStoreInfo(const KeyStoreInfo &from);
00632
00633 ~KeyStoreInfo();
00634
00640 KeyStoreInfo & operator=(const KeyStoreInfo &from);
00641
00647 bool isNull() const;
00648
00653 KeyStore::Type type() const;
00654
00659 QString id() const;
00660
00665 QString name() const;
00666
00667 private:
00668 class Private;
00669 QSharedDataPointer<Private> d;
00670 };
00671
00686 class QCA_EXPORT KeyStoreManager : public QObject
00687 {
00688 Q_OBJECT
00689 public:
00695 KeyStoreManager(QObject *parent = 0);
00696 ~KeyStoreManager();
00697
00701 static void start();
00702
00706 static void start(const QString &provider);
00707
00711 bool isBusy() const;
00712
00716 void waitForBusyFinished();
00717
00721 QStringList keyStores() const;
00722
00727 static QString diagnosticText();
00728
00732 static void clearDiagnosticText();
00733
00738 void sync();
00739
00740 Q_SIGNALS:
00744 void busyStarted();
00745
00749 void busyFinished();
00750
00754 void keyStoreAvailable(const QString &id);
00755
00756 private:
00757 Q_DISABLE_COPY(KeyStoreManager)
00758
00759 friend class KeyStoreManagerPrivate;
00760 KeyStoreManagerPrivate *d;
00761
00762 friend class Global;
00763 friend class KeyStorePrivate;
00764
00765 static void scan();
00766 static void shutdown();
00767 };
00768
00769 }
00770
00771 #endif