#include <QtCrypto>
Signals | |
void | finished () |
Public Member Functions | |
ConvertResult | convertResult () const |
KeyBundle | keyBundle () const |
KeyLoader (QObject *parent=0) | |
void | loadKeyBundleFromArray (const QByteArray &a) |
void | loadKeyBundleFromFile (const QString &fileName) |
void | loadPrivateKeyFromDER (const SecureArray &a) |
void | loadPrivateKeyFromPEM (const QString &s) |
void | loadPrivateKeyFromPEMFile (const QString &fileName) |
PrivateKey | privateKey () const |
Friends | |
class | Private |
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.
QCA::KeyLoader::KeyLoader | ( | QObject * | parent = 0 |
) |
ConvertResult QCA::KeyLoader::convertResult | ( | ) | const |
The result of the loading process.
This is not valid until the finished() signal has been emitted.
void QCA::KeyLoader::finished | ( | ) | [signal] |
Signal that is emitted when the load process has completed.
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).
void QCA::KeyLoader::loadKeyBundleFromArray | ( | const QByteArray & | a | ) |
Initiate an asynchronous loading of a KeyBundle from an array.
This function will return immediately.
a | the array containing the key bundle |
void QCA::KeyLoader::loadKeyBundleFromFile | ( | const QString & | fileName | ) |
Initiate an asynchronous loading of a KeyBundle from a file.
This function will return immediately.
fileName | the name of the file (and path, if necessary) to load the key bundle from |
void QCA::KeyLoader::loadPrivateKeyFromDER | ( | const SecureArray & | a | ) |
Initiate an asynchronous loading of a PrivateKey from a DER format array.
This function will return immediately.
a | the array containing the DER formatted key |
void QCA::KeyLoader::loadPrivateKeyFromPEM | ( | const QString & | s | ) |
Initiate an asynchronous loading of a PrivateKey from a PEM format string.
This function will return immediately.
s | the string containing the PEM formatted key |
void QCA::KeyLoader::loadPrivateKeyFromPEMFile | ( | const QString & | fileName | ) |
Initiate an asynchronous loading of a PrivateKey from a PEM format file.
This function will return immediately.
fileName | the name of the file (and path, if necessary) to load the key from |
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).