QCA::KeyLoader Class Reference

Asynchronous private key loader. More...

#include <qca_cert.h>

Inheritance diagram for QCA::KeyLoader:

QObject Collaboration diagram for QCA::KeyLoader:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 KeyLoader (QObject *parent=0)
void loadPrivateKeyFromPEMFile (const QString &fileName)
void loadPrivateKeyFromPEM (const QString &s)
void loadPrivateKeyFromDER (const SecureArray &a)
void loadKeyBundleFromFile (const QString &fileName)
void loadKeyBundleFromArray (const QByteArray &a)
ConvertResult convertResult () const
PrivateKey privateKey () const
KeyBundle keyBundle () const

Public Attributes

Q_SIGNALS __pad0__: void finished()

Friends

class Private

Detailed Description

Asynchronous private key loader.

GUI applications generally must use KeyLoader to load private keys. This is because the synchronous private key loading functions, for example QCA::PrivateKey::fromPEMFile(), cannot be used within the same thread as an EventHandler, and most GUI applications will use EventHandler from the main thread. KeyLoader does not have this problem. It can be used from any thread, including the same thread as EventHandler.

The KeyLoader class allows you to asynchronously load stand-alone private keys (QCA::PrivateKey) or private keys with a certificate (QCA::KeyBundle) with a signal that advises of completion.

To use this class to load a PrivateKey, you create a KeyLoader object then use one of the loadPrivateKeyFrom...() functions, depending on the format for your key. These functions return immediately. When you get the finished() signal, you can check that the loading operation succeeded (using convertResult()) and then obtain the PrivateKey using the privateKey() function.

The same process applies for loading a KeyBundle, except that you use either loadKeyBundleFromFile() or loadKeyBundleFromArray() instead of the loadPrivateKeyFrom...() function, and use keyBundle() instead of privateKey().

The loader may need a passphrase to complete the loading of the key or key bundle. You should use the QCA::EventHandler class to ensure that you deal with this correctly.

Note:
QCA also provides synchronous private key loading using QCA::PrivateKey::fromPEMFile(), QCA::PrivateKey::fromPEM() and QCA::PrivateKey::fromDER(). QCA provides synchronous key bundle loading using QCA::KeyBundle::fromArray() and QCA::KeyBundle::fromFile().
Examples:

keyloader.cpp.


Constructor & Destructor Documentation

QCA::KeyLoader::KeyLoader QObject parent = 0  ) 
 

Create a KeyLoader object.

Parameters:
parent the parent object for this object


Member Function Documentation

void QCA::KeyLoader::loadPrivateKeyFromPEMFile const QString fileName  ) 
 

Initiate an asynchronous loading of a PrivateKey from a PEM format file.

This function will return immediately.

Parameters:
fileName the name of the file (and path, if necessary) to load the key from

void QCA::KeyLoader::loadPrivateKeyFromPEM const QString s  ) 
 

Initiate an asynchronous loading of a PrivateKey from a PEM format string.

This function will return immediately.

Parameters:
s the string containing the PEM formatted key

void QCA::KeyLoader::loadPrivateKeyFromDER const SecureArray a  ) 
 

Initiate an asynchronous loading of a PrivateKey from a DER format array.

This function will return immediately.

Parameters:
a the array containing the DER formatted key

void QCA::KeyLoader::loadKeyBundleFromFile const QString fileName  ) 
 

Initiate an asynchronous loading of a KeyBundle from a file.

This function will return immediately.

Parameters:
fileName the name of the file (and path, if necessary) to load the key bundle from

void QCA::KeyLoader::loadKeyBundleFromArray const QByteArray a  ) 
 

Initiate an asynchronous loading of a KeyBundle from an array.

This function will return immediately.

Parameters:
a the array containing the key bundle

ConvertResult QCA::KeyLoader::convertResult  )  const
 

The result of the loading process.

This is not valid until the finished() signal has been emitted.

PrivateKey QCA::KeyLoader::privateKey  )  const
 

The private key that has been loaded.

This is only valid if loadPrivateKeyFromPEMFile(), loadPrivateKeyFromPEM() or loadPrivateKeyFromDER() has been used, the load has completed (that is, finished() has been emitted), and the conversion succeeded (that is, convertResult() returned ConvertGood).

KeyBundle QCA::KeyLoader::keyBundle  )  const
 

The key bundle that has been loaded.

This is only valid if loadKeyBundleFromFile() or loadKeyBundleFromArray() has been used, the load has completed (that is, finished() has been emitted), and the conversion succeeded (that is, convertResult() returned ConvertGood).


The documentation for this class was generated from the following file:
Generated on Fri Jul 6 12:15:00 2007 for Qt Cryptographic Architecture by  doxygen 1.4.6