~ubuntu-branches/ubuntu/karmic/psi/karmic

« back to all changes in this revision

Viewing changes to third-party/qca/qca/include/QtCrypto/qca_keystore.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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  02110-1301, USA
 
19
 *
 
20
 */
 
21
 
 
22
/**
 
23
   \file qca_keystore.h
 
24
 
 
25
   Header file for classes that provide and manage keys
 
26
 
 
27
   \note You should not use this header directly from an
 
28
   application. You should just use <tt> \#include \<QtCrypto>
 
29
   </tt> instead.
 
30
*/
 
31
 
 
32
#ifndef QCA_KEYSTORE_H
 
33
#define QCA_KEYSTORE_H
 
34
 
 
35
#include "qca_core.h"
 
36
#include "qca_cert.h"
 
37
 
 
38
namespace QCA {
 
39
 
 
40
class KeyStoreTracker;
 
41
class KeyStoreManagerPrivate;
 
42
class KeyStorePrivate;
 
43
 
 
44
/**
 
45
   \class KeyStoreEntry qca_keystore.h QtCrypto
 
46
 
 
47
   Single entry in a KeyStore
 
48
 
 
49
   This is a container for any kind of object in a KeyStore
 
50
   (such as PGP keys, or X.509 certificates / private keys).
 
51
 
 
52
   KeyStoreEntry objects are obtained through KeyStore or loaded from a
 
53
   serialized string format.  The latter method requires a KeyStoreEntry
 
54
   obtained through KeyStore to be serialized for future loading.  For
 
55
   example:
 
56
 
 
57
   \code
 
58
QString str = someKeyStoreEntry.toString();
 
59
[ app saves str to disk ]
 
60
[ app quits ]
 
61
...
 
62
[ app launches ]
 
63
[ app reads str from disk ]
 
64
KeyStoreEntry entry(str);
 
65
printf("Entry name: [%s]\n", qPrintable(entry.name()));
 
66
   \endcode
 
67
 
 
68
   KeyStoreEntry objects may or may not be available.  An entry is
 
69
   unavailable if it has a private content that is not present.  The
 
70
   private content might exist on external hardware.  To determine if an
 
71
   entry is available, call isAvailable().  To ensure an entry is available
 
72
   before performing a private key operation, call ensureAvailable.  For
 
73
   example:
 
74
 
 
75
   \code
 
76
if(entry.ensureAvailable())
 
77
{
 
78
   entry.keyBundle().privateKey().signMessage(...);
 
79
   ...
 
80
}
 
81
   \endcode
 
82
 
 
83
   ensureAvailable() blocks and may cause hardware access, but
 
84
   if it completes successfully then you may use the entry's private
 
85
   content.  It also means, in the case of a Smart Card token, that
 
86
   it is probably inserted.
 
87
 
 
88
   To watch this entry asynchronously, you would do:
 
89
 
 
90
   \code
 
91
KeyStoreEntryWatcher *watcher = new KeyStoreEntryWatcher(entry);
 
92
connect(watcher, SIGNAL(available()), SLOT(entry_available()));
 
93
...
 
94
void entry_available()
 
95
{
 
96
   // entry now available
 
97
   watcher->entry().keyBundle().privateKey().signMessage(...);
 
98
}
 
99
   \endcode
 
100
 
 
101
   Unlike private content, public content is always usable even if the
 
102
   entry is not available.  Serialized entry data contains all of the
 
103
   metadata necessary to reconstruct the public content.
 
104
 
 
105
   Now, even though an entry may be available, it does not
 
106
   mean you have access to use it for operations.  For
 
107
   example, even though a KeyBundle entry offered by a Smart Card
 
108
   may be available, as soon as you try to use the PrivateKey object
 
109
   for a signing operation, a PIN might be asked for.  You can call
 
110
   ensureAccess() if you want to synchronously provide the PIN
 
111
   early on:
 
112
 
 
113
   \code
 
114
if(entry.ensureAccess())
 
115
{
 
116
   // do private key stuff
 
117
   ...
 
118
}
 
119
   \endcode
 
120
 
 
121
   Note that you don't have to call ensureAvailable() before
 
122
   ensureAccess().  Calling the latter is enough to imply
 
123
   both.
 
124
 
 
125
   After an application is configured to use a particular key,
 
126
   it is expected that its usual running procedure will be:
 
127
 
 
128
   1) Construct KeyStoreEntry from the serialized data.
 
129
   2) If the content object is not available, wait for it
 
130
   (with either ensureAvailable() or KeyStoreEntryWatcher).
 
131
   3) Pass the content object(s) to a high level operation like TLS.
 
132
 
 
133
   In this case, any PIN prompting and private key operations
 
134
   would be caused/handled from the TLS object.  Omit step 2 and
 
135
   the private key operations might cause token prompting.
 
136
 
 
137
   \ingroup UserAPI
 
138
*/
 
139
class QCA_EXPORT KeyStoreEntry : public Algorithm
 
140
{
 
141
public:
 
142
        /**
 
143
           The type of entry in the KeyStore
 
144
        */
 
145
        enum Type
 
146
        {
 
147
                TypeKeyBundle,
 
148
                TypeCertificate,
 
149
                TypeCRL,
 
150
                TypePGPSecretKey,
 
151
                TypePGPPublicKey
 
152
        };
 
153
 
 
154
        /**
 
155
           Create an empty KeyStoreEntry
 
156
        */
 
157
        KeyStoreEntry();
 
158
 
 
159
        /**
 
160
           Create a passive KeyStoreEntry based on a serialized
 
161
           string
 
162
 
 
163
           \param serialized the string containing the keystore entry information
 
164
 
 
165
           \sa fromString
 
166
        */
 
167
        KeyStoreEntry(const QString &serialized);
 
168
 
 
169
        /**
 
170
           Standard copy constructor
 
171
 
 
172
           \param from the source entry
 
173
        */
 
174
        KeyStoreEntry(const KeyStoreEntry &from);
 
175
 
 
176
        ~KeyStoreEntry();
 
177
 
 
178
        /**
 
179
           Standard assignment operator
 
180
 
 
181
           \param from the source entry
 
182
        */
 
183
        KeyStoreEntry & operator=(const KeyStoreEntry &from);
 
184
 
 
185
        /**
 
186
           Test if this key is empty (null)
 
187
        */
 
188
        bool isNull() const;
 
189
 
 
190
        /**
 
191
           Test if the key is available for use.
 
192
 
 
193
           A key is considered available if the key's private
 
194
           content is present.
 
195
 
 
196
           \sa ensureAvailable
 
197
           \sa isAccessible
 
198
        */
 
199
        bool isAvailable() const;
 
200
 
 
201
        /**
 
202
           Test if the key is currently accessible.
 
203
 
 
204
           This means that the private key part can be used
 
205
           at this time. For a smartcard, this means that all
 
206
           required operations (e.g. login / PIN entry) are
 
207
           completed.
 
208
 
 
209
           If isAccessible() is true, then the key
 
210
           is necessarily available (i.e. isAvailable() is
 
211
           also true).
 
212
 
 
213
           \sa ensureAccessible
 
214
           \sa isAvailable
 
215
        */
 
216
        bool isAccessible() const;
 
217
 
 
218
        /**
 
219
           Determine the type of key stored in this object 
 
220
        */
 
221
        Type type() const;
 
222
 
 
223
        /**
 
224
           The name associated with the key stored in this object
 
225
        */
 
226
        QString name() const;
 
227
 
 
228
        /**
 
229
           The ID associated with the key stored in this object.
 
230
        */
 
231
        QString id() const;
 
232
 
 
233
        /**
 
234
           The name of the KeyStore for this key object
 
235
        */
 
236
        QString storeName() const;
 
237
 
 
238
        /**
 
239
           The id of the KeyStore for this key object
 
240
 
 
241
           \sa KeyStore::id()
 
242
        */
 
243
        QString storeId() const;
 
244
 
 
245
        /**
 
246
           Serialize into a string for use as a passive entry
 
247
        */
 
248
        QString toString() const;
 
249
 
 
250
        /**
 
251
           Load a passive entry by using a serialized string
 
252
           as input
 
253
 
 
254
           \param serialized the string containing the keystore entry information
 
255
 
 
256
           \return the newly created KeyStoreEntry
 
257
        */
 
258
        static KeyStoreEntry fromString(const QString &serialized);
 
259
 
 
260
        /**
 
261
           If a KeyBundle is stored in this object, return that
 
262
           bundle.
 
263
        */
 
264
        KeyBundle keyBundle() const;
 
265
 
 
266
        /**
 
267
           If a Certificate is stored in this object, return that
 
268
           certificate.
 
269
        */
 
270
        Certificate certificate() const;
 
271
 
 
272
        /**
 
273
           If a CRL is stored in this object, return the value
 
274
           of the CRL
 
275
        */
 
276
        CRL crl() const;
 
277
 
 
278
        /**
 
279
           If the key stored in this object is a private
 
280
           PGP key, return the contents of that key.
 
281
        */
 
282
        PGPKey pgpSecretKey() const;
 
283
 
 
284
        /**
 
285
           If the key stored in this object is either an 
 
286
           public or private PGP key, extract the public key
 
287
           part of that PGP key.
 
288
        */
 
289
        PGPKey pgpPublicKey() const;
 
290
 
 
291
        /**
 
292
           Returns true if the entry is available, otherwise false.
 
293
 
 
294
           Available means that any private content for this entry is
 
295
           present and ready for use.  In the case of a smart card, this
 
296
           will ensure the card is inserted, and may invoke a token
 
297
           prompt.
 
298
 
 
299
           Calling this function on an already available entry may cause
 
300
           the entry to be refreshed.
 
301
 
 
302
           \sa isAvailable
 
303
           \sa ensureAccess
 
304
 
 
305
           \note This function is blocking.
 
306
           \note This synchronous operation may require event handling, and so
 
307
           it must not be called from the same thread as an EventHandler.
 
308
        */
 
309
        bool ensureAvailable();
 
310
 
 
311
        /**
 
312
           Like ensureAvailable, but will also ensure
 
313
           that the PIN is provided if needed.
 
314
 
 
315
           \sa isAccessible
 
316
           \sa ensureAvailable
 
317
 
 
318
           \note This synchronous operation may require event handling, and so
 
319
           it must not be called from the same thread as an EventHandler.
 
320
        */
 
321
        bool ensureAccess();
 
322
 
 
323
private:
 
324
        class Private;
 
325
        Private *d;
 
326
 
 
327
        friend class KeyStoreTracker;
 
328
};
 
329
 
 
330
/**
 
331
   \class KeyStoreEntryWatcher qca_keystore.h QtCrypto
 
332
 
 
333
   Class to monitor the availability of a KeyStoreEntry
 
334
 
 
335
   Some KeyStore types have the concept of an entry that can be
 
336
   available only part of the time (for example, a smart card that
 
337
   can be removed). This class allows you to identify when a 
 
338
   KeyStoreEntry becomes available / unavailable.
 
339
 
 
340
   \note You can also monitor availability of a whole KeyStore,
 
341
   using KeyStoreManager::keyStoreAvailable() signal, and
 
342
   the KeyStore::unavailable() signal. 
 
343
 
 
344
   \sa KeyStore for more discussion on availability of 
 
345
   keys and related objects.
 
346
 
 
347
   \ingroup UserAPI
 
348
*/
 
349
class QCA_EXPORT KeyStoreEntryWatcher : public QObject
 
350
{
 
351
        Q_OBJECT
 
352
public:
 
353
        /**
 
354
           Standard constructor.
 
355
 
 
356
           This creates an object that monitors the specified KeyStore entry,
 
357
           emitting available() and unavailable() as the entry becomes available
 
358
           and unavailable respectively.
 
359
 
 
360
           \param e the KeyStoreEntry to monitor
 
361
           \param parent the parent object for this object
 
362
        */
 
363
        explicit KeyStoreEntryWatcher(const KeyStoreEntry &e, QObject *parent = 0);
 
364
 
 
365
        ~KeyStoreEntryWatcher();
 
366
 
 
367
        /**
 
368
           The KeyStoreEntry that is being monitored
 
369
        */
 
370
        KeyStoreEntry entry() const;
 
371
 
 
372
Q_SIGNALS:
 
373
        /**
 
374
           This signal is emitted when the entry that is being monitored
 
375
           becomes available.
 
376
        */
 
377
        void available();
 
378
 
 
379
        /**
 
380
           This signal is emitted when the entry that is being monitored
 
381
           becomes unavailble.
 
382
        */
 
383
        void unavailable();
 
384
 
 
385
private:
 
386
        Q_DISABLE_COPY(KeyStoreEntryWatcher)
 
387
 
 
388
        class Private;
 
389
        friend class Private;
 
390
        Private *d;
 
391
};
 
392
 
 
393
/**
 
394
   \class KeyStore qca_keystore.h QtCrypto
 
395
 
 
396
   General purpose key storage object
 
397
 
 
398
   Examples of use of this are:
 
399
    -  systemstore:          System TrustedCertificates
 
400
    -  accepted self-signed: Application TrustedCertificates
 
401
    -  apple keychain:       User Identities
 
402
    -  smartcard:            SmartCard Identities
 
403
    -  gnupg:                PGPKeyring Identities,PGPPublicKeys
 
404
 
 
405
    \note
 
406
    - there can be multiple KeyStore objects referring to the same id
 
407
    - when a KeyStore is constructed, it refers to a given id (deviceId)
 
408
    and internal contextId.  if the context goes away, the KeyStore
 
409
    becomes invalid (isValid() == false), and unavailable() is emitted.
 
410
    even if the device later reappears, the KeyStore remains invalid.
 
411
    a new KeyStore will have to be created to use the device again.
 
412
 
 
413
   \ingroup UserAPI
 
414
*/
 
415
class QCA_EXPORT KeyStore : public QObject, public Algorithm
 
416
{
 
417
        Q_OBJECT
 
418
public:
 
419
        /**
 
420
           The type of keystore
 
421
        */
 
422
        enum Type
 
423
        {
 
424
                System,      ///< objects such as root certificates
 
425
                User,        ///< objects such as Apple Keychain, KDE Wallet
 
426
                Application, ///< for caching accepted self-signed certificates
 
427
                SmartCard,   ///< for smartcards
 
428
                PGPKeyring   ///< for a PGP keyring
 
429
        };
 
430
 
 
431
        /**
 
432
           Obtain a specific KeyStore
 
433
 
 
434
           \param id the identification for the key store
 
435
           \param keyStoreManager the parent manager for this keystore
 
436
        */
 
437
        KeyStore(const QString &id, KeyStoreManager *keyStoreManager);
 
438
 
 
439
        ~KeyStore();
 
440
 
 
441
        /**
 
442
           Check if this KeyStore is valid
 
443
 
 
444
           \return true if the KeyStore is valid
 
445
        */
 
446
        bool isValid() const;
 
447
 
 
448
        /**
 
449
           The KeyStore Type
 
450
        */
 
451
        Type type() const;
 
452
 
 
453
        /**
 
454
           The name associated with the KeyStore
 
455
        */
 
456
        QString name() const;
 
457
 
 
458
        /**
 
459
           The ID associated with the KeyStore
 
460
        */
 
461
        QString id() const;
 
462
 
 
463
        /**
 
464
           Test if the KeyStore is writeable or not
 
465
 
 
466
           \return true if the KeyStore is read-only
 
467
        */
 
468
        bool isReadOnly() const;
 
469
 
 
470
        /**
 
471
           Turns on asynchronous mode for this KeyStore instance.
 
472
 
 
473
           Normally, entryList() and writeEntry() are blocking
 
474
           calls.  However, if startAsynchronousMode() is called,
 
475
           then these functions will return immediately.  entryList()
 
476
           will return with the latest known entries, or an empty
 
477
           list if none are known yet (in this mode, updated() will
 
478
           be emitted once the initial entries are known, even if the
 
479
           store has not actually been altered).  writeEntry() will
 
480
           always return an empty string, and the entryWritten()
 
481
           signal indicates the result of a write.
 
482
        */
 
483
        void startAsynchronousMode();
 
484
 
 
485
        /**
 
486
           A list of the KeyStoreEntry objects in this store
 
487
 
 
488
           \note This synchronous operation may require event handling, and so
 
489
           it must not be called from the same thread as an EventHandler
 
490
           (this is not a concern if asynchronous mode is enabled).
 
491
 
 
492
           \sa startAsynchronousMode
 
493
        */
 
494
        QList<KeyStoreEntry> entryList() const;
 
495
 
 
496
        /**
 
497
           test if the KeyStore holds trusted certificates (and CRLs)
 
498
        */
 
499
        bool holdsTrustedCertificates() const;
 
500
 
 
501
        /**
 
502
           test if the KeyStore holds identities (eg KeyBundle or PGPSecretKey)
 
503
        */
 
504
        bool holdsIdentities() const;
 
505
 
 
506
        /**
 
507
           test if the KeyStore holds PGPPublicKey objects
 
508
        */
 
509
        bool holdsPGPPublicKeys() const;
 
510
 
 
511
        /**
 
512
           Add a entry to the KeyStore
 
513
 
 
514
           Returns the entryId of the written entry or an empty
 
515
           string on failure.
 
516
 
 
517
           \param kb the KeyBundle to add to the KeyStore
 
518
 
 
519
           \note This synchronous operation may require event handling, and so
 
520
           it must not be called from the same thread as an EventHandler
 
521
           (this is not a concern if asynchronous mode is enabled).
 
522
 
 
523
           \sa startAsynchronousMode
 
524
        */
 
525
        QString writeEntry(const KeyBundle &kb);
 
526
 
 
527
        /**
 
528
           \overload
 
529
 
 
530
           \param cert the Certificate to add to the KeyStore
 
531
        */
 
532
        QString writeEntry(const Certificate &cert);
 
533
 
 
534
        /**
 
535
           \overload
 
536
 
 
537
           \param crl the CRL to add to the KeyStore
 
538
        */
 
539
        QString writeEntry(const CRL &crl);
 
540
 
 
541
        /**
 
542
           \overload
 
543
 
 
544
           \param key the PGPKey to add to the KeyStore
 
545
 
 
546
           \return a ref to the key in the keyring
 
547
        */
 
548
        QString writeEntry(const PGPKey &key);
 
549
 
 
550
        /**
 
551
           Delete the a specified KeyStoreEntry from this KeyStore
 
552
 
 
553
           \param id the ID for the entry to be deleted
 
554
 
 
555
           \note This synchronous operation may require event handling, and so
 
556
           it must not be called from the same thread as an EventHandler
 
557
           (this is not a concern if asynchronous mode is enabled).
 
558
 
 
559
           \sa startAsynchronousMode
 
560
        */
 
561
        bool removeEntry(const QString &id);
 
562
 
 
563
Q_SIGNALS:
 
564
        /**
 
565
           Emitted when the KeyStore is changed
 
566
 
 
567
           This occurs if entries are added, removed, or changed in this
 
568
           KeyStore, including changes in entry availability.
 
569
        */
 
570
        void updated();
 
571
 
 
572
        /**
 
573
           Emitted when the KeyStore becomes unavailable
 
574
        */
 
575
        void unavailable();
 
576
 
 
577
        /**
 
578
           Emitted when an entry has been written, in asynchronous
 
579
           mode.  
 
580
 
 
581
           \param entryId is the newly written entry id on success,
 
582
           or an empty string if the write failed.
 
583
        */
 
584
        void entryWritten(const QString &entryId);
 
585
 
 
586
        /**
 
587
           Emitted when an entry has been removed, in asynchronous
 
588
           mode.  
 
589
 
 
590
           \param success indicates if the removal succeeded (true) or not (false).
 
591
        */
 
592
        void entryRemoved(bool success);
 
593
 
 
594
private:
 
595
        Q_DISABLE_COPY(KeyStore)
 
596
 
 
597
        friend class KeyStorePrivate;
 
598
        KeyStorePrivate *d;
 
599
 
 
600
        friend class KeyStoreManagerPrivate;
 
601
};
 
602
 
 
603
/**
 
604
   \class KeyStoreInfo qca_keystore.h QtCrypto
 
605
 
 
606
   Key store information, outside of a KeyStore object
 
607
 
 
608
   This class is used in conjunction with the Event class,
 
609
   and related classes such as PasswordAsker and TokenAsker,
 
610
   to describe the key store source of the Event.
 
611
 
 
612
   Each KeyStoreInfo represents a single KeyStore, and describes
 
613
   the type of store (e.g. smartcard or PGP keyring - see 
 
614
   KeyStore::Type), and a couple of names. The id() of a KeyStore
 
615
   is used to reference it, and is typically of the form 
 
616
   "qca-mystorename". The name() of a KeyStore is used to describe
 
617
   it (i.e. this is the "pretty" name to show the user), and is
 
618
   typically of the form "My Store Name".
 
619
 
 
620
   \ingroup UserAPI
 
621
*/
 
622
class QCA_EXPORT KeyStoreInfo
 
623
{
 
624
public:
 
625
        /**
 
626
           Constructor.
 
627
 
 
628
           \note This form of constructor for KeyStoreInfo
 
629
           produces an object that does not describe any 
 
630
           KeyStore, and isNull() will return true.
 
631
        */
 
632
        KeyStoreInfo();
 
633
 
 
634
        /**
 
635
           Standard constructor.
 
636
 
 
637
           This builds a KeyStoreInfo object that descibes a
 
638
           KeyStore.
 
639
 
 
640
           \param type the type of KeyStore
 
641
           \param id the identification of the KeyStore
 
642
           \param name the descriptive name of the KeyStore
 
643
        */
 
644
        KeyStoreInfo(KeyStore::Type type, const QString &id, const QString &name);
 
645
 
 
646
        /**
 
647
           Copy constructor.
 
648
 
 
649
           \param from the KeyStoreInfo to copy from
 
650
        */
 
651
        KeyStoreInfo(const KeyStoreInfo &from);
 
652
 
 
653
        ~KeyStoreInfo();
 
654
 
 
655
        /**
 
656
           Assignment operator.
 
657
 
 
658
           \param from the KeyStoreInfo to copy from
 
659
        */
 
660
        KeyStoreInfo & operator=(const KeyStoreInfo &from);
 
661
 
 
662
        /**
 
663
           Test if this object is valid
 
664
 
 
665
           \return true if the object is not valid
 
666
        */
 
667
        bool isNull() const;
 
668
 
 
669
        /**
 
670
           The Type of KeyStore that this KeyStoreInfo object
 
671
           describes.
 
672
        */
 
673
        KeyStore::Type type() const;
 
674
 
 
675
        /**
 
676
           The unique identification of the KeyStore that
 
677
           this KeyStoreInfo object describes.
 
678
        */
 
679
        QString id() const;
 
680
 
 
681
        /**
 
682
           The descriptive name of the KeyStore that this
 
683
           KeyStoreInfo object describes.
 
684
        */
 
685
        QString name() const;
 
686
 
 
687
private:
 
688
        class Private;
 
689
        QSharedDataPointer<Private> d;
 
690
};
 
691
 
 
692
/**
 
693
   \class KeyStoreManager qca_keystore.h QtCrypto
 
694
 
 
695
   Access keystores, and monitor keystores for changes.
 
696
 
 
697
   Before you can access a KeyStore, you must create a
 
698
   KeyStoreManager. You then need to start()
 
699
   the KeyStoreManager, and either wait for the busyFinished()
 
700
   signal, or block using waitForBusyFinished().
 
701
 
 
702
   If you know the KeyStoreEntry that you need, you can
 
703
   use KeyStore passively, as described in the KeyStoreEntry
 
704
   documentation.
 
705
 
 
706
   \ingroup UserAPI
 
707
*/
 
708
class QCA_EXPORT KeyStoreManager : public QObject
 
709
{
 
710
        Q_OBJECT
 
711
public:
 
712
        /**
 
713
           Create a new KeyStoreManager
 
714
 
 
715
           \param parent the parent for this object
 
716
        */
 
717
        KeyStoreManager(QObject *parent = 0);
 
718
        ~KeyStoreManager();
 
719
 
 
720
        /**
 
721
           Initialize all key store providers
 
722
        */
 
723
        static void start();
 
724
 
 
725
        /**
 
726
           Initialize a specific key store provider
 
727
 
 
728
           \param provider the name of the provider to start
 
729
        */
 
730
        static void start(const QString &provider);
 
731
 
 
732
        /**
 
733
           Indicates if the manager is busy looking for key stores
 
734
        */
 
735
        bool isBusy() const;
 
736
 
 
737
        /**
 
738
           Blocks until the manager is done looking for key stores
 
739
        */
 
740
        void waitForBusyFinished();
 
741
 
 
742
        /**
 
743
           A list of all the key stores
 
744
        */
 
745
        QStringList keyStores() const;
 
746
 
 
747
        /**
 
748
           The diagnostic result of key store operations, such as
 
749
           warnings and errors
 
750
        */
 
751
        static QString diagnosticText();
 
752
 
 
753
        /**
 
754
           Clears the diagnostic result log
 
755
        */
 
756
        static void clearDiagnosticText();
 
757
 
 
758
        /**
 
759
           If you are not using the eventloop, call this to update
 
760
           the object state to the present
 
761
        */
 
762
        void sync();
 
763
 
 
764
Q_SIGNALS:
 
765
        /**
 
766
           emitted when the manager has started looking for key stores
 
767
        */
 
768
        void busyStarted();
 
769
 
 
770
        /**
 
771
           emitted when the manager has finished looking for key stores
 
772
        */
 
773
        void busyFinished();
 
774
 
 
775
        /**
 
776
           emitted when a new key store becomes available
 
777
 
 
778
           \param id the name of the key store that has become available
 
779
        */
 
780
        void keyStoreAvailable(const QString &id);
 
781
 
 
782
private:
 
783
        Q_DISABLE_COPY(KeyStoreManager)
 
784
 
 
785
        friend class KeyStoreManagerPrivate;
 
786
        KeyStoreManagerPrivate *d;
 
787
 
 
788
        friend class Global;
 
789
        friend class KeyStorePrivate;
 
790
 
 
791
        static void scan();
 
792
        static void shutdown();
 
793
};
 
794
 
 
795
}
 
796
 
 
797
#endif