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: #ifndef CMSCONTENTINFO_H sl@0: #define CMSCONTENTINFO_H sl@0: sl@0: #include "cmsdefs.h" sl@0: sl@0: class CASN1EncSequence; sl@0: sl@0: /** sl@0: The RFC2630 EncapsulatedContentInfo entity. sl@0: This class provides details about the Content Type in the Content Info, sl@0: provides access to the Content Data when the Content Type is Data and sl@0: provides access to the entire ContentInfo sequence. sl@0: */ sl@0: class CEncapsulatedContentInfo : public CBase sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates an EncapsulatedContentInfo as defined in RFC2630. sl@0: * @param aRawData the encoded encapsulated data. sl@0: * @return The fully constructed object sl@0: **/ sl@0: static CEncapsulatedContentInfo* NewL(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates an EncapsulatedContentInfo as defined in RFC2630, and leaves the instance on the cleanup stack. sl@0: * @param aRawData The encoded encapsulated data. sl@0: * @return The fully constructed object. sl@0: **/ sl@0: static CEncapsulatedContentInfo* NewLC(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates an EncapsulatedContentInfo as defined in RFC2630. sl@0: * @param aContentInfoType The type of the encapsulated content. sl@0: * @param aIsEContentDataPresent Indicates whether the encapsulated data is present. sl@0: * @param aContentData The encapsulated data. sl@0: * @return The fully constructed object. sl@0: **/ sl@0: static CEncapsulatedContentInfo* NewL(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData); sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates an EncapsulatedContentInfo as defined in RFC2630, and leaves the instance on the cleanup stack. sl@0: * @param aContentInfoType The type of the encapsulated content. sl@0: * @param aIsEContentDataPresent Indicates whether the encapsulated data is present. sl@0: * @param aContentData The encapsulated data. sl@0: * @return The fully constructed object sl@0: **/ sl@0: static CEncapsulatedContentInfo* NewLC(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData); sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * sl@0: * Creates the DER sequence of the ContentInfo and leaves the DER sequence on the cleanup stack. sl@0: * @return The ASN.1 sequence of the ContentInfo. sl@0: **/ sl@0: CASN1EncSequence* EncodeASN1DERLC() const; sl@0: sl@0: /** sl@0: Provides information about the ContentType in the ContentInfo sequence. sl@0: It returns the last number in the ObjectIdentifier. sl@0: @return The ContentType. This is: sl@0: sl@0: - 1 for Data sl@0: sl@0: - 2 for SignedData sl@0: sl@0: - 3 for EnvelopedData sl@0: sl@0: - 5 for DigestedData sl@0: sl@0: - 6 for EncryptedData sl@0: */ sl@0: IMPORT_C TCmsContentInfoType ContentType() const; sl@0: sl@0: /** sl@0: Returns whether the ContentInfo is present or not. sl@0: ContentData present in EncapsulatedContentInfo is OPTIONAL. sl@0: @return A boolean value that indicates whether or not the ContentInfo is present. sl@0: */ sl@0: IMPORT_C TBool IsContentDataPresent() const; sl@0: sl@0: /** sl@0: Provides access to the Content Data present in CMS. ContentData present sl@0: in EncapsulatedContentInfo is OPTIONAL. The client has to check for sl@0: data length 0 or if the data content is present in case there is no ContentData. sl@0: @return The ContentData. sl@0: */ sl@0: IMPORT_C const TPtrC8 ContentData() const; sl@0: sl@0: private: sl@0: /* sl@0: Constuctor and second phase constructor. sl@0: */ sl@0: CEncapsulatedContentInfo(); sl@0: CEncapsulatedContentInfo(TCmsContentInfoType aContentInfoType, TBool aIsEContentDataPresent, const TDesC8& aContentData); sl@0: void ConstructL(const TDesC8& aRawData); sl@0: sl@0: private: sl@0: /** sl@0: The Type of the ContentInfo sl@0: */ sl@0: TCmsContentInfoType iContentType; sl@0: sl@0: /** sl@0: Represents whether the Content is present or not. sl@0: */ sl@0: TBool iIsContentDataPresent; sl@0: sl@0: /** sl@0: The Content Data. sl@0: */ sl@0: TPtrC8 iContentData; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: The RFC2630 ContentInfo entity. sl@0: This class provides details about the content type in the ContentInfo, sl@0: provides access to the content data when the content type is Data and sl@0: provides access to the entire ContentInfo sequence. sl@0: At present, only data content type and signed data type are supported. sl@0: */ sl@0: class CCmsContentInfo : public CBase sl@0: { sl@0: public: sl@0: /** sl@0: Creates a ContentInfo as defined in RFC2630. sl@0: @param aRawData The encoded encapsulated data. sl@0: @return The fully constructed object. sl@0: */ sl@0: IMPORT_C static CCmsContentInfo* NewL(const TDesC8& aRawData); sl@0: /** sl@0: Creates a ContentInfo as defined in RFC2630, sl@0: and leaves the instance on the cleanup stack. sl@0: @param aRawData The encoded encapsulated data. sl@0: @return The fully constructed object. sl@0: */ sl@0: IMPORT_C static CCmsContentInfo* NewLC(const TDesC8& aRawData); sl@0: sl@0: /** sl@0: Creates a ContentInfo as defined in RFC2630. sl@0: @param aContentInfoType The type of the encapsulated content. sl@0: @param aContentData The encapsulated data. sl@0: @return The fully constructed object. sl@0: */ sl@0: IMPORT_C static CCmsContentInfo* NewL(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData); sl@0: sl@0: /** sl@0: Creates a ContentInfo as defined in RFC2630 and leaves the object on the cleanup stack. sl@0: @param aContentInfoType The type of the encapsulated content. sl@0: @param aContentData The encapsulated data. sl@0: @return The fully constructed object. sl@0: */ sl@0: IMPORT_C static CCmsContentInfo* NewLC(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData); sl@0: sl@0: /** sl@0: Creates the DER sequence of the ContentInfo and leaves the DER sequence on the cleanup stack. sl@0: @return The ASN.1 sequence of the ContentInfo. sl@0: */ sl@0: IMPORT_C CASN1EncSequence* EncodeASN1DERLC() const; sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: IMPORT_C ~CCmsContentInfo(); sl@0: sl@0: /** sl@0: Provides the information about the ContentType in the ContentInfo sequence. sl@0: It returns the last number in the Object Identifier. sl@0: @return The ContentType. This is: sl@0: sl@0: - 1 for Data sl@0: sl@0: - 2 for SignedData sl@0: sl@0: - 3 for EnvelopedData sl@0: sl@0: - 5 for DigestedData sl@0: sl@0: - 6 for EncryptedData sl@0: */ sl@0: IMPORT_C TCmsContentInfoType ContentType() const; sl@0: sl@0: /** sl@0: Provides access to the content data. sl@0: @return The content data. sl@0: */ sl@0: IMPORT_C const TPtrC8 ContentData() const; sl@0: sl@0: sl@0: private: sl@0: /** sl@0: default constructor sl@0: */ sl@0: CCmsContentInfo(); sl@0: sl@0: /** sl@0: constructor to build the CMS content info from the given parameters sl@0: @param aContentInfoType the type of data contained in the CMS content info sl@0: @param aContentData the descriptor which contains the encoded CMS oject sl@0: */ sl@0: CCmsContentInfo(TCmsContentInfoType aContentInfoType, const TDesC8& aContentData); sl@0: sl@0: /** sl@0: constructor to build the CMS content info from the raw data. sl@0: @param aContentInfoType the type of data contained in the CMS content info sl@0: @param aContentData the descriptor which contains the encoded CMS oject sl@0: */ sl@0: void ConstructL(const TDesC8& aRawData); sl@0: sl@0: private: sl@0: /** sl@0: The Type of the ContentInfo sl@0: */ sl@0: TCmsContentInfoType iContentType; sl@0: sl@0: /** sl@0: The Content Data sl@0: */ sl@0: TPtrC8 iContentData; sl@0: }; sl@0: sl@0: #endif // CMSCONTENTINFO_H sl@0: