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
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
00165 KeyStoreEntry(const QString &serialized);
00166
00172 KeyStoreEntry(const KeyStoreEntry &from);
00173
00174 ~KeyStoreEntry();
00175
00181 KeyStoreEntry & operator=(const KeyStoreEntry &from);
00182
00186 bool isNull() const;
00187
00197 bool isAvailable() const;
00198
00214 bool isAccessible() const;
00215
00219 Type type() const;
00220
00224 QString name() const;
00225
00229 QString id() const;
00230
00234 QString storeName() const;
00235
00241 QString storeId() const;
00242
00246 QString toString() const;
00247
00254 static KeyStoreEntry fromString(const QString &serialized);
00255
00260 KeyBundle keyBundle() const;
00261
00266 Certificate certificate() const;
00267
00272 CRL crl() const;
00273
00278 PGPKey pgpSecretKey() const;
00279
00285 PGPKey pgpPublicKey() const;
00286
00305 bool ensureAvailable();
00306
00317 bool ensureAccess();
00318
00319 private:
00320 class Private;
00321 Private *d;
00322
00323 friend class KeyStoreTracker;
00324 };
00325
00345 class QCA_EXPORT KeyStoreEntryWatcher : public QObject
00346 {
00347 Q_OBJECT
00348 public:
00359 explicit KeyStoreEntryWatcher(const KeyStoreEntry &e, QObject *parent = 0);
00360
00361 ~KeyStoreEntryWatcher();
00362
00366 KeyStoreEntry entry() const;
00367
00368 Q_SIGNALS:
00373 void available();
00374
00379 void unavailable();
00380
00381 private:
00382 Q_DISABLE_COPY(KeyStoreEntryWatcher)
00383
00384 class Private;
00385 friend class Private;
00386 Private *d;
00387 };
00388
00411 class QCA_EXPORT KeyStore : public QObject, public Algorithm
00412 {
00413 Q_OBJECT
00414 public:
00418 enum Type
00419 {
00420 System,
00421 User,
00422 Application,
00423 SmartCard,
00424 PGPKeyring
00425 };
00426
00433 KeyStore(const QString &id, KeyStoreManager *keyStoreManager);
00434
00435 ~KeyStore();
00436
00442 bool isValid() const;
00443
00447 Type type() const;
00448
00452 QString name() const;
00453
00457 QString id() const;
00458
00464 bool isReadOnly() const;
00465
00479 void startAsynchronousMode();
00480
00490 QList<KeyStoreEntry> entryList() const;
00491
00495 bool holdsTrustedCertificates() const;
00496
00500 bool holdsIdentities() const;
00501
00505 bool holdsPGPPublicKeys() const;
00506
00521 QString writeEntry(const KeyBundle &kb);
00522
00528 QString writeEntry(const Certificate &cert);
00529
00535 QString writeEntry(const CRL &crl);
00536
00544 QString writeEntry(const PGPKey &key);
00545
00557 bool removeEntry(const QString &id);
00558
00559 Q_SIGNALS:
00566 void updated();
00567
00571 void unavailable();
00572
00578 void entryWritten(const QString &entryId);
00579
00584 void entryRemoved(bool success);
00585
00586 private:
00587 Q_DISABLE_COPY(KeyStore)
00588
00589 friend class KeyStorePrivate;
00590 KeyStorePrivate *d;
00591
00592 friend class KeyStoreManagerPrivate;
00593 };
00594
00614 class QCA_EXPORT KeyStoreInfo
00615 {
00616 public:
00624 KeyStoreInfo();
00625
00636 KeyStoreInfo(KeyStore::Type type, const QString &id, const QString &name);
00637
00643 KeyStoreInfo(const KeyStoreInfo &from);
00644
00645 ~KeyStoreInfo();
00646
00652 KeyStoreInfo & operator=(const KeyStoreInfo &from);
00653
00659 bool isNull() const;
00660
00665 KeyStore::Type type() const;
00666
00671 QString id() const;
00672
00677 QString name() const;
00678
00679 private:
00680 class Private;
00681 QSharedDataPointer<Private> d;
00682 };
00683
00700 class QCA_EXPORT KeyStoreManager : public QObject
00701 {
00702 Q_OBJECT
00703 public:
00709 KeyStoreManager(QObject *parent = 0);
00710 ~KeyStoreManager();
00711
00715 static void start();
00716
00720 static void start(const QString &provider);
00721
00725 bool isBusy() const;
00726
00730 void waitForBusyFinished();
00731
00735 QStringList keyStores() const;
00736
00741 static QString diagnosticText();
00742
00746 static void clearDiagnosticText();
00747
00752 void sync();
00753
00754 Q_SIGNALS:
00758 void busyStarted();
00759
00763 void busyFinished();
00764
00768 void keyStoreAvailable(const QString &id);
00769
00770 private:
00771 Q_DISABLE_COPY(KeyStoreManager)
00772
00773 friend class KeyStoreManagerPrivate;
00774 KeyStoreManagerPrivate *d;
00775
00776 friend class Global;
00777 friend class KeyStorePrivate;
00778
00779 static void scan();
00780 static void shutdown();
00781 };
00782
00783 }
00784
00785 #endif