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