os/security/securityanddataprivacytools/securitytools/certapp/test/tcertapp/goodconfigwriter.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
#ifndef __CONFIGWRITER_H__
sl@0
     2
#define __CONFIGWRITER_H__/*
sl@0
     3
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     4
* All rights reserved.
sl@0
     5
* This component and the accompanying materials are made available
sl@0
     6
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     7
* which accompanies this distribution, and is available
sl@0
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     9
*
sl@0
    10
* Initial Contributors:
sl@0
    11
* Nokia Corporation - initial contribution.
sl@0
    12
*
sl@0
    13
* Contributors:
sl@0
    14
*
sl@0
    15
* Description: 
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
#include <string>
sl@0
    21
#include <fstream>
sl@0
    22
#include <sstream>
sl@0
    23
sl@0
    24
class GoodConfigWriter
sl@0
    25
	{
sl@0
    26
public:
sl@0
    27
	GoodConfigWriter(const std::stringstream &aFileName);
sl@0
    28
	~GoodConfigWriter();
sl@0
    29
	std::ofstream iFile;
sl@0
    30
	};
sl@0
    31
sl@0
    32
class FileCertStoreConfigWriter : public GoodConfigWriter
sl@0
    33
	{
sl@0
    34
public:
sl@0
    35
	FileCertStoreConfigWriter(const std::stringstream &aFileName);
sl@0
    36
	~FileCertStoreConfigWriter();
sl@0
    37
sl@0
    38
	void WriteFileEntry(const char *aGoodLabel= "\"Root5CA\"",
sl@0
    39
					const char *aGoodDeletable = "\"true\"",
sl@0
    40
					const char *aGoodFormat= "\"EX509Certificate\"",
sl@0
    41
					const char *aGoodCertOwnerType = "\"ECACertificate\"",
sl@0
    42
					const char *aGoodSubjectKeyId ="auto",
sl@0
    43
					const char *aGoodIssuerKeyId = "auto",
sl@0
    44
					const char *aGoodApplication = "\"SW Install\"",
sl@0
    45
					const char *aGoodTrusted = "\"true\"",
sl@0
    46
					const char *aGoodDataFileName  = "\"cert0.der\"");
sl@0
    47
	void WriteExtraFileEntry();
sl@0
    48
	
sl@0
    49
private:
sl@0
    50
	int iEntryCount;
sl@0
    51
	};
sl@0
    52
sl@0
    53
class FileCertClientConfigWriter : public GoodConfigWriter
sl@0
    54
	{
sl@0
    55
public:
sl@0
    56
	FileCertClientConfigWriter(const std::stringstream &aFileName);
sl@0
    57
	~FileCertClientConfigWriter();
sl@0
    58
sl@0
    59
	void WriteCertClientName(const char *arrayVal);
sl@0
    60
	void WriteCertClientUid(const char *arrayVal);
sl@0
    61
	void WriteExtraCertClientEntry();
sl@0
    62
private:
sl@0
    63
	int iEntryCount;
sl@0
    64
	};
sl@0
    65
sl@0
    66
sl@0
    67
class SwiCertStoreConfigWriter : public GoodConfigWriter
sl@0
    68
	{
sl@0
    69
public:
sl@0
    70
	SwiCertStoreConfigWriter(const std::stringstream &aFileName);
sl@0
    71
	~SwiCertStoreConfigWriter();
sl@0
    72
sl@0
    73
	void WriteSwiEntry(const char *aGoodLabel= "\"certificate_Label\"",
sl@0
    74
					/*const char *aGoodDeletable = "\"true\"",*/
sl@0
    75
					const char *aGoodFormat= "EX509Certificate",
sl@0
    76
					const char *aGoodCertOwnerType = "\"ECACertificate\"",
sl@0
    77
					const char *aGoodSubjectKeyId ="auto",
sl@0
    78
					const char *aGoodIssuerKeyId = "auto",
sl@0
    79
					const char *aGoodApplication = "\"SW Install\"",
sl@0
    80
					const char *aGoodTrusted = "\"true\"",
sl@0
    81
					const char *aGoodCapabilitySet = "TCB",
sl@0
    82
					const char *aGoodMandatory = "\"true\"",
sl@0
    83
					const char *aGoodSystemUpgrade = "\"true\"");
sl@0
    84
	void WriteExtraSwiEntry();
sl@0
    85
private:
sl@0
    86
	int iEntryCount;
sl@0
    87
	};
sl@0
    88
sl@0
    89
sl@0
    90
// to generate script and ini files to run tests on emulator
sl@0
    91
sl@0
    92
class ScriptAndIniGeneration : public GoodConfigWriter
sl@0
    93
	{
sl@0
    94
public:
sl@0
    95
	ScriptAndIniGeneration(const std::stringstream &aFileName);
sl@0
    96
	~ScriptAndIniGeneration();
sl@0
    97
	
sl@0
    98
	void WriteTestCaseToScript(const std::stringstream &aTestCaseType, int &aTestIndex, const char *aTestActionName, const char *aTestActionType, bool aHasActionBody = true);
sl@0
    99
sl@0
   100
protected:
sl@0
   101
	std::ofstream iIniFile;
sl@0
   102
	std::string   iIniFileName;
sl@0
   103
	};
sl@0
   104
sl@0
   105
sl@0
   106
// to generate script files for the file certstore to run tests on emulator
sl@0
   107
sl@0
   108
class FileStoreScriptGeneration : public ScriptAndIniGeneration
sl@0
   109
	{
sl@0
   110
public:
sl@0
   111
	FileStoreScriptGeneration(const std::stringstream &aFileName);
sl@0
   112
	~FileStoreScriptGeneration();
sl@0
   113
	
sl@0
   114
	void WriteInitialiseCert(const char *aMode, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   115
	void WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   116
	void WriteGetCertificateDetails(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   117
	void WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   118
	void WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   119
	void WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   120
	};
sl@0
   121
sl@0
   122
sl@0
   123
// to generate script files for the cert cleint store to run tests on emulator
sl@0
   124
sl@0
   125
class CertClientsStoreScriptGeneration : public ScriptAndIniGeneration
sl@0
   126
	{
sl@0
   127
public:
sl@0
   128
	CertClientsStoreScriptGeneration(const std::stringstream &aFileName);
sl@0
   129
	~CertClientsStoreScriptGeneration();
sl@0
   130
	
sl@0
   131
	void WriteInitialiseCertClient(const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   132
	void WriteGetCount(const int index, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   133
	void WriteGetApplicationsList(const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   134
	void WriteGetAppWithUid(const char *label, const char *uid, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   135
	void WriteDestroyManager(const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   136
	};
sl@0
   137
sl@0
   138
sl@0
   139
// to generate script files for the swicertstore to run tests on emulator
sl@0
   140
sl@0
   141
class SWIStoreScriptGeneration : public ScriptAndIniGeneration
sl@0
   142
	{
sl@0
   143
public:
sl@0
   144
	SWIStoreScriptGeneration(const std::stringstream &aFileName);
sl@0
   145
	~SWIStoreScriptGeneration();
sl@0
   146
	
sl@0
   147
	void WriteInitialiseCert(const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   148
	void WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   149
	void WriteGetSystemUpgrade(const char *label , const char *aSystemUpgrade, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   150
	void WriteGetCapabilities(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   151
	void WriteGetMandatoryFlag(const char *label, const char *aMandatory, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   152
	void WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   153
	void WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   154
	void WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex);
sl@0
   155
	};
sl@0
   156
sl@0
   157
class EmptyFileConfigWriter : public GoodConfigWriter
sl@0
   158
	{
sl@0
   159
public:
sl@0
   160
	EmptyFileConfigWriter(const std::stringstream &aFileName);
sl@0
   161
	~EmptyFileConfigWriter();
sl@0
   162
	};
sl@0
   163
sl@0
   164
#endif