secsrv_plat/cms_api/inc/CCMSOriginatorIdentifierOrKey.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2004 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 "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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CCMSOriginatorIdentifierOrKey_H
       
    21 #define CCMSOriginatorIdentifierOrKey_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <asn1cons.h>
       
    26 #include "MCMSModule.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CCMSIssuerAndSerialNumber;
       
    30 class CCMSOriginatorPublicKey;
       
    31 class CASN1EncBase;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 /**
       
    35 *  OriginatorIdentifierOrKey type module
       
    36 *
       
    37 *  ASN.1 definition:
       
    38 *  OriginatorIdentifierOrKey ::= CHOICE {
       
    39 *        issuerAndSerialNumber IssuerAndSerialNumber,
       
    40 *        subjectKeyIdentifier [0] SubjectKeyIdentifier,
       
    41 *        originatorKey [1] OriginatorPublicKey }
       
    42 *  @lib cms.lib
       
    43 *  @since 2.8
       
    44 */
       
    45 class CCMSOriginatorIdentifierOrKey : public CBase, public MCMSModule
       
    46     {
       
    47     public: // data types
       
    48         enum TType
       
    49             {
       
    50             ESubjectKeyIdentifier = 0,
       
    51             EOriginatorKey = 1,
       
    52             EIssuerAndSerialNumber
       
    53             };
       
    54 
       
    55     public:  // Constructors and destructor
       
    56 		/**
       
    57         * Two-phased constructor.
       
    58         */
       
    59         IMPORT_C static CCMSOriginatorIdentifierOrKey* NewL();
       
    60 
       
    61         /**
       
    62         * Two-phased constructor. Copies of the parameters are made.
       
    63         *
       
    64         * @param aIssuerAndSerialNumber identifies sender's certificate
       
    65         */
       
    66         IMPORT_C static CCMSOriginatorIdentifierOrKey* NewL(
       
    67             const CCMSIssuerAndSerialNumber& aIssuerAndSerialNumber );
       
    68 
       
    69         /**
       
    70         * Two-phased constructor. Copies of the parameters are made.
       
    71         *
       
    72         * @param aSubjectKeyIdentifier X.509 subjectKeyIdentifier
       
    73         */
       
    74         IMPORT_C static CCMSOriginatorIdentifierOrKey* NewL(
       
    75             const TDesC8& aSubjectKeyIdentifier );
       
    76 
       
    77         /**
       
    78         * Two-phased constructor. Copies of the parameters are made.
       
    79         *
       
    80         * @param aOriginatorKey includes algorithm identifier and public key
       
    81         */
       
    82         IMPORT_C static CCMSOriginatorIdentifierOrKey* NewL(
       
    83             const CCMSOriginatorPublicKey& aOriginatorKey );
       
    84 
       
    85         /**
       
    86         * Destructor.
       
    87         */
       
    88         virtual ~CCMSOriginatorIdentifierOrKey();
       
    89 
       
    90     public: // New functions
       
    91         /**
       
    92          * Getter for the CHOICE type. There is no corresponding
       
    93          * setter method as the type is set implicitly by the member
       
    94          * value setters.
       
    95          * @since 2.8
       
    96          * @return the CHOICE type
       
    97          */
       
    98         IMPORT_C TType Type() const;
       
    99 
       
   100         /**
       
   101         * Getter for IssuerAndSerialNumber. Leaves with KErrNotFound
       
   102         * if the type of this CHOICE is not EIssuerAndSerialNumber.
       
   103         * @since 2.8
       
   104         * @return IssuerAndSerialNumber
       
   105         */
       
   106 		IMPORT_C const CCMSIssuerAndSerialNumber&
       
   107         IssuerAndSerialNumberL() const;
       
   108 
       
   109         /**
       
   110         * Getter for the X.509 subjectKeyIdentifier. Leaves with
       
   111         * KErrNotFound if the type of this CHOICE is not ESubjectKeyIdentifier.
       
   112         * @since 2,8
       
   113         * @return subjectKeyIdentifier
       
   114         */
       
   115 		IMPORT_C const TDesC8& SubjectKeyIdentifierL() const;
       
   116 
       
   117         /**
       
   118          * Getter for OriginatorKey. Leaves with KErrNotFound if the
       
   119          * type of this CHOICE is not EOriginatorKey.
       
   120          * @since 2,8
       
   121          * @return OriginatorKey
       
   122          */
       
   123         IMPORT_C const CCMSOriginatorPublicKey& OriginatorKeyL() const;
       
   124 
       
   125 		/**
       
   126         * Setter for IssuerAndSerialNumber. Create a copy of the parameters.
       
   127         * @since 2.8
       
   128         * @param aIssuerAndSerialNumber identifies sender's certificate
       
   129         */
       
   130 		IMPORT_C void SetIssuerAndSerialNumberL(
       
   131             const CCMSIssuerAndSerialNumber& aIssuerAndSerialNumber );
       
   132 
       
   133         /**
       
   134         * Setter for subjectKeyIdentifier
       
   135         * @since 2,8
       
   136         * @param aSubjectKeyIdentifier X.509 subjectKeyIdentifier
       
   137         */
       
   138 		IMPORT_C void SetSubjectKeyIdentifierL(
       
   139             const TDesC8& aSubjectKeyIdentifier );
       
   140 
       
   141         /**
       
   142          * Setter for originatorKey
       
   143          * @since 2.8
       
   144          * @param aOriginatorKey includes algorithm identifier and
       
   145          * public key
       
   146          */
       
   147         IMPORT_C void SetOriginatorKeyL(
       
   148             const CCMSOriginatorPublicKey& aOriginatorKey );
       
   149 
       
   150     public: // Functions from base classes
       
   151 
       
   152         /**
       
   153         * From MCMSModule
       
   154         * @since 2.8
       
   155         * @param aResult Allocates and sets result in this variable
       
   156         * @return ?description
       
   157         */
       
   158         void EncodeL( HBufC8*& aResult ) const;
       
   159 
       
   160 	 	/**
       
   161         * From MCMSModule
       
   162         * @since 2.8
       
   163         * @param aRawData raw-data to be parsed in this instance
       
   164         */
       
   165         void DecodeL( const TDesC8& aRawData );
       
   166 
       
   167 	 	/**
       
   168         * From MCMSModule
       
   169         * @since 2.8
       
   170         * @return Returns ASN1 encoder and leaves it in CleanupStack
       
   171         */
       
   172         CASN1EncBase* EncoderLC() const;
       
   173 
       
   174     protected:  // New functions
       
   175 
       
   176 	   /**
       
   177         * Protected construction to allow derivation
       
   178         */
       
   179         IMPORT_C void ConstructL(
       
   180             const CCMSIssuerAndSerialNumber& aIssuerAndSerialNumber );
       
   181 
       
   182         /**
       
   183         * Protected construction to allow derivation
       
   184         */
       
   185         IMPORT_C void ConstructL(
       
   186             const TDesC8& aSubjectKeyIdentifier );
       
   187 
       
   188         /**
       
   189         * Protected construction to allow derivation
       
   190         */
       
   191         IMPORT_C void ConstructL(
       
   192             const CCMSOriginatorPublicKey& aOriginatorKey );
       
   193 
       
   194         /**
       
   195         * C++ default constructor.
       
   196         */
       
   197         IMPORT_C CCMSOriginatorIdentifierOrKey();
       
   198 
       
   199     private: // New functions
       
   200 
       
   201         /**
       
   202          * Deletes old value and changes the type of the choice.
       
   203          * @param aNewType The type of the CHOICE will be set to
       
   204          * aNewType.
       
   205          */
       
   206         void DeleteOldValueAndChangeTypeL( TType aNewType );
       
   207 
       
   208         /**
       
   209          * Creates Encoder for the SubjectKeyIdentifier value 
       
   210          * @return ASN1 encoder
       
   211          */
       
   212         CASN1EncBase* EncoderSubjectKeyIdentifierLC() const;
       
   213 
       
   214         /**
       
   215          * Creates Encoder for the OriginatorKey value
       
   216          * @return ASN1 encoder
       
   217          */
       
   218         CASN1EncBase* EncoderOriginatorKeyLC() const;
       
   219         
       
   220     private:    // Data
       
   221 
       
   222         // defines the type of this CHOICE
       
   223         TType iType;
       
   224 
       
   225         // IssuerAndSerialNumber value. owned.
       
   226         CCMSIssuerAndSerialNumber* iIssuerAndSerialNumber;
       
   227 
       
   228         // SubjectKeyIdentifier value. owned.
       
   229         HBufC8* iSubjectKeyIdentifier;
       
   230 
       
   231         // OriginatorPublicKey value. owned.
       
   232         CCMSOriginatorPublicKey* iOriginatorKey;
       
   233 
       
   234     };
       
   235 
       
   236 #endif      // CCMSOriginatorIdentifierOrKey_H
       
   237 
       
   238 // End of File