os/security/cryptoservices/certificateandkeymgmt/inc/cmscertchoice.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2006-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
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @publishedPartner
sl@0
    22
 @released
sl@0
    23
*/
sl@0
    24
sl@0
    25
sl@0
    26
#ifndef CMSCERTCHOICE_H
sl@0
    27
#define CMSCERTCHOICE_H
sl@0
    28
sl@0
    29
#include <e32base.h>
sl@0
    30
sl@0
    31
class CX509Certificate;
sl@0
    32
class CASN1EncEncoding;
sl@0
    33
sl@0
    34
/**
sl@0
    35
An instance of a member of the RFC2630 CertificateChoices.
sl@0
    36
At present, only X509 certificates and attribute certificate are supported.
sl@0
    37
(not PKCS#6 extended certificates).
sl@0
    38
*/
sl@0
    39
class CCmsCertificateChoice : public CBase
sl@0
    40
	{
sl@0
    41
public:
sl@0
    42
	/**
sl@0
    43
	Certificate Types
sl@0
    44
	*/
sl@0
    45
	enum TCertificateType
sl@0
    46
		{
sl@0
    47
		/**
sl@0
    48
		X.509 Certificate.
sl@0
    49
		*/
sl@0
    50
		ECertificateX509,
sl@0
    51
		/**
sl@0
    52
		Extended Certificate.
sl@0
    53
		*/
sl@0
    54
		ECertificateExtendedCerificate,
sl@0
    55
		/**
sl@0
    56
		Attribute Certificate.
sl@0
    57
		*/
sl@0
    58
		ECertificateAttribute
sl@0
    59
		};
sl@0
    60
		
sl@0
    61
	/**
sl@0
    62
	 * @internalComponent
sl@0
    63
	 * 
sl@0
    64
	 * Creates a CertificateChoices as defined in RFC2630.
sl@0
    65
	 * @param aCertificate The X509 certificate used to build the CertificateChoices object.
sl@0
    66
	 * The newly created object will create a copy of aCertificate.	
sl@0
    67
	 * @return The fully constructed object.
sl@0
    68
	 **/
sl@0
    69
	static CCmsCertificateChoice* NewL(const CX509Certificate& aCertificate);
sl@0
    70
sl@0
    71
	/**
sl@0
    72
	 * @internalComponent
sl@0
    73
	 *
sl@0
    74
	 * Creates a CertificateChoices object as defined in RFC2630
sl@0
    75
	 * and leaves the object on the cleanup stack.
sl@0
    76
	 * @param aCertificate The X509 certificate used to build the CertificateChoices object.
sl@0
    77
	 * The newly created object will create a copy of aCertificate.	
sl@0
    78
	 * @return The fully constructed object.
sl@0
    79
	 **/
sl@0
    80
	static CCmsCertificateChoice* NewLC(const CX509Certificate& aCertificate);
sl@0
    81
sl@0
    82
	/**
sl@0
    83
	 * @internalComponent
sl@0
    84
	 *
sl@0
    85
	 * Creates a CertificateChoices object as defined in RFC2630.
sl@0
    86
	 * @param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported.
sl@0
    87
	 * @param aEncodedCertificate The encoded certificate used to build the CertificateChoices object.
sl@0
    88
	 * The newly created object will create a copy of aEncodedCertificate.
sl@0
    89
	 * @return The fully constructed object.
sl@0
    90
	 **/	
sl@0
    91
	static CCmsCertificateChoice* NewL(TCertificateType aCertType, const TDesC8& aEncodedCertificate);
sl@0
    92
	
sl@0
    93
	/**
sl@0
    94
	 * @internalComponent
sl@0
    95
	 * 
sl@0
    96
	 * Creates a CertificateChoices object as defined in RFC2630 and leaves the object on the cleanup stack.
sl@0
    97
	 * @param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported.
sl@0
    98
	 * @param aEncodedCertificate The encoded certificate used to build the CertificateChoices object.
sl@0
    99
	 * The newly created object will create a copy of aEncodedCertificate.
sl@0
   100
	 * @return The fully constructed object.
sl@0
   101
	 **/		
sl@0
   102
	static CCmsCertificateChoice* NewLC(TCertificateType aCertType, const TDesC8& aEncodedCertificate);
sl@0
   103
	
sl@0
   104
	/**
sl@0
   105
	 * @internalComponent
sl@0
   106
	 * 
sl@0
   107
	 * Creates a CertificateChoices object as defined in RFC2630.
sl@0
   108
	 * @param aRawData The encoded CertificateChoices object to be decoded.
sl@0
   109
	 * @return The fully constructed object.
sl@0
   110
	 **/			
sl@0
   111
	static CCmsCertificateChoice* NewL(const TDesC8& aRawData);
sl@0
   112
	
sl@0
   113
	/**
sl@0
   114
	Destructor
sl@0
   115
	*/
sl@0
   116
	virtual ~CCmsCertificateChoice();
sl@0
   117
	
sl@0
   118
	/**
sl@0
   119
	Returns the type of the CertificateChoices object
sl@0
   120
	@return The type of the certificate.
sl@0
   121
	*/
sl@0
   122
	IMPORT_C TCertificateType CertificateType();
sl@0
   123
	
sl@0
   124
	/**
sl@0
   125
	Returns the x509 certificate reference if the certificate is a X509 certificate.
sl@0
   126
	Callers need to check whether the certificate's type is X509 beforehand.
sl@0
   127
	@return The x509 certificate reference.
sl@0
   128
	*/
sl@0
   129
	IMPORT_C const CX509Certificate& Certificate(void) const;
sl@0
   130
sl@0
   131
	/**
sl@0
   132
	Returns the encoded certificate's buffer. If the certificate is not an
sl@0
   133
	attribute certificate, NULL is returned. Callers can also check whether 
sl@0
   134
	the certificate's type is X509 beforehand.
sl@0
   135
	@return A pointer to the encoded certificate buffer.
sl@0
   136
	*/
sl@0
   137
	IMPORT_C const HBufC8* AttributeCertificate() const;
sl@0
   138
sl@0
   139
	/**
sl@0
   140
	 * @internalComponent
sl@0
   141
	 *
sl@0
   142
	 * Creates the ASN1 DER sequence of the CertificateChoices object
sl@0
   143
	 * and leaves it on the cleanup stack.
sl@0
   144
	 * @return  ASN1 DER sequence of this object.
sl@0
   145
	 **/		
sl@0
   146
	CASN1EncEncoding* EncodeASN1DERLC() const;
sl@0
   147
sl@0
   148
private:
sl@0
   149
	/**
sl@0
   150
	Default Constructor
sl@0
   151
	*/
sl@0
   152
	CCmsCertificateChoice();
sl@0
   153
	
sl@0
   154
	
sl@0
   155
	/**
sl@0
   156
	Second phase constructor for decoding.
sl@0
   157
	@param aRawData the raw data to be decoded.
sl@0
   158
	*/
sl@0
   159
	void ConstructL(const TDesC8& aRawData);
sl@0
   160
	
sl@0
   161
	/**
sl@0
   162
	Second phase constructor for encoding.
sl@0
   163
	@param aCertificate the X509 certificate used to create the object
sl@0
   164
	*/
sl@0
   165
	void ConstructL(const CX509Certificate& aCertificate);
sl@0
   166
sl@0
   167
	/**
sl@0
   168
	Second phase constructor for encoding.
sl@0
   169
	@param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported
sl@0
   170
	@param aEncodedCertificate the encoded certificate used to create the object
sl@0
   171
	*/	
sl@0
   172
	void ConstructL(TCertificateType aCertType, const TDesC8& aEncodedCertificate);
sl@0
   173
sl@0
   174
	
sl@0
   175
private:
sl@0
   176
	/**
sl@0
   177
	The type the embedded certificate type
sl@0
   178
	*/
sl@0
   179
	TCertificateType iCertificateType;
sl@0
   180
	
sl@0
   181
	/**
sl@0
   182
	The X509 certificate pointer
sl@0
   183
	*/
sl@0
   184
	CX509Certificate* iCertificate;
sl@0
   185
	
sl@0
   186
	/**
sl@0
   187
	The attribute certificate buffer
sl@0
   188
	*/	
sl@0
   189
	HBufC8* iEncodedAttributeCertificate;
sl@0
   190
	};
sl@0
   191
	
sl@0
   192
#endif