Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #include "tpkixcertval.h"
24 #include "tcertutils.h"
27 //tags for elements in specification file
28 _LIT(KRootStart, "<root>");
29 _LIT(KRootEnd, "</root>");
30 _LIT(KCertificateStart, "<certificate>");
31 _LIT(KCertificateEnd, "</certificate>");
32 _LIT(KLabelStart, "<label>");
33 _LIT(KLabelEnd, "</label>");
34 _LIT(KEEStart, "<ee>");
35 _LIT(KEEEnd, "</ee>");
36 _LIT(KInterStart, "<inter>");
37 _LIT(KInterEnd, "</inter>");
38 _LIT(KIPoliciesStart, "<ipolicies>");
39 _LIT(KIPoliciesEnd, "</ipolicies>");
40 _LIT(KIPolicyStart, "<ipolicy>");
41 _LIT(KIPolicyEnd, "</ipolicy>");
42 _LIT(KOResultStart, "<oresult>");
43 _LIT(KOResultEnd, "</oresult>");
44 _LIT(KOPoliciesStart, "<opolicies>");
45 _LIT(KOPoliciesEnd, "</opolicies>");
46 _LIT(KOPolicyStart, "<opolicy>");
47 _LIT(KOPolicyEnd, "</opolicy>");
49 //const TUint KUnicodeMarker = 0xfeff;
52 CTestChain* CTestChain::NewL(const TDesC& aBuf)
54 CTestChain* self = CTestChain::NewLC(aBuf);
59 CTestChain* CTestChain::NewLC(const TDesC& aBuf)
61 CTestChain* self = new(ELeave) CTestChain;
62 CleanupStack::PushL(self);
63 self->ConstructL(aBuf);
67 CTestChain::~CTestChain()
69 delete iIntermediateCertsFileName;
70 delete iIntermediateCertsLabel;
73 CTestChain::CTestChain()
77 void CTestChain::ConstructL(const TDesC& aBuf)
81 TPtrC rootCert(Input::ParseElement(aBuf, KRootStart, KRootEnd, pos, err));
83 iRootCertFileName = Input::ParseElement(rootCert, KCertificateStart,
84 KCertificateEnd, dummyPos, err);
85 iRootCertLabel = Input::ParseElement(rootCert, KLabelStart,
86 KLabelEnd, dummyPos, err);
87 if (iRootCertLabel == KNullDesC)
89 User::Leave(KErrNotFound);
92 TPtrC EECert(Input::ParseElement(aBuf, KEEStart, KEEEnd, pos));
94 iEECertFileName = Input::ParseElement(EECert, KCertificateStart,
95 KCertificateEnd, dummyPos);
96 iEECertLabel = Input::ParseElement(EECert, KLabelStart,
99 iIntermediateCertsFileName = new(ELeave) CDesCArrayFlat(1);
100 iIntermediateCertsLabel = new(ELeave) CDesCArrayFlat(1);
101 while(AddInter(aBuf, pos))
106 TBool CTestChain::AddInter(const TDesC& aBuf, TInt& aPos)
108 TPtrC interBuf = Input::ParseElement(aBuf, KInterStart, KInterEnd, aPos);
110 if (interBuf != KNullDesC)
112 iIntermediateCertsFileName->AppendL(Input::ParseElement(interBuf,
113 KCertificateStart, KCertificateEnd, dummyPos));
114 iIntermediateCertsLabel->AppendL(Input::ParseElement(interBuf,
115 KLabelStart, KLabelEnd, dummyPos));
121 //**Policy Input/Output**//
122 CTestParameters* CTestParameters::NewL(const TDesC& aBuf)
124 CTestParameters* self = CTestParameters::NewLC(aBuf);
129 CTestParameters* CTestParameters::NewLC(const TDesC& aBuf)
131 CTestParameters* self = new(ELeave) CTestParameters;
132 CleanupStack::PushL(self);
133 self->ConstructL(aBuf);
137 CTestParameters::~CTestParameters()
141 delete iExpectedPolicyOutput;
144 CTestParameters::CTestParameters()
145 :iIPoliciesSet(ETrue), iOPoliciesSet(ETrue), iOWarningsSet(ETrue)
149 void CTestParameters::ConstructL(const TDesC& aBuf)
151 iWarnings = new(ELeave)CArrayFixFlat<TValidationStatus> (1);
152 iPolicyInput = new(ELeave) CDesCArrayFlat (1);
153 iExpectedPolicyOutput = new(ELeave) CDesCArrayFlat (1);
157 TPtrC iIPolicyBuf = Input::ParseElement(aBuf, KIPoliciesStart, KIPoliciesEnd, pos, err);
160 iIPoliciesSet = EFalse;//input policies are optional
163 while(AddPolicy(iIPolicyBuf, KIPolicyStart, KIPolicyEnd,pos, *iPolicyInput))
166 iError = Input::ParseElement(aBuf, KOResultStart, KOResultEnd, pos);
167 TPtrC iOPolicyBuf = Input::ParseElement(aBuf, KOPoliciesStart, KOPoliciesEnd, pos, err);
170 iOPoliciesSet = EFalse;//output policies are optional
173 while(AddPolicy(iOPolicyBuf, KOPolicyStart, KOPolicyEnd, pos, *iExpectedPolicyOutput))
178 TBool CTestParameters::AddPolicy(const TDesC& aBuf, const TDesC& aStart, const TDesC& aEnd, TInt& aPos, CDesCArray& aPolicySet)
180 TPtrC policyBuf = Input::ParseElement(aBuf, aStart, aEnd, aPos);
181 if (policyBuf != KNullDesC)
183 aPolicySet.AppendL(policyBuf);