Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE task
PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-1733B4E1-3264-58DF-957B-F5C0AE1E0644" xml:lang="en"><title>Retrieving
Keystores</title><shortdesc>This section explains how to retrieve keystore implementations. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<context><p>Keystores can be used in manager mode or user mode. In manager
mode, modifications to an existing keystore can be performed through the <xref href="GUID-89FFDC49-F722-3A68-8601-C461AD2FBDF2.dita"><apiname>MCTKeyStoreManager</apiname></xref> interface.
In user mode, a keystore can be viewed using the <xref href="GUID-2B3202F8-469D-3253-90E8-B553506AD47A.dita"><apiname>MCTKeyStore</apiname></xref> interface. </p><p> The
following steps explain the process of retrieving keystores:</p> </context>
<steps id="GUID-D16D66C2-BD90-584D-BD2E-0096D85A8C15">
<step id="GUID-EE9F9F53-52F2-59C3-A65D-0569ABECBCB2"><cmd/>
<info>Create an object of type CUnifiedKeyStore using <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-C7A96153-4179-3B3F-878D-1EAA64A98D39"><apiname>CUnifiedKeyStore::NewL()</apiname></xref> or <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-217FBB3B-CEF5-36F2-A612-EDDA0982053C"><apiname>CUnifiedKeyStore::NewLC()</apiname></xref>. </info>
</step>
<step id="GUID-1CFCBA6B-7BAC-5994-BFB0-5AA63703BA06"><cmd/>
<info>Initialise the member functions and keystore using the asynchronous
function <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-6C5D732C-1FD1-3EF0-AC90-87690F891B8D"><apiname>CUnifiedKeyStore::Initialize()</apiname></xref>. </info>
</step>
<step id="GUID-4E386CB7-118B-5E5D-AE61-A4911719E029"><cmd/>
<info>Retrieve the keystore in either of the following modes. </info>
<substeps id="GUID-019BBF0F-33B9-5A7D-B245-D65C2463F1B4">
<substep id="GUID-6B9577C5-15C8-50FC-B553-E9B8EB7BAC1E"><cmd/>
<info>Read/write mode </info>
<info>Use the <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-AB8E29A7-8C56-3B54-A1F1-A1BB140F4DD3"><apiname>CUnifiedKeyStore::KeyStoreManager()</apiname></xref> function
to get the required <xref href="GUID-89FFDC49-F722-3A68-8601-C461AD2FBDF2.dita"><apiname>MCTKeyStoreManager</apiname></xref> object using an
appropriate index of the keystore. </info>
</substep>
<substep id="GUID-4A2D4A9C-BF5B-58AB-91B8-3703F9AE5F4D"><cmd/>
<info>Read-only mode </info>
<info>Use the <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-534E9428-E03F-3C90-948E-9456365B1D67"><apiname>CUnifiedKeyStore::KeyStore()</apiname></xref> function to
get the required <xref href="GUID-2B3202F8-469D-3253-90E8-B553506AD47A.dita"><apiname>MCTKeyStore</apiname></xref> object using an appropriate
index of the keystore. </info>
</substep>
</substeps>
</step>
</steps>
<result><p>Returns a keystore, which can be used to perform operations. </p><p>The
following code snippet shows how to retrieve keystores in manager mode. </p> <codeblock id="GUID-E4C9D64F-F1DB-5C81-9574-5E0C149C4756" xml:space="preserve">
//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</codeblock> </result>
</taskbody></task>