First public contribution.
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * PKCS#10 Certificate Request Attributes class.
26 #if !defined (__PKCS10ATTR_H__)
27 #define __PKCS10ATTR_H__
30 class CASN1EncSequence;
34 // Class capturing common functionality of a PKCS attribute.
36 class CPKCSAttributeBase : public CBase
40 /** Get the ASN.1 encoding of the attribute and relinquish ownership of it,
41 leaving it on the cleanup stack. This is called by CPKCS10Attribtues
42 when AddAttribute() is called.
43 @panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
44 @return ASN.1 encoding object
46 virtual CASN1EncBase* GetEncodingLC() = 0;
48 virtual ~CPKCSAttributeBase();
51 /** @internalComponent */
53 CASN1EncSequence* iRoot;
54 CASN1EncSet* iValueSet;
57 /** Class representing a generic certificate attribute. Attributes have an
58 object identifier and one or more values.
60 class CPKCS10Attribute : public CPKCSAttributeBase
64 /** Create an attribute with a specified OID and no values, leaving it on
66 NOTE: This method is deprecated. Use the other forms of NewLC instead.
67 @param aAttrOID The specified OID in the form a.b.c. etc.
68 @return New PKCS10 attribute object on the cleanup stack
71 IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID);
73 /** Create an attribute with a specified OID and one value, leaving it on
74 the cleanup stack. The value forms part of a set. Additional values can
75 be added by calling the AddValueL method.
76 @param aAttrOID The specified OID in the form a.b.c. etc.
77 @param aASN1 ASN1 encoding object for attribute value
78 -- this method takes ownership.
79 @return New PKCS10 attribute object on the cleanup stack
81 IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID, CASN1EncBase* aASN1);
83 /** Create an attribute with a specified OID and one value. The value forms
84 part of a set. Additional values can be added by calling the AddValueL method.
85 @param aAttrOID The specified OID in the form a.b.c. etc.
86 @param aASN1 ASN1 encoding object for attribute value
87 -- this method takes ownership.
88 @return New PKCS10 attribute object
90 IMPORT_C static CPKCS10Attribute* NewL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
92 /** Add a value to the attribute.
93 @param aASN1 ASN1 encoding object for attribute value
94 -- this method takes ownership.
96 IMPORT_C void AddValueL(CASN1EncBase* aASN1);
98 /** ResetL method to allow for re-use of the generic attribute object.
99 Additional values can be added by calling the AddValueL method.
100 @param aAttrOID The specified OID in the form a.b.c. etc.
101 @param aASN1 ASN1 encoding object for attribute value
102 -- this method takes ownership.
104 IMPORT_C void ResetL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
106 virtual ~CPKCS10Attribute();
111 * Get the ASN1 encoding of the attribute and relinquish ownership of it,
112 leaving it on the cleanup stack. This is called by CPKCS10Attribtues
113 when AddAttribute() is called. This method may leave with E32USER-CBase:66
114 if a stack frame for the next PushL() cannot be allocated.
115 NOTE: This method is deprecated. Use GetEncodingLC() instead.
118 CASN1EncBase* TakeEncodingC();
123 * Get the ASN1 encoding of the attribute and relinquish ownership of it,
124 leaving it on the cleanup stack. This is called by CPKCS10Attribtues
125 when AddAttribute() is called. This method may leave with E32USER-CBase:66
126 if a stack frame for the next PushL() cannot be allocated.
127 NOTE: This method is deprecated. Use GetEncodingLC() instead.
130 CASN1EncBase* TakeEncodingLC();
132 /** Calls the base class implementation for getting the ASN1 encoding of the attribute.
133 Note that this method cannot be reused unless ResetL() has been called.
134 @panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
135 @return ASN.1 encoding object
137 virtual CASN1EncBase* GetEncodingLC();
140 // Default constructor.
143 // Second phase construction function.
144 void ConstructL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
147 /** Class for encoding a collection of certificate attributes and passing them
148 to the CPKCS10Request class. Some possible attributes are described in
154 class CPKCS10Attributes : public CBase
157 /** Creates an instance of the class.
158 @return New attributes object on the cleanup stack.
160 IMPORT_C static CPKCS10Attributes* NewLC();
162 /** Creates an instance of the class.
163 @return New attributes object.
165 IMPORT_C static CPKCS10Attributes* NewL();
167 /** Adds a new attribute for the certificate request.
168 @param aAttr The attribute to add - this method takes ownership.
171 IMPORT_C void AddAttributeL(CPKCS10Attribute* aAttr);
173 /** Adds a new attribute for the certificate request.
174 @param aAttr The attribute to add - this method takes ownership.
176 IMPORT_C void AddPKCSAttributeL(CPKCSAttributeBase* aAttr);
178 IMPORT_C ~CPKCS10Attributes(); // virtual from base
183 * Get the ASN1 encoding of the attributes and relinquish ownership of it,
184 leaving it on the cleanup stack. This is called by CPKCS10Request when
185 SetAttributes() is called. This method may leave with E32USER-CBase:66
186 if a stack frame for the next PushL() cannot be allocated.
189 CASN1EncBase* TakeEncodingC();
194 * Get the ASN.1 encoding of the attribute and relinquish ownership of it,
195 leaving it on the cleanup stack. This is called by CPKCS10Request when
196 SetAttributes() is called.
197 @panic E32USER-CBase 66 if a stack frame for the next PushL() cannot be allocated.
198 @return ASN.1 encoding object
200 CASN1EncBase* TakeEncodingLC();
203 /** Default constructor.
207 /** Second phase construction function.
208 @note The structure of the attribute node is as follows:
220 /** Pointer to sequence of user-supplied certificate attributes.
221 #AddAttributeL method is used to create and fill this member.
222 If it is initialized by the time #CalculateEncodingL method
223 is called, the latter uses attributes from this member variable
224 for the request, otherwise no attributes are inserted into
227 See #AddAttributeL for the explanation of ASN.1 encoding of
230 CASN1EncSequence* iRoot;
233 #endif // __PKCS10ATTR_H__