Qt Cryptographic Architecture: qca_keystore.h Source File

Qt Cryptographic Architecture

qca_keystore.h
Go to the documentation of this file.
1 /*
2 * qca_keystore.h - Qt Cryptographic Architecture
3 * Copyright (C) 2003-2007 Justin Karneges <justin@affinix.com>
4 * Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 */
22
33 #ifndef QCA_KEYSTORE_H
34 #define QCA_KEYSTORE_H
35
36 #include "qca_core.h"
37 #include "qca_cert.h"
38
39 namespace QCA {
40
41 class KeyStoreTracker;
42 class KeyStoreManagerPrivate;
43 class KeyStorePrivate;
44
140 class QCA_EXPORT KeyStoreEntry : public Algorithm
141 {
142 public:
146 enum Type
147 {
148 TypeKeyBundle,
149 TypeCertificate,
150 TypeCRL,
151 TypePGPSecretKey,
152 TypePGPPublicKey
153 };
154
158 KeyStoreEntry();
159
168 KeyStoreEntry(const QString &serialized);
169
175 KeyStoreEntry(const KeyStoreEntry &from);
176
177 ~KeyStoreEntry();
178
184 KeyStoreEntry & operator=(const KeyStoreEntry &from);
185
189 bool isNull() const;
190
200 bool isAvailable() const;
201
217 bool isAccessible() const;
218
222 Type type() const;
223
227 QString name() const;
228
232 QString id() const;
233
237 QString storeName() const;
238
244 QString storeId() const;
245
249 QString toString() const;
250
259 static KeyStoreEntry fromString(const QString &serialized);
260
265 KeyBundle keyBundle() const;
266
271 Certificate certificate() const;
272
277 CRL crl() const;
278
283 PGPKey pgpSecretKey() const;
284
290 PGPKey pgpPublicKey() const;
291
310 bool ensureAvailable();
311
322 bool ensureAccess();
323
324 private:
325 class Private;
326 Private *d;
327
328 friend class KeyStoreTracker;
329 };
330
350 class QCA_EXPORT KeyStoreEntryWatcher : public QObject
351 {
352 Q_OBJECT
353 public:
364 explicit KeyStoreEntryWatcher(const KeyStoreEntry &e, QObject *parent = 0);
365
366 ~KeyStoreEntryWatcher();
367
371 KeyStoreEntry entry() const;
372
373 Q_SIGNALS:
378 void available();
379
384 void unavailable();
385
386 private:
387 Q_DISABLE_COPY(KeyStoreEntryWatcher)
388
389 class Private;
390 friend class Private;
391 Private *d;
392 };
393
416 class QCA_EXPORT KeyStore : public QObject, public Algorithm
417 {
418 Q_OBJECT
419 public:
423 enum Type
424 {
425 System,
426 User,
427 Application,
428 SmartCard,
429 PGPKeyring
430 };
431
438 KeyStore(const QString &id, KeyStoreManager *keyStoreManager);
439
440 ~KeyStore();
441
447 bool isValid() const;
448
452 Type type() const;
453
457 QString name() const;
458
462 QString id() const;
463
469 bool isReadOnly() const;
470
484 void startAsynchronousMode();
485
495 QList<KeyStoreEntry> entryList() const;
496
500 bool holdsTrustedCertificates() const;
501
505 bool holdsIdentities() const;
506
510 bool holdsPGPPublicKeys() const;
511
526 QString writeEntry(const KeyBundle &kb);
527
533 QString writeEntry(const Certificate &cert);
534
540 QString writeEntry(const CRL &crl);
541
549 QString writeEntry(const PGPKey &key);
550
562 bool removeEntry(const QString &id);
563
564 Q_SIGNALS:
571 void updated();
572
576 void unavailable();
577
585 void entryWritten(const QString &entryId);
586
593 void entryRemoved(bool success);
594
595 private:
596 Q_DISABLE_COPY(KeyStore)
597
598 friend class KeyStorePrivate;
599 KeyStorePrivate *d;
600
601 friend class KeyStoreManagerPrivate;
602 };
603
623 class QCA_EXPORT KeyStoreInfo
624 {
625 public:
633 KeyStoreInfo();
634
645 KeyStoreInfo(KeyStore::Type type, const QString &id, const QString &name);
646
652 KeyStoreInfo(const KeyStoreInfo &from);
653
654 ~KeyStoreInfo();
655
661 KeyStoreInfo & operator=(const KeyStoreInfo &from);
662
668 bool isNull() const;
669
674 KeyStore::Type type() const;
675
680 QString id() const;
681
686 QString name() const;
687
688 private:
689 class Private;
690 QSharedDataPointer<Private> d;
691 };
692
709 class QCA_EXPORT KeyStoreManager : public QObject
710 {
711 Q_OBJECT
712 public:
718 KeyStoreManager(QObject *parent = 0);
719 ~KeyStoreManager();
720
724 static void start();
725
731 static void start(const QString &provider);
732
736 bool isBusy() const;
737
741 void waitForBusyFinished();
742
746 QStringList keyStores() const;
747
752 static QString diagnosticText();
753
757 static void clearDiagnosticText();
758
763 void sync();
764
765 Q_SIGNALS:
769 void busyStarted();
770
774 void busyFinished();
775
781 void keyStoreAvailable(const QString &id);
782
783 private:
784 Q_DISABLE_COPY(KeyStoreManager)
785
786 friend class KeyStoreManagerPrivate;
787 KeyStoreManagerPrivate *d;
788
789 friend class Global;
790 friend class KeyStorePrivate;
791
792 static void scan();
793 static void shutdown();
794 };
795
796 }
797
798 #endif
QCA::Algorithm
General superclass for an algorithm.
Definition: qca_core.h:1121
QCA::KeyStoreEntry::Type
Type
The type of entry in the KeyStore.
Definition: qca_keystore.h:146
QCA::KeyBundle
Certificate chain and private key pair.
Definition: qca_cert.h:2135
qca_cert.h
Header file for PGP key and X.509 certificate related classes.
QCA::KeyStore::Application
for caching accepted self-signed certificates
Definition: qca_keystore.h:427
QCA::KeyStoreInfo
Key store information, outside of a KeyStore object.
Definition: qca_keystore.h:623
QObject
QCA::KeyStore::User
objects such as Apple Keychain, KDE Wallet
Definition: qca_keystore.h:426
QCA::KeyStore::System
objects such as root certificates
Definition: qca_keystore.h:425
QCA::CRL
Certificate Revocation List
Definition: qca_cert.h:1702
qca_core.h
Header file for core QCA infrastructure.
QCA::KeyStore
General purpose key storage object.
Definition: qca_keystore.h:416
QCA
QCA - the Qt Cryptographic Architecture.
Definition: qca_basic.h:47
QCA::KeyStoreManager
Access keystores, and monitor keystores for changes.
Definition: qca_keystore.h:709
QCA::KeyStoreEntry
Single entry in a KeyStore.
Definition: qca_keystore.h:140
QCA::KeyStore::Type
Type
The type of keystore.
Definition: qca_keystore.h:423
QCA::Certificate
Public Key (X.509) certificate.
Definition: qca_cert.h:848
QCA::PGPKey
Pretty Good Privacy key.
Definition: qca_cert.h:2360
QCA::KeyStoreEntryWatcher
Class to monitor the availability of a KeyStoreEntry.
Definition: qca_keystore.h:350
QList
QCA::KeyStore::SmartCard
for smartcards
Definition: qca_keystore.h:428