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