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