os/security/cryptoservices/filebasedcertificateandkeystores/test/ttesttools/ttesttoolengine.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/test/ttesttools/ttesttoolengine.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,169 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef __TTESTTOOLENGINE_H_
1.23 +#define __TTESTTOOLENGINE_H_
1.24 +
1.25 +#include <e32base.h>
1.26 +#include <unifiedcertstore.h>
1.27 +#include <unifiedkeystore.h>
1.28 +#include <test/testexecutestepbase.h>
1.29 +#include <ct/rmpointerarray.h>
1.30 +#include <securitydefs.h>
1.31 +
1.32 +class CTestToolEngine : public CActive
1.33 + {
1.34 +public:
1.35 + static CTestToolEngine* NewLC();
1.36 + ~CTestToolEngine();
1.37 + void ConstructL();
1.38 +
1.39 +public:
1.40 + TVerdict ListCerts(const TDesC& aLabel, const TInt aExpectedNumLabel);
1.41 + TVerdict ListCerts(const TDesC& aLabel1, const TDesC& aLabel2, const TInt aExpectedNumLabel);
1.42 + TVerdict ListCerts(RPointerArray<HBufC>& aCerts);
1.43 + TVerdict ListCerts(RPointerArray<HBufC>& aCerts, const TDesC& aLabel);
1.44 + TVerdict ListCerts(RPointerArray<HBufC>& aCerts, TInt aStore);
1.45 + TVerdict ListStore(RPointerArray<HBufC>& aCerts);
1.46 + TVerdict ListKeys(const TDesC& aLabel, const TInt aExpectedNumLabel);
1.47 + TVerdict ListKeys(const TDesC& aLabel1, const TDesC& aLabel2, const TInt aExpectedNumLabel);
1.48 + TVerdict ListKeys(RPointerArray<HBufC>& aKeys);
1.49 + TVerdict ListKeys(RPointerArray<HBufC>& aKeys, TInt aStore);
1.50 + TVerdict CheckApps(RPointerArray<HBufC>& aApps, const TDesC& aLabel1);
1.51 + TVerdict CheckTrust(const TDesC& aLabel,TBool aTrust);
1.52 + TVerdict GetPolicy(const TDesC& aLabel1, const TDesC& aLabel2, TInt aUser);
1.53 + TVerdict ListStoreKey(RPointerArray<HBufC>& aKeys);
1.54 + void Initilize();
1.55 + void KeyInitilize();
1.56 + TBool VerifyApps(RPointerArray<HBufC>& aApps);
1.57 + TBool VerifyTrust(TBool aTrust);
1.58 + TBool VerifyPolicy(TInt aUser);
1.59 + TBool CheckAppForUid(const TDesC& aAppName, RPointerArray<HBufC>& aApps);
1.60 + TBool CompareWithExpectedCertificates(RPointerArray<HBufC>& aCerts);
1.61 + TBool CompareWithExpectedStore(RPointerArray<HBufC>& aCerts);
1.62 + TBool CompareWithExpectedStoreKey(RPointerArray<HBufC>& aKeys);
1.63 + TBool CompareWithExpectedKeys(RPointerArray<HBufC>& aKeys);
1.64 + void FilterCerts(RMPointerArray<CCTCertInfo>& aCertList, TCertificateOwnerType& aOwnerType);
1.65 + TInt FilterCerts(RMPointerArray<CCTCertInfo>& aCertList, TDesC& aLabel, TInt& aIndex, TBool aFilterOnly = EFalse);
1.66 + TInt FilterKeys(RMPointerArray<CCTKeyInfo>& aKeyList, TDesC& aLabel, TInt& aIndex);
1.67 +public: // From CActive
1.68 + void RunL();
1.69 + void DoCancel();
1.70 + TInt RunError(TInt aError);
1.71 +
1.72 +private:
1.73 + CTestToolEngine();
1.74 +
1.75 +private:
1.76 + enum
1.77 + {
1.78 + EInitialiseKeyStore,
1.79 + EFilterKey,
1.80 + EInitialise,
1.81 + EGetApps,
1.82 + EGetTrust,
1.83 + EGetPolicy,
1.84 + EFilter,
1.85 + EDone
1.86 + } iState;
1.87 +
1.88 + RFs iFs;
1.89 + CUnifiedCertStore* iCertStore;
1.90 + TPtrC iLabel1;
1.91 + TPtrC iLabel2;
1.92 + TInt iNumCert1;
1.93 + TInt iNumCert2;
1.94 + RFs iFsKeyStore;
1.95 + CUnifiedKeyStore* iKeyStore;
1.96 + RMPointerArray<CCTCertInfo> iCertInfos;
1.97 + RMPointerArray<CCTKeyInfo> iKeys;
1.98 + TInt iAppsCount;
1.99 + TInt iCertsCount;
1.100 + TInt iKeysListCount;
1.101 + RArray<TUid> iUids;
1.102 + TInt iStore;
1.103 + CCertAttributeFilter* iFilter;
1.104 + TCTKeyAttributeFilter iKeyFilter;
1.105 + TBool iPolicy;
1.106 + TInt iIndex;
1.107 + TInt iGetTrust;
1.108 + TBool iActualTrust;
1.109 + };
1.110 +
1.111 +
1.112 +/**
1.113 +TCompiledSecurityPolicy is a test class used for accessing private data members
1.114 +of TSecurityPolicy class. It uses the fact that TSecurityPolicy class has a friend class,
1.115 +which name is TCompiledSecurityPolicy.
1.116 +@internalComponent
1.117 +*/
1.118 +class TCompiledSecurityPolicy
1.119 + {
1.120 +public:
1.121 + TCompiledSecurityPolicy(const TSecurityPolicy& aSecurityPolicy) :
1.122 + iSecurityPolicy(aSecurityPolicy)
1.123 + {
1.124 + }
1.125 + TSecurityPolicy::TType Type() const
1.126 + {
1.127 + return static_cast <TSecurityPolicy::TType> (iSecurityPolicy.iType);
1.128 + }
1.129 + TUint32 SecureId() const
1.130 + {
1.131 + return iSecurityPolicy.iSecureId;
1.132 + }
1.133 + TUint32 VendorId() const
1.134 + {
1.135 + return iSecurityPolicy.iVendorId;
1.136 + }
1.137 + TCapability Capability(TInt aIndex) const
1.138 + {
1.139 + if(aIndex < 3)
1.140 + {
1.141 + return static_cast <TCapability> (iSecurityPolicy.iCaps[aIndex]);
1.142 + }
1.143 + else if(aIndex < 7)
1.144 + {
1.145 + return static_cast <TCapability> (iSecurityPolicy.iExtraCaps[aIndex - 3]);
1.146 + }
1.147 + User::Invariant();
1.148 + return ECapability_None;
1.149 + }
1.150 +
1.151 +private:
1.152 + const TSecurityPolicy& iSecurityPolicy;
1.153 +};
1.154 +
1.155 +
1.156 +inline TBool operator==(const TCompiledSecurityPolicy& aLeft, const TCompiledSecurityPolicy& aRight)
1.157 + {
1.158 + return aLeft.Type() == aRight.Type() &&
1.159 + aLeft.SecureId() == aRight.SecureId() &&
1.160 + aLeft.VendorId() == aRight.VendorId() &&
1.161 + aLeft.Capability(0) == aRight.Capability(0) &&
1.162 + aLeft.Capability(1) == aRight.Capability(1) &&
1.163 + aLeft.Capability(2) == aRight.Capability(2) &&
1.164 + aLeft.Capability(3) == aRight.Capability(3) &&
1.165 + aLeft.Capability(4) == aRight.Capability(4) &&
1.166 + aLeft.Capability(5) == aRight.Capability(5) &&
1.167 + aLeft.Capability(6) == aRight.Capability(6);
1.168 + }
1.169 +
1.170 +#endif //__TTESTTOOLENGINE_H_
1.171 +
1.172 +