sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1998-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 "pkixvalidationresult.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
//validationresult
|
sl@0
|
22 |
EXPORT_C CPKIXValidationResultBase* CPKIXValidationResultBase::NewL()
|
sl@0
|
23 |
{
|
sl@0
|
24 |
CPKIXValidationResultBase* s = CPKIXValidationResultBase::NewLC();
|
sl@0
|
25 |
CleanupStack::Pop();//s
|
sl@0
|
26 |
return s;
|
sl@0
|
27 |
}
|
sl@0
|
28 |
|
sl@0
|
29 |
EXPORT_C CPKIXValidationResultBase* CPKIXValidationResultBase::NewLC()
|
sl@0
|
30 |
{
|
sl@0
|
31 |
CPKIXValidationResultBase* s = new(ELeave) CPKIXValidationResultBase;
|
sl@0
|
32 |
CleanupStack::PushL(s);
|
sl@0
|
33 |
s->ConstructL();
|
sl@0
|
34 |
return s;
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
EXPORT_C CPKIXValidationResultBase::~CPKIXValidationResultBase()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
delete iWarnings;
|
sl@0
|
40 |
if (iPolicies != NULL)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
iPolicies->ResetAndDestroy();
|
sl@0
|
43 |
}
|
sl@0
|
44 |
delete iPolicies;
|
sl@0
|
45 |
iCertWarnings.ResetAndDestroy();
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
EXPORT_C CPKIXValidationResultBase::CPKIXValidationResultBase()
|
sl@0
|
49 |
:iError(EChainHasNoRoot, 0)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
EXPORT_C void CPKIXValidationResultBase::ConstructL()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
#ifdef _DEBUG
|
sl@0
|
56 |
// In OOM we don't want the size of the arrays to change because this will
|
sl@0
|
57 |
// cause a change in the numbers of allocated cells
|
sl@0
|
58 |
iWarnings = new(ELeave) CArrayFixFlat<TValidationStatus> (100);
|
sl@0
|
59 |
iPolicies = new(ELeave) CArrayPtrFlat<CX509CertPolicyInfo> (100);
|
sl@0
|
60 |
iPolicies->AppendL(0);
|
sl@0
|
61 |
iPolicies->ResetAndDestroy();
|
sl@0
|
62 |
#else
|
sl@0
|
63 |
iWarnings = new(ELeave) CArrayFixFlat<TValidationStatus> (1);
|
sl@0
|
64 |
iPolicies = new(ELeave) CArrayPtrFlat<CX509CertPolicyInfo> (1);
|
sl@0
|
65 |
#endif
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
EXPORT_C const TValidationStatus CPKIXValidationResultBase::Error() const
|
sl@0
|
69 |
{
|
sl@0
|
70 |
return iError;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
EXPORT_C const CArrayFixFlat<TValidationStatus>& CPKIXValidationResultBase::Warnings() const
|
sl@0
|
74 |
{
|
sl@0
|
75 |
return *iWarnings;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
EXPORT_C const CArrayPtrFlat<CX509CertPolicyInfo>& CPKIXValidationResultBase::Policies() const
|
sl@0
|
79 |
{
|
sl@0
|
80 |
return *iPolicies;
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
void CPKIXValidationResultBase::Reset()
|
sl@0
|
84 |
{
|
sl@0
|
85 |
iError = TValidationStatus(EChainHasNoRoot, 0);
|
sl@0
|
86 |
iWarnings->Reset();
|
sl@0
|
87 |
RemovePolicies();
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
void CPKIXValidationResultBase::SetErrorAndLeaveL(const TValidationError aError, const TInt aCert)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
SetError(aError, aCert);
|
sl@0
|
93 |
User::Leave(KErrGeneral);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
void CPKIXValidationResultBase::SetError(const TValidationError aError, const TInt aCert)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
iError.iReason = aError;
|
sl@0
|
99 |
iError.iCert = aCert;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
void CPKIXValidationResultBase::AppendWarningL(TValidationStatus aWarning)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
iWarnings->AppendL(aWarning);
|
sl@0
|
105 |
|
sl@0
|
106 |
if (aWarning.iReason != ECriticalExtendedKeyUsage && aWarning.iReason != ECriticalPolicyMapping &&
|
sl@0
|
107 |
aWarning.iReason != ECriticalDeviceId && aWarning.iReason != ECriticalSid &&
|
sl@0
|
108 |
aWarning.iReason != ECriticalVid && aWarning.iReason != ECriticalCapabilities)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
(*iCertWarnings[iCertWarnings.Count()-1]).AppendWarningL(aWarning);
|
sl@0
|
111 |
}
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
void CPKIXValidationResultBase::AppendPolicyL(CX509CertPolicyInfo& aPolicy)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
iPolicies->AppendL(&aPolicy);
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
void CPKIXValidationResultBase::RemovePolicies()
|
sl@0
|
120 |
{
|
sl@0
|
121 |
iPolicies->ResetAndDestroy();
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
EXPORT_C void CPKIXValidationResultBase::ExternalizeL(RWriteStream& aStream) const
|
sl@0
|
125 |
{
|
sl@0
|
126 |
// iError
|
sl@0
|
127 |
aStream.WriteL(TPckgC<TValidationStatus>(iError));
|
sl@0
|
128 |
|
sl@0
|
129 |
// iWarnings
|
sl@0
|
130 |
aStream.WriteInt32L(iWarnings->Count());
|
sl@0
|
131 |
TInt32 i;
|
sl@0
|
132 |
for (i = 0;i < iWarnings->Count(); ++i)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
aStream.WriteL(TPckgC<TValidationStatus>((*iWarnings)[i]));
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
// iPolicies
|
sl@0
|
138 |
aStream.WriteInt32L(iPolicies->Count());
|
sl@0
|
139 |
for (i = 0;i < iPolicies->Count(); ++i)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
(*iPolicies)[i]->ExternalizeL(aStream);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
// iCertWarnings
|
sl@0
|
145 |
aStream.WriteInt32L(iCertWarnings.Count());
|
sl@0
|
146 |
for (i = 0;i< iCertWarnings.Count(); ++i)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
(*iCertWarnings[i]).ExternalizeL(aStream);
|
sl@0
|
149 |
}
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
EXPORT_C void CPKIXValidationResultBase::InternalizeL(RReadStream& aStream)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
// iError
|
sl@0
|
155 |
TPckg<TValidationStatus> pckg(iError);
|
sl@0
|
156 |
aStream.ReadL(pckg);
|
sl@0
|
157 |
|
sl@0
|
158 |
// iWarnings
|
sl@0
|
159 |
iWarnings->Reset();
|
sl@0
|
160 |
|
sl@0
|
161 |
TInt32 count=aStream.ReadInt32L();
|
sl@0
|
162 |
TInt32 i;
|
sl@0
|
163 |
for (i = 0;i < count; ++i)
|
sl@0
|
164 |
{
|
sl@0
|
165 |
TValidationStatus warning(EValidatedOK,0);
|
sl@0
|
166 |
TPckg<TValidationStatus> pckg(warning);
|
sl@0
|
167 |
aStream.ReadL(pckg);
|
sl@0
|
168 |
iWarnings->AppendL(warning);
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
// iPolicies
|
sl@0
|
172 |
iPolicies->ResetAndDestroy();
|
sl@0
|
173 |
|
sl@0
|
174 |
count=aStream.ReadInt32L();
|
sl@0
|
175 |
for (i = 0;i < count; ++i)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
CX509CertPolicyInfo* certPolicyInfo=CX509CertPolicyInfo::NewLC(aStream);
|
sl@0
|
178 |
iPolicies->AppendL(certPolicyInfo);
|
sl@0
|
179 |
CleanupStack::Pop(certPolicyInfo);
|
sl@0
|
180 |
}
|
sl@0
|
181 |
|
sl@0
|
182 |
// iCertWarnings
|
sl@0
|
183 |
iCertWarnings.Reset();
|
sl@0
|
184 |
|
sl@0
|
185 |
count=aStream.ReadInt32L();
|
sl@0
|
186 |
for (i = 0;i < count; ++i)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
CCertificateValidationWarnings* certWarning=CCertificateValidationWarnings::InternalizeL(aStream);
|
sl@0
|
189 |
CleanupStack::PushL(certWarning);
|
sl@0
|
190 |
iCertWarnings.AppendL(certWarning);
|
sl@0
|
191 |
CleanupStack::Pop(certWarning);
|
sl@0
|
192 |
}
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
EXPORT_C const RPointerArray<CCertificateValidationWarnings>& CPKIXValidationResultBase::ValidationWarnings() const
|
sl@0
|
196 |
{
|
sl@0
|
197 |
return iCertWarnings;
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
EXPORT_C void CPKIXValidationResultBase::AppendCertificateValidationObjectL(const CCertificateValidationWarnings& aCertWarning)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
iCertWarnings.AppendL(&aCertWarning);
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
EXPORT_C void CPKIXValidationResultBase::AppendCriticalExtensionWarningL(TDesC& aCriticalExt)
|
sl@0
|
206 |
{
|
sl@0
|
207 |
(*iCertWarnings[iCertWarnings.Count()-1]).AppendCriticalExtensionWarningL(aCriticalExt);
|
sl@0
|
208 |
}
|