|
1 /* |
|
2 * Copyright (c) 2007-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 |
|
19 #ifndef __TTESTTOOLENGINE_H_ |
|
20 #define __TTESTTOOLENGINE_H_ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <unifiedcertstore.h> |
|
24 #include <unifiedkeystore.h> |
|
25 #include <test/testexecutestepbase.h> |
|
26 #include <ct/rmpointerarray.h> |
|
27 #include <securitydefs.h> |
|
28 |
|
29 class CTestToolEngine : public CActive |
|
30 { |
|
31 public: |
|
32 static CTestToolEngine* NewLC(); |
|
33 ~CTestToolEngine(); |
|
34 void ConstructL(); |
|
35 |
|
36 public: |
|
37 TVerdict ListCerts(const TDesC& aLabel, const TInt aExpectedNumLabel); |
|
38 TVerdict ListCerts(const TDesC& aLabel1, const TDesC& aLabel2, const TInt aExpectedNumLabel); |
|
39 TVerdict ListCerts(RPointerArray<HBufC>& aCerts); |
|
40 TVerdict ListCerts(RPointerArray<HBufC>& aCerts, const TDesC& aLabel); |
|
41 TVerdict ListCerts(RPointerArray<HBufC>& aCerts, TInt aStore); |
|
42 TVerdict ListStore(RPointerArray<HBufC>& aCerts); |
|
43 TVerdict ListKeys(const TDesC& aLabel, const TInt aExpectedNumLabel); |
|
44 TVerdict ListKeys(const TDesC& aLabel1, const TDesC& aLabel2, const TInt aExpectedNumLabel); |
|
45 TVerdict ListKeys(RPointerArray<HBufC>& aKeys); |
|
46 TVerdict ListKeys(RPointerArray<HBufC>& aKeys, TInt aStore); |
|
47 TVerdict CheckApps(RPointerArray<HBufC>& aApps, const TDesC& aLabel1); |
|
48 TVerdict CheckTrust(const TDesC& aLabel,TBool aTrust); |
|
49 TVerdict GetPolicy(const TDesC& aLabel1, const TDesC& aLabel2, TInt aUser); |
|
50 TVerdict ListStoreKey(RPointerArray<HBufC>& aKeys); |
|
51 void Initilize(); |
|
52 void KeyInitilize(); |
|
53 TBool VerifyApps(RPointerArray<HBufC>& aApps); |
|
54 TBool VerifyTrust(TBool aTrust); |
|
55 TBool VerifyPolicy(TInt aUser); |
|
56 TBool CheckAppForUid(const TDesC& aAppName, RPointerArray<HBufC>& aApps); |
|
57 TBool CompareWithExpectedCertificates(RPointerArray<HBufC>& aCerts); |
|
58 TBool CompareWithExpectedStore(RPointerArray<HBufC>& aCerts); |
|
59 TBool CompareWithExpectedStoreKey(RPointerArray<HBufC>& aKeys); |
|
60 TBool CompareWithExpectedKeys(RPointerArray<HBufC>& aKeys); |
|
61 void FilterCerts(RMPointerArray<CCTCertInfo>& aCertList, TCertificateOwnerType& aOwnerType); |
|
62 TInt FilterCerts(RMPointerArray<CCTCertInfo>& aCertList, TDesC& aLabel, TInt& aIndex, TBool aFilterOnly = EFalse); |
|
63 TInt FilterKeys(RMPointerArray<CCTKeyInfo>& aKeyList, TDesC& aLabel, TInt& aIndex); |
|
64 public: // From CActive |
|
65 void RunL(); |
|
66 void DoCancel(); |
|
67 TInt RunError(TInt aError); |
|
68 |
|
69 private: |
|
70 CTestToolEngine(); |
|
71 |
|
72 private: |
|
73 enum |
|
74 { |
|
75 EInitialiseKeyStore, |
|
76 EFilterKey, |
|
77 EInitialise, |
|
78 EGetApps, |
|
79 EGetTrust, |
|
80 EGetPolicy, |
|
81 EFilter, |
|
82 EDone |
|
83 } iState; |
|
84 |
|
85 RFs iFs; |
|
86 CUnifiedCertStore* iCertStore; |
|
87 TPtrC iLabel1; |
|
88 TPtrC iLabel2; |
|
89 TInt iNumCert1; |
|
90 TInt iNumCert2; |
|
91 RFs iFsKeyStore; |
|
92 CUnifiedKeyStore* iKeyStore; |
|
93 RMPointerArray<CCTCertInfo> iCertInfos; |
|
94 RMPointerArray<CCTKeyInfo> iKeys; |
|
95 TInt iAppsCount; |
|
96 TInt iCertsCount; |
|
97 TInt iKeysListCount; |
|
98 RArray<TUid> iUids; |
|
99 TInt iStore; |
|
100 CCertAttributeFilter* iFilter; |
|
101 TCTKeyAttributeFilter iKeyFilter; |
|
102 TBool iPolicy; |
|
103 TInt iIndex; |
|
104 TInt iGetTrust; |
|
105 TBool iActualTrust; |
|
106 }; |
|
107 |
|
108 |
|
109 /** |
|
110 TCompiledSecurityPolicy is a test class used for accessing private data members |
|
111 of TSecurityPolicy class. It uses the fact that TSecurityPolicy class has a friend class, |
|
112 which name is TCompiledSecurityPolicy. |
|
113 @internalComponent |
|
114 */ |
|
115 class TCompiledSecurityPolicy |
|
116 { |
|
117 public: |
|
118 TCompiledSecurityPolicy(const TSecurityPolicy& aSecurityPolicy) : |
|
119 iSecurityPolicy(aSecurityPolicy) |
|
120 { |
|
121 } |
|
122 TSecurityPolicy::TType Type() const |
|
123 { |
|
124 return static_cast <TSecurityPolicy::TType> (iSecurityPolicy.iType); |
|
125 } |
|
126 TUint32 SecureId() const |
|
127 { |
|
128 return iSecurityPolicy.iSecureId; |
|
129 } |
|
130 TUint32 VendorId() const |
|
131 { |
|
132 return iSecurityPolicy.iVendorId; |
|
133 } |
|
134 TCapability Capability(TInt aIndex) const |
|
135 { |
|
136 if(aIndex < 3) |
|
137 { |
|
138 return static_cast <TCapability> (iSecurityPolicy.iCaps[aIndex]); |
|
139 } |
|
140 else if(aIndex < 7) |
|
141 { |
|
142 return static_cast <TCapability> (iSecurityPolicy.iExtraCaps[aIndex - 3]); |
|
143 } |
|
144 User::Invariant(); |
|
145 return ECapability_None; |
|
146 } |
|
147 |
|
148 private: |
|
149 const TSecurityPolicy& iSecurityPolicy; |
|
150 }; |
|
151 |
|
152 |
|
153 inline TBool operator==(const TCompiledSecurityPolicy& aLeft, const TCompiledSecurityPolicy& aRight) |
|
154 { |
|
155 return aLeft.Type() == aRight.Type() && |
|
156 aLeft.SecureId() == aRight.SecureId() && |
|
157 aLeft.VendorId() == aRight.VendorId() && |
|
158 aLeft.Capability(0) == aRight.Capability(0) && |
|
159 aLeft.Capability(1) == aRight.Capability(1) && |
|
160 aLeft.Capability(2) == aRight.Capability(2) && |
|
161 aLeft.Capability(3) == aRight.Capability(3) && |
|
162 aLeft.Capability(4) == aRight.Capability(4) && |
|
163 aLeft.Capability(5) == aRight.Capability(5) && |
|
164 aLeft.Capability(6) == aRight.Capability(6); |
|
165 } |
|
166 |
|
167 #endif //__TTESTTOOLENGINE_H_ |