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