Update contrib.
2 * Copyright (c) 1998-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.
15 * PKIXVALIDATIONRESULT.H
16 * Implementation of the class storing PKIX validation result information
27 #ifndef __PKIXVALIDATIONRESULT_H__
28 #define __PKIXVALIDATIONRESULT_H__
30 #include <x509certchain.h>
31 #include <x509certext.h>
35 * Base class for CPKIXValidationResult.
37 class CPKIXValidationResultBase : public CBase
40 /** Creates a new PKIX Validation Result object.
42 * @return The new PKIX Validation Result object. */
43 IMPORT_C static CPKIXValidationResultBase* NewL();
45 /** Creates a new PKIX Validation Result object, and puts a pointer to it onto
48 * @return The new PKIX Validation Result object. */
49 IMPORT_C static CPKIXValidationResultBase* NewLC();
51 /** Creates a new PKIX Validation Result object from a stream.
53 * @return The new PKIX Validation Result object. */
54 IMPORT_C static CPKIXValidationResultBase* NewL(RReadStream& aStream);
56 /** Creates a new PKIX Validation Result object from a stream, and puts a pointer to it onto
59 * @return The new PKIX Validation Result object. */
60 IMPORT_C static CPKIXValidationResultBase* NewLC(RReadStream& aStream);
64 * Frees all resources owned by the object. */
65 IMPORT_C ~CPKIXValidationResultBase();
67 /** Gets the error status of the operation.
69 * Errors are considered fatal, i.e. validation has failed.
71 * @return The error status of the operation. */
72 IMPORT_C const TValidationStatus Error() const;
74 /** Gets a list of warnings generated.
76 * The warnings may or may not be fatal, depending on the context, which the
77 * client is expected to provide.
79 * @return An array of any warnings generated. */
80 IMPORT_C const CArrayFixFlat<TValidationStatus>& Warnings() const;
82 /** Gets a list of all the certificate policies which have been accepted implicitly
83 * in the course of validation.
85 * @return An array of certificate policies. */
86 IMPORT_C const CArrayPtrFlat<CX509CertPolicyInfo>& Policies() const;
88 /** Resets the validation result object to its default values.
93 /** Sets the error status, and then leaves.
95 * The function uses SetError() to set the error status.
97 * @param aError The error type that occurred when validating the certificate chain.
98 * @param aCert The index number identifying the certificate that gave rise to
100 * @internalTechnology
102 void SetErrorAndLeaveL(const TValidationError aError, const TInt aCert);
104 /** Sets the error status.
106 * @param aError The error type that occurred when validating the certificate chain.
107 * @param aCert The index number identifying the certificate that gave rise to
109 * @internalTechnology
111 void SetError(const TValidationError aError, const TInt aCert);
113 /** Adds a warning to the validation result.
115 * @param aWarning The warning to be added.
116 * @internalTechnology
118 void AppendWarningL(TValidationStatus aWarning);
120 /** Adds a policy to the validation result.
122 * @param aPolicy The policy to be added.
123 * @internalTechnology
125 void AppendPolicyL(CX509CertPolicyInfo& aPolicy);
127 /** Removes all policies from the validation result.
129 * It is used by the validation process to remove policies it has added when
130 * the computation cannot complete because of environmental conditions such as
131 * out of memory, file access failures, etc..
132 * @internalTechnology
134 // (not like signature validation...)
135 void RemovePolicies();
137 // Internalization/Externalization
138 // Externalize. Writes the data out to a stream
139 /** Externalises an object of this class to a write stream.
141 * The presence of this function means that the standard templated operator<<()
142 * can be used to externalise objects of this class.
144 * @param aStream Stream to which the object should be externalised. */
145 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
147 // Internalize. Reads the data from a stream
148 /** Internalises an object of this class from a read stream.
150 * The presence of this function means that the standard templated operator>>()
151 * can be used to internalise objects of this class.
153 * Note that this function has assignment semantics: it replaces the old value
154 * of the object with a new value read from the read stream.
156 * @param aStream Stream from which the object should be internalised. */
157 IMPORT_C void InternalizeL(RReadStream& aStream);
159 /** Returns a list of critical extensions encountered and warnings generated by
160 * certificates during chain validation.
162 * @return An array of certificate warnings. */
163 IMPORT_C const RPointerArray<CCertificateValidationWarnings>& ValidationWarnings() const;
165 /** Adds a certificate warning to the validation result.
167 * @param aCertWarning The warning to be added. */
168 IMPORT_C void AppendCertificateValidationObjectL(const CCertificateValidationWarnings& aCertWarning);
170 /** Adds a critical extension OID warning.
172 * @param aCriticalExt The critical extension OID to be added. */
173 IMPORT_C void AppendCriticalExtensionWarningL(TDesC& aCriticalExt);
176 IMPORT_C CPKIXValidationResultBase();
177 IMPORT_C void ConstructL();
180 TValidationStatus iError;
181 CArrayFixFlat<TValidationStatus>* iWarnings;
182 CArrayPtrFlat<CX509CertPolicyInfo>* iPolicies;
183 RPointerArray<CCertificateValidationWarnings> iCertWarnings;
186 /** Stores the information regarding the results of a validation of a PKIX
190 class CPKIXValidationResult : public CPKIXValidationResultBase
193 /** Creates a new PKIX Validation Result object.
195 * @return The new PKIX Validation Result object. */
196 IMPORT_C static CPKIXValidationResult* NewL();
198 /** Creates a new PKIX Validation Result object, and puts a pointer to it onto
201 * @return The new PKIX Validation Result object. */
202 IMPORT_C static CPKIXValidationResult* NewLC();
206 * Frees all resources owned by the object. */
207 IMPORT_C ~CPKIXValidationResult();
209 /** Gets the error status of the operation.
211 * Errors are considered fatal, i.e. validation has failed.
213 * @return The error status of the operation. */
214 IMPORT_C const TValidationStatus Error() const;
216 /** Gets a list of warnings generated.
218 * The warnings may or may not be fatal, depending on the context, which the
219 * client is expected to provide.
221 * @return An array of any warnings generated. */
222 IMPORT_C const CArrayFixFlat<TValidationStatus>& Warnings() const;
224 /** Gets a list of all the certificate policies which have been accepted implicitly
225 * in the course of validation.
227 * @return An array of certificate policies. */
228 IMPORT_C const CArrayPtrFlat<CX509CertPolicyInfo>& Policies() const;
230 /** Returns a list of critical extensions encountered and warnings generated by
231 * certificates during chain validation. A CCertificateWarning object is returned for
232 * each certificate in the chain, even if no critical extensions or warnings were
233 * encountered. The array's data is in the same order as the certificate chain.
235 * @return An array of certificate warnings. Ownership is not transferred
237 IMPORT_C const RPointerArray<CCertificateValidationWarnings>& ValidationWarnings() const;
240 CPKIXValidationResult();