Retrieving Keystores

This section explains how to retrieve keystore implementations.

Keystores can be used in manager mode or user mode. In manager mode, modifications to an existing keystore can be performed through the MCTKeyStoreManager interface. In user mode, a keystore can be viewed using the MCTKeyStore interface.

The following steps explain the process of retrieving keystores:


  1. Create an object of type CUnifiedKeyStore using CUnifiedKeyStore::NewL() or CUnifiedKeyStore::NewLC().

  2. Initialise the member functions and keystore using the asynchronous function CUnifiedKeyStore::Initialize().

  3. Retrieve the keystore in either of the following modes.

    1. Read/write mode Use the CUnifiedKeyStore::KeyStoreManager() function to get the required MCTKeyStoreManager object using an appropriate index of the keystore.

    2. Read-only mode Use the CUnifiedKeyStore::KeyStore() function to get the required MCTKeyStore object using an appropriate index of the keystore.

Returns a keystore, which can be used to perform operations.

The following code snippet shows how to retrieve keystores in manager mode.


//Create a file system session object
RFs iFs;
CleanupClosePushL(&iFs); 

...


//Initialise the keystore and member functions
CUnifiedKeyStore* keyStore = CUnifiedKeyStore::NewL(fs);
keyStore->Initialize(iStatus); //iStatus is a TRequestStatus object

...


//Retrieve the keystore present at the specified index
//If the keystore index is invalid 
//or the specified keystore cannot be opened in manager mode
//then the manager object is NULL

MCTKeyStoreManager& manager = keyStore->KeyStoreManager(0);


//Clean up
CleanupStack::PopAndDestroy(); // iFs