Symbian3/PDK/Source/GUID-384A25D6-EC89-576E-857F-D8D26292FED9.dita
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
--- a/Symbian3/PDK/Source/GUID-384A25D6-EC89-576E-857F-D8D26292FED9.dita	Tue Mar 30 11:42:04 2010 +0100
+++ b/Symbian3/PDK/Source/GUID-384A25D6-EC89-576E-857F-D8D26292FED9.dita	Tue Mar 30 11:56:28 2010 +0100
@@ -1,104 +1,104 @@
-<?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-384A25D6-EC89-576E-857F-D8D26292FED9" xml:lang="en"><title> Importing
-Keys</title><shortdesc>This section describes how to import a key from a file using the
-keystore. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
-<context><p>An externally generated key can be stored in the keystore using
-the import functionality. Use the <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-9A2E3ABC-4992-31F1-B03E-090DB3C6DC66"><apiname>CUnifiedKeyStore::ImportKey()</apiname></xref> function
-to import a key into the keystore. </p><p> The following steps explain the
-process of importing keys:</p> </context>
-<steps id="GUID-7AD9B618-A5E5-5C32-82D4-1B8E18B13C2C">
-<step id="GUID-0349CB41-E21A-5BED-BB0C-5A9AFE3AF7CA"><cmd/>
-<info>Create a file system session using an <xref href="GUID-E263C747-946F-35AA-9F1D-41833BD350FC.dita"><apiname>RFs</apiname></xref> object. </info>
-</step>
-<step id="GUID-72A8537C-75A3-51B4-ACD2-0647A69D5528"><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> function. </info>
-</step>
-<step id="GUID-AF402EF4-C1A5-5124-9C21-4A45B81F1D0C"><cmd/>
-<info>Initialize 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-03708DBC-2367-55CE-B492-1E3CE0F42EA6"><cmd/>
-<info>Open the file in read-only mode using the <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita"><apiname>RFile</apiname></xref> object. </info>
-</step>
-<step id="GUID-00E736F5-E3AA-5537-92EC-8D287790516E"><cmd/>
-<info>Import the key using <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-9A2E3ABC-4992-31F1-B03E-090DB3C6DC66"><apiname>CUnifiedKeyStore::ImportKey()</apiname></xref>. </info>
-</step>
-</steps>
-<result><p>The required key is imported into the selected keystore. </p> </result>
-<example><title>Example</title> <p>The following code snippet shows how to
-create a file system session object, initialize keystore and member functions,
-and import a key. </p> <codeblock id="GUID-3FB35264-562C-5FD8-B3B6-1770BF5CA28D" xml:space="preserve">
-//Create a file system session object
-RFs iFs;
-CleanupClosePushL(&amp;iFs);
-
-
-
-//Initialise the keystore and member functions
-CUnifiedKeyStore* keyStore = CUnifiedKeyStore::NewL(iFs);
-keyStore-&gt;Initialize(iStatus); //iStatus is a TRequestStatus object
-
-
-...
-
-
-HBufC8* keyData = NULL;
-CleanupStack::PushL(keyData);
-
-
-
-// Specify the path of the file containing the key details
-TDriveUnit sysDrive (RFs::GetSystemDrive());
-TFileName keyDataFile (sysDrive.Name());
-keyDataFile.Append(_LIT("&lt;path where key is located; relative to the system drive in this case.&gt;"));
-
-
-//Specify the filename
-TFileName buf;
-buf.FillZ();
-buf.Copy(aDes); //Filename
-keyDataFile.Append(buf); 
-
-
-//Open the file in read-only mode
-RFile file;
-User::LeaveIfError(file.Open(iFs, keyDataFile, EFileRead));
-CleanupClosePushL(file);
-
-TInt fileSize = 0;
-User::LeaveIfError(file.Size(fileSize));
-HBufC8* iKeyData;
-
-if (fileSize &gt; 0)
-    {
-     iKeyData = HBufC8::NewMaxLC(fileSize);    
-     TPtr8 data(iKeyData-&gt;Des());
-     data.FillZ();
-     User::LeaveIfError(file.Read(data, fileSize));
-    }
-
-
-
-//Import the key into the keystore
-keyStore-&gt;ImportKey(0, iKeyData-&gt;Des(), usage, KLabel, accessType,
-                TTime(0), keyInfo, iStatus);
-
-
-//Clean up
-CleanupStack::Pop(keyData);
-CleanupStack::PopAndDestroy(); // file
-CleanupStack::PopAndDestroy(); // iFs</codeblock> </example>
-</taskbody><related-links>
-<link href="GUID-C4389D60-2A8D-532D-9D92-E57B0CCD14CF.dita"><linktext>Unified Keystore</linktext>
-</link>
+<?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-384A25D6-EC89-576E-857F-D8D26292FED9" xml:lang="en"><title> Importing
+Keys</title><shortdesc>This section describes how to import a key from a file using the
+keystore. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
+<context><p>An externally generated key can be stored in the keystore using
+the import functionality. Use the <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-9A2E3ABC-4992-31F1-B03E-090DB3C6DC66"><apiname>CUnifiedKeyStore::ImportKey()</apiname></xref> function
+to import a key into the keystore. </p><p> The following steps explain the
+process of importing keys:</p> </context>
+<steps id="GUID-7AD9B618-A5E5-5C32-82D4-1B8E18B13C2C">
+<step id="GUID-0349CB41-E21A-5BED-BB0C-5A9AFE3AF7CA"><cmd/>
+<info>Create a file system session using an <xref href="GUID-E263C747-946F-35AA-9F1D-41833BD350FC.dita"><apiname>RFs</apiname></xref> object. </info>
+</step>
+<step id="GUID-72A8537C-75A3-51B4-ACD2-0647A69D5528"><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> function. </info>
+</step>
+<step id="GUID-AF402EF4-C1A5-5124-9C21-4A45B81F1D0C"><cmd/>
+<info>Initialize 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-03708DBC-2367-55CE-B492-1E3CE0F42EA6"><cmd/>
+<info>Open the file in read-only mode using the <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita"><apiname>RFile</apiname></xref> object. </info>
+</step>
+<step id="GUID-00E736F5-E3AA-5537-92EC-8D287790516E"><cmd/>
+<info>Import the key using <xref href="GUID-818689D6-EB99-382E-A435-D9C6C5D464DE.dita#GUID-818689D6-EB99-382E-A435-D9C6C5D464DE/GUID-9A2E3ABC-4992-31F1-B03E-090DB3C6DC66"><apiname>CUnifiedKeyStore::ImportKey()</apiname></xref>. </info>
+</step>
+</steps>
+<result><p>The required key is imported into the selected keystore. </p> </result>
+<example><title>Example</title> <p>The following code snippet shows how to
+create a file system session object, initialize keystore and member functions,
+and import a key. </p> <codeblock id="GUID-3FB35264-562C-5FD8-B3B6-1770BF5CA28D" xml:space="preserve">
+//Create a file system session object
+RFs iFs;
+CleanupClosePushL(&amp;iFs);
+
+
+
+//Initialise the keystore and member functions
+CUnifiedKeyStore* keyStore = CUnifiedKeyStore::NewL(iFs);
+keyStore-&gt;Initialize(iStatus); //iStatus is a TRequestStatus object
+
+
+...
+
+
+HBufC8* keyData = NULL;
+CleanupStack::PushL(keyData);
+
+
+
+// Specify the path of the file containing the key details
+TDriveUnit sysDrive (RFs::GetSystemDrive());
+TFileName keyDataFile (sysDrive.Name());
+keyDataFile.Append(_LIT("&lt;path where key is located; relative to the system drive in this case.&gt;"));
+
+
+//Specify the filename
+TFileName buf;
+buf.FillZ();
+buf.Copy(aDes); //Filename
+keyDataFile.Append(buf); 
+
+
+//Open the file in read-only mode
+RFile file;
+User::LeaveIfError(file.Open(iFs, keyDataFile, EFileRead));
+CleanupClosePushL(file);
+
+TInt fileSize = 0;
+User::LeaveIfError(file.Size(fileSize));
+HBufC8* iKeyData;
+
+if (fileSize &gt; 0)
+    {
+     iKeyData = HBufC8::NewMaxLC(fileSize);    
+     TPtr8 data(iKeyData-&gt;Des());
+     data.FillZ();
+     User::LeaveIfError(file.Read(data, fileSize));
+    }
+
+
+
+//Import the key into the keystore
+keyStore-&gt;ImportKey(0, iKeyData-&gt;Des(), usage, KLabel, accessType,
+                TTime(0), keyInfo, iStatus);
+
+
+//Clean up
+CleanupStack::Pop(keyData);
+CleanupStack::PopAndDestroy(); // file
+CleanupStack::PopAndDestroy(); // iFs</codeblock> </example>
+</taskbody><related-links>
+<link href="GUID-C4389D60-2A8D-532D-9D92-E57B0CCD14CF.dita"><linktext>Unified Keystore</linktext>
+</link>
 </related-links></task>
\ No newline at end of file