First public contribution.
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.
24 #include "TestChain.h"
27 _LIT(KServerStart, "<server>");
28 _LIT(KRootStart, "<root>");
29 _LIT(KValueStart, "<value>");
31 _LIT(KCertificateStart, "<certificate>");
32 _LIT(KLabelStart, "<label>");
33 _LIT(KResultStart, "<oresult>");
35 //test chain superclass
36 CTestChain::CTestChain()
40 CTestChain::~CTestChain()
50 void CTestChain::ConstructL()
52 iServerCerts = new(ELeave) CDesCArrayFlat (1);
53 iServerLabels = new(ELeave) CDesCArrayFlat (1);
54 iRootCerts = new(ELeave) CDesCArrayFlat (1);
55 iRootLabels = new(ELeave) CDesCArrayFlat (1);
56 iExtraCerts = new(ELeave) CDesCArrayFlat (1);
57 iExtraLabels = new(ELeave) CDesCArrayFlat (1);
61 CTestChainBuild* CTestChainBuild::NewL()
63 CTestChainBuild* self = CTestChainBuild::NewLC();
68 CTestChainBuild* CTestChainBuild::NewLC()
70 CTestChainBuild* self = new(ELeave) CTestChainBuild;
71 CleanupStack::PushL(self);
76 CTestChainBuild::~CTestChainBuild()
81 //test chain validate class
82 CTestChainValidate* CTestChainValidate::NewL(void)
84 CTestChainValidate* self = CTestChainValidate::NewLC();
89 CTestChainValidate* CTestChainValidate::NewLC(void)
91 CTestChainValidate* self = new(ELeave) CTestChainValidate;
92 CleanupStack::PushL(self);
97 void CTestChainValidate::ConstructL(void)
99 CTestChain::ConstructL();
100 iWarnings = new(ELeave)CArrayFixFlat<TWTLSValidationStatus> (1);
104 void CTestChainValidate::AddChainL(const TDesC& aValues)
110 void CTestChainValidate::AddDateIssued(const TDesC& aValues)
112 TPtrC iResultBuf = Input::ParseElement(aValues, KValueStart);
113 if((iResultBuf == _L("true")) || (iResultBuf == _L("1")))
116 void CTestChainValidate::AddIOL(const TDesC& aValues)
118 TPtrC iResultBuf = Input::ParseElement(aValues, KResultStart);
119 if (iResultBuf != KNullDesC)
121 TValidationError expectedError;
123 if(iResultBuf == _L("ValidatedOK"))
124 expectedError = EValidatedOK;
125 else if(iResultBuf == _L("SignatureInvalid"))
126 expectedError = ESignatureInvalid;
127 else if(iResultBuf == _L("ChainHasNoRoot"))
128 expectedError = EChainHasNoRoot;
129 else if(iResultBuf == _L("NamesDontChain"))
130 expectedError = ENamesDontChain;
131 else if(iResultBuf == _L("NotCACert"))
132 expectedError = ENotCACert;
136 iError = new(ELeave) TWTLSValidationStatus(expectedError, 0);
140 CTestChainValidate::~CTestChainValidate()
146 TBool CTestChainValidate::AddServerL(const TDesC& aBuf)
149 TPtrC ioSection(aBuf);
151 if (ioSection != KNullDesC)
156 ioBuf.Set(Input::ParseElement(ioSection, KServerStart, nPos));
159 ioSection.Set(ioSection.Mid(nPos));
161 TPtrC iCertBuf = Input::ParseElement(ioBuf, KCertificateStart, n);
162 iServerCerts->AppendL(iCertBuf);
163 TPtrC iLabelBuf = Input::ParseElement(ioBuf, KLabelStart, n);
164 iServerLabels->AppendL(iLabelBuf);
174 TBool CTestChainValidate::AddRootL(const TDesC& aBuf)
177 TPtrC ioSection(aBuf);
179 if (ioSection != KNullDesC)
184 ioBuf.Set(Input::ParseElement(ioSection, KRootStart, nPos));
187 ioSection.Set(ioSection.Mid(nPos));
189 TPtrC iCertBuf = Input::ParseElement(ioBuf, KCertificateStart, n);
190 iRootCerts->AppendL(iCertBuf);
191 TPtrC iLabelBuf = Input::ParseElement(ioBuf, KLabelStart, n);
192 iRootLabels->AppendL(iLabelBuf);