First public contribution.
2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
24 #ifndef __T_CERTSTOREACTIONS_H__
25 #define __T_CERTSTOREACTIONS_H__
27 #include "t_testhandler.h"
28 #include <unifiedcertstore.h>
29 #include <unifiedkeystore.h>
30 #include <certificateapps.h>
33 #include "t_testaction.h"
34 #include <cctcertinfo.h>
45 class CCertStoreChangeNotifier : public CActive
48 static CCertStoreChangeNotifier* NewL(TInt& aNotificationFlag);
49 virtual ~CCertStoreChangeNotifier();
50 void StartNotification();
51 TInt& iNotifiedCounter;
52 void SetCompleteStatus(TRequestStatus* aStatus);
54 CCertStoreChangeNotifier(TInt& aNotificationFlag);
59 RProperty iCertStoreChangeProperty;
60 TRequestStatus* iCompleteStatus;
64 * Contains either a unified cert store instance or a SWI cert store instance.
66 * Either can be accessed through the CertStore() method, but
67 * AsUnifiedCertStore() and AsSWICertStore() will panic if the store is the
70 * This class owns the cert store pointer.
72 class COpenCertStore : public CBase
75 virtual ~COpenCertStore();
77 TCertStoreType Type();
78 MCertStore& CertStore();
80 void SetCertStore(CUnifiedCertStore* aCertStore);
81 CUnifiedCertStore& AsUnifiedCertStore();
83 void SetCertStore(CSWICertStore* aCertStore);
84 CSWICertStore& AsSWICertStore();
95 CUnifiedCertStore* iUnifiedCertStore;
96 CSWICertStore* iSwiCertStore;
101 * Per-thread shared data.
103 * This contains stuff that is shared by more than one test action, eg the cert
104 * stores we are testing.
106 class CSharedData : public CBase
110 void InitCertificateAppInfoManagerL();
111 void DeleteCertificateAppInfoManager();
112 RPointerArray<COpenCertStore>& CertStores();
115 RPointerArray<COpenCertStore> iCertStores;
116 CCertificateAppInfoManager* iCertificateAppInfoManager;
119 class CCertStoreTestAction : public CTestAction
122 virtual ~CCertStoreTestAction();
125 CCertStoreTestAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
127 // Methods for accessing the shared app info manager
128 void InitTheCertificateAppInfoManagerL();
129 void DeleteTheCertificateAppInfoManager();
130 CCertificateAppInfoManager* TheCertificateAppInfoManager();
132 // Methods for accessing the shared cert stores
133 TInt CertStoreCount();
134 TCertStoreType CertStoreType(TInt aIndex = 0);
135 MCertStore& CertStore(TInt aIndex = 0);
136 void AddCertStoreL(CUnifiedCertStore* aCertStore);
137 CUnifiedCertStore& UnifiedCertStore(TInt aIndex = 0);
138 void AddCertStoreL(CSWICertStore* aCertStore);
139 CSWICertStore& SWICertStore(TInt aIndex = 0);
140 void RemoveCertStore(TInt aIndex);
146 CSharedData& CertStoreSharedData();
147 RPointerArray<COpenCertStore>& CertStores();
148 void DoPerformPrerequisite(TRequestStatus& aStatus);
149 void DoPerformPostrequisite(TRequestStatus& aStatus);
152 class CSubscriberAction: public CCertStoreTestAction
155 virtual ~CSubscriberAction();
158 CSubscriberAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
159 void ConstructL(const TTestActionSpec& aTestActionSpec);
161 TInt iNotificationSubscribed;
162 CCertStoreChangeNotifier* iNotifier;
166 * This action creates and initializes a certificate store manager.
167 * It should be used before any action requiring a certificate store manager.
168 * All the actions are likely to require one.
170 class CInitialiseCertStore : public CCertStoreTestAction
173 static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole,
174 Output& aOut, const TTestActionSpec& aTestActionSpec);
175 static CTestAction* NewLC(RFs& aFs, CConsoleBase& aConsole,
176 Output& aOut, const TTestActionSpec& aTestActionSpec);
177 ~CInitialiseCertStore();
180 virtual void PerformAction(TRequestStatus& aStatus);
181 virtual void PerformCancel();
182 virtual void Reset();
185 CInitialiseCertStore(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
186 void ConstructL(const TTestActionSpec& aTestActionSpec);
187 void DoReportAction();
188 void DoCheckResult(TInt aError);
201 TBool iOpenedForWrite;
202 RArray<TInt> iFilterOrdering;
203 RArray<TInt32> iExpectedOrderingResult;
204 CUnifiedCertStore* iNewUnifiedCertStore;
207 class COnlyCreateCertStore : public CCertStoreTestAction
210 static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
211 const TTestActionSpec& aTestActionSpec);
212 ~COnlyCreateCertStore() {};
215 virtual void PerformAction(TRequestStatus& aStatus);
216 virtual void PerformCancel();
217 virtual void Reset();
227 COnlyCreateCertStore(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
228 void ConstructL(const TTestActionSpec& aTestActionSpec);
229 void DoReportAction();
230 void DoCheckResult(TInt aError);
234 TBool iOpenedForWrite;
236 CUnifiedCertStore* iNewUnifiedCertStore;
239 class CDeleteCertStore : public CCertStoreTestAction
242 static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
243 const TTestActionSpec& aTestActionSpec);
244 static CTestAction* NewLC(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
245 const TTestActionSpec& aTestActionSpec);
247 virtual void PerformAction(TRequestStatus& aStatus);
248 virtual void PerformCancel();
249 virtual void Reset();
252 CDeleteCertStore(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
253 void ConstructL(const TTestActionSpec& aTestActionSpec);
254 void DoReportAction();
255 void DoCheckResult(TInt aError);
269 class CX509Certificate;
270 class CWTLSCertificate;
272 // This is the base class used by both CSetApplications and CSetTrusters. This
273 // is required because of the merging of the SetApplicability and SetTrust API
274 // calls on the certstore
275 class CSetAppsAndTrust : public CSubscriberAction
280 virtual void PerformAction(TRequestStatus& aStatus);
281 virtual void Reset();
282 virtual void PerformCancel();
285 CSetAppsAndTrust(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
286 void ConstructL(const TTestActionSpec& aTestActionSpec);
287 void GetCerts(TRequestStatus& aStatus);
288 void SetCertLabel(const TDesC8& aLabel);
290 /** Implemented by derived classes, called from PerformAction. */
291 virtual void DoSetAppTrust(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus) = 0;
292 /** Implemented by derived classes, called from PerformCancel. */
293 virtual void DoPerformCancel() = 0;
306 * The label of the certificate we want to set the trust settings for
310 // Index into the certinfo list which points to the certificate we
315 CCertAttributeFilter *iFilter;
316 RMPointerArray<CCTCertInfo> iCertInfos;
322 * This class is used to test the trust settings of a certificate.
324 class CSetApplications : public CSetAppsAndTrust
328 * @param aInfo This is what is enclosed in the <actionbody> and </actionbody> tags
329 * of the test script.
331 static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
332 const TTestActionSpec& aTestActionSpec);
336 CSetApplications(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
337 void ConstructL(const TTestActionSpec& aTestActionSpec);
338 void DoReportAction();
339 void DoCheckResult(TInt aError);
340 void AppendUid(const TDesC8& aUid);
341 void DoSetAppTrust(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus);
342 void DoPerformCancel();
346 * The array of applications that trust this certificate.
348 RArray<TUid> iApplications;
352 * This class is used to test the trust settings of a certificate.
354 class CSetTrusters : public CSetAppsAndTrust
358 * @param aInfo This is what is enclosed in the <actionbody> and </actionbody> tags
359 * of the test script.
361 static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
362 const TTestActionSpec& aTestActionSpec);
366 CSetTrusters(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
367 void ConstructL(const TTestActionSpec& aTestActionSpec);
368 void DoReportAction();
369 void DoCheckResult(TInt aError);
370 void SetTrusted(const TDesC8& aTrusted);
371 void DoSetAppTrust(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus);
372 void DoPerformCancel();
375 // The trusted setting to set
380 * This class is used to test the trust settings of a certificate.
382 class CGetTrusters : public CCertStoreTestAction
386 * @param aInfo This is what is enclosed in the <actionbody> and </actionbody> tags
387 * of the test script.
389 static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
390 const TTestActionSpec& aTestActionSpec);
392 virtual void PerformAction(TRequestStatus& aStatus);
393 virtual void PerformCancel();
394 virtual void Reset();
397 CGetTrusters(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
398 void ConstructL(const TTestActionSpec& aTestActionSpec);
399 void GetCerts(TRequestStatus& aStatus);
400 void SetCertLabel(const TDesC8& aLabel);
401 void SetExpectedTrusters(const TDesC8& aExpectedTrusters);
402 void DoReportAction();
403 void DoCheckResult(TInt aError);
415 * The label of the certificate we want to get the trust settings of
420 TBool iExpectedTrust;
421 CCertAttributeFilter *iFilter;
422 RMPointerArray<CCTCertInfo> iCertInfos;
423 RArray<TUid> iTrusters;
424 RArray<TUid> iExpectedTrusters;