1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "tAuthSvrStep.h" |
|
19 #include <testexecutelog.h> |
|
20 #include "authserver/protectionkey.h" |
|
21 #include "../source/server/encryptedprotectionkey.h" |
|
22 #include "../source/server/transientkey.h" |
|
23 #include "../source/server/transientkey.h" |
|
24 #include "../source/server/transientkeyinfo.h" |
|
25 #include "../source/server/authdb.h" |
|
26 |
|
27 #include <s32file.h> |
|
28 #include <f32file.h> |
|
29 |
|
30 using namespace AuthServer; |
|
31 |
|
32 CTStepCreateDb::CTStepCreateDb() |
|
33 { |
|
34 SetTestStepName(KTStepCreateDb); |
|
35 } |
|
36 |
|
37 TVerdict CTStepCreateDb::doTestStepL() |
|
38 { |
|
39 if (TestStepResult() != EPass) |
|
40 { |
|
41 return TestStepResult(); |
|
42 } |
|
43 __UHEAP_MARK; // Check for memory leaks |
|
44 |
|
45 TBool res = ETrue; |
|
46 |
|
47 /* |
|
48 */ |
|
49 // TBuf<50> path; |
|
50 _LIT(kAuthDbFile, "authdb.db"); |
|
51 _LIT(kPath,"\\private\\102740FC\\"); |
|
52 |
|
53 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
54 iFs.CreatePrivatePath(sysDrive); |
|
55 |
|
56 TBuf<128> filePath (sysDrive.Name()); |
|
57 filePath.Append(kPath); |
|
58 TInt err = iFs.MkDirAll(filePath); |
|
59 if (err != KErrAlreadyExists) |
|
60 { |
|
61 User::LeaveIfError(err); |
|
62 } |
|
63 |
|
64 filePath.Insert(filePath.Length(), kAuthDbFile); |
|
65 |
|
66 // Set up database |
|
67 CAuthDb* authDb = CAuthDb::NewL(); |
|
68 CleanupStack::PushL(authDb); |
|
69 |
|
70 for (TInt i = 0 ; i < KNumPlugins ; ++i) |
|
71 { |
|
72 authDb->AddPluginL(iPlugins[i]); |
|
73 iPlugins[i] = 0; // transfer ownership |
|
74 } |
|
75 |
|
76 _LIT(kId1Name, "Identity1"); |
|
77 _LIT(kId2Name, "Identity2"); |
|
78 _LIT(kId3Name, "Identity3"); |
|
79 |
|
80 authDb->AddIdentityL(1, kId1Name, iId1Keys[0]); |
|
81 iId1Keys[0] = 0; // transfer ownership |
|
82 authDb->AddIdentityL(2, kId2Name, iId2Keys[0]); |
|
83 iId2Keys[0] = 0; // transfer ownership |
|
84 authDb->AddIdentityL(3, kId3Name, iId3Keys[0]); |
|
85 iId3Keys[0] = 0; // transfer ownership |
|
86 |
|
87 for (TInt i = 1 ; i < KNumPlugins ; ++i) |
|
88 { |
|
89 // add a new key info |
|
90 authDb->UpdateL(1, iId1Keys[i]); |
|
91 iId1Keys[i] = 0; // transfer ownership |
|
92 authDb->UpdateL(2, iId2Keys[i]); |
|
93 iId2Keys[i] = 0; // transfer ownership |
|
94 authDb->UpdateL(3, iId3Keys[i]); |
|
95 iId3Keys[i] = 0; // transfer ownership |
|
96 } |
|
97 |
|
98 // Externalize |
|
99 RFileWriteStream writeStore; |
|
100 User::LeaveIfError(writeStore.Replace(iFs, filePath, |
|
101 EFileShareExclusive | EFileStream)); |
|
102 CleanupClosePushL(writeStore); |
|
103 |
|
104 authDb->ExternalizeL(writeStore); |
|
105 |
|
106 CleanupStack::PopAndDestroy(&writeStore); |
|
107 |
|
108 CleanupStack::PopAndDestroy(1,authDb); |
|
109 |
|
110 SetTestStepResult(res ? EPass : EFail); |
|
111 |
|
112 __UHEAP_MARKEND; |
|
113 return TestStepResult(); |
|
114 } |
|
115 |
|