sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "t_certstoreactions.h"
|
sl@0
|
20 |
#include "t_certstoreout.h"
|
sl@0
|
21 |
#include "t_certstoredefs.h"
|
sl@0
|
22 |
#include "t_input.h"
|
sl@0
|
23 |
#include <x509cert.h>
|
sl@0
|
24 |
#include <wtlscert.h>
|
sl@0
|
25 |
#include <securityerr.h>
|
sl@0
|
26 |
#include <ecom/ecom.h>
|
sl@0
|
27 |
#include "testutilclient.h"
|
sl@0
|
28 |
#include <swicertstore.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
// CCertStoreChangeNotifier //////////////////////////////////////////////////////////////
|
sl@0
|
31 |
CCertStoreChangeNotifier* CCertStoreChangeNotifier::NewL(TInt& aNotificationFlag)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
CCertStoreChangeNotifier* self = new(ELeave) CCertStoreChangeNotifier(aNotificationFlag);
|
sl@0
|
34 |
CleanupStack::PushL(self);
|
sl@0
|
35 |
self->ConstructL();
|
sl@0
|
36 |
CleanupStack::Pop();
|
sl@0
|
37 |
return self;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
CCertStoreChangeNotifier::~CCertStoreChangeNotifier()
|
sl@0
|
40 |
{
|
sl@0
|
41 |
Cancel();
|
sl@0
|
42 |
iCertStoreChangeProperty.Close();
|
sl@0
|
43 |
}
|
sl@0
|
44 |
CCertStoreChangeNotifier::CCertStoreChangeNotifier(TInt& aNotificationFlag): CActive(EPriorityHigh), iNotifiedCounter(aNotificationFlag)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
CActiveScheduler::Add(this);
|
sl@0
|
47 |
}
|
sl@0
|
48 |
void CCertStoreChangeNotifier::ConstructL()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
TInt r=iCertStoreChangeProperty.Attach(KUnifiedCertStorePropertyCat,EUnifiedCertStoreFlag,EOwnerThread);
|
sl@0
|
51 |
User::LeaveIfError(r);
|
sl@0
|
52 |
}
|
sl@0
|
53 |
void CCertStoreChangeNotifier::StartNotification()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
iCertStoreChangeProperty.Subscribe(iStatus);
|
sl@0
|
56 |
SetActive();
|
sl@0
|
57 |
}
|
sl@0
|
58 |
void CCertStoreChangeNotifier::DoCancel()
|
sl@0
|
59 |
{
|
sl@0
|
60 |
iCertStoreChangeProperty.Cancel();
|
sl@0
|
61 |
}
|
sl@0
|
62 |
void CCertStoreChangeNotifier::RunL()
|
sl@0
|
63 |
{
|
sl@0
|
64 |
iNotifiedCounter++;
|
sl@0
|
65 |
if (iCompleteStatus)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
User::RequestComplete(iCompleteStatus, KErrNone);
|
sl@0
|
68 |
}
|
sl@0
|
69 |
}
|
sl@0
|
70 |
void CCertStoreChangeNotifier::SetCompleteStatus(TRequestStatus* aStatus)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
iCompleteStatus=aStatus;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
// COpenCertStore //////////////////////////////////////////////////////////////
|
sl@0
|
76 |
|
sl@0
|
77 |
_LIT(KCOpenCertStore, "COpenCertStore");
|
sl@0
|
78 |
|
sl@0
|
79 |
COpenCertStore::~COpenCertStore()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
if (iSet)
|
sl@0
|
82 |
{
|
sl@0
|
83 |
switch (iType)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
case EUnifiedCertStore:
|
sl@0
|
86 |
delete iUnifiedCertStore;
|
sl@0
|
87 |
break;
|
sl@0
|
88 |
|
sl@0
|
89 |
case ESWICertStore:
|
sl@0
|
90 |
iSwiCertStore->Release();
|
sl@0
|
91 |
break;
|
sl@0
|
92 |
|
sl@0
|
93 |
default:
|
sl@0
|
94 |
User::Panic(KCOpenCertStore, 1);
|
sl@0
|
95 |
}
|
sl@0
|
96 |
}
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
void COpenCertStore::SetCertStore(CUnifiedCertStore* aCertStore)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
__ASSERT_ALWAYS(!iSet, User::Panic(KCOpenCertStore, 1));
|
sl@0
|
102 |
iType = EUnifiedCertStore;
|
sl@0
|
103 |
iUnifiedCertStore = aCertStore;
|
sl@0
|
104 |
iSet = ETrue;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
CUnifiedCertStore& COpenCertStore::AsUnifiedCertStore()
|
sl@0
|
108 |
{
|
sl@0
|
109 |
__ASSERT_ALWAYS(iSet && iType == EUnifiedCertStore, User::Panic(KCOpenCertStore, 1));
|
sl@0
|
110 |
return *iUnifiedCertStore;
|
sl@0
|
111 |
}
|
sl@0
|
112 |
|
sl@0
|
113 |
|
sl@0
|
114 |
void COpenCertStore::SetCertStore(CSWICertStore* aCertStore)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
__ASSERT_ALWAYS(!iSet, User::Panic(KCOpenCertStore, 1));
|
sl@0
|
117 |
iType = ESWICertStore;
|
sl@0
|
118 |
iSwiCertStore = aCertStore;
|
sl@0
|
119 |
iSet = ETrue;
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
CSWICertStore& COpenCertStore::AsSWICertStore()
|
sl@0
|
123 |
{
|
sl@0
|
124 |
__ASSERT_ALWAYS(iSet && iType == ESWICertStore, User::Panic(KCOpenCertStore, 1));
|
sl@0
|
125 |
return *iSwiCertStore;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
|
sl@0
|
129 |
TCertStoreType COpenCertStore::Type()
|
sl@0
|
130 |
{
|
sl@0
|
131 |
__ASSERT_ALWAYS(iSet, User::Panic(KCOpenCertStore, 1));
|
sl@0
|
132 |
return iType;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
|
sl@0
|
136 |
MCertStore& COpenCertStore::CertStore()
|
sl@0
|
137 |
{
|
sl@0
|
138 |
__ASSERT_ALWAYS(iSet, User::Panic(KCOpenCertStore, 1));
|
sl@0
|
139 |
|
sl@0
|
140 |
MCertStore* result = NULL;
|
sl@0
|
141 |
|
sl@0
|
142 |
switch (iType)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
case EUnifiedCertStore:
|
sl@0
|
145 |
result = iUnifiedCertStore;
|
sl@0
|
146 |
break;
|
sl@0
|
147 |
|
sl@0
|
148 |
case ESWICertStore:
|
sl@0
|
149 |
result = iSwiCertStore;
|
sl@0
|
150 |
break;
|
sl@0
|
151 |
|
sl@0
|
152 |
default:
|
sl@0
|
153 |
User::Panic(KCOpenCertStore, 1);
|
sl@0
|
154 |
}
|
sl@0
|
155 |
|
sl@0
|
156 |
return *result;
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
// CSharedData /////////////////////////////////////////////////////////////////
|
sl@0
|
160 |
|
sl@0
|
161 |
CSharedData::~CSharedData()
|
sl@0
|
162 |
{
|
sl@0
|
163 |
iCertStores.ResetAndDestroy();
|
sl@0
|
164 |
iCertStores.Close();
|
sl@0
|
165 |
DeleteCertificateAppInfoManager();
|
sl@0
|
166 |
REComSession::FinalClose();
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|
sl@0
|
169 |
void CSharedData::InitCertificateAppInfoManagerL()
|
sl@0
|
170 |
{
|
sl@0
|
171 |
ASSERT(!iCertificateAppInfoManager);
|
sl@0
|
172 |
User::LeaveIfError(iFs.Connect());
|
sl@0
|
173 |
iCertificateAppInfoManager = CCertificateAppInfoManager::NewL(iFs, ETrue);
|
sl@0
|
174 |
}
|
sl@0
|
175 |
|
sl@0
|
176 |
void CSharedData::DeleteCertificateAppInfoManager()
|
sl@0
|
177 |
{
|
sl@0
|
178 |
if (iCertificateAppInfoManager)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
delete iCertificateAppInfoManager;
|
sl@0
|
181 |
iCertificateAppInfoManager = NULL;
|
sl@0
|
182 |
iFs.Close();
|
sl@0
|
183 |
}
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
RPointerArray<COpenCertStore>& CSharedData::CertStores()
|
sl@0
|
187 |
{
|
sl@0
|
188 |
return iCertStores;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
/////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
192 |
//CCertStoreTestAction base class
|
sl@0
|
193 |
/////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
194 |
|
sl@0
|
195 |
CCertStoreTestAction::~CCertStoreTestAction()
|
sl@0
|
196 |
{
|
sl@0
|
197 |
}
|
sl@0
|
198 |
|
sl@0
|
199 |
CCertStoreTestAction::CCertStoreTestAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut) :
|
sl@0
|
200 |
CTestAction(aConsole, aOut), iFs(aFs)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
}
|
sl@0
|
203 |
|
sl@0
|
204 |
CSharedData& CCertStoreTestAction::CertStoreSharedData()
|
sl@0
|
205 |
{
|
sl@0
|
206 |
if (!SharedData())
|
sl@0
|
207 |
{
|
sl@0
|
208 |
SetSharedData(new CSharedData);
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
CSharedData* data = static_cast<CSharedData*>(SharedData());
|
sl@0
|
212 |
ASSERT(data); // panic if out of memory
|
sl@0
|
213 |
return *data;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
void CCertStoreTestAction::DoPerformPrerequisite(TRequestStatus& aStatus)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
// Ensure shared data is already created to prevent panic in oom test
|
sl@0
|
219 |
CertStoreSharedData();
|
sl@0
|
220 |
|
sl@0
|
221 |
iActionState = EAction;
|
sl@0
|
222 |
TRequestStatus* status = &aStatus;
|
sl@0
|
223 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
void CCertStoreTestAction::DoPerformPostrequisite(TRequestStatus& aStatus)
|
sl@0
|
227 |
{
|
sl@0
|
228 |
TRequestStatus* status = &aStatus;
|
sl@0
|
229 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
230 |
}
|
sl@0
|
231 |
|
sl@0
|
232 |
CCertificateAppInfoManager* CCertStoreTestAction::TheCertificateAppInfoManager()
|
sl@0
|
233 |
{
|
sl@0
|
234 |
return CertStoreSharedData().iCertificateAppInfoManager;
|
sl@0
|
235 |
}
|
sl@0
|
236 |
|
sl@0
|
237 |
void CCertStoreTestAction::InitTheCertificateAppInfoManagerL()
|
sl@0
|
238 |
{
|
sl@0
|
239 |
CertStoreSharedData().InitCertificateAppInfoManagerL();
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
void CCertStoreTestAction::DeleteTheCertificateAppInfoManager()
|
sl@0
|
243 |
{
|
sl@0
|
244 |
CertStoreSharedData().DeleteCertificateAppInfoManager();
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
RPointerArray<COpenCertStore>& CCertStoreTestAction::CertStores()
|
sl@0
|
248 |
{
|
sl@0
|
249 |
return CertStoreSharedData().CertStores();
|
sl@0
|
250 |
}
|
sl@0
|
251 |
|
sl@0
|
252 |
TInt CCertStoreTestAction::CertStoreCount()
|
sl@0
|
253 |
{
|
sl@0
|
254 |
return CertStores().Count();
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
TCertStoreType CCertStoreTestAction::CertStoreType(TInt aIndex)
|
sl@0
|
258 |
{
|
sl@0
|
259 |
return CertStores()[aIndex]->Type();
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
MCertStore& CCertStoreTestAction::CertStore(TInt aIndex)
|
sl@0
|
263 |
{
|
sl@0
|
264 |
return CertStores()[aIndex]->CertStore();
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
void CCertStoreTestAction::AddCertStoreL(CUnifiedCertStore* aCertStore)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
COpenCertStore* openStore = new (ELeave) COpenCertStore;
|
sl@0
|
270 |
CleanupStack::PushL(openStore);
|
sl@0
|
271 |
User::LeaveIfError(CertStores().Append(openStore));
|
sl@0
|
272 |
CleanupStack::Pop(openStore);
|
sl@0
|
273 |
openStore->SetCertStore(aCertStore); // takes ownership
|
sl@0
|
274 |
}
|
sl@0
|
275 |
|
sl@0
|
276 |
CUnifiedCertStore& CCertStoreTestAction::UnifiedCertStore(TInt aIndex)
|
sl@0
|
277 |
{
|
sl@0
|
278 |
return CertStores()[aIndex]->AsUnifiedCertStore();
|
sl@0
|
279 |
}
|
sl@0
|
280 |
|
sl@0
|
281 |
|
sl@0
|
282 |
void CCertStoreTestAction::AddCertStoreL(CSWICertStore* aCertStore)
|
sl@0
|
283 |
{
|
sl@0
|
284 |
COpenCertStore* openStore = new (ELeave) COpenCertStore;
|
sl@0
|
285 |
CleanupStack::PushL(openStore);
|
sl@0
|
286 |
User::LeaveIfError(CertStores().Append(openStore));
|
sl@0
|
287 |
CleanupStack::Pop(openStore);
|
sl@0
|
288 |
openStore->SetCertStore(aCertStore); // takes ownership
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|
sl@0
|
291 |
CSWICertStore& CCertStoreTestAction::SWICertStore(TInt aIndex)
|
sl@0
|
292 |
{
|
sl@0
|
293 |
return CertStores()[aIndex]->AsSWICertStore();
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
|
sl@0
|
297 |
void CCertStoreTestAction::RemoveCertStore(TInt aIndex)
|
sl@0
|
298 |
{
|
sl@0
|
299 |
COpenCertStore* openStore = CertStores()[aIndex];
|
sl@0
|
300 |
TBool delCertstore = EFalse;
|
sl@0
|
301 |
|
sl@0
|
302 |
if (openStore->Type() == ESWICertStore)
|
sl@0
|
303 |
{
|
sl@0
|
304 |
delCertstore = ETrue;
|
sl@0
|
305 |
}
|
sl@0
|
306 |
|
sl@0
|
307 |
CertStores().Remove(aIndex);
|
sl@0
|
308 |
delete openStore;
|
sl@0
|
309 |
|
sl@0
|
310 |
if (delCertstore)
|
sl@0
|
311 |
{
|
sl@0
|
312 |
RTestUtilSession testutil;
|
sl@0
|
313 |
User::LeaveIfError(testutil.Connect());
|
sl@0
|
314 |
CleanupClosePushL(testutil);
|
sl@0
|
315 |
|
sl@0
|
316 |
TDriveUnit sysDrive (RFs::GetSystemDrive());
|
sl@0
|
317 |
TDriveName driveName(sysDrive.Name());
|
sl@0
|
318 |
TBuf<64> certstoreFile (driveName);
|
sl@0
|
319 |
certstoreFile.Append(_L("\\Resource\\SwiCertstore\\"));
|
sl@0
|
320 |
testutil.RmDir(certstoreFile);
|
sl@0
|
321 |
|
sl@0
|
322 |
CleanupStack::PopAndDestroy(&testutil);
|
sl@0
|
323 |
}
|
sl@0
|
324 |
}
|
sl@0
|
325 |
/////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
326 |
//CSubscriberAction base class
|
sl@0
|
327 |
/////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
328 |
CSubscriberAction::~CSubscriberAction()
|
sl@0
|
329 |
{
|
sl@0
|
330 |
if (iNotifier)
|
sl@0
|
331 |
delete iNotifier;
|
sl@0
|
332 |
}
|
sl@0
|
333 |
CSubscriberAction::CSubscriberAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut)
|
sl@0
|
334 |
:CCertStoreTestAction(aFs, aConsole, aOut)
|
sl@0
|
335 |
{
|
sl@0
|
336 |
}
|
sl@0
|
337 |
void CSubscriberAction::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
338 |
{
|
sl@0
|
339 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
340 |
TInt pos = 0;
|
sl@0
|
341 |
TInt err = KErrNone;
|
sl@0
|
342 |
TPtrC8 ptr1 = Input::ParseElement(aTestActionSpec.iActionBody, KChangeNotifiedStart, KChangeNotifiedEnd, pos, err);
|
sl@0
|
343 |
if (ptr1 != KNullDesC8)
|
sl@0
|
344 |
{
|
sl@0
|
345 |
TLex8 lexi(ptr1);
|
sl@0
|
346 |
TInt val;
|
sl@0
|
347 |
TInt ret=lexi.Val(val);
|
sl@0
|
348 |
if (val != 0)
|
sl@0
|
349 |
{
|
sl@0
|
350 |
iNotificationSubscribed=1;
|
sl@0
|
351 |
}
|
sl@0
|
352 |
}
|
sl@0
|
353 |
}
|
sl@0
|
354 |
/////////////////////////////////////////////////////////////////
|
sl@0
|
355 |
//CInitialiseCertStore::
|
sl@0
|
356 |
///////////////////////////////////////////////////////////////////
|
sl@0
|
357 |
CTestAction* CInitialiseCertStore::NewL(RFs& aFs,
|
sl@0
|
358 |
CConsoleBase& aConsole,
|
sl@0
|
359 |
Output& aOut,
|
sl@0
|
360 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
361 |
{
|
sl@0
|
362 |
CTestAction* self = CInitialiseCertStore::NewLC(aFs,
|
sl@0
|
363 |
aConsole, aOut, aTestActionSpec);
|
sl@0
|
364 |
CleanupStack::Pop(self);
|
sl@0
|
365 |
return self;
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
CTestAction* CInitialiseCertStore::NewLC(RFs& aFs,
|
sl@0
|
369 |
CConsoleBase& aConsole,
|
sl@0
|
370 |
Output& aOut,
|
sl@0
|
371 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
372 |
{
|
sl@0
|
373 |
CInitialiseCertStore* self = new(ELeave) CInitialiseCertStore(aFs, aConsole, aOut);
|
sl@0
|
374 |
CleanupStack::PushL(self);
|
sl@0
|
375 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
376 |
return self;
|
sl@0
|
377 |
}
|
sl@0
|
378 |
|
sl@0
|
379 |
CInitialiseCertStore::~CInitialiseCertStore()
|
sl@0
|
380 |
{
|
sl@0
|
381 |
delete iNewUnifiedCertStore;
|
sl@0
|
382 |
iFilterOrdering.Close();
|
sl@0
|
383 |
iExpectedOrderingResult.Close();
|
sl@0
|
384 |
}
|
sl@0
|
385 |
|
sl@0
|
386 |
CInitialiseCertStore::CInitialiseCertStore(RFs& aFs,
|
sl@0
|
387 |
CConsoleBase& aConsole,
|
sl@0
|
388 |
Output& aOut)
|
sl@0
|
389 |
|
sl@0
|
390 |
:CCertStoreTestAction(aFs, aConsole, aOut), iState(ENew)
|
sl@0
|
391 |
{
|
sl@0
|
392 |
}
|
sl@0
|
393 |
|
sl@0
|
394 |
void CInitialiseCertStore::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
395 |
{
|
sl@0
|
396 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
397 |
|
sl@0
|
398 |
TInt err = KErrNone;
|
sl@0
|
399 |
TInt pos = 0;
|
sl@0
|
400 |
TPtrC8 ptr =
|
sl@0
|
401 |
Input::ParseElement(aTestActionSpec.iActionBody, KModeStart, KModeEnd, pos, err);
|
sl@0
|
402 |
if (ptr == KNullDesC8)
|
sl@0
|
403 |
{
|
sl@0
|
404 |
User::Leave(KErrNotFound);
|
sl@0
|
405 |
}
|
sl@0
|
406 |
|
sl@0
|
407 |
if (ptr == _L8("read"))
|
sl@0
|
408 |
{
|
sl@0
|
409 |
iOpenedForWrite = EFalse;
|
sl@0
|
410 |
}
|
sl@0
|
411 |
else if (ptr == _L8("write"))
|
sl@0
|
412 |
{
|
sl@0
|
413 |
iOpenedForWrite = ETrue;
|
sl@0
|
414 |
}
|
sl@0
|
415 |
else
|
sl@0
|
416 |
{
|
sl@0
|
417 |
User::Leave(KErrNotSupported);
|
sl@0
|
418 |
}
|
sl@0
|
419 |
pos = 0;
|
sl@0
|
420 |
err = KErrNone;
|
sl@0
|
421 |
TPtrC8 ptr1 = Input::ParseElement(aTestActionSpec.iActionBody, KOrderingFilterStart, KOrderingFilterEnd, pos, err);
|
sl@0
|
422 |
if (ptr1 != KNullDesC8)
|
sl@0
|
423 |
{
|
sl@0
|
424 |
TInt lastPos=0;
|
sl@0
|
425 |
TInt startPos=0;
|
sl@0
|
426 |
TLex8 lexi;
|
sl@0
|
427 |
do
|
sl@0
|
428 |
{
|
sl@0
|
429 |
startPos=lastPos;
|
sl@0
|
430 |
while (lastPos<ptr1.Length() && ptr1[lastPos]!=',')
|
sl@0
|
431 |
{
|
sl@0
|
432 |
lastPos++;
|
sl@0
|
433 |
}
|
sl@0
|
434 |
TPtrC8 uidInA(&ptr1[startPos], lastPos-startPos);
|
sl@0
|
435 |
TLex8 lexi(uidInA);
|
sl@0
|
436 |
TInt32 uidInD=0;
|
sl@0
|
437 |
TInt err=lexi.Val(uidInD);
|
sl@0
|
438 |
User::LeaveIfError(iFilterOrdering.Append(uidInD));
|
sl@0
|
439 |
lastPos++;
|
sl@0
|
440 |
}
|
sl@0
|
441 |
while (lastPos < ptr1.Length());
|
sl@0
|
442 |
}
|
sl@0
|
443 |
pos = 0;
|
sl@0
|
444 |
err = KErrNone;
|
sl@0
|
445 |
TPtrC8 ptr2 = Input::ParseElement(aTestActionSpec.iActionResult, KOrderingResultStart, KOrderingResultEnd, pos, err);
|
sl@0
|
446 |
if (ptr2 != KNullDesC8)
|
sl@0
|
447 |
{
|
sl@0
|
448 |
TInt lastPos=0;
|
sl@0
|
449 |
TInt startPos=0;
|
sl@0
|
450 |
TLex8 lexi;
|
sl@0
|
451 |
do
|
sl@0
|
452 |
{
|
sl@0
|
453 |
startPos=lastPos;
|
sl@0
|
454 |
while (lastPos<ptr2.Length() && ptr2[lastPos]!=',')
|
sl@0
|
455 |
{
|
sl@0
|
456 |
lastPos++;
|
sl@0
|
457 |
}
|
sl@0
|
458 |
TPtrC8 uidInA(&ptr2[startPos], lastPos-startPos);
|
sl@0
|
459 |
TLex8 lexi(uidInA);
|
sl@0
|
460 |
TInt32 uidInD=0;
|
sl@0
|
461 |
TInt err=lexi.Val(uidInD);
|
sl@0
|
462 |
User::LeaveIfError(iExpectedOrderingResult.Append(uidInD));
|
sl@0
|
463 |
lastPos++;
|
sl@0
|
464 |
}
|
sl@0
|
465 |
while (lastPos < ptr2.Length());
|
sl@0
|
466 |
}
|
sl@0
|
467 |
pos = 0;
|
sl@0
|
468 |
err = KErrNone;
|
sl@0
|
469 |
|
sl@0
|
470 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
471 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
472 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
473 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
474 |
}
|
sl@0
|
475 |
|
sl@0
|
476 |
void CInitialiseCertStore::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
477 |
{
|
sl@0
|
478 |
if (aStatus != KErrNone)
|
sl@0
|
479 |
{
|
sl@0
|
480 |
iState = EFinished;
|
sl@0
|
481 |
}
|
sl@0
|
482 |
|
sl@0
|
483 |
switch (iState)
|
sl@0
|
484 |
{
|
sl@0
|
485 |
case ENew:
|
sl@0
|
486 |
__ASSERT_DEBUG(!iNewUnifiedCertStore, User::Panic(_L("CInitialiseCertStore"), 1));
|
sl@0
|
487 |
iNewUnifiedCertStore = CUnifiedCertStore::NewL(iFs, iOpenedForWrite, iFilterOrdering);
|
sl@0
|
488 |
|
sl@0
|
489 |
iNewUnifiedCertStore->Initialize(aStatus);
|
sl@0
|
490 |
iState = EAppend;
|
sl@0
|
491 |
break;
|
sl@0
|
492 |
|
sl@0
|
493 |
case EAppend:
|
sl@0
|
494 |
{
|
sl@0
|
495 |
AddCertStoreL(iNewUnifiedCertStore);
|
sl@0
|
496 |
iNewUnifiedCertStore = 0; // we don't own this any more
|
sl@0
|
497 |
if (iFilterOrdering.Count()==0)
|
sl@0
|
498 |
{
|
sl@0
|
499 |
iState = EFinished;
|
sl@0
|
500 |
}
|
sl@0
|
501 |
else
|
sl@0
|
502 |
{
|
sl@0
|
503 |
iState = ECheckOrder;
|
sl@0
|
504 |
}
|
sl@0
|
505 |
TRequestStatus* status = &aStatus;
|
sl@0
|
506 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
507 |
}
|
sl@0
|
508 |
break;
|
sl@0
|
509 |
|
sl@0
|
510 |
case ECheckOrder:
|
sl@0
|
511 |
{
|
sl@0
|
512 |
TInt ret=KErrNone;
|
sl@0
|
513 |
TInt count = UnifiedCertStore().CertStoreCount();
|
sl@0
|
514 |
MCTCertStore* p=NULL;
|
sl@0
|
515 |
TInt j=-1;
|
sl@0
|
516 |
TInt32 previous=0;
|
sl@0
|
517 |
TInt32 current=0;
|
sl@0
|
518 |
for (TInt i=0;i<count;i++)
|
sl@0
|
519 |
{
|
sl@0
|
520 |
p=&(UnifiedCertStore().CertStore(i));
|
sl@0
|
521 |
current = p->Token().TokenType().Type().iUid;
|
sl@0
|
522 |
if (previous != current)
|
sl@0
|
523 |
{
|
sl@0
|
524 |
j++;
|
sl@0
|
525 |
previous = current;
|
sl@0
|
526 |
}
|
sl@0
|
527 |
TInt32 l1=iExpectedOrderingResult[j];
|
sl@0
|
528 |
if (current != iExpectedOrderingResult[j])
|
sl@0
|
529 |
{
|
sl@0
|
530 |
ret=KErrNotFound;
|
sl@0
|
531 |
break;
|
sl@0
|
532 |
}
|
sl@0
|
533 |
}
|
sl@0
|
534 |
if (count<iExpectedOrderingResult.Count())
|
sl@0
|
535 |
{
|
sl@0
|
536 |
ret=KErrNotFound;
|
sl@0
|
537 |
}
|
sl@0
|
538 |
iState = EFinished;
|
sl@0
|
539 |
TRequestStatus* status = &aStatus;
|
sl@0
|
540 |
User::RequestComplete(status, ret);
|
sl@0
|
541 |
}
|
sl@0
|
542 |
break;
|
sl@0
|
543 |
case EFinished:
|
sl@0
|
544 |
{
|
sl@0
|
545 |
TRequestStatus* status = &aStatus;
|
sl@0
|
546 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
547 |
if (aStatus == iExpectedResult)
|
sl@0
|
548 |
{
|
sl@0
|
549 |
iResult = ETrue;
|
sl@0
|
550 |
}
|
sl@0
|
551 |
else
|
sl@0
|
552 |
{
|
sl@0
|
553 |
iResult = EFalse;
|
sl@0
|
554 |
}
|
sl@0
|
555 |
if (aStatus == KErrNoMemory)
|
sl@0
|
556 |
{
|
sl@0
|
557 |
iState = ENew;
|
sl@0
|
558 |
}
|
sl@0
|
559 |
else
|
sl@0
|
560 |
{
|
sl@0
|
561 |
iFinished = ETrue;
|
sl@0
|
562 |
}
|
sl@0
|
563 |
}
|
sl@0
|
564 |
break;
|
sl@0
|
565 |
}
|
sl@0
|
566 |
}
|
sl@0
|
567 |
|
sl@0
|
568 |
void CInitialiseCertStore::PerformCancel()
|
sl@0
|
569 |
{
|
sl@0
|
570 |
switch (iState)
|
sl@0
|
571 |
{
|
sl@0
|
572 |
case EAppend:
|
sl@0
|
573 |
ASSERT(iNewUnifiedCertStore);
|
sl@0
|
574 |
iNewUnifiedCertStore->CancelInitialize();
|
sl@0
|
575 |
break;
|
sl@0
|
576 |
|
sl@0
|
577 |
default:
|
sl@0
|
578 |
// do nothing
|
sl@0
|
579 |
break;
|
sl@0
|
580 |
}
|
sl@0
|
581 |
}
|
sl@0
|
582 |
|
sl@0
|
583 |
void CInitialiseCertStore::Reset()
|
sl@0
|
584 |
{
|
sl@0
|
585 |
iState = ENew;
|
sl@0
|
586 |
delete iNewUnifiedCertStore;
|
sl@0
|
587 |
iNewUnifiedCertStore = 0;
|
sl@0
|
588 |
}
|
sl@0
|
589 |
|
sl@0
|
590 |
void CInitialiseCertStore::DoReportAction()
|
sl@0
|
591 |
{
|
sl@0
|
592 |
iOut.writeString(_L("Initializing certstore manager..."));
|
sl@0
|
593 |
iOut.writeNewLine();
|
sl@0
|
594 |
}
|
sl@0
|
595 |
|
sl@0
|
596 |
void CInitialiseCertStore::DoCheckResult(TInt aError)
|
sl@0
|
597 |
{
|
sl@0
|
598 |
if (iFinished)
|
sl@0
|
599 |
{
|
sl@0
|
600 |
if (aError == KErrNone)
|
sl@0
|
601 |
{
|
sl@0
|
602 |
iConsole.Write(_L("\tstore manager initialised successfully\n"));
|
sl@0
|
603 |
iOut.writeString(_L("\tstore manager initialised successfully"));
|
sl@0
|
604 |
iOut.writeNewLine();
|
sl@0
|
605 |
iOut.writeNewLine();
|
sl@0
|
606 |
}
|
sl@0
|
607 |
else if (aError == KErrInUse)
|
sl@0
|
608 |
{
|
sl@0
|
609 |
iConsole.Write(_L("\tstore manager initialised error : KErrInUse\n"));
|
sl@0
|
610 |
iOut.writeString(_L("\tstore manager initialization error : KErrInUse"));
|
sl@0
|
611 |
iOut.writeNewLine();
|
sl@0
|
612 |
iOut.writeNewLine();
|
sl@0
|
613 |
}
|
sl@0
|
614 |
}
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
/////////////////////////////////////////////////////////////////
|
sl@0
|
618 |
//COnlyCreateCertStore::
|
sl@0
|
619 |
///////////////////////////////////////////////////////////////////
|
sl@0
|
620 |
|
sl@0
|
621 |
CTestAction* COnlyCreateCertStore::NewL(RFs& aFs,
|
sl@0
|
622 |
CConsoleBase& aConsole,
|
sl@0
|
623 |
Output& aOut,
|
sl@0
|
624 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
625 |
{
|
sl@0
|
626 |
COnlyCreateCertStore* self = new(ELeave) COnlyCreateCertStore(aFs, aConsole, aOut);
|
sl@0
|
627 |
CleanupStack::PushL(self);
|
sl@0
|
628 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
629 |
CleanupStack::Pop(self);
|
sl@0
|
630 |
return self;
|
sl@0
|
631 |
}
|
sl@0
|
632 |
|
sl@0
|
633 |
COnlyCreateCertStore::COnlyCreateCertStore(RFs& aFs,
|
sl@0
|
634 |
CConsoleBase& aConsole,
|
sl@0
|
635 |
Output& aOut)
|
sl@0
|
636 |
:CCertStoreTestAction(aFs, aConsole, aOut), iState(EInit)
|
sl@0
|
637 |
{
|
sl@0
|
638 |
}
|
sl@0
|
639 |
|
sl@0
|
640 |
void COnlyCreateCertStore::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
641 |
{
|
sl@0
|
642 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
643 |
|
sl@0
|
644 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
645 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
646 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
647 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
648 |
}
|
sl@0
|
649 |
|
sl@0
|
650 |
void COnlyCreateCertStore::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
651 |
{
|
sl@0
|
652 |
switch (iState)
|
sl@0
|
653 |
{
|
sl@0
|
654 |
case EInit:
|
sl@0
|
655 |
{
|
sl@0
|
656 |
__ASSERT_DEBUG(!iNewUnifiedCertStore, User::Panic(_L("CInitialiseCertStore"), 1));
|
sl@0
|
657 |
TRAPD(err, iNewUnifiedCertStore = CUnifiedCertStore::NewL(iFs, ETrue));
|
sl@0
|
658 |
if (err != KErrNone)
|
sl@0
|
659 |
{
|
sl@0
|
660 |
iState = EFinished;
|
sl@0
|
661 |
TRequestStatus* status = &aStatus;
|
sl@0
|
662 |
User::RequestComplete(status, err);
|
sl@0
|
663 |
}
|
sl@0
|
664 |
else
|
sl@0
|
665 |
{
|
sl@0
|
666 |
AddCertStoreL(iNewUnifiedCertStore);
|
sl@0
|
667 |
iNewUnifiedCertStore = 0; // we don't own this any more
|
sl@0
|
668 |
iState = EFinished;
|
sl@0
|
669 |
TRequestStatus* status = &aStatus;
|
sl@0
|
670 |
User::RequestComplete(status, err);
|
sl@0
|
671 |
}
|
sl@0
|
672 |
}
|
sl@0
|
673 |
break;
|
sl@0
|
674 |
|
sl@0
|
675 |
case EFinished:
|
sl@0
|
676 |
{
|
sl@0
|
677 |
TRequestStatus* status = &aStatus;
|
sl@0
|
678 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
679 |
if (aStatus == iExpectedResult)
|
sl@0
|
680 |
{
|
sl@0
|
681 |
iResult = ETrue;
|
sl@0
|
682 |
}
|
sl@0
|
683 |
else
|
sl@0
|
684 |
{
|
sl@0
|
685 |
iResult = EFalse;
|
sl@0
|
686 |
}
|
sl@0
|
687 |
if (aStatus == KErrNoMemory)
|
sl@0
|
688 |
{
|
sl@0
|
689 |
iState = EInit;
|
sl@0
|
690 |
}
|
sl@0
|
691 |
else
|
sl@0
|
692 |
{
|
sl@0
|
693 |
iFinished = ETrue;
|
sl@0
|
694 |
}
|
sl@0
|
695 |
}
|
sl@0
|
696 |
break;
|
sl@0
|
697 |
}
|
sl@0
|
698 |
}
|
sl@0
|
699 |
|
sl@0
|
700 |
void COnlyCreateCertStore::PerformCancel()
|
sl@0
|
701 |
{
|
sl@0
|
702 |
}
|
sl@0
|
703 |
|
sl@0
|
704 |
void COnlyCreateCertStore::Reset()
|
sl@0
|
705 |
{
|
sl@0
|
706 |
__ASSERT_DEBUG(EFalse, User::Panic(_L("COnlyCreateCertStore::Reset()"), 1));
|
sl@0
|
707 |
}
|
sl@0
|
708 |
|
sl@0
|
709 |
void COnlyCreateCertStore::DoReportAction()
|
sl@0
|
710 |
{
|
sl@0
|
711 |
iOut.writeString(_L("Only creating certstore manager..."));
|
sl@0
|
712 |
iOut.writeNewLine();
|
sl@0
|
713 |
}
|
sl@0
|
714 |
|
sl@0
|
715 |
void COnlyCreateCertStore::DoCheckResult(TInt aError)
|
sl@0
|
716 |
{
|
sl@0
|
717 |
if (iFinished)
|
sl@0
|
718 |
{
|
sl@0
|
719 |
if (aError == KErrNone)
|
sl@0
|
720 |
{
|
sl@0
|
721 |
iConsole.Write(_L("\tstore manager created successfully\n"));
|
sl@0
|
722 |
iOut.writeString(_L("\tstore manager created successfully"));
|
sl@0
|
723 |
iOut.writeNewLine();
|
sl@0
|
724 |
iOut.writeNewLine();
|
sl@0
|
725 |
}
|
sl@0
|
726 |
else if (aError == KErrInUse)
|
sl@0
|
727 |
{
|
sl@0
|
728 |
iConsole.Write(_L("\tstore manager creation error : KErrInUse\n"));
|
sl@0
|
729 |
iOut.writeString(_L("\tstore manager creation error : KErrInUse"));
|
sl@0
|
730 |
iOut.writeNewLine();
|
sl@0
|
731 |
iOut.writeNewLine();
|
sl@0
|
732 |
}
|
sl@0
|
733 |
}
|
sl@0
|
734 |
}
|
sl@0
|
735 |
|
sl@0
|
736 |
/////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
737 |
// CDeleteCertStore
|
sl@0
|
738 |
/////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
739 |
|
sl@0
|
740 |
CTestAction* CDeleteCertStore::NewL(RFs& aFs,
|
sl@0
|
741 |
CConsoleBase& aConsole,
|
sl@0
|
742 |
Output& aOut,
|
sl@0
|
743 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
744 |
{
|
sl@0
|
745 |
CTestAction* self = CDeleteCertStore::NewLC(aFs, aConsole, aOut, aTestActionSpec);
|
sl@0
|
746 |
CleanupStack::Pop(self);
|
sl@0
|
747 |
return self;
|
sl@0
|
748 |
}
|
sl@0
|
749 |
|
sl@0
|
750 |
CTestAction* CDeleteCertStore::NewLC(RFs& aFs,
|
sl@0
|
751 |
CConsoleBase& aConsole,
|
sl@0
|
752 |
Output& aOut,
|
sl@0
|
753 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
754 |
{
|
sl@0
|
755 |
CDeleteCertStore* self = new(ELeave) CDeleteCertStore(aFs, aConsole, aOut);
|
sl@0
|
756 |
CleanupStack::PushL(self);
|
sl@0
|
757 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
758 |
return self;
|
sl@0
|
759 |
}
|
sl@0
|
760 |
|
sl@0
|
761 |
CDeleteCertStore::~CDeleteCertStore()
|
sl@0
|
762 |
{
|
sl@0
|
763 |
}
|
sl@0
|
764 |
|
sl@0
|
765 |
CDeleteCertStore::CDeleteCertStore(RFs& aFs, CConsoleBase& aConsole, Output& aOut)
|
sl@0
|
766 |
: CCertStoreTestAction(aFs, aConsole, aOut), iState(EDelete)
|
sl@0
|
767 |
{
|
sl@0
|
768 |
}
|
sl@0
|
769 |
|
sl@0
|
770 |
void CDeleteCertStore::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
771 |
{
|
sl@0
|
772 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
773 |
|
sl@0
|
774 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
775 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
776 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
777 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
778 |
}
|
sl@0
|
779 |
|
sl@0
|
780 |
void CDeleteCertStore::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
781 |
{
|
sl@0
|
782 |
switch (iState)
|
sl@0
|
783 |
{
|
sl@0
|
784 |
case EDelete:
|
sl@0
|
785 |
{
|
sl@0
|
786 |
TInt err = KErrNotFound;
|
sl@0
|
787 |
TInt count = CertStoreCount();
|
sl@0
|
788 |
if (count)
|
sl@0
|
789 |
{
|
sl@0
|
790 |
RemoveCertStore(count - 1);
|
sl@0
|
791 |
err = KErrNone;
|
sl@0
|
792 |
}
|
sl@0
|
793 |
iState = EFinished;
|
sl@0
|
794 |
TRequestStatus* status = &aStatus;
|
sl@0
|
795 |
User::RequestComplete(status, err);
|
sl@0
|
796 |
}
|
sl@0
|
797 |
break;
|
sl@0
|
798 |
|
sl@0
|
799 |
case EFinished:
|
sl@0
|
800 |
{
|
sl@0
|
801 |
TRequestStatus* status = &aStatus;
|
sl@0
|
802 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
803 |
if (aStatus == iExpectedResult)
|
sl@0
|
804 |
{
|
sl@0
|
805 |
iResult = ETrue;
|
sl@0
|
806 |
}
|
sl@0
|
807 |
else
|
sl@0
|
808 |
{
|
sl@0
|
809 |
iResult = EFalse;
|
sl@0
|
810 |
}
|
sl@0
|
811 |
if (aStatus == KErrNoMemory)
|
sl@0
|
812 |
{
|
sl@0
|
813 |
iState = EDelete;
|
sl@0
|
814 |
}
|
sl@0
|
815 |
else
|
sl@0
|
816 |
{
|
sl@0
|
817 |
iFinished = ETrue;
|
sl@0
|
818 |
}
|
sl@0
|
819 |
}
|
sl@0
|
820 |
break;
|
sl@0
|
821 |
}
|
sl@0
|
822 |
}
|
sl@0
|
823 |
|
sl@0
|
824 |
void CDeleteCertStore::PerformCancel()
|
sl@0
|
825 |
{
|
sl@0
|
826 |
iState = EDelete;
|
sl@0
|
827 |
}
|
sl@0
|
828 |
|
sl@0
|
829 |
void CDeleteCertStore::Reset()
|
sl@0
|
830 |
{
|
sl@0
|
831 |
}
|
sl@0
|
832 |
|
sl@0
|
833 |
void CDeleteCertStore::DoReportAction()
|
sl@0
|
834 |
{
|
sl@0
|
835 |
iOut.writeString(_L("Deleting certstore manager..."));
|
sl@0
|
836 |
iOut.writeNewLine();
|
sl@0
|
837 |
}
|
sl@0
|
838 |
|
sl@0
|
839 |
void CDeleteCertStore::DoCheckResult(TInt aError)
|
sl@0
|
840 |
{
|
sl@0
|
841 |
if (iFinished)
|
sl@0
|
842 |
{
|
sl@0
|
843 |
if (aError == KErrNone)
|
sl@0
|
844 |
{
|
sl@0
|
845 |
iConsole.Write(_L("\tstore manager deleted successfully\n"));
|
sl@0
|
846 |
iOut.writeString(_L("\tstore manager deleted successfully"));
|
sl@0
|
847 |
iOut.writeNewLine();
|
sl@0
|
848 |
iOut.writeNewLine();
|
sl@0
|
849 |
}
|
sl@0
|
850 |
else
|
sl@0
|
851 |
{
|
sl@0
|
852 |
iConsole.Write(_L("\tstore manager deleted failed\n"));
|
sl@0
|
853 |
iOut.writeString(_L("\tstore manager deleted failed"));
|
sl@0
|
854 |
iOut.writeNewLine();
|
sl@0
|
855 |
iOut.writeNewLine();
|
sl@0
|
856 |
}
|
sl@0
|
857 |
}
|
sl@0
|
858 |
}
|
sl@0
|
859 |
|
sl@0
|
860 |
CSetAppsAndTrust::~CSetAppsAndTrust()
|
sl@0
|
861 |
{
|
sl@0
|
862 |
delete iFilter;
|
sl@0
|
863 |
iCertInfos.Close();
|
sl@0
|
864 |
}
|
sl@0
|
865 |
|
sl@0
|
866 |
void CSetAppsAndTrust::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
867 |
{
|
sl@0
|
868 |
switch (iState)
|
sl@0
|
869 |
{
|
sl@0
|
870 |
case EGetCAEntries:
|
sl@0
|
871 |
iState = ESetAppTrust;
|
sl@0
|
872 |
GetCerts(aStatus);
|
sl@0
|
873 |
break;
|
sl@0
|
874 |
|
sl@0
|
875 |
case ESetAppTrust:
|
sl@0
|
876 |
{
|
sl@0
|
877 |
// Find the certificate we want to set the trust settings for
|
sl@0
|
878 |
// and edit its trust settings
|
sl@0
|
879 |
iState = EFinished;
|
sl@0
|
880 |
TInt iEnd = iCertInfos.Count();
|
sl@0
|
881 |
for (TInt i = 0; i < iEnd; i++)
|
sl@0
|
882 |
{
|
sl@0
|
883 |
if (iCertInfos[i]->Label() == iLabel)
|
sl@0
|
884 |
{
|
sl@0
|
885 |
if (iNotificationSubscribed)
|
sl@0
|
886 |
{
|
sl@0
|
887 |
if (!iNotifier)
|
sl@0
|
888 |
{
|
sl@0
|
889 |
iNotifier = CCertStoreChangeNotifier::NewL(iNotifierFlag);
|
sl@0
|
890 |
iNotifier->StartNotification();
|
sl@0
|
891 |
}
|
sl@0
|
892 |
iState = ECheckNotification;
|
sl@0
|
893 |
}
|
sl@0
|
894 |
else
|
sl@0
|
895 |
{
|
sl@0
|
896 |
iState = EFinished;
|
sl@0
|
897 |
}
|
sl@0
|
898 |
DoSetAppTrust(*iCertInfos[i], aStatus);
|
sl@0
|
899 |
return;
|
sl@0
|
900 |
}
|
sl@0
|
901 |
}
|
sl@0
|
902 |
TRequestStatus* status = &aStatus;
|
sl@0
|
903 |
User::RequestComplete(status, KErrNotFound);
|
sl@0
|
904 |
}
|
sl@0
|
905 |
break;
|
sl@0
|
906 |
|
sl@0
|
907 |
case ECheckNotification:
|
sl@0
|
908 |
{
|
sl@0
|
909 |
iState = EFinished;
|
sl@0
|
910 |
if (iNotifierFlag)
|
sl@0
|
911 |
{
|
sl@0
|
912 |
TRequestStatus* status = &aStatus;
|
sl@0
|
913 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
914 |
}
|
sl@0
|
915 |
else
|
sl@0
|
916 |
{
|
sl@0
|
917 |
iNotifier->SetCompleteStatus(&aStatus);
|
sl@0
|
918 |
}
|
sl@0
|
919 |
}
|
sl@0
|
920 |
break;
|
sl@0
|
921 |
case EFinished:
|
sl@0
|
922 |
{
|
sl@0
|
923 |
if (!iNotifierFlag && iNotificationSubscribed)
|
sl@0
|
924 |
{
|
sl@0
|
925 |
iResult = EFalse;
|
sl@0
|
926 |
}
|
sl@0
|
927 |
else
|
sl@0
|
928 |
{
|
sl@0
|
929 |
if (aStatus == iExpectedResult)
|
sl@0
|
930 |
{
|
sl@0
|
931 |
iResult = ETrue;
|
sl@0
|
932 |
}
|
sl@0
|
933 |
else
|
sl@0
|
934 |
{
|
sl@0
|
935 |
iResult = EFalse;
|
sl@0
|
936 |
}
|
sl@0
|
937 |
}
|
sl@0
|
938 |
|
sl@0
|
939 |
iFinished = ETrue;
|
sl@0
|
940 |
|
sl@0
|
941 |
TRequestStatus* status = &aStatus;
|
sl@0
|
942 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
943 |
}
|
sl@0
|
944 |
break;
|
sl@0
|
945 |
|
sl@0
|
946 |
default:
|
sl@0
|
947 |
User::Invariant();
|
sl@0
|
948 |
break;
|
sl@0
|
949 |
}
|
sl@0
|
950 |
}
|
sl@0
|
951 |
|
sl@0
|
952 |
void CSetAppsAndTrust::PerformCancel()
|
sl@0
|
953 |
{
|
sl@0
|
954 |
switch (iState)
|
sl@0
|
955 |
{
|
sl@0
|
956 |
case ESetAppTrust:
|
sl@0
|
957 |
CertStore().CancelList();
|
sl@0
|
958 |
break;
|
sl@0
|
959 |
case ECheckNotification:
|
sl@0
|
960 |
case EFinished:
|
sl@0
|
961 |
DoPerformCancel();
|
sl@0
|
962 |
break;
|
sl@0
|
963 |
|
sl@0
|
964 |
default:
|
sl@0
|
965 |
// do nothing
|
sl@0
|
966 |
break;
|
sl@0
|
967 |
}
|
sl@0
|
968 |
}
|
sl@0
|
969 |
|
sl@0
|
970 |
void CSetAppsAndTrust::Reset()
|
sl@0
|
971 |
{
|
sl@0
|
972 |
iState = EGetCAEntries;
|
sl@0
|
973 |
iCertInfos.Close();
|
sl@0
|
974 |
}
|
sl@0
|
975 |
|
sl@0
|
976 |
CSetAppsAndTrust::CSetAppsAndTrust(RFs& aFs, CConsoleBase& aConsole, Output& aOut)
|
sl@0
|
977 |
: CSubscriberAction(aFs, aConsole, aOut), iState(EGetCAEntries)
|
sl@0
|
978 |
|
sl@0
|
979 |
{
|
sl@0
|
980 |
}
|
sl@0
|
981 |
|
sl@0
|
982 |
void CSetAppsAndTrust::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
983 |
{
|
sl@0
|
984 |
CSubscriberAction::ConstructL(aTestActionSpec);
|
sl@0
|
985 |
iFilter = CCertAttributeFilter::NewL();
|
sl@0
|
986 |
|
sl@0
|
987 |
// Let derived class do its own parsing
|
sl@0
|
988 |
}
|
sl@0
|
989 |
|
sl@0
|
990 |
void CSetAppsAndTrust::GetCerts(TRequestStatus& aStatus)
|
sl@0
|
991 |
{
|
sl@0
|
992 |
CertStore().List(iCertInfos, *iFilter, aStatus);
|
sl@0
|
993 |
}
|
sl@0
|
994 |
|
sl@0
|
995 |
void CSetAppsAndTrust::SetCertLabel(const TDesC8& aLabel)
|
sl@0
|
996 |
{
|
sl@0
|
997 |
iLabel.Copy(aLabel);
|
sl@0
|
998 |
}
|
sl@0
|
999 |
|
sl@0
|
1000 |
CTestAction* CSetApplications::NewL(RFs& aFs,
|
sl@0
|
1001 |
CConsoleBase& aConsole,
|
sl@0
|
1002 |
Output& aOut,
|
sl@0
|
1003 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
1004 |
{
|
sl@0
|
1005 |
CSetApplications* self = new(ELeave) CSetApplications(aFs, aConsole, aOut);
|
sl@0
|
1006 |
CleanupStack::PushL(self);
|
sl@0
|
1007 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
1008 |
CleanupStack::Pop(self);
|
sl@0
|
1009 |
return self;
|
sl@0
|
1010 |
}
|
sl@0
|
1011 |
|
sl@0
|
1012 |
CSetApplications::~CSetApplications()
|
sl@0
|
1013 |
{
|
sl@0
|
1014 |
iApplications.Close();
|
sl@0
|
1015 |
}
|
sl@0
|
1016 |
|
sl@0
|
1017 |
CSetApplications::CSetApplications(RFs& aFs, CConsoleBase& aConsole,
|
sl@0
|
1018 |
Output& aOut)
|
sl@0
|
1019 |
: CSetAppsAndTrust(aFs, aConsole, aOut)
|
sl@0
|
1020 |
{
|
sl@0
|
1021 |
}
|
sl@0
|
1022 |
|
sl@0
|
1023 |
void CSetApplications::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
1024 |
{
|
sl@0
|
1025 |
CSetAppsAndTrust::ConstructL(aTestActionSpec);
|
sl@0
|
1026 |
|
sl@0
|
1027 |
TInt err = KErrNone;
|
sl@0
|
1028 |
TInt pos = 0;
|
sl@0
|
1029 |
SetCertLabel(Input::ParseElement(aTestActionSpec.iActionBody,
|
sl@0
|
1030 |
KCertLabelStart, KCertLabelEnd, pos, err));
|
sl@0
|
1031 |
AppendUid(Input::ParseElement(aTestActionSpec.iActionBody, KUIDStart, KUIDEnd, pos, err));
|
sl@0
|
1032 |
// Set expected result
|
sl@0
|
1033 |
pos = 0;
|
sl@0
|
1034 |
|
sl@0
|
1035 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
1036 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
1037 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
1038 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
1039 |
}
|
sl@0
|
1040 |
|
sl@0
|
1041 |
void CSetApplications::AppendUid(const TDesC8& aUid)
|
sl@0
|
1042 |
{
|
sl@0
|
1043 |
TLex8 lex(aUid);
|
sl@0
|
1044 |
|
sl@0
|
1045 |
TInt err = KErrNone;
|
sl@0
|
1046 |
while (err == KErrNone)
|
sl@0
|
1047 |
{
|
sl@0
|
1048 |
TUid u ;
|
sl@0
|
1049 |
err = lex.Val(u.iUid);
|
sl@0
|
1050 |
if (err == KErrNone)
|
sl@0
|
1051 |
{
|
sl@0
|
1052 |
lex.SkipSpace();
|
sl@0
|
1053 |
User::LeaveIfError(iApplications.Append(u));
|
sl@0
|
1054 |
}
|
sl@0
|
1055 |
}
|
sl@0
|
1056 |
}
|
sl@0
|
1057 |
|
sl@0
|
1058 |
void CSetApplications::DoSetAppTrust(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus)
|
sl@0
|
1059 |
{
|
sl@0
|
1060 |
UnifiedCertStore().SetApplicability(aCertInfo, iApplications, aStatus);
|
sl@0
|
1061 |
}
|
sl@0
|
1062 |
|
sl@0
|
1063 |
void CSetApplications::DoPerformCancel()
|
sl@0
|
1064 |
{
|
sl@0
|
1065 |
UnifiedCertStore().CancelSetApplicability();
|
sl@0
|
1066 |
}
|
sl@0
|
1067 |
|
sl@0
|
1068 |
void CSetApplications::DoReportAction()
|
sl@0
|
1069 |
{
|
sl@0
|
1070 |
iOut.writeString(_L("Setting Application settings..."));
|
sl@0
|
1071 |
iOut.writeNewLine();
|
sl@0
|
1072 |
iOut.writeString(_L("\tLabel = "));
|
sl@0
|
1073 |
iOut.writeString(iLabel);
|
sl@0
|
1074 |
iOut.writeNewLine();
|
sl@0
|
1075 |
iOut.writeString(_L("\tApplications = "));
|
sl@0
|
1076 |
TInt count = iApplications.Count();
|
sl@0
|
1077 |
for (TInt i = 0; i < count; i++)
|
sl@0
|
1078 |
{
|
sl@0
|
1079 |
iOut.writeNum(iApplications[i].iUid);
|
sl@0
|
1080 |
iOut.writeString(_L(" "));
|
sl@0
|
1081 |
}
|
sl@0
|
1082 |
iOut.writeNewLine();
|
sl@0
|
1083 |
iOut.writeNewLine();
|
sl@0
|
1084 |
}
|
sl@0
|
1085 |
|
sl@0
|
1086 |
void CSetApplications::DoCheckResult(TInt /*aError*/)
|
sl@0
|
1087 |
{
|
sl@0
|
1088 |
if (iFinished)
|
sl@0
|
1089 |
{
|
sl@0
|
1090 |
if (iResult)
|
sl@0
|
1091 |
{
|
sl@0
|
1092 |
iConsole.Write(_L("\tapplications set successfully\n"));
|
sl@0
|
1093 |
iOut.writeString(_L("\tapplications set successfully"));
|
sl@0
|
1094 |
iOut.writeNewLine();
|
sl@0
|
1095 |
iOut.writeNewLine();
|
sl@0
|
1096 |
}
|
sl@0
|
1097 |
else
|
sl@0
|
1098 |
{
|
sl@0
|
1099 |
iConsole.Write(_L("\tapplications set failed\n"));
|
sl@0
|
1100 |
iOut.writeString(_L("\tapplications set failed"));
|
sl@0
|
1101 |
iOut.writeNewLine();
|
sl@0
|
1102 |
iOut.writeNewLine();
|
sl@0
|
1103 |
}
|
sl@0
|
1104 |
}
|
sl@0
|
1105 |
}
|
sl@0
|
1106 |
|
sl@0
|
1107 |
CTestAction* CSetTrusters::NewL(RFs& aFs,
|
sl@0
|
1108 |
CConsoleBase& aConsole,
|
sl@0
|
1109 |
Output& aOut,
|
sl@0
|
1110 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
1111 |
{
|
sl@0
|
1112 |
CSetTrusters* self = new(ELeave) CSetTrusters(aFs, aConsole, aOut);
|
sl@0
|
1113 |
CleanupStack::PushL(self);
|
sl@0
|
1114 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
1115 |
CleanupStack::Pop(self);
|
sl@0
|
1116 |
return self;
|
sl@0
|
1117 |
}
|
sl@0
|
1118 |
|
sl@0
|
1119 |
CSetTrusters::~CSetTrusters()
|
sl@0
|
1120 |
{
|
sl@0
|
1121 |
}
|
sl@0
|
1122 |
|
sl@0
|
1123 |
|
sl@0
|
1124 |
CSetTrusters::CSetTrusters(RFs& aFs, CConsoleBase& aConsole,
|
sl@0
|
1125 |
Output& aOut)
|
sl@0
|
1126 |
: CSetAppsAndTrust(aFs, aConsole, aOut)
|
sl@0
|
1127 |
{
|
sl@0
|
1128 |
}
|
sl@0
|
1129 |
|
sl@0
|
1130 |
void CSetTrusters::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
1131 |
{
|
sl@0
|
1132 |
CSetAppsAndTrust::ConstructL(aTestActionSpec);
|
sl@0
|
1133 |
|
sl@0
|
1134 |
TInt err = KErrNone;
|
sl@0
|
1135 |
TInt pos = 0;
|
sl@0
|
1136 |
SetCertLabel(Input::ParseElement(aTestActionSpec.iActionBody, KCertLabelStart, KCertLabelEnd, pos, err));
|
sl@0
|
1137 |
SetTrusted(Input::ParseElement(aTestActionSpec.iActionBody, KTrustersStart, KTrustersEnd, pos, err));
|
sl@0
|
1138 |
// Set expected result
|
sl@0
|
1139 |
pos = 0;
|
sl@0
|
1140 |
|
sl@0
|
1141 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
1142 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
1143 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
1144 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
1145 |
}
|
sl@0
|
1146 |
|
sl@0
|
1147 |
void CSetTrusters::SetTrusted(const TDesC8& aTrusted)
|
sl@0
|
1148 |
{
|
sl@0
|
1149 |
TLex8 lex(aTrusted);
|
sl@0
|
1150 |
|
sl@0
|
1151 |
TInt err = KErrNone;
|
sl@0
|
1152 |
while (err == KErrNone)
|
sl@0
|
1153 |
{
|
sl@0
|
1154 |
TInt val;
|
sl@0
|
1155 |
err = lex.Val(val);
|
sl@0
|
1156 |
if (err == KErrNone)
|
sl@0
|
1157 |
{
|
sl@0
|
1158 |
iTrusted = static_cast<TBool>(val);
|
sl@0
|
1159 |
}
|
sl@0
|
1160 |
}
|
sl@0
|
1161 |
}
|
sl@0
|
1162 |
|
sl@0
|
1163 |
void CSetTrusters::DoSetAppTrust(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus)
|
sl@0
|
1164 |
{
|
sl@0
|
1165 |
UnifiedCertStore().SetTrust(aCertInfo, iTrusted, aStatus);
|
sl@0
|
1166 |
}
|
sl@0
|
1167 |
|
sl@0
|
1168 |
void CSetTrusters::DoPerformCancel()
|
sl@0
|
1169 |
{
|
sl@0
|
1170 |
UnifiedCertStore().CancelSetTrust();
|
sl@0
|
1171 |
}
|
sl@0
|
1172 |
|
sl@0
|
1173 |
void CSetTrusters::DoReportAction()
|
sl@0
|
1174 |
{
|
sl@0
|
1175 |
iOut.writeString(_L("Setting trust..."));
|
sl@0
|
1176 |
iOut.writeNewLine();
|
sl@0
|
1177 |
iOut.writeString(_L("\tLabel = "));
|
sl@0
|
1178 |
iOut.writeString(iLabel);
|
sl@0
|
1179 |
iOut.writeNewLine();
|
sl@0
|
1180 |
iOut.writeNewLine();
|
sl@0
|
1181 |
}
|
sl@0
|
1182 |
|
sl@0
|
1183 |
void CSetTrusters::DoCheckResult(TInt aError)
|
sl@0
|
1184 |
{
|
sl@0
|
1185 |
if (iFinished)
|
sl@0
|
1186 |
{
|
sl@0
|
1187 |
if (iResult && aError == KErrNone)
|
sl@0
|
1188 |
{
|
sl@0
|
1189 |
iConsole.Write(_L("\ttrust set successfully\n"));
|
sl@0
|
1190 |
iOut.writeString(_L("\ttrust set successfully"));
|
sl@0
|
1191 |
iOut.writeNewLine();
|
sl@0
|
1192 |
iOut.writeNewLine();
|
sl@0
|
1193 |
}
|
sl@0
|
1194 |
else
|
sl@0
|
1195 |
{
|
sl@0
|
1196 |
iConsole.Write(_L("\ttrust set failed\n"));
|
sl@0
|
1197 |
iOut.writeString(_L("\ttrust set failed"));
|
sl@0
|
1198 |
iOut.writeNewLine();
|
sl@0
|
1199 |
iOut.writeNewLine();
|
sl@0
|
1200 |
}
|
sl@0
|
1201 |
}
|
sl@0
|
1202 |
}
|
sl@0
|
1203 |
|
sl@0
|
1204 |
CTestAction* CGetTrusters::NewL(RFs& aFs,
|
sl@0
|
1205 |
CConsoleBase& aConsole,
|
sl@0
|
1206 |
Output& aOut,
|
sl@0
|
1207 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
1208 |
{
|
sl@0
|
1209 |
CGetTrusters* self = new(ELeave) CGetTrusters(aFs, aConsole, aOut);
|
sl@0
|
1210 |
CleanupStack::PushL(self);
|
sl@0
|
1211 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
1212 |
CleanupStack::Pop(self);
|
sl@0
|
1213 |
return self;
|
sl@0
|
1214 |
}
|
sl@0
|
1215 |
|
sl@0
|
1216 |
CGetTrusters::~CGetTrusters()
|
sl@0
|
1217 |
{
|
sl@0
|
1218 |
iCertInfos.Close();
|
sl@0
|
1219 |
iTrusters.Close();
|
sl@0
|
1220 |
iExpectedTrusters.Close();
|
sl@0
|
1221 |
delete iFilter;
|
sl@0
|
1222 |
}
|
sl@0
|
1223 |
|
sl@0
|
1224 |
void CGetTrusters::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
1225 |
{
|
sl@0
|
1226 |
switch (iState)
|
sl@0
|
1227 |
{
|
sl@0
|
1228 |
case EGetCAEntries:
|
sl@0
|
1229 |
iState = EGetTrusters;
|
sl@0
|
1230 |
GetCerts(aStatus);
|
sl@0
|
1231 |
break;
|
sl@0
|
1232 |
|
sl@0
|
1233 |
case EGetTrusters:
|
sl@0
|
1234 |
{
|
sl@0
|
1235 |
TInt end = iCertInfos.Count();
|
sl@0
|
1236 |
TBool calledCertStore = EFalse;
|
sl@0
|
1237 |
for (TInt i = 0; i < end; i++)
|
sl@0
|
1238 |
{
|
sl@0
|
1239 |
if (iCertInfos[i]->Label() == iLabel)
|
sl@0
|
1240 |
{
|
sl@0
|
1241 |
CertStore().Trusted(*iCertInfos[i], iTrust, aStatus);
|
sl@0
|
1242 |
calledCertStore = ETrue;
|
sl@0
|
1243 |
break;
|
sl@0
|
1244 |
}
|
sl@0
|
1245 |
}
|
sl@0
|
1246 |
iState = EFinished;
|
sl@0
|
1247 |
if (EFalse==calledCertStore)
|
sl@0
|
1248 |
{// None with the appropriate label
|
sl@0
|
1249 |
TRequestStatus* status = &aStatus;
|
sl@0
|
1250 |
User::RequestComplete(status, KErrNotFound);
|
sl@0
|
1251 |
}
|
sl@0
|
1252 |
}
|
sl@0
|
1253 |
break;
|
sl@0
|
1254 |
|
sl@0
|
1255 |
case EFinished:
|
sl@0
|
1256 |
{
|
sl@0
|
1257 |
TRequestStatus* status = &aStatus;
|
sl@0
|
1258 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
1259 |
if (aStatus == iExpectedResult)
|
sl@0
|
1260 |
{
|
sl@0
|
1261 |
|
sl@0
|
1262 |
if (iTrust == iExpectedTrusters[0].iUid)
|
sl@0
|
1263 |
{
|
sl@0
|
1264 |
iResult = ETrue;
|
sl@0
|
1265 |
}
|
sl@0
|
1266 |
else
|
sl@0
|
1267 |
{
|
sl@0
|
1268 |
iResult = EFalse;
|
sl@0
|
1269 |
}
|
sl@0
|
1270 |
}
|
sl@0
|
1271 |
else
|
sl@0
|
1272 |
{
|
sl@0
|
1273 |
iResult = EFalse;
|
sl@0
|
1274 |
}
|
sl@0
|
1275 |
|
sl@0
|
1276 |
iFinished = ETrue;
|
sl@0
|
1277 |
}
|
sl@0
|
1278 |
break;
|
sl@0
|
1279 |
|
sl@0
|
1280 |
default:
|
sl@0
|
1281 |
break;
|
sl@0
|
1282 |
}
|
sl@0
|
1283 |
}
|
sl@0
|
1284 |
|
sl@0
|
1285 |
void CGetTrusters::PerformCancel()
|
sl@0
|
1286 |
{
|
sl@0
|
1287 |
switch (iState)
|
sl@0
|
1288 |
{
|
sl@0
|
1289 |
case EGetTrusters:
|
sl@0
|
1290 |
CertStore().CancelList();
|
sl@0
|
1291 |
break;
|
sl@0
|
1292 |
|
sl@0
|
1293 |
case EFinished:
|
sl@0
|
1294 |
CertStore().CancelTrusted();
|
sl@0
|
1295 |
break;
|
sl@0
|
1296 |
|
sl@0
|
1297 |
default:
|
sl@0
|
1298 |
break;
|
sl@0
|
1299 |
}
|
sl@0
|
1300 |
}
|
sl@0
|
1301 |
|
sl@0
|
1302 |
void CGetTrusters::Reset()
|
sl@0
|
1303 |
{
|
sl@0
|
1304 |
iCertInfos.Close();
|
sl@0
|
1305 |
iState = EGetCAEntries;
|
sl@0
|
1306 |
}
|
sl@0
|
1307 |
|
sl@0
|
1308 |
CGetTrusters::CGetTrusters(RFs& aFs, CConsoleBase& aConsole, Output& aOut)
|
sl@0
|
1309 |
: CCertStoreTestAction(aFs, aConsole, aOut), iState(EGetCAEntries)
|
sl@0
|
1310 |
{
|
sl@0
|
1311 |
}
|
sl@0
|
1312 |
|
sl@0
|
1313 |
void CGetTrusters::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
1314 |
{
|
sl@0
|
1315 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
1316 |
iFilter = CCertAttributeFilter::NewL();
|
sl@0
|
1317 |
TInt err = KErrNone;
|
sl@0
|
1318 |
TInt pos = 0;
|
sl@0
|
1319 |
SetCertLabel(Input::ParseElement(aTestActionSpec.iActionBody,
|
sl@0
|
1320 |
KCertLabelStart, KCertLabelEnd, pos, err));
|
sl@0
|
1321 |
|
sl@0
|
1322 |
// Set the expected result
|
sl@0
|
1323 |
pos = 0;
|
sl@0
|
1324 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
1325 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
1326 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
1327 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
1328 |
|
sl@0
|
1329 |
SetExpectedTrusters(Input::ParseElement(aTestActionSpec.iActionResult, KTrustersStart,
|
sl@0
|
1330 |
KTrustersEnd, pos, err));
|
sl@0
|
1331 |
|
sl@0
|
1332 |
}
|
sl@0
|
1333 |
|
sl@0
|
1334 |
void CGetTrusters::GetCerts(TRequestStatus& aStatus)
|
sl@0
|
1335 |
{
|
sl@0
|
1336 |
CertStore().List(iCertInfos, *iFilter, aStatus);
|
sl@0
|
1337 |
}
|
sl@0
|
1338 |
|
sl@0
|
1339 |
void CGetTrusters::SetCertLabel(const TDesC8& aLabel)
|
sl@0
|
1340 |
{
|
sl@0
|
1341 |
iLabel.Copy(aLabel);
|
sl@0
|
1342 |
}
|
sl@0
|
1343 |
|
sl@0
|
1344 |
void CGetTrusters::SetExpectedTrusters(const TDesC8& aExpectedTrusters)
|
sl@0
|
1345 |
{
|
sl@0
|
1346 |
TLex8 lex(aExpectedTrusters);
|
sl@0
|
1347 |
TInt err = KErrNone;
|
sl@0
|
1348 |
while (err == KErrNone)
|
sl@0
|
1349 |
{
|
sl@0
|
1350 |
TUid uid;
|
sl@0
|
1351 |
err = lex.Val(uid.iUid);
|
sl@0
|
1352 |
if (err == KErrNone)
|
sl@0
|
1353 |
{
|
sl@0
|
1354 |
lex.SkipSpace();
|
sl@0
|
1355 |
User::LeaveIfError(iExpectedTrusters.Append(uid));
|
sl@0
|
1356 |
}
|
sl@0
|
1357 |
}
|
sl@0
|
1358 |
}
|
sl@0
|
1359 |
|
sl@0
|
1360 |
void CGetTrusters::DoReportAction()
|
sl@0
|
1361 |
{
|
sl@0
|
1362 |
iOut.writeString(_L("Getting trust settings..."));
|
sl@0
|
1363 |
iOut.writeNewLine();
|
sl@0
|
1364 |
iOut.writeString(_L("\tLabel = "));
|
sl@0
|
1365 |
iOut.writeString(iLabel);
|
sl@0
|
1366 |
iOut.writeNewLine();
|
sl@0
|
1367 |
iOut.writeNewLine();
|
sl@0
|
1368 |
}
|
sl@0
|
1369 |
|
sl@0
|
1370 |
void CGetTrusters::DoCheckResult(TInt /*aError*/)
|
sl@0
|
1371 |
{
|
sl@0
|
1372 |
if (iFinished)
|
sl@0
|
1373 |
{
|
sl@0
|
1374 |
iConsole.Printf(_L("\ttrust Setting : "));
|
sl@0
|
1375 |
iOut.writeString(_L("\tTrust Setting: "));
|
sl@0
|
1376 |
iOut.writeString(_L("\t\t"));
|
sl@0
|
1377 |
iConsole.Printf(_L("%D \n"), iTrust);
|
sl@0
|
1378 |
iOut.writeNum(iTrust);
|
sl@0
|
1379 |
iOut.writeString(_L(" "));
|
sl@0
|
1380 |
iOut.writeNewLine();
|
sl@0
|
1381 |
iOut.writeNewLine();
|
sl@0
|
1382 |
|
sl@0
|
1383 |
iConsole.Printf(_L("\texpected Trust Setting: "));
|
sl@0
|
1384 |
iOut.writeString(_L("\tExpected Trust Setting: "));
|
sl@0
|
1385 |
iOut.writeNewLine();
|
sl@0
|
1386 |
iOut.writeString(_L("\t\t"));
|
sl@0
|
1387 |
iConsole.Printf(_L("%D \n"), iExpectedTrusters[0].iUid);
|
sl@0
|
1388 |
iOut.writeNum(iExpectedTrusters[0].iUid);
|
sl@0
|
1389 |
iOut.writeString(_L(" "));
|
sl@0
|
1390 |
iOut.writeNewLine();
|
sl@0
|
1391 |
iOut.writeNewLine();
|
sl@0
|
1392 |
if (iResult)
|
sl@0
|
1393 |
{
|
sl@0
|
1394 |
iConsole.Printf(_L("\tTrust retrieved successfully\n"));
|
sl@0
|
1395 |
iOut.writeString(_L("\tTrust retrieved successfully"));
|
sl@0
|
1396 |
iOut.writeNewLine();
|
sl@0
|
1397 |
}
|
sl@0
|
1398 |
else
|
sl@0
|
1399 |
{
|
sl@0
|
1400 |
iConsole.Printf(_L("\tTrust retrieved failed\n"));
|
sl@0
|
1401 |
iOut.writeString(_L("\tTrust retrieved failed"));
|
sl@0
|
1402 |
iOut.writeNewLine();
|
sl@0
|
1403 |
}
|
sl@0
|
1404 |
iOut.writeNewLine();
|
sl@0
|
1405 |
|
sl@0
|
1406 |
}
|
sl@0
|
1407 |
}
|