epoc32/include/pkcs10attr.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2 * Copyright (c) 2002-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 * PKCS#10 Certificate Request Attributes class.
    16 *
    17 */
    18 
    19 
    20 
    21 
    22 /**
    23  @file
    24  @publishedPartner
    25  @released 
    26 */
    27 
    28 #if !defined (__PKCS10ATTR_H__)
    29 #define __PKCS10ATTR_H__
    30 
    31 class CASN1EncBase;
    32 class CASN1EncSequence;
    33 
    34 //
    35 // Class capturing common functionality of a PKCS attribute.
    36 //
    37 class CPKCSAttributeBase : public CBase
    38 	{
    39 public:
    40 
    41 	/** Get the ASN.1 encoding of the attribute and relinquish ownership of it,
    42 		leaving it on the cleanup stack.  This is called by CPKCS10Attribtues
    43 		when AddAttribute() is called. 
    44 		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
    45 		@return ASN.1 encoding object
    46 	*/
    47 	virtual CASN1EncBase* GetEncodingLC() = 0;
    48 
    49 	virtual ~CPKCSAttributeBase();
    50 
    51 protected:
    52 	/** @internalComponent */
    53 	CPKCSAttributeBase();
    54 	CASN1EncSequence* iRoot;
    55 	CASN1EncSet* iValueSet;
    56 	};
    57 
    58 /** Class representing a generic certificate attribute.  Attributes have an
    59 	object identifier and one or more values.
    60 */
    61 class CPKCS10Attribute : public CPKCSAttributeBase
    62 	{
    63 public:
    64 
    65 	/** Create an attribute with a specified OID and no values, leaving it on
    66 		the cleanup stack.
    67 		NOTE: This method is deprecated. Use the other forms of NewLC instead.
    68 		@param aAttrOID	The specified OID in the form a.b.c. etc.
    69 		@return New PKCS10 attribute object on the cleanup stack
    70 		@deprecated
    71 	*/
    72 	IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID);
    73 
    74 	/** Create an attribute with a specified OID and one value, leaving it on
    75 		the cleanup stack. The value forms part of a set. Additional values can
    76 		be added by calling the AddValueL method.
    77 		@param aAttrOID	The specified OID in the form a.b.c. etc.
    78 		@param aASN1	ASN1 encoding object for attribute value
    79 		 				-- this method takes ownership.
    80 		@return New PKCS10 attribute object on the cleanup stack
    81 	*/
    82 	IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID, CASN1EncBase* aASN1);
    83 
    84 	/** Create an attribute with a specified OID and one value. The value forms 
    85 		part of a set. Additional values can be added by calling the AddValueL method.
    86 		@param aAttrOID	The specified OID in the form a.b.c. etc.
    87 		@param aASN1	ASN1 encoding object for attribute value
    88 		 				-- this method takes ownership.
    89 		@return New PKCS10 attribute object
    90 	*/
    91 	IMPORT_C static CPKCS10Attribute* NewL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
    92 
    93 	/** Add a value to the attribute.
    94 		@param aASN1	ASN1 encoding object for attribute value
    95 		 				-- this method takes ownership.
    96 	*/
    97 	IMPORT_C void AddValueL(CASN1EncBase* aASN1);
    98 
    99 	/** ResetL method to allow for re-use of the generic attribute object. 
   100 		Additional values can be added by calling the AddValueL method.
   101 		@param aAttrOID	The specified OID in the form a.b.c. etc.
   102 		@param aASN1	ASN1 encoding object for attribute value
   103 		 				-- this method takes ownership.
   104 	*/
   105 	IMPORT_C void ResetL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
   106 
   107 	virtual ~CPKCS10Attribute();
   108 
   109 	/** 
   110 	 * @internalComponent
   111 	 *
   112 	 * Get the ASN1 encoding of the attribute and relinquish ownership of it,
   113 		leaving it on the cleanup stack. This is called by CPKCS10Attribtues
   114 		when AddAttribute() is called. This method may leave with E32USER-CBase:66 
   115 		if a stack frame for the next PushL() cannot be allocated.
   116 		NOTE: This method is deprecated. Use GetEncodingLC() instead.
   117 		@deprecated
   118 	*/
   119 	CASN1EncBase* TakeEncodingC();
   120 
   121 	/** 
   122 	 * @internalComponent
   123 	 *
   124 	 * Get the ASN1 encoding of the attribute and relinquish ownership of it,
   125 		leaving it on the cleanup stack.  This is called by CPKCS10Attribtues
   126 		when AddAttribute() is called. This method may leave with E32USER-CBase:66 
   127 		if a stack frame for the next PushL() cannot be allocated.
   128 		NOTE: This method is deprecated. Use GetEncodingLC() instead.
   129 		@deprecated
   130 	*/
   131 	CASN1EncBase* TakeEncodingLC();
   132 
   133 	/** Calls the base class implementation for getting the ASN1 encoding of the attribute.
   134 		Note that this method cannot be reused unless ResetL() has been called. 
   135 		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
   136 		@return ASN.1 encoding object
   137 	*/
   138 	virtual CASN1EncBase* GetEncodingLC();
   139 
   140 private:
   141 	// Default constructor.
   142 	CPKCS10Attribute();
   143 
   144 	// Second phase construction function.
   145 	void ConstructL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
   146 	};
   147 
   148 /** Class for encoding a collection of certificate attributes and passing them
   149 	to the CPKCS10Request class. Some possible attributes are described in
   150 	PKCS#9.
   151   
   152 	@publishedPartner
   153 	@released
   154 */
   155 class CPKCS10Attributes : public CBase
   156 	{
   157 public:
   158 	/** Creates an instance of the class.
   159 		@return New attributes object on the cleanup stack.
   160 	*/
   161 	IMPORT_C static CPKCS10Attributes* NewLC();
   162 
   163 	/** Creates an instance of the class.
   164 		@return New attributes object.
   165 	*/
   166 	IMPORT_C static CPKCS10Attributes* NewL();
   167 
   168 	/** Adds a new attribute for the certificate request.
   169 		@param aAttr The attribute to add - this method takes ownership.
   170 		@deprecated
   171 	*/
   172 	IMPORT_C void AddAttributeL(CPKCS10Attribute* aAttr);
   173 
   174 	/** Adds a new attribute for the certificate request.
   175 		@param aAttr The attribute to add - this method takes ownership.
   176 	*/
   177 	IMPORT_C void AddPKCSAttributeL(CPKCSAttributeBase* aAttr);
   178 
   179 	IMPORT_C ~CPKCS10Attributes(); // virtual from base
   180 
   181 	/** 
   182 	 * @internalComponent
   183 	 *
   184 	 * Get the ASN1 encoding of the attributes and relinquish ownership of it,
   185 		leaving it on the cleanup stack. This is called by CPKCS10Request when
   186 		SetAttributes() is called. This method may leave with E32USER-CBase:66 
   187 		if a stack frame for the next PushL() cannot be allocated.
   188 		@deprecated
   189 	*/
   190 	CASN1EncBase* TakeEncodingC();
   191 
   192 	/** 
   193 	 * @internalComponent
   194 	 *
   195 	 * Get the ASN.1 encoding of the attribute and relinquish ownership of it,
   196 		leaving it on the cleanup stack. This is called by CPKCS10Request when
   197 		SetAttributes() is called. 
   198 		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
   199 		@return ASN.1 encoding object
   200 	*/
   201 	CASN1EncBase* TakeEncodingLC();
   202 
   203 private:
   204 	/** Default constructor.
   205 	*/
   206 	CPKCS10Attributes();
   207 
   208 	/** Second phase construction function. 
   209 		@note The structure of the attribute node is as follows:
   210 		@code
   211 		  SET
   212 		    SEQUENCE
   213 			  OID of attribute
   214 			  SET values
   215 			...
   216 		@endcode
   217 	*/
   218 	void ConstructL();
   219 	
   220 private:
   221 	/** Pointer to sequence of user-supplied certificate attributes. 
   222 		#AddAttributeL method is used to create and fill this member. 
   223 		If it is initialized by the time #CalculateEncodingL method 
   224 		is called, the latter uses attributes from this member variable 
   225 		for the request, otherwise no attributes are inserted into 
   226 		the request. 
   227 		
   228 		See #AddAttributeL for the explanation of ASN.1 encoding of
   229 		attributes.
   230 	*/
   231 	CASN1EncSequence* iRoot;
   232 	};
   233 
   234 #endif // __PKCS10ATTR_H__