os/security/securityanddataprivacytools/securitytools/certapp/test/tcertapp/goodconfigwriter.cpp
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 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include "goodconfigwriter.h"
    20 #include <iostream>
    21 #include <sstream>
    22 #include <stdio.h>
    23 #include "tcertapp_good.h"
    24 
    25 // Array for the StatCA- holds all relevant details
    26 const char *swicertemu_array[]=
    27 	{
    28 	"X509",
    29 	"c7014670ad9c8ac296c2ae665c4e78f3d4df4a99"
    30 	};
    31 
    32 const char *cert_array[]=
    33 	{
    34 	"X509",
    35 	"ca",
    36 	"7ce306295116207214d425affd185b6d5e48af6f",
    37 	"",
    38 	"1"
    39 	};
    40 
    41 // uids required for cacerts
    42 const char *emu_cacertsUid[]=
    43 	{
    44 	"268452523",
    45 	"268478646"
    46 	};
    47 
    48 
    49 /**
    50 Class required to create files to write data
    51 */
    52 GoodConfigWriter::GoodConfigWriter(const std::stringstream &aFileName)
    53 {
    54 	std::string name = aFileName.str();
    55 	iFile.open(name.c_str(), std::ios_base::trunc | std::ios_base::out);
    56 	if(iFile.fail())
    57 		{
    58 		std::cout << "Failed to open '" << name.c_str()<< "' for output!" << std::endl;
    59 		exit(-1);
    60 		}
    61 }
    62 
    63 GoodConfigWriter::~GoodConfigWriter()
    64 {
    65 	iFile.close();
    66 }
    67 
    68 /**
    69 Class definition for creating cacerts config files
    70 */
    71 FileCertStoreConfigWriter::FileCertStoreConfigWriter(const std::stringstream &aFileName)
    72 	: GoodConfigWriter(aFileName), iEntryCount(0)
    73 {
    74 	iFile << "StartCertStoreEntries" << std::endl;
    75 }
    76 
    77 FileCertStoreConfigWriter::~FileCertStoreConfigWriter()
    78 {
    79 	iFile << "EndCertStoreEntries" << std::endl;
    80 }
    81 
    82 void FileCertStoreConfigWriter::WriteExtraFileEntry()
    83 {
    84 	iFile << "\tStartEntry " << "\"AugmentData\"" << std::endl;
    85 	iFile << "\t\tDeletable " << "\"true\"" << std::endl;
    86 	iFile << "\t\tFormat " << "\"EX509Certificate\"" << std::endl;
    87 	iFile << "\t\tCertOwnerType " << "\"ECACertificate\"" << std::endl;
    88 	iFile << "\t\tSubjectKeyId " << "auto" << std::endl;
    89 	iFile << "\t\tIssuerKeyId " << "auto" << std::endl;
    90 	iFile << "\t\tStartApplicationList" << std::endl;
    91 	iFile << "\t\t\t#Entry 1" << std::endl;
    92 	iFile << "\t\t\t\tApplication " << "\"0x100042ab\"" << std::endl;
    93 	iFile << "\t\t\t\tApplication " << "\"0x1000a8b6\"" << std::endl;
    94 	iFile << "\t\tEndApplicationList" << std::endl;
    95 	iFile << "\t\tTrusted " << "\"true\"" << std::endl;
    96 	iFile << "\t\tDataFileName " << "\"cert0.der\"" << std::endl;
    97 	iFile <<"\tEndEntry" <<std::endl;
    98 }
    99 
   100 void FileCertStoreConfigWriter::WriteFileEntry(const char *aGoodLabel,
   101 										   const char *aGoodDeletable,
   102 										   const char *aGoodFormat,
   103 										   const char *aGoodCertOwnerType,
   104 										   const char *aGoodSubjectKeyId,
   105 										   const char *aGoodIssuerKeyId,
   106 										   const char *aGoodApplication,
   107 										   const char *aGoodTrusted,
   108 										   const char *aGoodDataFileName)
   109 {
   110 	++iEntryCount;
   111 	// Setup default values
   112 	if(!aGoodDeletable) 
   113 	{
   114 	aGoodDeletable = "\"true\"";
   115 	}
   116 	if(!aGoodFormat) aGoodFormat = "\"EX509Certificate\"";
   117 	if(!aGoodCertOwnerType) aGoodCertOwnerType = "\"ECACertificate\"";
   118 	if(!aGoodSubjectKeyId) aGoodSubjectKeyId = "auto";
   119 	if(!aGoodIssuerKeyId) aGoodIssuerKeyId = "auto";
   120 	if(!aGoodApplication) aGoodApplication = "\"Server Authentication\"";
   121 	if(!aGoodTrusted) aGoodTrusted = "\"true\"";
   122 	
   123 	iFile << "\t# Entry " << iEntryCount << std::endl;
   124 	iFile << "\tStartEntry " << aGoodLabel <<std::endl;
   125 	iFile << "\t\tDeletable " << aGoodDeletable << std::endl;
   126 	iFile << "\t\tFormat " << aGoodFormat << std::endl;
   127 	iFile << "\t\tCertOwnerType " << aGoodCertOwnerType << std::endl;
   128 	iFile << "\t\tSubjectKeyId " << aGoodSubjectKeyId << std::endl;
   129 	iFile << "\t\tIssuerKeyId " << aGoodIssuerKeyId << std::endl;
   130 	iFile << "\t\tStartApplicationList" << std::endl;
   131 	// write down the applications
   132 	for(int i = 0; i<2; i++)
   133 		{
   134 		iFile << "\t\t\t# Entry " << i << std::endl;
   135 		iFile << "\t\t\t\tApplication " << goodApplications[i]<< std::endl;
   136 		}
   137 	iFile << "\t\tEndApplicationList" << std::endl;
   138 	iFile << "\t\tTrusted " << aGoodTrusted << std::endl;
   139 	iFile << "\t\tDataFileName " << aGoodDataFileName << std::endl;
   140 	iFile <<"\tEndEntry" <<std::endl;
   141 }
   142 
   143 /**
   144 Class definition for generating certclient configuration files
   145 */
   146 FileCertClientConfigWriter::FileCertClientConfigWriter(const std::stringstream &aFileName)
   147 	: GoodConfigWriter(aFileName),iEntryCount(0)
   148 {
   149 	iFile << "StartClientInfo" << std::endl;
   150 }
   151 
   152 FileCertClientConfigWriter::~FileCertClientConfigWriter()
   153 {
   154 	iFile << "EndClientInfo" << std::endl;
   155 }
   156 
   157 void FileCertClientConfigWriter::WriteCertClientName(const char *aGoodAppName)
   158 {
   159 	iFile << "\t\tName "<< aGoodAppName << std::endl;
   160 }
   161 
   162 void FileCertClientConfigWriter::WriteCertClientUid(const char *aGoodUid)
   163 {
   164 	++iEntryCount;
   165 	iFile << "\t#Entry "<< iEntryCount << std::endl;
   166 	iFile << "\t\tUid "<< aGoodUid << std::endl;
   167 }
   168 
   169 void FileCertClientConfigWriter::WriteExtraCertClientEntry()
   170 {
   171 	iFile << "\t#Entry "<< iEntryCount << std::endl;
   172 	iFile << "\t\tUid "<< "0x12345678" << std::endl;
   173 	iFile << "\t\tName "<< "Augment_Label" << std::endl;
   174 }
   175 
   176 /**
   177 Swi certstore config writer
   178 */
   179 SwiCertStoreConfigWriter::SwiCertStoreConfigWriter(const std::stringstream &aFileName)
   180 	: GoodConfigWriter(aFileName), iEntryCount(0)
   181 {
   182 	iFile <<"StartSwiCertStoreEntries" << std::endl;
   183 }
   184 
   185 SwiCertStoreConfigWriter::~SwiCertStoreConfigWriter()
   186 {
   187 	iFile << "EndSwiCertStoreEntries" << std::endl;
   188 }
   189 
   190 void SwiCertStoreConfigWriter::WriteExtraSwiEntry()
   191 {
   192 	iFile << "\tStartEntry " << "\"AugmentData\"" << std::endl;
   193 	iFile << "\t\tFormat " << "\"EX509Certificate\"" << std::endl;
   194 	iFile << "\t\tCertOwnerType " << "\"ECACertificate\"" << std::endl;
   195 	iFile << "\t\tSubjectKeyId " << "auto" << std::endl;
   196 	iFile << "\t\tIssuerKeyId " << "auto" << std::endl;
   197 	iFile << "\t\tStartApplicationList" << std::endl;
   198 	iFile << "\t\t\t# Entry 1" << std::endl;
   199 	iFile << "\t\t\t\tApplication " << "0x1000aaaa" << std::endl;
   200 	iFile << "\t\tEndApplicationList" << std::endl;
   201 	iFile << "\t\tTrusted " << "true" << std::endl;
   202 	iFile << "\t\tDataFileName " << "\"swicertstore_cert0.der\"" << std::endl;
   203 	iFile << "\t\tCapabilitySet " << "{ TCB LocalServices }";
   204 	iFile << "\t\tMandatory " << "true" << std::endl;
   205 	iFile << "\t\tSystemUpgrade " << "false"<< std::endl;
   206 	iFile <<"\tEndEntry" <<std::endl;
   207 }
   208 
   209 
   210 void SwiCertStoreConfigWriter::WriteSwiEntry(const char *aGoodLabel,
   211 										   const char *aGoodFormat,
   212 										   const char *aGoodCertOwnerType,
   213 										   const char *aGoodSubjectKeyId,
   214 										   const char *aGoodIssuerKeyId,
   215 										   const char *aGoodApplication,
   216 										   const char *aGoodTrusted,
   217 										   const char *aGoodCapabilitySets,
   218 										   const char *aGoodMandatory,
   219 										   const char *aGoodSystemUpgrade)
   220 {
   221 	++iEntryCount;
   222 	// Setup default values
   223 	if(!aGoodFormat) aGoodFormat = "\"EX509Certificate\"";
   224 	if(!aGoodCertOwnerType) aGoodCertOwnerType = "ECACertificate";
   225 	if(!aGoodSubjectKeyId) aGoodSubjectKeyId = "auto";
   226 	if(!aGoodIssuerKeyId) aGoodIssuerKeyId = "auto";
   227 	if(!aGoodApplication) aGoodApplication = "\"Server Authentication\"";
   228 	if(!aGoodTrusted) aGoodTrusted = "\"true\"";
   229 	if(!aGoodCapabilitySets) aGoodCapabilitySets = "TCB";
   230 	if(!aGoodMandatory) aGoodMandatory = "\"true\"";
   231 	if(!aGoodSystemUpgrade) aGoodSystemUpgrade = "\"true\"";
   232 
   233 	iFile << "\t#Entry " << iEntryCount << std::endl;
   234 	iFile << "\tStartEntry " << aGoodLabel << std::endl;
   235 	iFile << "\t\tFormat " << aGoodFormat << std::endl;
   236 	iFile << "\t\tCertOwnerType " << aGoodCertOwnerType << std::endl;
   237 	iFile << "\t\tSubjectKeyId " << aGoodSubjectKeyId << std::endl;
   238 	iFile << "\t\tIssuerKeyId " << aGoodIssuerKeyId << std::endl;
   239 	iFile << "\t\tStartApplicationList" << std::endl;
   240 	//write application
   241 	for(int k = 0; k<2 ; k++)
   242 		{
   243 		iFile << "\t\t\t# Entry " << k << std::endl;
   244 		iFile << "\t\t\t\tApplication " << goodUids[k] << std::endl;
   245 		}
   246 	iFile << "\t\tEndApplicationList" << std::endl;
   247 	iFile << "\t\tTrusted " << aGoodTrusted << std::endl;
   248 	iFile << "\t\tDataFileName " << "\"swicertstore_cert0.der\"" << std::endl;
   249 	iFile << "\t\tCapabilitySet " << "{ ";
   250 	for(int i = 0; i< 20; i++)
   251 		{
   252 		iFile << goodCapabilitySets[i];
   253 		iFile <<" ";
   254 		}
   255 	iFile <<"}" <<std::endl;
   256 	iFile << "\t\tMandatory " << aGoodMandatory << std::endl;
   257 	iFile << "\t\tSystemUpgrade " << aGoodSystemUpgrade << std::endl;
   258 	iFile << "\tEndEntry" << std::endl;
   259 }
   260 
   261 
   262 //Script and INI file generator
   263 ScriptAndIniGeneration::ScriptAndIniGeneration(const std::stringstream &aFileName)
   264 	: GoodConfigWriter(aFileName)
   265 {
   266 	int last_dot = aFileName.str().rfind('.');
   267 	if(last_dot>=0)
   268 	{
   269 		iIniFileName = aFileName.str().substr(0,last_dot);
   270 		iIniFileName.append(".ini");
   271 		iIniFile.open(iIniFileName.c_str(), std::ios_base::trunc | std::ios_base::out);
   272 		if(iIniFile.fail())
   273 		{
   274 			std::cout << "Failed to open '" << iIniFileName.c_str()<< "' for output!" << std::endl;
   275 			exit(-1);
   276 		}
   277 	}	
   278 }
   279 
   280 ScriptAndIniGeneration::~ScriptAndIniGeneration()
   281 {
   282 	iIniFile.close();
   283 }
   284 
   285 void ScriptAndIniGeneration::WriteTestCaseToScript(const std::stringstream &aTestCaseType,int &aTestIndex,const char *aTestActionName,const char *aTestActionType,bool aHasActionBody)
   286 {
   287 	// set test case ID string
   288 	char testCaseIndexBuffer[6];
   289 	sprintf(testCaseIndexBuffer, "-%04d", aTestIndex);
   290 
   291 	iFile << "START_TESTCASE                " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
   292 	iFile << "//! @SYMTestCaseID            " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
   293 	iFile << "//! @SYMTestCaseDesc          " << aTestActionName << std::endl;
   294 	iFile << "RUN_TEST_STEP                 -1\tCTestHandler\t" << aTestActionType;
   295 	if(aHasActionBody)
   296 	{
   297 		iFile << "\t" << iIniFileName << "\t" << aTestCaseType.str() << testCaseIndexBuffer << "-001";
   298 		iIniFile << "[" << aTestCaseType.str() << testCaseIndexBuffer << "-001" << "]" << std::endl;
   299 	}
   300 	iFile << std::endl;
   301 	iFile << "END_TESTCASE                  " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
   302 	iFile << std::endl;
   303 }
   304 
   305 
   306 FileStoreScriptGeneration::FileStoreScriptGeneration(const std::stringstream &aFileName)
   307 	: ScriptAndIniGeneration(aFileName)
   308 {
   309 	
   310 }
   311 
   312 FileStoreScriptGeneration::~FileStoreScriptGeneration()
   313 {
   314 }
   315 
   316 void FileStoreScriptGeneration:: WriteInitialiseCert(const char *aMode, const std::stringstream &aTestCaseType, int &aTestIndex)
   317 {
   318 	const char *testcasename = "Initializing a CUnifiedCertStore";
   319 	const char *testcasetype = "init";
   320 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   321 	iIniFile << "<actionbody>" << std::endl;
   322 	iIniFile << "\t<mode>" << aMode << "</mode>" << std::endl;
   323 	iIniFile << "</actionbody>" << std::endl;
   324 	iIniFile << std::endl;
   325 }
   326 
   327 
   328 
   329 void  FileStoreScriptGeneration::WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex)
   330 {
   331 	const char *testcasename = "Get the list of certificates";
   332 	const char *testcasetype = "listcert";
   333 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   334 	iIniFile << "<actionbody>" << std::endl;
   335 	iIniFile << "\t<filter>" << std::endl;
   336 	iIniFile << "\t\t<ownertype>" << aGoodOwnerType << "</ownertype>" << std::endl;
   337 	iIniFile << "\t</filter>" << std::endl;
   338 	iIniFile << "</actionbody>" << std::endl;
   339 	iIniFile << "<actionresult>" << std::endl;
   340 	for(int z =0; z<6; z++)
   341 		{
   342 		iIniFile << "\t<CCTCertInfo><label>" << goodEmuCert_array[z] << "</label></CCTCertInfo>" << std::endl;
   343 		}
   344 	iIniFile << "</actionresult>" << std::endl;
   345 	iIniFile << std::endl;
   346 }
   347 
   348 void  FileStoreScriptGeneration::WriteGetCertificateDetails(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   349 {
   350 	const char *testcasename = "Get certificate details";
   351 	const char *testcasetype = "listcert";
   352 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   353 	int i = 0;
   354 	iIniFile << "<actionbody>" << std::endl;
   355 	iIniFile << "\t<filter>" << std::endl;
   356 	iIniFile << "\t\t<label>" << label << "</label>" << std::endl;
   357 	iIniFile << "\t\t<format>" << cert_array[i++]<< "</format>" << std::endl;
   358 	iIniFile << "\t\t<certowner>" << cert_array[i++] << "</certowner>" << std::endl;
   359 	iIniFile << "\t\t<subjectkeyid>" << cert_array[i++] << "</subjectkeyid>" << std::endl;
   360 	iIniFile << "\t\t<issuerkeyid>" <<cert_array[i++] << "</issuerkeyid>" << std::endl;
   361 	iIniFile << "\t\t<deletable>" << cert_array[i++] << "</deletable>" << std::endl;
   362 	iIniFile << "\t</filter>" << std::endl;
   363 	iIniFile << "</actionbody>" << std::endl;
   364 	iIniFile << "<actionresult>" << std::endl;
   365 	iIniFile << "\t<CCTCertInfo><label>" << label << "</label></CCTCertInfo>" << std::endl;
   366 	iIniFile << "</actionresult>" << std::endl;
   367 	iIniFile << std::endl;
   368 }
   369 
   370 
   371 void  FileStoreScriptGeneration::WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex)
   372 {
   373 	const char *testcasename = "Get Trust certificate";
   374 	const char *testcasetype = "gettrusters";
   375 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   376 	iIniFile << "<actionbody>" << std::endl;
   377 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   378 	iIniFile << "</actionbody>" << std::endl;
   379 	iIniFile << "<actionresult>" << std::endl;
   380 	iIniFile << "\t<trust>" << trust << "</trust>" << std::endl;
   381 	iIniFile << "</actionresult>" << std::endl;
   382 	iIniFile << std::endl;
   383 }
   384 
   385 
   386 void  FileStoreScriptGeneration::WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   387 {
   388 	const char *testcasename = "Get applications";
   389 	const char *testcasetype = "getapplications";
   390 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   391 	iIniFile << "<actionbody>" << std::endl;
   392 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   393 	iIniFile << "</actionbody>" << std::endl;
   394 	iIniFile << "<actionresult>" << std::endl;
   395 	iIniFile << "\t<uid>";
   396 	for(int j = 0; j<2; j++)
   397 		{
   398 		iIniFile << emu_cacertsUid[j] << " ";
   399 		}
   400 	iIniFile << "</uid>" << std::endl;
   401 	iIniFile << "</actionresult>" << std::endl;
   402 	iIniFile << std::endl;
   403 }
   404 
   405 
   406 void  FileStoreScriptGeneration::WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   407 {
   408 	const char *testcasename = "Retrieve Certificate";
   409 	const char *testcasetype = "retrieve";
   410 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   411 	iIniFile << "<actionbody>" << std::endl;
   412 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   413 	iIniFile << "</actionbody>" << std::endl;
   414 	iIniFile << std::endl;
   415 }
   416 
   417 
   418 
   419 //Swi store script generator for emulator tests
   420 SWIStoreScriptGeneration::SWIStoreScriptGeneration(const std::stringstream &aFileName)
   421 	: ScriptAndIniGeneration(aFileName)
   422 {
   423 	
   424 }
   425 
   426 SWIStoreScriptGeneration::~SWIStoreScriptGeneration()
   427 {
   428 }
   429 
   430 void SWIStoreScriptGeneration:: WriteInitialiseCert(const std::stringstream &aTestCaseType, int &aTestIndex)
   431 {
   432 	const char *testcasename = "Initialise a SWICertStore";
   433 	const char *testcasetype = "initswicertstore";
   434 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
   435 }
   436 
   437 
   438 void  SWIStoreScriptGeneration::WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex)
   439 {
   440 	const char *testcasename = "Get the list of certificates";
   441 	const char *testcasetype = "listcert";
   442 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   443 	iIniFile << "<actionbody>" << std::endl;
   444 	iIniFile << "\t<filter>" << std::endl;
   445 	iIniFile << "\t\t<ownertype>" << aGoodOwnerType << "</ownertype>" << std::endl;
   446 	iIniFile << "\t</filter>" << std::endl;
   447 	iIniFile << "</actionbody>" << std::endl;
   448 	iIniFile << "<actionresult>" << std::endl;
   449 	for(int i =0; i<6; i++)
   450 		{
   451 		iIniFile << "\t<CCTCertInfo><label>" << goodSwiCert_array[i] << "</label><readonly>True</readonly></CCTCertInfo>" << std::endl;
   452 		}
   453 	iIniFile << "</actionresult>" << std::endl;
   454 	iIniFile << std::endl;
   455 }
   456 
   457 void  SWIStoreScriptGeneration::WriteGetSystemUpgrade(const char *label, const char *aSystemUpgrade, const std::stringstream &aTestCaseType, int &aTestIndex)
   458 {
   459 	const char *testcasename = "Get the systemupgrade flag";
   460 	const char *testcasetype = "getsystemupgrade";
   461 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   462 	iIniFile << "<actionbody>" << std::endl;
   463 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   464 	iIniFile << "</actionbody>" << std::endl;
   465 	iIniFile << "<actionresult>" << std::endl;
   466 	iIniFile << "\t<systemupgrade>" << aSystemUpgrade << "</systemupgrade>" << std::endl;
   467 	iIniFile << "</actionresult>" << std::endl;
   468 	iIniFile << std::endl;
   469 }
   470 
   471 
   472 void  SWIStoreScriptGeneration::WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   473 {
   474 	const char *testcasename = "Retrieve Certificate";
   475 	const char *testcasetype = "retrieve";
   476 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   477 	iIniFile << "<actionbody>" << std::endl;
   478 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   479 	iIniFile << "</actionbody>" << std::endl;
   480 	iIniFile << std::endl;
   481 }
   482 
   483 
   484 
   485 void  SWIStoreScriptGeneration::WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   486 {
   487 	const char *testcasename = "Get applications";
   488 	const char *testcasetype = "getapplications";
   489 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   490 	iIniFile << "<actionbody>" << std::endl;
   491 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   492 	iIniFile << "</actionbody>" << std::endl;
   493 	iIniFile << "<actionresult>" << std::endl;
   494 	iIniFile << "\t<uid>";
   495 	for(int j = 0; j<2; j++)
   496 		{
   497 		iIniFile << emu_cacertsUid[j] << " ";
   498 		}
   499 	iIniFile << "</uid>" << std::endl;
   500 	iIniFile << "</actionresult>" << std::endl;
   501 	iIniFile << std::endl;
   502 }
   503 
   504 
   505 void  SWIStoreScriptGeneration::WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex)
   506 {
   507 	const char *testcasename = "Get Trust certificate";
   508 	const char *testcasetype = "gettrusters";
   509 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   510 	iIniFile << "<actionbody>" << std::endl;
   511 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   512 	iIniFile << "</actionbody>" << std::endl;
   513 	iIniFile << "<actionresult>" << std::endl;
   514 	iIniFile << "\t<trust>" << trust << "</trust>" << std::endl;
   515 	iIniFile << "</actionresult>" << std::endl;
   516 	iIniFile << std::endl;
   517 }
   518 
   519 
   520 
   521 void  SWIStoreScriptGeneration::WriteGetCapabilities(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
   522 {
   523 	const char *testcasename = "Get the capabilities";
   524 	const char *testcasetype = "getcapabilities";
   525 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   526 	iIniFile << "<actionbody>" << std::endl;
   527 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   528 	iIniFile << "</actionbody>" << std::endl;
   529 	iIniFile << "<actionresult>" << std::endl;
   530 	for(int i=0; i<20; i++)
   531 		{
   532 		iIniFile << "\t<capability>" << goodCapabilitySets[i] << "</capability>" << std::endl;
   533 		}
   534 	iIniFile << "</actionresult>" << std::endl;
   535 	iIniFile << std::endl;
   536 }
   537 
   538 
   539 void  SWIStoreScriptGeneration::WriteGetMandatoryFlag(const char *label, const char *aMandatory, const std::stringstream &aTestCaseType, int &aTestIndex)
   540 {
   541 	const char *testcasename = "Get the mandatory flag";
   542 	const char *testcasetype = "getmandatory";
   543 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   544 	iIniFile << "<actionbody>" << std::endl;
   545 	iIniFile << "\t<label>" << label << "</label>" << std::endl;
   546 	iIniFile << "</actionbody>" << std::endl;
   547 	iIniFile << "<actionresult>" << std::endl;
   548 	iIniFile << "\t<mandatory>" << aMandatory << "</mandatory>" << std::endl;
   549 	iIniFile << "</actionresult>" << std::endl;
   550 	iIniFile << std::endl;
   551 }
   552 
   553 
   554 //Cert client script generator
   555 CertClientsStoreScriptGeneration::CertClientsStoreScriptGeneration(const std::stringstream &aFileName)
   556 	: ScriptAndIniGeneration(aFileName)
   557 {
   558 }
   559 
   560 CertClientsStoreScriptGeneration::~CertClientsStoreScriptGeneration()
   561 {
   562 }
   563 
   564 void CertClientsStoreScriptGeneration::WriteInitialiseCertClient(const std::stringstream &aTestCaseType, int &aTestIndex)
   565 {
   566 	const char *testcasename = "Initialise a CertClientStore";
   567 	const char *testcasetype = "InitManager";
   568 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
   569 }
   570 
   571 void CertClientsStoreScriptGeneration::WriteGetCount(const int aApp_uidIndex, const std::stringstream &aTestCaseType, int &aTestIndex)
   572 {
   573 	const char *testcasename = "Get Count of Applications";
   574 	const char *testcasetype = "AppCount";
   575 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   576 	iIniFile << "<actionbody>" << std::endl;
   577 	iIniFile << "\t<count>" << aApp_uidIndex << "</count>" << std::endl;
   578 	iIniFile << "</actionbody>" << std::endl;
   579 	iIniFile << std::endl;
   580 }
   581 
   582 
   583 void CertClientsStoreScriptGeneration::WriteGetApplicationsList(const std::stringstream &aTestCaseType, int &aTestIndex)
   584 {
   585 	const char *testcasename = "Getting the application list";
   586 	const char *testcasetype = "GetApplications";
   587 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   588 	iIniFile << "<actionbody>" << std::endl;
   589 	for(int i = 0 ; i<4 ; i++)
   590 		{
   591 		iIniFile << "\t<uid>" << gooddecimalUid_array[i] << "</uid>"<<"<appname>" << goodcertclient_array[i] << "</appname>" << std::endl;
   592 		}
   593 	iIniFile << "</actionbody>" << std::endl;
   594 	iIniFile << std::endl;
   595 }
   596 
   597 
   598 void CertClientsStoreScriptGeneration::WriteGetAppWithUid(const char *goodlabel,const char *uid,const std::stringstream &aTestCaseType,int &aTestIndex)
   599 {
   600 	const char *testcasename = "Get application with given id";
   601 	const char *testcasetype = "GetApp";
   602 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
   603 	iIniFile << "<actionbody>" << std::endl;
   604 	iIniFile << "\t<uid>" << uid << "</uid>" << std::endl;
   605 	iIniFile << "\t<appname>" << goodlabel << "</appname>" << std::endl;
   606 	iIniFile << "</actionbody>" << std::endl;
   607 	iIniFile << std::endl;
   608 }
   609 
   610 
   611 void CertClientsStoreScriptGeneration::WriteDestroyManager(const std::stringstream &aTestCaseType, int &aTestIndex)
   612 {
   613 	const char *testcasename = "Destroy the manager";
   614 	const char *testcasetype = "DestroyManager";
   615 	WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
   616 }
   617 
   618 
   619 /**
   620 Class definition for creating cacerts
   621 */
   622 EmptyFileConfigWriter::EmptyFileConfigWriter(const std::stringstream &aFileName)
   623 	: GoodConfigWriter(aFileName)
   624 {
   625 	iFile << "StartCertStoreEntries" << std::endl;
   626 }
   627 
   628 EmptyFileConfigWriter::~EmptyFileConfigWriter()
   629 {
   630 	iFile << "EndCertStoreEntries" << std::endl;
   631 }
   632 
   633 // End of file
   634