os/security/securityanddataprivacytools/securitytools/certapp/test/tcertapp/goodconfigwriter.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/securityanddataprivacytools/securitytools/certapp/test/tcertapp/goodconfigwriter.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,164 @@
     1.4 +#ifndef __CONFIGWRITER_H__
     1.5 +#define __CONFIGWRITER_H__/*
     1.6 +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Eclipse Public License v1.0"
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description: 
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#include <string>
    1.24 +#include <fstream>
    1.25 +#include <sstream>
    1.26 +
    1.27 +class GoodConfigWriter
    1.28 +	{
    1.29 +public:
    1.30 +	GoodConfigWriter(const std::stringstream &aFileName);
    1.31 +	~GoodConfigWriter();
    1.32 +	std::ofstream iFile;
    1.33 +	};
    1.34 +
    1.35 +class FileCertStoreConfigWriter : public GoodConfigWriter
    1.36 +	{
    1.37 +public:
    1.38 +	FileCertStoreConfigWriter(const std::stringstream &aFileName);
    1.39 +	~FileCertStoreConfigWriter();
    1.40 +
    1.41 +	void WriteFileEntry(const char *aGoodLabel= "\"Root5CA\"",
    1.42 +					const char *aGoodDeletable = "\"true\"",
    1.43 +					const char *aGoodFormat= "\"EX509Certificate\"",
    1.44 +					const char *aGoodCertOwnerType = "\"ECACertificate\"",
    1.45 +					const char *aGoodSubjectKeyId ="auto",
    1.46 +					const char *aGoodIssuerKeyId = "auto",
    1.47 +					const char *aGoodApplication = "\"SW Install\"",
    1.48 +					const char *aGoodTrusted = "\"true\"",
    1.49 +					const char *aGoodDataFileName  = "\"cert0.der\"");
    1.50 +	void WriteExtraFileEntry();
    1.51 +	
    1.52 +private:
    1.53 +	int iEntryCount;
    1.54 +	};
    1.55 +
    1.56 +class FileCertClientConfigWriter : public GoodConfigWriter
    1.57 +	{
    1.58 +public:
    1.59 +	FileCertClientConfigWriter(const std::stringstream &aFileName);
    1.60 +	~FileCertClientConfigWriter();
    1.61 +
    1.62 +	void WriteCertClientName(const char *arrayVal);
    1.63 +	void WriteCertClientUid(const char *arrayVal);
    1.64 +	void WriteExtraCertClientEntry();
    1.65 +private:
    1.66 +	int iEntryCount;
    1.67 +	};
    1.68 +
    1.69 +
    1.70 +class SwiCertStoreConfigWriter : public GoodConfigWriter
    1.71 +	{
    1.72 +public:
    1.73 +	SwiCertStoreConfigWriter(const std::stringstream &aFileName);
    1.74 +	~SwiCertStoreConfigWriter();
    1.75 +
    1.76 +	void WriteSwiEntry(const char *aGoodLabel= "\"certificate_Label\"",
    1.77 +					/*const char *aGoodDeletable = "\"true\"",*/
    1.78 +					const char *aGoodFormat= "EX509Certificate",
    1.79 +					const char *aGoodCertOwnerType = "\"ECACertificate\"",
    1.80 +					const char *aGoodSubjectKeyId ="auto",
    1.81 +					const char *aGoodIssuerKeyId = "auto",
    1.82 +					const char *aGoodApplication = "\"SW Install\"",
    1.83 +					const char *aGoodTrusted = "\"true\"",
    1.84 +					const char *aGoodCapabilitySet = "TCB",
    1.85 +					const char *aGoodMandatory = "\"true\"",
    1.86 +					const char *aGoodSystemUpgrade = "\"true\"");
    1.87 +	void WriteExtraSwiEntry();
    1.88 +private:
    1.89 +	int iEntryCount;
    1.90 +	};
    1.91 +
    1.92 +
    1.93 +// to generate script and ini files to run tests on emulator
    1.94 +
    1.95 +class ScriptAndIniGeneration : public GoodConfigWriter
    1.96 +	{
    1.97 +public:
    1.98 +	ScriptAndIniGeneration(const std::stringstream &aFileName);
    1.99 +	~ScriptAndIniGeneration();
   1.100 +	
   1.101 +	void WriteTestCaseToScript(const std::stringstream &aTestCaseType, int &aTestIndex, const char *aTestActionName, const char *aTestActionType, bool aHasActionBody = true);
   1.102 +
   1.103 +protected:
   1.104 +	std::ofstream iIniFile;
   1.105 +	std::string   iIniFileName;
   1.106 +	};
   1.107 +
   1.108 +
   1.109 +// to generate script files for the file certstore to run tests on emulator
   1.110 +
   1.111 +class FileStoreScriptGeneration : public ScriptAndIniGeneration
   1.112 +	{
   1.113 +public:
   1.114 +	FileStoreScriptGeneration(const std::stringstream &aFileName);
   1.115 +	~FileStoreScriptGeneration();
   1.116 +	
   1.117 +	void WriteInitialiseCert(const char *aMode, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.118 +	void WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.119 +	void WriteGetCertificateDetails(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.120 +	void WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.121 +	void WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.122 +	void WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.123 +	};
   1.124 +
   1.125 +
   1.126 +// to generate script files for the cert cleint store to run tests on emulator
   1.127 +
   1.128 +class CertClientsStoreScriptGeneration : public ScriptAndIniGeneration
   1.129 +	{
   1.130 +public:
   1.131 +	CertClientsStoreScriptGeneration(const std::stringstream &aFileName);
   1.132 +	~CertClientsStoreScriptGeneration();
   1.133 +	
   1.134 +	void WriteInitialiseCertClient(const std::stringstream &aTestCaseType, int &aTestIndex);
   1.135 +	void WriteGetCount(const int index, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.136 +	void WriteGetApplicationsList(const std::stringstream &aTestCaseType, int &aTestIndex);
   1.137 +	void WriteGetAppWithUid(const char *label, const char *uid, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.138 +	void WriteDestroyManager(const std::stringstream &aTestCaseType, int &aTestIndex);
   1.139 +	};
   1.140 +
   1.141 +
   1.142 +// to generate script files for the swicertstore to run tests on emulator
   1.143 +
   1.144 +class SWIStoreScriptGeneration : public ScriptAndIniGeneration
   1.145 +	{
   1.146 +public:
   1.147 +	SWIStoreScriptGeneration(const std::stringstream &aFileName);
   1.148 +	~SWIStoreScriptGeneration();
   1.149 +	
   1.150 +	void WriteInitialiseCert(const std::stringstream &aTestCaseType, int &aTestIndex);
   1.151 +	void WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.152 +	void WriteGetSystemUpgrade(const char *label , const char *aSystemUpgrade, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.153 +	void WriteGetCapabilities(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.154 +	void WriteGetMandatoryFlag(const char *label, const char *aMandatory, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.155 +	void WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.156 +	void WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.157 +	void WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
   1.158 +	};
   1.159 +
   1.160 +class EmptyFileConfigWriter : public GoodConfigWriter
   1.161 +	{
   1.162 +public:
   1.163 +	EmptyFileConfigWriter(const std::stringstream &aFileName);
   1.164 +	~EmptyFileConfigWriter();
   1.165 +	};
   1.166 +
   1.167 +#endif