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 |
* PKIXVALIDATIONRESULT.H
|
sl@0
|
16 |
* Implementation of the class storing PKIX validation result information
|
sl@0
|
17 |
*
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
@file
|
sl@0
|
23 |
@publishedAll
|
sl@0
|
24 |
@released
|
sl@0
|
25 |
*/
|
sl@0
|
26 |
|
sl@0
|
27 |
#ifndef __PKIXVALIDATIONRESULT_H__
|
sl@0
|
28 |
#define __PKIXVALIDATIONRESULT_H__
|
sl@0
|
29 |
|
sl@0
|
30 |
#include <x509certchain.h>
|
sl@0
|
31 |
#include <x509certext.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
class RReadStream;
|
sl@0
|
34 |
/**
|
sl@0
|
35 |
* Base class for CPKIXValidationResult.
|
sl@0
|
36 |
*/
|
sl@0
|
37 |
class CPKIXValidationResultBase : public CBase
|
sl@0
|
38 |
{
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
/** Creates a new PKIX Validation Result object.
|
sl@0
|
41 |
*
|
sl@0
|
42 |
* @return The new PKIX Validation Result object. */
|
sl@0
|
43 |
IMPORT_C static CPKIXValidationResultBase* NewL();
|
sl@0
|
44 |
|
sl@0
|
45 |
/** Creates a new PKIX Validation Result object, and puts a pointer to it onto
|
sl@0
|
46 |
* the cleanup stack.
|
sl@0
|
47 |
*
|
sl@0
|
48 |
* @return The new PKIX Validation Result object. */
|
sl@0
|
49 |
IMPORT_C static CPKIXValidationResultBase* NewLC();
|
sl@0
|
50 |
|
sl@0
|
51 |
/** Creates a new PKIX Validation Result object from a stream.
|
sl@0
|
52 |
*
|
sl@0
|
53 |
* @return The new PKIX Validation Result object. */
|
sl@0
|
54 |
IMPORT_C static CPKIXValidationResultBase* NewL(RReadStream& aStream);
|
sl@0
|
55 |
|
sl@0
|
56 |
/** Creates a new PKIX Validation Result object from a stream, and puts a pointer to it onto
|
sl@0
|
57 |
* the cleanup stack.
|
sl@0
|
58 |
*
|
sl@0
|
59 |
* @return The new PKIX Validation Result object. */
|
sl@0
|
60 |
IMPORT_C static CPKIXValidationResultBase* NewLC(RReadStream& aStream);
|
sl@0
|
61 |
|
sl@0
|
62 |
/** The destructor.
|
sl@0
|
63 |
*
|
sl@0
|
64 |
* Frees all resources owned by the object. */
|
sl@0
|
65 |
IMPORT_C ~CPKIXValidationResultBase();
|
sl@0
|
66 |
|
sl@0
|
67 |
/** Gets the error status of the operation.
|
sl@0
|
68 |
*
|
sl@0
|
69 |
* Errors are considered fatal, i.e. validation has failed.
|
sl@0
|
70 |
*
|
sl@0
|
71 |
* @return The error status of the operation. */
|
sl@0
|
72 |
IMPORT_C const TValidationStatus Error() const;
|
sl@0
|
73 |
|
sl@0
|
74 |
/** Gets a list of warnings generated.
|
sl@0
|
75 |
*
|
sl@0
|
76 |
* The warnings may or may not be fatal, depending on the context, which the
|
sl@0
|
77 |
* client is expected to provide.
|
sl@0
|
78 |
*
|
sl@0
|
79 |
* @return An array of any warnings generated. */
|
sl@0
|
80 |
IMPORT_C const CArrayFixFlat<TValidationStatus>& Warnings() const;
|
sl@0
|
81 |
|
sl@0
|
82 |
/** Gets a list of all the certificate policies which have been accepted implicitly
|
sl@0
|
83 |
* in the course of validation.
|
sl@0
|
84 |
*
|
sl@0
|
85 |
* @return An array of certificate policies. */
|
sl@0
|
86 |
IMPORT_C const CArrayPtrFlat<CX509CertPolicyInfo>& Policies() const;
|
sl@0
|
87 |
|
sl@0
|
88 |
/** Resets the validation result object to its default values.
|
sl@0
|
89 |
* @internalTechnology
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
void Reset();
|
sl@0
|
92 |
|
sl@0
|
93 |
/** Sets the error status, and then leaves.
|
sl@0
|
94 |
*
|
sl@0
|
95 |
* The function uses SetError() to set the error status.
|
sl@0
|
96 |
*
|
sl@0
|
97 |
* @param aError The error type that occurred when validating the certificate chain.
|
sl@0
|
98 |
* @param aCert The index number identifying the certificate that gave rise to
|
sl@0
|
99 |
* the error.
|
sl@0
|
100 |
* @internalTechnology
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
void SetErrorAndLeaveL(const TValidationError aError, const TInt aCert);
|
sl@0
|
103 |
|
sl@0
|
104 |
/** Sets the error status.
|
sl@0
|
105 |
*
|
sl@0
|
106 |
* @param aError The error type that occurred when validating the certificate chain.
|
sl@0
|
107 |
* @param aCert The index number identifying the certificate that gave rise to
|
sl@0
|
108 |
* the error.
|
sl@0
|
109 |
* @internalTechnology
|
sl@0
|
110 |
*/
|
sl@0
|
111 |
void SetError(const TValidationError aError, const TInt aCert);
|
sl@0
|
112 |
|
sl@0
|
113 |
/** Adds a warning to the validation result.
|
sl@0
|
114 |
*
|
sl@0
|
115 |
* @param aWarning The warning to be added.
|
sl@0
|
116 |
* @internalTechnology
|
sl@0
|
117 |
*/
|
sl@0
|
118 |
void AppendWarningL(TValidationStatus aWarning);
|
sl@0
|
119 |
|
sl@0
|
120 |
/** Adds a policy to the validation result.
|
sl@0
|
121 |
*
|
sl@0
|
122 |
* @param aPolicy The policy to be added.
|
sl@0
|
123 |
* @internalTechnology
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
void AppendPolicyL(CX509CertPolicyInfo& aPolicy);
|
sl@0
|
126 |
|
sl@0
|
127 |
/** Removes all policies from the validation result.
|
sl@0
|
128 |
*
|
sl@0
|
129 |
* It is used by the validation process to remove policies it has added when
|
sl@0
|
130 |
* the computation cannot complete because of environmental conditions such as
|
sl@0
|
131 |
* out of memory, file access failures, etc..
|
sl@0
|
132 |
* @internalTechnology
|
sl@0
|
133 |
*/
|
sl@0
|
134 |
// (not like signature validation...)
|
sl@0
|
135 |
void RemovePolicies();
|
sl@0
|
136 |
|
sl@0
|
137 |
// Internalization/Externalization
|
sl@0
|
138 |
// Externalize. Writes the data out to a stream
|
sl@0
|
139 |
/** Externalises an object of this class to a write stream.
|
sl@0
|
140 |
*
|
sl@0
|
141 |
* The presence of this function means that the standard templated operator<<()
|
sl@0
|
142 |
* can be used to externalise objects of this class.
|
sl@0
|
143 |
*
|
sl@0
|
144 |
* @param aStream Stream to which the object should be externalised. */
|
sl@0
|
145 |
IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
|
sl@0
|
146 |
|
sl@0
|
147 |
// Internalize. Reads the data from a stream
|
sl@0
|
148 |
/** Internalises an object of this class from a read stream.
|
sl@0
|
149 |
*
|
sl@0
|
150 |
* The presence of this function means that the standard templated operator>>()
|
sl@0
|
151 |
* can be used to internalise objects of this class.
|
sl@0
|
152 |
*
|
sl@0
|
153 |
* Note that this function has assignment semantics: it replaces the old value
|
sl@0
|
154 |
* of the object with a new value read from the read stream.
|
sl@0
|
155 |
*
|
sl@0
|
156 |
* @param aStream Stream from which the object should be internalised. */
|
sl@0
|
157 |
IMPORT_C void InternalizeL(RReadStream& aStream);
|
sl@0
|
158 |
|
sl@0
|
159 |
/** Returns a list of critical extensions encountered and warnings generated by
|
sl@0
|
160 |
* certificates during chain validation.
|
sl@0
|
161 |
*
|
sl@0
|
162 |
* @return An array of certificate warnings. */
|
sl@0
|
163 |
IMPORT_C const RPointerArray<CCertificateValidationWarnings>& ValidationWarnings() const;
|
sl@0
|
164 |
|
sl@0
|
165 |
/** Adds a certificate warning to the validation result.
|
sl@0
|
166 |
*
|
sl@0
|
167 |
* @param aCertWarning The warning to be added. */
|
sl@0
|
168 |
IMPORT_C void AppendCertificateValidationObjectL(const CCertificateValidationWarnings& aCertWarning);
|
sl@0
|
169 |
|
sl@0
|
170 |
/** Adds a critical extension OID warning.
|
sl@0
|
171 |
*
|
sl@0
|
172 |
* @param aCriticalExt The critical extension OID to be added. */
|
sl@0
|
173 |
IMPORT_C void AppendCriticalExtensionWarningL(TDesC& aCriticalExt);
|
sl@0
|
174 |
|
sl@0
|
175 |
protected:
|
sl@0
|
176 |
IMPORT_C CPKIXValidationResultBase();
|
sl@0
|
177 |
IMPORT_C void ConstructL();
|
sl@0
|
178 |
|
sl@0
|
179 |
private:
|
sl@0
|
180 |
TValidationStatus iError;
|
sl@0
|
181 |
CArrayFixFlat<TValidationStatus>* iWarnings;
|
sl@0
|
182 |
CArrayPtrFlat<CX509CertPolicyInfo>* iPolicies;
|
sl@0
|
183 |
RPointerArray<CCertificateValidationWarnings> iCertWarnings;
|
sl@0
|
184 |
};
|
sl@0
|
185 |
|
sl@0
|
186 |
/** Stores the information regarding the results of a validation of a PKIX
|
sl@0
|
187 |
* certificate chain.
|
sl@0
|
188 |
*
|
sl@0
|
189 |
* @since v6.0 */
|
sl@0
|
190 |
class CPKIXValidationResult : public CPKIXValidationResultBase
|
sl@0
|
191 |
{
|
sl@0
|
192 |
public:
|
sl@0
|
193 |
/** Creates a new PKIX Validation Result object.
|
sl@0
|
194 |
*
|
sl@0
|
195 |
* @return The new PKIX Validation Result object. */
|
sl@0
|
196 |
IMPORT_C static CPKIXValidationResult* NewL();
|
sl@0
|
197 |
|
sl@0
|
198 |
/** Creates a new PKIX Validation Result object, and puts a pointer to it onto
|
sl@0
|
199 |
* the cleanup stack.
|
sl@0
|
200 |
*
|
sl@0
|
201 |
* @return The new PKIX Validation Result object. */
|
sl@0
|
202 |
IMPORT_C static CPKIXValidationResult* NewLC();
|
sl@0
|
203 |
|
sl@0
|
204 |
/** The destructor.
|
sl@0
|
205 |
*
|
sl@0
|
206 |
* Frees all resources owned by the object. */
|
sl@0
|
207 |
IMPORT_C ~CPKIXValidationResult();
|
sl@0
|
208 |
|
sl@0
|
209 |
/** Gets the error status of the operation.
|
sl@0
|
210 |
*
|
sl@0
|
211 |
* Errors are considered fatal, i.e. validation has failed.
|
sl@0
|
212 |
*
|
sl@0
|
213 |
* @return The error status of the operation. */
|
sl@0
|
214 |
IMPORT_C const TValidationStatus Error() const;
|
sl@0
|
215 |
|
sl@0
|
216 |
/** Gets a list of warnings generated.
|
sl@0
|
217 |
*
|
sl@0
|
218 |
* The warnings may or may not be fatal, depending on the context, which the
|
sl@0
|
219 |
* client is expected to provide.
|
sl@0
|
220 |
*
|
sl@0
|
221 |
* @return An array of any warnings generated. */
|
sl@0
|
222 |
IMPORT_C const CArrayFixFlat<TValidationStatus>& Warnings() const;
|
sl@0
|
223 |
|
sl@0
|
224 |
/** Gets a list of all the certificate policies which have been accepted implicitly
|
sl@0
|
225 |
* in the course of validation.
|
sl@0
|
226 |
*
|
sl@0
|
227 |
* @return An array of certificate policies. */
|
sl@0
|
228 |
IMPORT_C const CArrayPtrFlat<CX509CertPolicyInfo>& Policies() const;
|
sl@0
|
229 |
|
sl@0
|
230 |
/** Returns a list of critical extensions encountered and warnings generated by
|
sl@0
|
231 |
* certificates during chain validation. A CCertificateWarning object is returned for
|
sl@0
|
232 |
* each certificate in the chain, even if no critical extensions or warnings were
|
sl@0
|
233 |
* encountered. The array's data is in the same order as the certificate chain.
|
sl@0
|
234 |
*
|
sl@0
|
235 |
* @return An array of certificate warnings. Ownership is not transferred
|
sl@0
|
236 |
* to the caller. */
|
sl@0
|
237 |
IMPORT_C const RPointerArray<CCertificateValidationWarnings>& ValidationWarnings() const;
|
sl@0
|
238 |
|
sl@0
|
239 |
private:
|
sl@0
|
240 |
CPKIXValidationResult();
|
sl@0
|
241 |
};
|
sl@0
|
242 |
|
sl@0
|
243 |
#endif
|