os/security/securityanddataprivacytools/securitytools/certapp/test/tcertapp/goodconfigwriter.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/securityanddataprivacytools/securitytools/certapp/test/tcertapp/goodconfigwriter.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,634 @@
1.4 +/*
1.5 +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "goodconfigwriter.h"
1.23 +#include <iostream>
1.24 +#include <sstream>
1.25 +#include <stdio.h>
1.26 +#include "tcertapp_good.h"
1.27 +
1.28 +// Array for the StatCA- holds all relevant details
1.29 +const char *swicertemu_array[]=
1.30 + {
1.31 + "X509",
1.32 + "c7014670ad9c8ac296c2ae665c4e78f3d4df4a99"
1.33 + };
1.34 +
1.35 +const char *cert_array[]=
1.36 + {
1.37 + "X509",
1.38 + "ca",
1.39 + "7ce306295116207214d425affd185b6d5e48af6f",
1.40 + "",
1.41 + "1"
1.42 + };
1.43 +
1.44 +// uids required for cacerts
1.45 +const char *emu_cacertsUid[]=
1.46 + {
1.47 + "268452523",
1.48 + "268478646"
1.49 + };
1.50 +
1.51 +
1.52 +/**
1.53 +Class required to create files to write data
1.54 +*/
1.55 +GoodConfigWriter::GoodConfigWriter(const std::stringstream &aFileName)
1.56 +{
1.57 + std::string name = aFileName.str();
1.58 + iFile.open(name.c_str(), std::ios_base::trunc | std::ios_base::out);
1.59 + if(iFile.fail())
1.60 + {
1.61 + std::cout << "Failed to open '" << name.c_str()<< "' for output!" << std::endl;
1.62 + exit(-1);
1.63 + }
1.64 +}
1.65 +
1.66 +GoodConfigWriter::~GoodConfigWriter()
1.67 +{
1.68 + iFile.close();
1.69 +}
1.70 +
1.71 +/**
1.72 +Class definition for creating cacerts config files
1.73 +*/
1.74 +FileCertStoreConfigWriter::FileCertStoreConfigWriter(const std::stringstream &aFileName)
1.75 + : GoodConfigWriter(aFileName), iEntryCount(0)
1.76 +{
1.77 + iFile << "StartCertStoreEntries" << std::endl;
1.78 +}
1.79 +
1.80 +FileCertStoreConfigWriter::~FileCertStoreConfigWriter()
1.81 +{
1.82 + iFile << "EndCertStoreEntries" << std::endl;
1.83 +}
1.84 +
1.85 +void FileCertStoreConfigWriter::WriteExtraFileEntry()
1.86 +{
1.87 + iFile << "\tStartEntry " << "\"AugmentData\"" << std::endl;
1.88 + iFile << "\t\tDeletable " << "\"true\"" << std::endl;
1.89 + iFile << "\t\tFormat " << "\"EX509Certificate\"" << std::endl;
1.90 + iFile << "\t\tCertOwnerType " << "\"ECACertificate\"" << std::endl;
1.91 + iFile << "\t\tSubjectKeyId " << "auto" << std::endl;
1.92 + iFile << "\t\tIssuerKeyId " << "auto" << std::endl;
1.93 + iFile << "\t\tStartApplicationList" << std::endl;
1.94 + iFile << "\t\t\t#Entry 1" << std::endl;
1.95 + iFile << "\t\t\t\tApplication " << "\"0x100042ab\"" << std::endl;
1.96 + iFile << "\t\t\t\tApplication " << "\"0x1000a8b6\"" << std::endl;
1.97 + iFile << "\t\tEndApplicationList" << std::endl;
1.98 + iFile << "\t\tTrusted " << "\"true\"" << std::endl;
1.99 + iFile << "\t\tDataFileName " << "\"cert0.der\"" << std::endl;
1.100 + iFile <<"\tEndEntry" <<std::endl;
1.101 +}
1.102 +
1.103 +void FileCertStoreConfigWriter::WriteFileEntry(const char *aGoodLabel,
1.104 + const char *aGoodDeletable,
1.105 + const char *aGoodFormat,
1.106 + const char *aGoodCertOwnerType,
1.107 + const char *aGoodSubjectKeyId,
1.108 + const char *aGoodIssuerKeyId,
1.109 + const char *aGoodApplication,
1.110 + const char *aGoodTrusted,
1.111 + const char *aGoodDataFileName)
1.112 +{
1.113 + ++iEntryCount;
1.114 + // Setup default values
1.115 + if(!aGoodDeletable)
1.116 + {
1.117 + aGoodDeletable = "\"true\"";
1.118 + }
1.119 + if(!aGoodFormat) aGoodFormat = "\"EX509Certificate\"";
1.120 + if(!aGoodCertOwnerType) aGoodCertOwnerType = "\"ECACertificate\"";
1.121 + if(!aGoodSubjectKeyId) aGoodSubjectKeyId = "auto";
1.122 + if(!aGoodIssuerKeyId) aGoodIssuerKeyId = "auto";
1.123 + if(!aGoodApplication) aGoodApplication = "\"Server Authentication\"";
1.124 + if(!aGoodTrusted) aGoodTrusted = "\"true\"";
1.125 +
1.126 + iFile << "\t# Entry " << iEntryCount << std::endl;
1.127 + iFile << "\tStartEntry " << aGoodLabel <<std::endl;
1.128 + iFile << "\t\tDeletable " << aGoodDeletable << std::endl;
1.129 + iFile << "\t\tFormat " << aGoodFormat << std::endl;
1.130 + iFile << "\t\tCertOwnerType " << aGoodCertOwnerType << std::endl;
1.131 + iFile << "\t\tSubjectKeyId " << aGoodSubjectKeyId << std::endl;
1.132 + iFile << "\t\tIssuerKeyId " << aGoodIssuerKeyId << std::endl;
1.133 + iFile << "\t\tStartApplicationList" << std::endl;
1.134 + // write down the applications
1.135 + for(int i = 0; i<2; i++)
1.136 + {
1.137 + iFile << "\t\t\t# Entry " << i << std::endl;
1.138 + iFile << "\t\t\t\tApplication " << goodApplications[i]<< std::endl;
1.139 + }
1.140 + iFile << "\t\tEndApplicationList" << std::endl;
1.141 + iFile << "\t\tTrusted " << aGoodTrusted << std::endl;
1.142 + iFile << "\t\tDataFileName " << aGoodDataFileName << std::endl;
1.143 + iFile <<"\tEndEntry" <<std::endl;
1.144 +}
1.145 +
1.146 +/**
1.147 +Class definition for generating certclient configuration files
1.148 +*/
1.149 +FileCertClientConfigWriter::FileCertClientConfigWriter(const std::stringstream &aFileName)
1.150 + : GoodConfigWriter(aFileName),iEntryCount(0)
1.151 +{
1.152 + iFile << "StartClientInfo" << std::endl;
1.153 +}
1.154 +
1.155 +FileCertClientConfigWriter::~FileCertClientConfigWriter()
1.156 +{
1.157 + iFile << "EndClientInfo" << std::endl;
1.158 +}
1.159 +
1.160 +void FileCertClientConfigWriter::WriteCertClientName(const char *aGoodAppName)
1.161 +{
1.162 + iFile << "\t\tName "<< aGoodAppName << std::endl;
1.163 +}
1.164 +
1.165 +void FileCertClientConfigWriter::WriteCertClientUid(const char *aGoodUid)
1.166 +{
1.167 + ++iEntryCount;
1.168 + iFile << "\t#Entry "<< iEntryCount << std::endl;
1.169 + iFile << "\t\tUid "<< aGoodUid << std::endl;
1.170 +}
1.171 +
1.172 +void FileCertClientConfigWriter::WriteExtraCertClientEntry()
1.173 +{
1.174 + iFile << "\t#Entry "<< iEntryCount << std::endl;
1.175 + iFile << "\t\tUid "<< "0x12345678" << std::endl;
1.176 + iFile << "\t\tName "<< "Augment_Label" << std::endl;
1.177 +}
1.178 +
1.179 +/**
1.180 +Swi certstore config writer
1.181 +*/
1.182 +SwiCertStoreConfigWriter::SwiCertStoreConfigWriter(const std::stringstream &aFileName)
1.183 + : GoodConfigWriter(aFileName), iEntryCount(0)
1.184 +{
1.185 + iFile <<"StartSwiCertStoreEntries" << std::endl;
1.186 +}
1.187 +
1.188 +SwiCertStoreConfigWriter::~SwiCertStoreConfigWriter()
1.189 +{
1.190 + iFile << "EndSwiCertStoreEntries" << std::endl;
1.191 +}
1.192 +
1.193 +void SwiCertStoreConfigWriter::WriteExtraSwiEntry()
1.194 +{
1.195 + iFile << "\tStartEntry " << "\"AugmentData\"" << std::endl;
1.196 + iFile << "\t\tFormat " << "\"EX509Certificate\"" << std::endl;
1.197 + iFile << "\t\tCertOwnerType " << "\"ECACertificate\"" << std::endl;
1.198 + iFile << "\t\tSubjectKeyId " << "auto" << std::endl;
1.199 + iFile << "\t\tIssuerKeyId " << "auto" << std::endl;
1.200 + iFile << "\t\tStartApplicationList" << std::endl;
1.201 + iFile << "\t\t\t# Entry 1" << std::endl;
1.202 + iFile << "\t\t\t\tApplication " << "0x1000aaaa" << std::endl;
1.203 + iFile << "\t\tEndApplicationList" << std::endl;
1.204 + iFile << "\t\tTrusted " << "true" << std::endl;
1.205 + iFile << "\t\tDataFileName " << "\"swicertstore_cert0.der\"" << std::endl;
1.206 + iFile << "\t\tCapabilitySet " << "{ TCB LocalServices }";
1.207 + iFile << "\t\tMandatory " << "true" << std::endl;
1.208 + iFile << "\t\tSystemUpgrade " << "false"<< std::endl;
1.209 + iFile <<"\tEndEntry" <<std::endl;
1.210 +}
1.211 +
1.212 +
1.213 +void SwiCertStoreConfigWriter::WriteSwiEntry(const char *aGoodLabel,
1.214 + const char *aGoodFormat,
1.215 + const char *aGoodCertOwnerType,
1.216 + const char *aGoodSubjectKeyId,
1.217 + const char *aGoodIssuerKeyId,
1.218 + const char *aGoodApplication,
1.219 + const char *aGoodTrusted,
1.220 + const char *aGoodCapabilitySets,
1.221 + const char *aGoodMandatory,
1.222 + const char *aGoodSystemUpgrade)
1.223 +{
1.224 + ++iEntryCount;
1.225 + // Setup default values
1.226 + if(!aGoodFormat) aGoodFormat = "\"EX509Certificate\"";
1.227 + if(!aGoodCertOwnerType) aGoodCertOwnerType = "ECACertificate";
1.228 + if(!aGoodSubjectKeyId) aGoodSubjectKeyId = "auto";
1.229 + if(!aGoodIssuerKeyId) aGoodIssuerKeyId = "auto";
1.230 + if(!aGoodApplication) aGoodApplication = "\"Server Authentication\"";
1.231 + if(!aGoodTrusted) aGoodTrusted = "\"true\"";
1.232 + if(!aGoodCapabilitySets) aGoodCapabilitySets = "TCB";
1.233 + if(!aGoodMandatory) aGoodMandatory = "\"true\"";
1.234 + if(!aGoodSystemUpgrade) aGoodSystemUpgrade = "\"true\"";
1.235 +
1.236 + iFile << "\t#Entry " << iEntryCount << std::endl;
1.237 + iFile << "\tStartEntry " << aGoodLabel << std::endl;
1.238 + iFile << "\t\tFormat " << aGoodFormat << std::endl;
1.239 + iFile << "\t\tCertOwnerType " << aGoodCertOwnerType << std::endl;
1.240 + iFile << "\t\tSubjectKeyId " << aGoodSubjectKeyId << std::endl;
1.241 + iFile << "\t\tIssuerKeyId " << aGoodIssuerKeyId << std::endl;
1.242 + iFile << "\t\tStartApplicationList" << std::endl;
1.243 + //write application
1.244 + for(int k = 0; k<2 ; k++)
1.245 + {
1.246 + iFile << "\t\t\t# Entry " << k << std::endl;
1.247 + iFile << "\t\t\t\tApplication " << goodUids[k] << std::endl;
1.248 + }
1.249 + iFile << "\t\tEndApplicationList" << std::endl;
1.250 + iFile << "\t\tTrusted " << aGoodTrusted << std::endl;
1.251 + iFile << "\t\tDataFileName " << "\"swicertstore_cert0.der\"" << std::endl;
1.252 + iFile << "\t\tCapabilitySet " << "{ ";
1.253 + for(int i = 0; i< 20; i++)
1.254 + {
1.255 + iFile << goodCapabilitySets[i];
1.256 + iFile <<" ";
1.257 + }
1.258 + iFile <<"}" <<std::endl;
1.259 + iFile << "\t\tMandatory " << aGoodMandatory << std::endl;
1.260 + iFile << "\t\tSystemUpgrade " << aGoodSystemUpgrade << std::endl;
1.261 + iFile << "\tEndEntry" << std::endl;
1.262 +}
1.263 +
1.264 +
1.265 +//Script and INI file generator
1.266 +ScriptAndIniGeneration::ScriptAndIniGeneration(const std::stringstream &aFileName)
1.267 + : GoodConfigWriter(aFileName)
1.268 +{
1.269 + int last_dot = aFileName.str().rfind('.');
1.270 + if(last_dot>=0)
1.271 + {
1.272 + iIniFileName = aFileName.str().substr(0,last_dot);
1.273 + iIniFileName.append(".ini");
1.274 + iIniFile.open(iIniFileName.c_str(), std::ios_base::trunc | std::ios_base::out);
1.275 + if(iIniFile.fail())
1.276 + {
1.277 + std::cout << "Failed to open '" << iIniFileName.c_str()<< "' for output!" << std::endl;
1.278 + exit(-1);
1.279 + }
1.280 + }
1.281 +}
1.282 +
1.283 +ScriptAndIniGeneration::~ScriptAndIniGeneration()
1.284 +{
1.285 + iIniFile.close();
1.286 +}
1.287 +
1.288 +void ScriptAndIniGeneration::WriteTestCaseToScript(const std::stringstream &aTestCaseType,int &aTestIndex,const char *aTestActionName,const char *aTestActionType,bool aHasActionBody)
1.289 +{
1.290 + // set test case ID string
1.291 + char testCaseIndexBuffer[6];
1.292 + sprintf(testCaseIndexBuffer, "-%04d", aTestIndex);
1.293 +
1.294 + iFile << "START_TESTCASE " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
1.295 + iFile << "//! @SYMTestCaseID " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
1.296 + iFile << "//! @SYMTestCaseDesc " << aTestActionName << std::endl;
1.297 + iFile << "RUN_TEST_STEP -1\tCTestHandler\t" << aTestActionType;
1.298 + if(aHasActionBody)
1.299 + {
1.300 + iFile << "\t" << iIniFileName << "\t" << aTestCaseType.str() << testCaseIndexBuffer << "-001";
1.301 + iIniFile << "[" << aTestCaseType.str() << testCaseIndexBuffer << "-001" << "]" << std::endl;
1.302 + }
1.303 + iFile << std::endl;
1.304 + iFile << "END_TESTCASE " << aTestCaseType.str() << testCaseIndexBuffer << std::endl;
1.305 + iFile << std::endl;
1.306 +}
1.307 +
1.308 +
1.309 +FileStoreScriptGeneration::FileStoreScriptGeneration(const std::stringstream &aFileName)
1.310 + : ScriptAndIniGeneration(aFileName)
1.311 +{
1.312 +
1.313 +}
1.314 +
1.315 +FileStoreScriptGeneration::~FileStoreScriptGeneration()
1.316 +{
1.317 +}
1.318 +
1.319 +void FileStoreScriptGeneration:: WriteInitialiseCert(const char *aMode, const std::stringstream &aTestCaseType, int &aTestIndex)
1.320 +{
1.321 + const char *testcasename = "Initializing a CUnifiedCertStore";
1.322 + const char *testcasetype = "init";
1.323 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.324 + iIniFile << "<actionbody>" << std::endl;
1.325 + iIniFile << "\t<mode>" << aMode << "</mode>" << std::endl;
1.326 + iIniFile << "</actionbody>" << std::endl;
1.327 + iIniFile << std::endl;
1.328 +}
1.329 +
1.330 +
1.331 +
1.332 +void FileStoreScriptGeneration::WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex)
1.333 +{
1.334 + const char *testcasename = "Get the list of certificates";
1.335 + const char *testcasetype = "listcert";
1.336 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.337 + iIniFile << "<actionbody>" << std::endl;
1.338 + iIniFile << "\t<filter>" << std::endl;
1.339 + iIniFile << "\t\t<ownertype>" << aGoodOwnerType << "</ownertype>" << std::endl;
1.340 + iIniFile << "\t</filter>" << std::endl;
1.341 + iIniFile << "</actionbody>" << std::endl;
1.342 + iIniFile << "<actionresult>" << std::endl;
1.343 + for(int z =0; z<6; z++)
1.344 + {
1.345 + iIniFile << "\t<CCTCertInfo><label>" << goodEmuCert_array[z] << "</label></CCTCertInfo>" << std::endl;
1.346 + }
1.347 + iIniFile << "</actionresult>" << std::endl;
1.348 + iIniFile << std::endl;
1.349 +}
1.350 +
1.351 +void FileStoreScriptGeneration::WriteGetCertificateDetails(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
1.352 +{
1.353 + const char *testcasename = "Get certificate details";
1.354 + const char *testcasetype = "listcert";
1.355 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.356 + int i = 0;
1.357 + iIniFile << "<actionbody>" << std::endl;
1.358 + iIniFile << "\t<filter>" << std::endl;
1.359 + iIniFile << "\t\t<label>" << label << "</label>" << std::endl;
1.360 + iIniFile << "\t\t<format>" << cert_array[i++]<< "</format>" << std::endl;
1.361 + iIniFile << "\t\t<certowner>" << cert_array[i++] << "</certowner>" << std::endl;
1.362 + iIniFile << "\t\t<subjectkeyid>" << cert_array[i++] << "</subjectkeyid>" << std::endl;
1.363 + iIniFile << "\t\t<issuerkeyid>" <<cert_array[i++] << "</issuerkeyid>" << std::endl;
1.364 + iIniFile << "\t\t<deletable>" << cert_array[i++] << "</deletable>" << std::endl;
1.365 + iIniFile << "\t</filter>" << std::endl;
1.366 + iIniFile << "</actionbody>" << std::endl;
1.367 + iIniFile << "<actionresult>" << std::endl;
1.368 + iIniFile << "\t<CCTCertInfo><label>" << label << "</label></CCTCertInfo>" << std::endl;
1.369 + iIniFile << "</actionresult>" << std::endl;
1.370 + iIniFile << std::endl;
1.371 +}
1.372 +
1.373 +
1.374 +void FileStoreScriptGeneration::WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex)
1.375 +{
1.376 + const char *testcasename = "Get Trust certificate";
1.377 + const char *testcasetype = "gettrusters";
1.378 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.379 + iIniFile << "<actionbody>" << std::endl;
1.380 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.381 + iIniFile << "</actionbody>" << std::endl;
1.382 + iIniFile << "<actionresult>" << std::endl;
1.383 + iIniFile << "\t<trust>" << trust << "</trust>" << std::endl;
1.384 + iIniFile << "</actionresult>" << std::endl;
1.385 + iIniFile << std::endl;
1.386 +}
1.387 +
1.388 +
1.389 +void FileStoreScriptGeneration::WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
1.390 +{
1.391 + const char *testcasename = "Get applications";
1.392 + const char *testcasetype = "getapplications";
1.393 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.394 + iIniFile << "<actionbody>" << std::endl;
1.395 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.396 + iIniFile << "</actionbody>" << std::endl;
1.397 + iIniFile << "<actionresult>" << std::endl;
1.398 + iIniFile << "\t<uid>";
1.399 + for(int j = 0; j<2; j++)
1.400 + {
1.401 + iIniFile << emu_cacertsUid[j] << " ";
1.402 + }
1.403 + iIniFile << "</uid>" << std::endl;
1.404 + iIniFile << "</actionresult>" << std::endl;
1.405 + iIniFile << std::endl;
1.406 +}
1.407 +
1.408 +
1.409 +void FileStoreScriptGeneration::WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
1.410 +{
1.411 + const char *testcasename = "Retrieve Certificate";
1.412 + const char *testcasetype = "retrieve";
1.413 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.414 + iIniFile << "<actionbody>" << std::endl;
1.415 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.416 + iIniFile << "</actionbody>" << std::endl;
1.417 + iIniFile << std::endl;
1.418 +}
1.419 +
1.420 +
1.421 +
1.422 +//Swi store script generator for emulator tests
1.423 +SWIStoreScriptGeneration::SWIStoreScriptGeneration(const std::stringstream &aFileName)
1.424 + : ScriptAndIniGeneration(aFileName)
1.425 +{
1.426 +
1.427 +}
1.428 +
1.429 +SWIStoreScriptGeneration::~SWIStoreScriptGeneration()
1.430 +{
1.431 +}
1.432 +
1.433 +void SWIStoreScriptGeneration:: WriteInitialiseCert(const std::stringstream &aTestCaseType, int &aTestIndex)
1.434 +{
1.435 + const char *testcasename = "Initialise a SWICertStore";
1.436 + const char *testcasetype = "initswicertstore";
1.437 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
1.438 +}
1.439 +
1.440 +
1.441 +void SWIStoreScriptGeneration::WriteListcert(const char *aGoodOwnerType, const std::stringstream &aTestCaseType, int &aTestIndex)
1.442 +{
1.443 + const char *testcasename = "Get the list of certificates";
1.444 + const char *testcasetype = "listcert";
1.445 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.446 + iIniFile << "<actionbody>" << std::endl;
1.447 + iIniFile << "\t<filter>" << std::endl;
1.448 + iIniFile << "\t\t<ownertype>" << aGoodOwnerType << "</ownertype>" << std::endl;
1.449 + iIniFile << "\t</filter>" << std::endl;
1.450 + iIniFile << "</actionbody>" << std::endl;
1.451 + iIniFile << "<actionresult>" << std::endl;
1.452 + for(int i =0; i<6; i++)
1.453 + {
1.454 + iIniFile << "\t<CCTCertInfo><label>" << goodSwiCert_array[i] << "</label><readonly>True</readonly></CCTCertInfo>" << std::endl;
1.455 + }
1.456 + iIniFile << "</actionresult>" << std::endl;
1.457 + iIniFile << std::endl;
1.458 +}
1.459 +
1.460 +void SWIStoreScriptGeneration::WriteGetSystemUpgrade(const char *label, const char *aSystemUpgrade, const std::stringstream &aTestCaseType, int &aTestIndex)
1.461 +{
1.462 + const char *testcasename = "Get the systemupgrade flag";
1.463 + const char *testcasetype = "getsystemupgrade";
1.464 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.465 + iIniFile << "<actionbody>" << std::endl;
1.466 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.467 + iIniFile << "</actionbody>" << std::endl;
1.468 + iIniFile << "<actionresult>" << std::endl;
1.469 + iIniFile << "\t<systemupgrade>" << aSystemUpgrade << "</systemupgrade>" << std::endl;
1.470 + iIniFile << "</actionresult>" << std::endl;
1.471 + iIniFile << std::endl;
1.472 +}
1.473 +
1.474 +
1.475 +void SWIStoreScriptGeneration::WriteRetrieveCerts(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
1.476 +{
1.477 + const char *testcasename = "Retrieve Certificate";
1.478 + const char *testcasetype = "retrieve";
1.479 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.480 + iIniFile << "<actionbody>" << std::endl;
1.481 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.482 + iIniFile << "</actionbody>" << std::endl;
1.483 + iIniFile << std::endl;
1.484 +}
1.485 +
1.486 +
1.487 +
1.488 +void SWIStoreScriptGeneration::WriteGetApplications(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
1.489 +{
1.490 + const char *testcasename = "Get applications";
1.491 + const char *testcasetype = "getapplications";
1.492 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.493 + iIniFile << "<actionbody>" << std::endl;
1.494 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.495 + iIniFile << "</actionbody>" << std::endl;
1.496 + iIniFile << "<actionresult>" << std::endl;
1.497 + iIniFile << "\t<uid>";
1.498 + for(int j = 0; j<2; j++)
1.499 + {
1.500 + iIniFile << emu_cacertsUid[j] << " ";
1.501 + }
1.502 + iIniFile << "</uid>" << std::endl;
1.503 + iIniFile << "</actionresult>" << std::endl;
1.504 + iIniFile << std::endl;
1.505 +}
1.506 +
1.507 +
1.508 +void SWIStoreScriptGeneration::WriteGetTrust(const char *label, const char *trust, const std::stringstream &aTestCaseType, int &aTestIndex)
1.509 +{
1.510 + const char *testcasename = "Get Trust certificate";
1.511 + const char *testcasetype = "gettrusters";
1.512 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.513 + iIniFile << "<actionbody>" << std::endl;
1.514 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.515 + iIniFile << "</actionbody>" << std::endl;
1.516 + iIniFile << "<actionresult>" << std::endl;
1.517 + iIniFile << "\t<trust>" << trust << "</trust>" << std::endl;
1.518 + iIniFile << "</actionresult>" << std::endl;
1.519 + iIniFile << std::endl;
1.520 +}
1.521 +
1.522 +
1.523 +
1.524 +void SWIStoreScriptGeneration::WriteGetCapabilities(const char *label, const std::stringstream &aTestCaseType, int &aTestIndex)
1.525 +{
1.526 + const char *testcasename = "Get the capabilities";
1.527 + const char *testcasetype = "getcapabilities";
1.528 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.529 + iIniFile << "<actionbody>" << std::endl;
1.530 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.531 + iIniFile << "</actionbody>" << std::endl;
1.532 + iIniFile << "<actionresult>" << std::endl;
1.533 + for(int i=0; i<20; i++)
1.534 + {
1.535 + iIniFile << "\t<capability>" << goodCapabilitySets[i] << "</capability>" << std::endl;
1.536 + }
1.537 + iIniFile << "</actionresult>" << std::endl;
1.538 + iIniFile << std::endl;
1.539 +}
1.540 +
1.541 +
1.542 +void SWIStoreScriptGeneration::WriteGetMandatoryFlag(const char *label, const char *aMandatory, const std::stringstream &aTestCaseType, int &aTestIndex)
1.543 +{
1.544 + const char *testcasename = "Get the mandatory flag";
1.545 + const char *testcasetype = "getmandatory";
1.546 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.547 + iIniFile << "<actionbody>" << std::endl;
1.548 + iIniFile << "\t<label>" << label << "</label>" << std::endl;
1.549 + iIniFile << "</actionbody>" << std::endl;
1.550 + iIniFile << "<actionresult>" << std::endl;
1.551 + iIniFile << "\t<mandatory>" << aMandatory << "</mandatory>" << std::endl;
1.552 + iIniFile << "</actionresult>" << std::endl;
1.553 + iIniFile << std::endl;
1.554 +}
1.555 +
1.556 +
1.557 +//Cert client script generator
1.558 +CertClientsStoreScriptGeneration::CertClientsStoreScriptGeneration(const std::stringstream &aFileName)
1.559 + : ScriptAndIniGeneration(aFileName)
1.560 +{
1.561 +}
1.562 +
1.563 +CertClientsStoreScriptGeneration::~CertClientsStoreScriptGeneration()
1.564 +{
1.565 +}
1.566 +
1.567 +void CertClientsStoreScriptGeneration::WriteInitialiseCertClient(const std::stringstream &aTestCaseType, int &aTestIndex)
1.568 +{
1.569 + const char *testcasename = "Initialise a CertClientStore";
1.570 + const char *testcasetype = "InitManager";
1.571 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
1.572 +}
1.573 +
1.574 +void CertClientsStoreScriptGeneration::WriteGetCount(const int aApp_uidIndex, const std::stringstream &aTestCaseType, int &aTestIndex)
1.575 +{
1.576 + const char *testcasename = "Get Count of Applications";
1.577 + const char *testcasetype = "AppCount";
1.578 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.579 + iIniFile << "<actionbody>" << std::endl;
1.580 + iIniFile << "\t<count>" << aApp_uidIndex << "</count>" << std::endl;
1.581 + iIniFile << "</actionbody>" << std::endl;
1.582 + iIniFile << std::endl;
1.583 +}
1.584 +
1.585 +
1.586 +void CertClientsStoreScriptGeneration::WriteGetApplicationsList(const std::stringstream &aTestCaseType, int &aTestIndex)
1.587 +{
1.588 + const char *testcasename = "Getting the application list";
1.589 + const char *testcasetype = "GetApplications";
1.590 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.591 + iIniFile << "<actionbody>" << std::endl;
1.592 + for(int i = 0 ; i<4 ; i++)
1.593 + {
1.594 + iIniFile << "\t<uid>" << gooddecimalUid_array[i] << "</uid>"<<"<appname>" << goodcertclient_array[i] << "</appname>" << std::endl;
1.595 + }
1.596 + iIniFile << "</actionbody>" << std::endl;
1.597 + iIniFile << std::endl;
1.598 +}
1.599 +
1.600 +
1.601 +void CertClientsStoreScriptGeneration::WriteGetAppWithUid(const char *goodlabel,const char *uid,const std::stringstream &aTestCaseType,int &aTestIndex)
1.602 +{
1.603 + const char *testcasename = "Get application with given id";
1.604 + const char *testcasetype = "GetApp";
1.605 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype);
1.606 + iIniFile << "<actionbody>" << std::endl;
1.607 + iIniFile << "\t<uid>" << uid << "</uid>" << std::endl;
1.608 + iIniFile << "\t<appname>" << goodlabel << "</appname>" << std::endl;
1.609 + iIniFile << "</actionbody>" << std::endl;
1.610 + iIniFile << std::endl;
1.611 +}
1.612 +
1.613 +
1.614 +void CertClientsStoreScriptGeneration::WriteDestroyManager(const std::stringstream &aTestCaseType, int &aTestIndex)
1.615 +{
1.616 + const char *testcasename = "Destroy the manager";
1.617 + const char *testcasetype = "DestroyManager";
1.618 + WriteTestCaseToScript(aTestCaseType, ++aTestIndex, testcasename, testcasetype, false);
1.619 +}
1.620 +
1.621 +
1.622 +/**
1.623 +Class definition for creating cacerts
1.624 +*/
1.625 +EmptyFileConfigWriter::EmptyFileConfigWriter(const std::stringstream &aFileName)
1.626 + : GoodConfigWriter(aFileName)
1.627 +{
1.628 + iFile << "StartCertStoreEntries" << std::endl;
1.629 +}
1.630 +
1.631 +EmptyFileConfigWriter::~EmptyFileConfigWriter()
1.632 +{
1.633 + iFile << "EndCertStoreEntries" << std::endl;
1.634 +}
1.635 +
1.636 +// End of file
1.637 +