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