First public contribution.
2 * Copyright (c) 2006-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.
26 #ifndef CMSCERTCHOICE_H
27 #define CMSCERTCHOICE_H
31 class CX509Certificate;
32 class CASN1EncEncoding;
35 An instance of a member of the RFC2630 CertificateChoices.
36 At present, only X509 certificates and attribute certificate are supported.
37 (not PKCS#6 extended certificates).
39 class CCmsCertificateChoice : public CBase
54 ECertificateExtendedCerificate,
56 Attribute Certificate.
64 * Creates a CertificateChoices as defined in RFC2630.
65 * @param aCertificate The X509 certificate used to build the CertificateChoices object.
66 * The newly created object will create a copy of aCertificate.
67 * @return The fully constructed object.
69 static CCmsCertificateChoice* NewL(const CX509Certificate& aCertificate);
74 * Creates a CertificateChoices object as defined in RFC2630
75 * and leaves the object on the cleanup stack.
76 * @param aCertificate The X509 certificate used to build the CertificateChoices object.
77 * The newly created object will create a copy of aCertificate.
78 * @return The fully constructed object.
80 static CCmsCertificateChoice* NewLC(const CX509Certificate& aCertificate);
85 * Creates a CertificateChoices object as defined in RFC2630.
86 * @param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported.
87 * @param aEncodedCertificate The encoded certificate used to build the CertificateChoices object.
88 * The newly created object will create a copy of aEncodedCertificate.
89 * @return The fully constructed object.
91 static CCmsCertificateChoice* NewL(TCertificateType aCertType, const TDesC8& aEncodedCertificate);
96 * Creates a CertificateChoices object as defined in RFC2630 and leaves the object on the cleanup stack.
97 * @param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported.
98 * @param aEncodedCertificate The encoded certificate used to build the CertificateChoices object.
99 * The newly created object will create a copy of aEncodedCertificate.
100 * @return The fully constructed object.
102 static CCmsCertificateChoice* NewLC(TCertificateType aCertType, const TDesC8& aEncodedCertificate);
107 * Creates a CertificateChoices object as defined in RFC2630.
108 * @param aRawData The encoded CertificateChoices object to be decoded.
109 * @return The fully constructed object.
111 static CCmsCertificateChoice* NewL(const TDesC8& aRawData);
116 virtual ~CCmsCertificateChoice();
119 Returns the type of the CertificateChoices object
120 @return The type of the certificate.
122 IMPORT_C TCertificateType CertificateType();
125 Returns the x509 certificate reference if the certificate is a X509 certificate.
126 Callers need to check whether the certificate's type is X509 beforehand.
127 @return The x509 certificate reference.
129 IMPORT_C const CX509Certificate& Certificate(void) const;
132 Returns the encoded certificate's buffer. If the certificate is not an
133 attribute certificate, NULL is returned. Callers can also check whether
134 the certificate's type is X509 beforehand.
135 @return A pointer to the encoded certificate buffer.
137 IMPORT_C const HBufC8* AttributeCertificate() const;
142 * Creates the ASN1 DER sequence of the CertificateChoices object
143 * and leaves it on the cleanup stack.
144 * @return ASN1 DER sequence of this object.
146 CASN1EncEncoding* EncodeASN1DERLC() const;
152 CCmsCertificateChoice();
156 Second phase constructor for decoding.
157 @param aRawData the raw data to be decoded.
159 void ConstructL(const TDesC8& aRawData);
162 Second phase constructor for encoding.
163 @param aCertificate the X509 certificate used to create the object
165 void ConstructL(const CX509Certificate& aCertificate);
168 Second phase constructor for encoding.
169 @param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported
170 @param aEncodedCertificate the encoded certificate used to create the object
172 void ConstructL(TCertificateType aCertType, const TDesC8& aEncodedCertificate);
177 The type the embedded certificate type
179 TCertificateType iCertificateType;
182 The X509 certificate pointer
184 CX509Certificate* iCertificate;
187 The attribute certificate buffer
189 HBufC8* iEncodedAttributeCertificate;