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