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