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