sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: sl@0: sl@0: #ifndef CMSCERTCHOICE_H sl@0: #define CMSCERTCHOICE_H sl@0: sl@0: #include sl@0: sl@0: class CX509Certificate; sl@0: class CASN1EncEncoding; sl@0: sl@0: /** sl@0: An instance of a member of the RFC2630 CertificateChoices. sl@0: At present, only X509 certificates and attribute certificate are supported. sl@0: (not PKCS#6 extended certificates). sl@0: */ sl@0: class CCmsCertificateChoice : public CBase sl@0: { sl@0: public: sl@0: /** sl@0: Certificate Types sl@0: */ sl@0: enum TCertificateType sl@0: { sl@0: /** sl@0: X.509 Certificate. sl@0: */ sl@0: ECertificateX509, sl@0: /** sl@0: Extended Certificate. sl@0: */ sl@0: ECertificateExtendedCerificate, sl@0: /** sl@0: Attribute Certificate. sl@0: */ sl@0: ECertificateAttribute sl@0: }; sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates a CertificateChoices as defined in RFC2630. sl@0: * @param aCertificate The X509 certificate used to build the CertificateChoices object. sl@0: * The newly created object will create a copy of aCertificate. sl@0: * @return The fully constructed object. sl@0: **/ sl@0: static CCmsCertificateChoice* NewL(const CX509Certificate& aCertificate); sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates a CertificateChoices object as defined in RFC2630 sl@0: * and leaves the object on the cleanup stack. sl@0: * @param aCertificate The X509 certificate used to build the CertificateChoices object. sl@0: * The newly created object will create a copy of aCertificate. sl@0: * @return The fully constructed object. sl@0: **/ sl@0: static CCmsCertificateChoice* NewLC(const CX509Certificate& aCertificate); sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates a CertificateChoices object as defined in RFC2630. sl@0: * @param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported. sl@0: * @param aEncodedCertificate The encoded certificate used to build the CertificateChoices object. sl@0: * The newly created object will create a copy of aEncodedCertificate. sl@0: * @return The fully constructed object. sl@0: **/ sl@0: static CCmsCertificateChoice* NewL(TCertificateType aCertType, const TDesC8& aEncodedCertificate); sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates a CertificateChoices object as defined in RFC2630 and leaves the object on the cleanup stack. sl@0: * @param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported. sl@0: * @param aEncodedCertificate The encoded certificate used to build the CertificateChoices object. sl@0: * The newly created object will create a copy of aEncodedCertificate. sl@0: * @return The fully constructed object. sl@0: **/ sl@0: static CCmsCertificateChoice* NewLC(TCertificateType aCertType, const TDesC8& aEncodedCertificate); sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates a CertificateChoices object as defined in RFC2630. sl@0: * @param aRawData The encoded CertificateChoices object to be decoded. sl@0: * @return The fully constructed object. sl@0: **/ sl@0: static CCmsCertificateChoice* NewL(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: virtual ~CCmsCertificateChoice(); sl@0: sl@0: /** sl@0: Returns the type of the CertificateChoices object sl@0: @return The type of the certificate. sl@0: */ sl@0: IMPORT_C TCertificateType CertificateType(); sl@0: sl@0: /** sl@0: Returns the x509 certificate reference if the certificate is a X509 certificate. sl@0: Callers need to check whether the certificate's type is X509 beforehand. sl@0: @return The x509 certificate reference. sl@0: */ sl@0: IMPORT_C const CX509Certificate& Certificate(void) const; sl@0: sl@0: /** sl@0: Returns the encoded certificate's buffer. If the certificate is not an sl@0: attribute certificate, NULL is returned. Callers can also check whether sl@0: the certificate's type is X509 beforehand. sl@0: @return A pointer to the encoded certificate buffer. sl@0: */ sl@0: IMPORT_C const HBufC8* AttributeCertificate() const; sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates the ASN1 DER sequence of the CertificateChoices object sl@0: * and leaves it on the cleanup stack. sl@0: * @return ASN1 DER sequence of this object. sl@0: **/ sl@0: CASN1EncEncoding* EncodeASN1DERLC() const; sl@0: sl@0: private: sl@0: /** sl@0: Default Constructor sl@0: */ sl@0: CCmsCertificateChoice(); sl@0: sl@0: sl@0: /** sl@0: Second phase constructor for decoding. sl@0: @param aRawData the raw data to be decoded. sl@0: */ sl@0: void ConstructL(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: Second phase constructor for encoding. sl@0: @param aCertificate the X509 certificate used to create the object sl@0: */ sl@0: void ConstructL(const CX509Certificate& aCertificate); sl@0: sl@0: /** sl@0: Second phase constructor for encoding. sl@0: @param aCertType The encoded certificate type. ECertificateExtendedCerificate is not supported sl@0: @param aEncodedCertificate the encoded certificate used to create the object sl@0: */ sl@0: void ConstructL(TCertificateType aCertType, const TDesC8& aEncodedCertificate); sl@0: sl@0: sl@0: private: sl@0: /** sl@0: The type the embedded certificate type sl@0: */ sl@0: TCertificateType iCertificateType; sl@0: sl@0: /** sl@0: The X509 certificate pointer sl@0: */ sl@0: CX509Certificate* iCertificate; sl@0: sl@0: /** sl@0: The attribute certificate buffer sl@0: */ sl@0: HBufC8* iEncodedAttributeCertificate; sl@0: }; sl@0: sl@0: #endif