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.
28 #if !defined (__PKCS10ATTR_H__)
29 #define __PKCS10ATTR_H__
32 class CASN1EncSequence;
35 // Class capturing common functionality of a PKCS attribute.
37 class CPKCSAttributeBase : public CBase
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
47 virtual CASN1EncBase* GetEncodingLC() = 0;
49 virtual ~CPKCSAttributeBase();
52 /** @internalComponent */
54 CASN1EncSequence* iRoot;
55 CASN1EncSet* iValueSet;
58 /** Class representing a generic certificate attribute. Attributes have an
59 object identifier and one or more values.
61 class CPKCS10Attribute : public CPKCSAttributeBase
65 /** Create an attribute with a specified OID and no values, leaving it on
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
72 IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID);
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
82 IMPORT_C static CPKCS10Attribute* NewLC(const TDesC& aAttrOID, CASN1EncBase* aASN1);
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
91 IMPORT_C static CPKCS10Attribute* NewL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
93 /** Add a value to the attribute.
94 @param aASN1 ASN1 encoding object for attribute value
95 -- this method takes ownership.
97 IMPORT_C void AddValueL(CASN1EncBase* aASN1);
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.
105 IMPORT_C void ResetL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
107 virtual ~CPKCS10Attribute();
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.
119 CASN1EncBase* TakeEncodingC();
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.
131 CASN1EncBase* TakeEncodingLC();
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
138 virtual CASN1EncBase* GetEncodingLC();
141 // Default constructor.
144 // Second phase construction function.
145 void ConstructL(const TDesC& aAttrOID, CASN1EncBase* aASN1);
148 /** Class for encoding a collection of certificate attributes and passing them
149 to the CPKCS10Request class. Some possible attributes are described in
155 class CPKCS10Attributes : public CBase
158 /** Creates an instance of the class.
159 @return New attributes object on the cleanup stack.
161 IMPORT_C static CPKCS10Attributes* NewLC();
163 /** Creates an instance of the class.
164 @return New attributes object.
166 IMPORT_C static CPKCS10Attributes* NewL();
168 /** Adds a new attribute for the certificate request.
169 @param aAttr The attribute to add - this method takes ownership.
172 IMPORT_C void AddAttributeL(CPKCS10Attribute* aAttr);
174 /** Adds a new attribute for the certificate request.
175 @param aAttr The attribute to add - this method takes ownership.
177 IMPORT_C void AddPKCSAttributeL(CPKCSAttributeBase* aAttr);
179 IMPORT_C ~CPKCS10Attributes(); // virtual from base
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.
190 CASN1EncBase* TakeEncodingC();
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
201 CASN1EncBase* TakeEncodingLC();
204 /** Default constructor.
208 /** Second phase construction function.
209 @note The structure of the attribute node is as follows:
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
228 See #AddAttributeL for the explanation of ASN.1 encoding of
231 CASN1EncSequence* iRoot;
234 #endif // __PKCS10ATTR_H__