epoc32/include/x500dn.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
* Implementation of the class that holds the Distinguished Name of a subject
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
/**
williamr@2
    21
 @file 
williamr@2
    22
 @publishedAll
williamr@2
    23
 @released
williamr@2
    24
*/
williamr@2
    25
#if !defined (__X500DN_H__)
williamr@2
    26
#define __X500DN_H__
williamr@2
    27
williamr@2
    28
#include <e32base.h>
williamr@2
    29
#include <e32std.h>
williamr@2
    30
#include <s32file.h>
williamr@2
    31
#include <x520ava.h>
williamr@2
    32
williamr@2
    33
class CX500DistinguishedName : public CBase
williamr@2
    34
/** Holds the Distinguished Name of a subject.
williamr@2
    35
*
williamr@2
    36
* A collection of 'attribute type and value' objects, as defined by the X.520 
williamr@2
    37
* standard.
williamr@2
    38
*
williamr@2
    39
* The name used in X.509 certificates is the X.500 Distinguished Name, which 
williamr@2
    40
* describes a path through an X.500 Directory Information Tree.
williamr@2
    41
*
williamr@2
    42
* A Distinguished Name is a series of name-value pairs that uniquely identify 
williamr@2
    43
* an entity, i.e. the certificate subject. 
williamr@2
    44
*
williamr@2
    45
* @publishedAll
williamr@2
    46
* @released
williamr@2
    47
*
williamr@2
    48
* <!-- 
williamr@2
    49
* This is necessary when working with certificates, certificate requests, directories, etc. 
williamr@2
    50
* -->
williamr@2
    51
*/
williamr@2
    52
	{
williamr@2
    53
public:
williamr@2
    54
	/** Creates a new Distinguished Name object from the specified buffer containing 
williamr@2
    55
	* the encoded binary representation, starting at the specified offset.
williamr@2
    56
	* 
williamr@2
    57
	* @param aBinaryData	The encoded binary representation.
williamr@2
    58
	* @param aPos			The position from which to start decoding.
williamr@2
    59
	* @return				The new Distinguished Name object. */
williamr@2
    60
	IMPORT_C static CX500DistinguishedName* NewL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
    61
	
williamr@2
    62
	/** Creates a new Distinguished Name object from the specified buffer containing 
williamr@2
    63
	* the encoded binary representation, starting at the specified offset, and puts 
williamr@2
    64
	* a pointer to it onto the cleanup stack.
williamr@2
    65
	* 
williamr@2
    66
	* @param aBinaryData	The encoded binary representation.
williamr@2
    67
	* @param aPos			The position from which to start decoding.
williamr@2
    68
	* @return				The new Distinguished Name object. */
williamr@2
    69
	IMPORT_C static CX500DistinguishedName* NewLC(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
    70
	
williamr@2
    71
	/** Creates a new Distinguished Name object from the specified buffer containing 
williamr@2
    72
	* the encoded binary representation.
williamr@2
    73
	* 
williamr@2
    74
	* Initialises the object from its encoded binary form into an internal representation.
williamr@2
    75
	* 
williamr@2
    76
	* @param aBinaryData	The encoded binary representation.
williamr@2
    77
	* @return				The new Distinguished Name object. */
williamr@2
    78
	IMPORT_C static CX500DistinguishedName* NewL(const TDesC8& aBinaryData);
williamr@2
    79
	
williamr@2
    80
	/** Creates a new Distinguished Name object from the specified buffer containing 
williamr@2
    81
	* the encoded binary representation, and puts a pointer to it onto the cleanup stack.
williamr@2
    82
	* 
williamr@2
    83
	* Initialises the object from its encoded binary form into an internal representation.
williamr@2
    84
	* 
williamr@2
    85
	* @param aBinaryData	The encoded binary representation.
williamr@2
    86
	* @return				The new Distinguished Name object. */
williamr@2
    87
	IMPORT_C static CX500DistinguishedName* NewLC(const TDesC8& aBinaryData);
williamr@2
    88
	
williamr@2
    89
	/** Creates a new Distinguished Name object from the specified read stream.
williamr@2
    90
	* 
williamr@2
    91
	* Construction is from a stream.
williamr@2
    92
	* 
williamr@2
    93
	* @param aStream	Stream from which the contents should be internalised.
williamr@2
    94
	* @return			The newDistinguished Name object. */
williamr@2
    95
	IMPORT_C static CX500DistinguishedName* NewL(RReadStream& aStream);
williamr@2
    96
	
williamr@2
    97
	/** Creates a new Distinguished Name object from the specified read stream, and 
williamr@2
    98
	* puts a pointer to it onto the cleanup stack.
williamr@2
    99
	* 
williamr@2
   100
	* @param aStream	Stream from which the contents should be internalised.
williamr@2
   101
	* @return			The new Distinguished Name object. */
williamr@2
   102
	IMPORT_C static CX500DistinguishedName* NewLC(RReadStream& aStream);	
williamr@2
   103
	
williamr@2
   104
	/** Creates a new Distinguished Name object from the specified array of 'attribute 
williamr@2
   105
	* type and value' objects.
williamr@2
   106
	* 
williamr@2
   107
	* The elements of the specified array are copied into this object.
williamr@2
   108
	* 
williamr@2
   109
	* @param aElements	The array of 'attribute type and value' objects to be copied.
williamr@2
   110
	* @return			The new Distinguished Name object. */
williamr@2
   111
	IMPORT_C static CX500DistinguishedName* NewL(const CArrayPtr<CX520AttributeTypeAndValue>& aElements);
williamr@2
   112
	
williamr@2
   113
	/** Creates a new Distinguished Name object from the specified array of 'attribute 
williamr@2
   114
	* type and value' objects, and puts a pointer to it onto the cleanup stack.
williamr@2
   115
	* 
williamr@2
   116
	* The elements of the specified array are copied into this object.
williamr@2
   117
	* 
williamr@2
   118
	* @param aElements	The array of 'attribute type and value' objects to be copied.
williamr@2
   119
	* @return			The new Distinguished Name object. */
williamr@2
   120
	IMPORT_C static CX500DistinguishedName* NewLC(const CArrayPtr<CX520AttributeTypeAndValue>& aElements);	
williamr@2
   121
	
williamr@2
   122
	/** Creates a new Distinguished Name object from an existing object.
williamr@2
   123
	* 
williamr@2
   124
	* This is equivalent to a copy constructor.
williamr@2
   125
	* 
williamr@2
   126
	* @param aName	The Distinguished Name object to be copied.
williamr@2
   127
	* @return		The new Distinguished Name object. */
williamr@2
   128
	IMPORT_C static CX500DistinguishedName* NewL(const CX500DistinguishedName& aName);
williamr@2
   129
	
williamr@2
   130
	/** Creates a new Distinguished Name object from an existing object, and puts a 
williamr@2
   131
	* pointer to it onto the cleanup stack.
williamr@2
   132
	* 
williamr@2
   133
	* This is equivalent to a copy constructor.
williamr@2
   134
	* 
williamr@2
   135
	* @param aName	The Distinguished Name object to be copied.
williamr@2
   136
	* @return		The new Distinguished Name object. */
williamr@2
   137
	IMPORT_C static CX500DistinguishedName* NewLC(const CX500DistinguishedName& aName);
williamr@2
   138
	
williamr@2
   139
	/** Externalises an object of this class to a write stream.
williamr@2
   140
	* 
williamr@2
   141
	* The presence of this function means that the standard templated operator<<() 
williamr@2
   142
	* can be used to externalise objects of this class.
williamr@2
   143
	* 
williamr@2
   144
	* @param aStream	Stream to which the object should be externalised. */
williamr@2
   145
	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
williamr@2
   146
	
williamr@2
   147
	/** Gets the number of 'attribute type and value' objects contained by this Distinguished 
williamr@2
   148
	* Name object.
williamr@2
   149
	* 
williamr@2
   150
	* @return	The number of 'attribute type and value' objects. */
williamr@2
   151
	IMPORT_C TInt Count() const;
williamr@2
   152
	
williamr@2
   153
	/** Gets a reference to specific 'attribute type and value' object as identified 
williamr@2
   154
	* by the specified index.
williamr@2
   155
	* 
williamr@2
   156
	* @param aIndex	The index number identifying the specific 'attribute type and 
williamr@2
   157
	* 				value' object. This number is relative to zero. This value must be non-negative 
williamr@2
   158
	* 				and less than the number of objects currently contained by this Distinguished 
williamr@2
   159
	* 				Name object.
williamr@2
   160
	* @return		The referenced 'attribute type and value' object. */
williamr@2
   161
	IMPORT_C const CX520AttributeTypeAndValue& Element(TInt aIndex) const;
williamr@2
   162
	
williamr@2
   163
	/** Destructor.
williamr@2
   164
	* 
williamr@2
   165
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
   166
	IMPORT_C ~CX500DistinguishedName(); 
williamr@2
   167
williamr@2
   168
	/** Compares the specified Distinguished Name object with this Distinguished Name 
williamr@2
   169
	* object.
williamr@2
   170
	* 
williamr@2
   171
	* @param aName	The Distinguished Name object to be compared.
williamr@2
   172
	* @return		ETrue, if the Distinguished Name objects contain exactly the same 'attribute 
williamr@2
   173
	* 				type and value' objects; EFalse, otherwise.
williamr@2
   174
	* @see CX520AttributeTypeAndValue::ExactMatchL() 
williamr@2
   175
	*
williamr@2
   176
	* <!--	This function checks if all the fields of aName and 
williamr@2
   177
	*		iElements are the same but not necessarily in the same order. -->
williamr@2
   178
	*/
williamr@2
   179
	IMPORT_C TBool ExactMatchL(const CX500DistinguishedName& aName) const;
williamr@2
   180
williamr@2
   181
	/** <!--
williamr@2
   182
	 // This function checks if the elements of iElements are a superset of
williamr@2
   183
	 // the fields in aName.
williamr@2
   184
	 // @param aName We want to check that the fields in aName are present in iElements.
williamr@2
   185
	 // @return 
williamr@2
   186
	 // <UL>
williamr@2
   187
	 // <LI>ETrue if all the fields in aName have a corresponding field in iElements.</LI>
williamr@2
   188
	 // <LI>EFalse otherwise</LI>
williamr@2
   189
	 // </UL>
williamr@2
   190
	 -->
williamr@2
   191
	* Tests whether all 'attribute type and value' objects contained in the specified 
williamr@2
   192
	* Distinguished Name object are also contained within this Distinguished Name object.
williamr@2
   193
	* 
williamr@2
   194
	* This function checks if the elements of iElements are a superset of the fields in aName.
williamr@2
   195
	* 
williamr@2
   196
	* @param aName	The Distinguished Name object to be compared.
williamr@2
   197
	* @return		ETrue, if all 'attribute type and value' objects contained in the specified 
williamr@2
   198
	* 				Distinguished Name object are also contained within this Distinguished Name 
williamr@2
   199
	* 				object; EFalse, otherwise. */
williamr@2
   200
	IMPORT_C TBool IsWithinSubtreeL(const CX500DistinguishedName& aName) const;
williamr@2
   201
williamr@2
   202
	/** <!--
williamr@2
   203
	 // This function compares each of the elements in iElements with aElement. The comparison
williamr@2
   204
	 // is made by the CX520AttributeTypeAndValue::ExactMatchL function.
williamr@2
   205
	 // @param aElement The element which we want to compare the elements of iElements with.
williamr@2
   206
	 // @return 
williamr@2
   207
	 // <UL>
williamr@2
   208
	 // <LI>ETrue if one of the elements in iElements is equal to aElement.</LI>
williamr@2
   209
	 // <LI>EFalse otherwise</LI>
williamr@2
   210
	 // </UL>
williamr@2
   211
	 -->
williamr@2
   212
	* Tests whether this Distinguished Name object contains the specified 'attribute 
williamr@2
   213
	* type and value' object.
williamr@2
   214
	* 
williamr@2
   215
	* This function compares each of the elements in iElements with aElement. The comparison
williamr@2
   216
	* is made by the CX520AttributeTypeAndValue::ExactMatchL() function.
williamr@2
   217
	* 
williamr@2
   218
	* @param aElement	The 'attribute type and value' object to be checked.
williamr@2
   219
	* @return			ETrue, if the specified 'attribute type and value' object is contained 
williamr@2
   220
	* 					in this Distinguished Name object; EFalse otherwise. */
williamr@2
   221
	IMPORT_C TBool MatchElementL(const CX520AttributeTypeAndValue& aElement) const;
williamr@2
   222
	
williamr@2
   223
	/** Gets the decoded value associated with the specified field/attribute name, 
williamr@2
   224
	* from the Distinguished Name.
williamr@2
   225
	* 
williamr@2
   226
	* @param aFieldName	The field name.
williamr@2
   227
	* @return			A heap descriptor containing the decoded value associated with the 
williamr@2
   228
	* 					specified field name. */
williamr@2
   229
	IMPORT_C HBufC* ExtractFieldL(const TDesC& aFieldName) const;
williamr@2
   230
	
williamr@2
   231
	/** Gets the decoded value for the common or organisation name.
williamr@2
   232
	* 
williamr@2
   233
	* @return A heap descriptor containing the decoded value of the common or organisation name. */
williamr@2
   234
	IMPORT_C HBufC* DisplayNameL() const;
williamr@2
   235
williamr@2
   236
	/** Encodes a DN into an ASN.1 object tree.
williamr@2
   237
	* 
williamr@2
   238
	* Note that the tree has the following format:
williamr@2
   239
	* @code
williamr@2
   240
    *         SEQUENCE-OF
williamr@2
   241
    *             SET-OF
williamr@2
   242
    *                 SEQUENCE-OF
williamr@2
   243
    *                     OID
williamr@2
   244
    *                     value (usually OCTET STRING)
williamr@2
   245
    *             ...
williamr@2
   246
    * @endcode
williamr@2
   247
	* 
williamr@2
   248
	* A SEQUENCE-OF object with a changed tag is used instead of 
williamr@2
   249
	* a SET-OF object. This should be all right as long as it 
williamr@2
   250
	* contains only one child, because otherwise child order in 
williamr@2
   251
	* a SET-OF becomes important.
williamr@2
   252
	* 
williamr@2
   253
	* This function does not introduce an additional dependency 
williamr@2
   254
	* on ASN1 library because X500 library already depends on 
williamr@2
   255
	* it -- the attribute type/value class stores and manipulated 
williamr@2
   256
	* ASN.1 encodings as its values.
williamr@2
   257
	* 	
williamr@2
   258
	* @return	ASN.1 sequence object containing the DN, 
williamr@2
   259
	* 			pushed on the cleanup stack.
williamr@2
   260
	*/
williamr@2
   261
	IMPORT_C CASN1EncSequence* EncodeASN1LC() const;
williamr@2
   262
williamr@2
   263
	/** Encodes a DN into an ASN.1 object tree. 
williamr@2
   264
	* 
williamr@2
   265
	* See note in the description of #EncodeASN1LC for the explanation of 
williamr@2
   266
	* the resulting encoding tree format.
williamr@2
   267
	* 	
williamr@2
   268
	* @return	ASN.1 sequence object containing the DN. */
williamr@2
   269
	IMPORT_C CASN1EncSequence* EncodeASN1L() const;
williamr@2
   270
williamr@2
   271
private:
williamr@2
   272
	CX500DistinguishedName();
williamr@2
   273
	void ConstructL(const CArrayPtr<CX520AttributeTypeAndValue>& aElements);
williamr@2
   274
	void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   275
	void ConstructL(RReadStream& aStream);
williamr@2
   276
	void InternalizeL(RReadStream& aStream);
williamr@2
   277
	CArrayPtrFlat<CX520AttributeTypeAndValue>* iElements;
williamr@2
   278
	};
williamr@2
   279
williamr@2
   280
#endif