epoc32/include/pkcs10attr.h
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/pkcs10attr.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,234 @@
     1.4 +/*
     1.5 +* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* PKCS#10 Certificate Request Attributes class.
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +
    1.24 +
    1.25 +/**
    1.26 + @file
    1.27 + @publishedPartner
    1.28 + @released 
    1.29 +*/
    1.30 +
    1.31 +#if !defined (__PKCS10ATTR_H__)
    1.32 +#define __PKCS10ATTR_H__
    1.33 +
    1.34 +class CASN1EncBase;
    1.35 +class CASN1EncSequence;
    1.36 +
    1.37 +//
    1.38 +// Class capturing common functionality of a PKCS attribute.
    1.39 +//
    1.40 +class CPKCSAttributeBase : public CBase
    1.41 +	{
    1.42 +public:
    1.43 +
    1.44 +	/** Get the ASN.1 encoding of the attribute and relinquish ownership of it,
    1.45 +		leaving it on the cleanup stack.  This is called by CPKCS10Attribtues
    1.46 +		when AddAttribute() is called. 
    1.47 +		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
    1.48 +		@return ASN.1 encoding object
    1.49 +	*/
    1.50 +	virtual CASN1EncBase* GetEncodingLC() = 0;
    1.51 +
    1.52 +	virtual ~CPKCSAttributeBase();
    1.53 +
    1.54 +protected:
    1.55 +	/** @internalComponent */
    1.56 +	CPKCSAttributeBase();
    1.57 +	CASN1EncSequence* iRoot;
    1.58 +	CASN1EncSet* iValueSet;
    1.59 +	};
    1.60 +
    1.61 +/** Class representing a generic certificate attribute.  Attributes have an
    1.62 +	object identifier and one or more values.
    1.63 +*/
    1.64 +class CPKCS10Attribute : public CPKCSAttributeBase
    1.65 +	{
    1.66 +public:
    1.67 +
    1.68 +	/** Create an attribute with a specified OID and no values, leaving it on
    1.69 +		the cleanup stack.
    1.70 +		NOTE: This method is deprecated. Use the other forms of NewLC instead.
    1.71 +		@param aAttrOID	The specified OID in the form a.b.c. etc.
    1.72 +		@return New PKCS10 attribute object on the cleanup stack
    1.73 +		@deprecated
    1.74 +	*/
    1.75 +	IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID);
    1.76 +
    1.77 +	/** Create an attribute with a specified OID and one value, leaving it on
    1.78 +		the cleanup stack. The value forms part of a set. Additional values can
    1.79 +		be added by calling the AddValueL method.
    1.80 +		@param aAttrOID	The specified OID in the form a.b.c. etc.
    1.81 +		@param aASN1	ASN1 encoding object for attribute value
    1.82 +		 				-- this method takes ownership.
    1.83 +		@return New PKCS10 attribute object on the cleanup stack
    1.84 +	*/
    1.85 +	IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID, CASN1EncBase* aASN1);
    1.86 +
    1.87 +	/** Create an attribute with a specified OID and one value. The value forms 
    1.88 +		part of a set. Additional values can be added by calling the AddValueL method.
    1.89 +		@param aAttrOID	The specified OID in the form a.b.c. etc.
    1.90 +		@param aASN1	ASN1 encoding object for attribute value
    1.91 +		 				-- this method takes ownership.
    1.92 +		@return New PKCS10 attribute object
    1.93 +	*/
    1.94 +	IMPORT_C static CPKCS10Attribute* NewL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
    1.95 +
    1.96 +	/** Add a value to the attribute.
    1.97 +		@param aASN1	ASN1 encoding object for attribute value
    1.98 +		 				-- this method takes ownership.
    1.99 +	*/
   1.100 +	IMPORT_C void AddValueL(CASN1EncBase* aASN1);
   1.101 +
   1.102 +	/** ResetL method to allow for re-use of the generic attribute object. 
   1.103 +		Additional values can be added by calling the AddValueL method.
   1.104 +		@param aAttrOID	The specified OID in the form a.b.c. etc.
   1.105 +		@param aASN1	ASN1 encoding object for attribute value
   1.106 +		 				-- this method takes ownership.
   1.107 +	*/
   1.108 +	IMPORT_C void ResetL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
   1.109 +
   1.110 +	virtual ~CPKCS10Attribute();
   1.111 +
   1.112 +	/** 
   1.113 +	 * @internalComponent
   1.114 +	 *
   1.115 +	 * Get the ASN1 encoding of the attribute and relinquish ownership of it,
   1.116 +		leaving it on the cleanup stack. This is called by CPKCS10Attribtues
   1.117 +		when AddAttribute() is called. This method may leave with E32USER-CBase:66 
   1.118 +		if a stack frame for the next PushL() cannot be allocated.
   1.119 +		NOTE: This method is deprecated. Use GetEncodingLC() instead.
   1.120 +		@deprecated
   1.121 +	*/
   1.122 +	CASN1EncBase* TakeEncodingC();
   1.123 +
   1.124 +	/** 
   1.125 +	 * @internalComponent
   1.126 +	 *
   1.127 +	 * Get the ASN1 encoding of the attribute and relinquish ownership of it,
   1.128 +		leaving it on the cleanup stack.  This is called by CPKCS10Attribtues
   1.129 +		when AddAttribute() is called. This method may leave with E32USER-CBase:66 
   1.130 +		if a stack frame for the next PushL() cannot be allocated.
   1.131 +		NOTE: This method is deprecated. Use GetEncodingLC() instead.
   1.132 +		@deprecated
   1.133 +	*/
   1.134 +	CASN1EncBase* TakeEncodingLC();
   1.135 +
   1.136 +	/** Calls the base class implementation for getting the ASN1 encoding of the attribute.
   1.137 +		Note that this method cannot be reused unless ResetL() has been called. 
   1.138 +		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
   1.139 +		@return ASN.1 encoding object
   1.140 +	*/
   1.141 +	virtual CASN1EncBase* GetEncodingLC();
   1.142 +
   1.143 +private:
   1.144 +	// Default constructor.
   1.145 +	CPKCS10Attribute();
   1.146 +
   1.147 +	// Second phase construction function.
   1.148 +	void ConstructL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
   1.149 +	};
   1.150 +
   1.151 +/** Class for encoding a collection of certificate attributes and passing them
   1.152 +	to the CPKCS10Request class. Some possible attributes are described in
   1.153 +	PKCS#9.
   1.154 +  
   1.155 +	@publishedPartner
   1.156 +	@released
   1.157 +*/
   1.158 +class CPKCS10Attributes : public CBase
   1.159 +	{
   1.160 +public:
   1.161 +	/** Creates an instance of the class.
   1.162 +		@return New attributes object on the cleanup stack.
   1.163 +	*/
   1.164 +	IMPORT_C static CPKCS10Attributes* NewLC();
   1.165 +
   1.166 +	/** Creates an instance of the class.
   1.167 +		@return New attributes object.
   1.168 +	*/
   1.169 +	IMPORT_C static CPKCS10Attributes* NewL();
   1.170 +
   1.171 +	/** Adds a new attribute for the certificate request.
   1.172 +		@param aAttr The attribute to add - this method takes ownership.
   1.173 +		@deprecated
   1.174 +	*/
   1.175 +	IMPORT_C void AddAttributeL(CPKCS10Attribute* aAttr);
   1.176 +
   1.177 +	/** Adds a new attribute for the certificate request.
   1.178 +		@param aAttr The attribute to add - this method takes ownership.
   1.179 +	*/
   1.180 +	IMPORT_C void AddPKCSAttributeL(CPKCSAttributeBase* aAttr);
   1.181 +
   1.182 +	IMPORT_C ~CPKCS10Attributes(); // virtual from base
   1.183 +
   1.184 +	/** 
   1.185 +	 * @internalComponent
   1.186 +	 *
   1.187 +	 * Get the ASN1 encoding of the attributes and relinquish ownership of it,
   1.188 +		leaving it on the cleanup stack. This is called by CPKCS10Request when
   1.189 +		SetAttributes() is called. This method may leave with E32USER-CBase:66 
   1.190 +		if a stack frame for the next PushL() cannot be allocated.
   1.191 +		@deprecated
   1.192 +	*/
   1.193 +	CASN1EncBase* TakeEncodingC();
   1.194 +
   1.195 +	/** 
   1.196 +	 * @internalComponent
   1.197 +	 *
   1.198 +	 * Get the ASN.1 encoding of the attribute and relinquish ownership of it,
   1.199 +		leaving it on the cleanup stack. This is called by CPKCS10Request when
   1.200 +		SetAttributes() is called. 
   1.201 +		@panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
   1.202 +		@return ASN.1 encoding object
   1.203 +	*/
   1.204 +	CASN1EncBase* TakeEncodingLC();
   1.205 +
   1.206 +private:
   1.207 +	/** Default constructor.
   1.208 +	*/
   1.209 +	CPKCS10Attributes();
   1.210 +
   1.211 +	/** Second phase construction function. 
   1.212 +		@note The structure of the attribute node is as follows:
   1.213 +		@code
   1.214 +		  SET
   1.215 +		    SEQUENCE
   1.216 +			  OID of attribute
   1.217 +			  SET values
   1.218 +			...
   1.219 +		@endcode
   1.220 +	*/
   1.221 +	void ConstructL();
   1.222 +	
   1.223 +private:
   1.224 +	/** Pointer to sequence of user-supplied certificate attributes. 
   1.225 +		#AddAttributeL method is used to create and fill this member. 
   1.226 +		If it is initialized by the time #CalculateEncodingL method 
   1.227 +		is called, the latter uses attributes from this member variable 
   1.228 +		for the request, otherwise no attributes are inserted into 
   1.229 +		the request. 
   1.230 +		
   1.231 +		See #AddAttributeL for the explanation of ASN.1 encoding of
   1.232 +		attributes.
   1.233 +	*/
   1.234 +	CASN1EncSequence* iRoot;
   1.235 +	};
   1.236 +
   1.237 +#endif // __PKCS10ATTR_H__