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