Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 1997-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.
20 #if !defined (__WTLSNAMES_H__)
21 #define __WTLSNAMES_H__
29 This file contains the definition for class CWTLSName.
33 enum { null(0), text(1), binary(2), key_hash_sha(254), x509_name(255)}
36 We only support text and x509_name as these are the only meaningful identifiers..
37 x509_name is X.500 Distinguished Name, and should use our existing X.500 DN implementation.
40 IdentifierType identifier_type;
41 select (identifier_type) {
44 CharacterSet character_set;
45 opaque name<1.. 2^8-1>;
46 case binary: opaque identifier<1..2^8-1>;
47 case key_hash_sha: opaque key_hash[20];
48 case x509_name: opaque distinguished_name<1..2^8-1>;
54 This maps on to one of the IANA defined character sets. There are rather a lot
55 of these. We just support the text type, with either Latin1 or UTF8 encoding.
59 * Enumerates the types of WTLS certificate name forms/identifiers.
61 * Only text strings and X.500 Distinguished Names are currently supported.
70 /* Text string (Latin-1 or Unicode).
72 * A text identifier consists of a 16-bit character set identifier;
73 * this represents the IANA-assigned character set number. */
77 * Certificates of this type will be rejected.*/
81 * Certificates of this type will be rejected.*/
82 EWTLSKeyHashSha = 0xfe,
83 /* X.500 Distinguished Name. */
91 typedef TUint8 TWTLSNameType;
97 typedef TInt TWTLSCharSet;
99 // MIBenum constants from the IANA list of character sets.
100 // See http://www.iana.org/assignments/character-sets for more info.
102 /** MIBenum constant for the Latin1 IANA character set */
103 const TInt KWTLSLatin1CharSet = 4;
105 /** MIBenum constant for the UTF-8 IANA character set */
106 const TInt KWTLSUTF8CharSet = 106;
108 class CWTLSName : public CBase
110 * Stores the type of a WTLS name and the underlying encoding of the type.
118 * Creates a new CWTLSName object from the specified buffer containing the binary coded representation.
120 * @param aBinaryData The encoded binary representation.
121 * @return The new CWTLSName object.
123 IMPORT_C static CWTLSName* NewL(const TDesC8& aBinaryData);
126 * Creates a new CWTLSName object from the specified buffer containing the binary coded representation,
127 * and puts a pointer to it onto the cleanup stack.
129 * @param aBinaryData The encoded binary representation.
130 * @return The new CWTLSName object.
132 IMPORT_C static CWTLSName* NewLC(const TDesC8& aBinaryData);
135 * Creates a new CWTLSName object from the specified buffer containing the binary coded representation,
136 * starting at the specified offset.
138 * @param aBinaryData The encoded binary representation.
139 * @param aPos The offset position from which to start decoding. It specifies an offset into the descriptor,
140 * and is updated to the position at the end of the object.
141 * @return The new CWTLSName object.
143 IMPORT_C static CWTLSName* NewL(const TDesC8& aBinaryData, TInt& aPos);
146 * Creates a new CWTLSName object from the specified buffer containing the binary coded representation,
147 * starting at the specified offset, and puts a pointer to it onto the cleanup stack.
149 * @param aBinaryData The encoded binary representation.
150 * @param aPos The offset position from which to start decoding. It specifies an offset into the descriptor,
151 * and is updated to the position at the end of the object.
152 * @return The new CWTLSName object.
154 IMPORT_C static CWTLSName* NewLC(const TDesC8& aBinaryData, TInt& aPos);
157 * Creates a new CWTLSName object from an existing one.
159 * @param aName An existing CWTLSName object.
160 * @return The new CWTLSName object.
162 IMPORT_C static CWTLSName* NewL(const CWTLSName& aName);
165 * Creates a new CWTLSName object from an existing one,
166 * and puts a pointer to it onto the cleanup stack.
168 * @param aName An existing CWTLSName object.
169 * @return The new CWTLSName object.
171 IMPORT_C static CWTLSName* NewLC(const CWTLSName& aName);
176 * Frees all resources owned by the object, prior to its destruction.
178 IMPORT_C ~CWTLSName();
181 * Performs a simple byte compare between this WTLS name and a specified WTLS name.
183 * Needed for the constructing/validating of certificate chains.
185 * @param aName An existing CWTLSName object.
186 * @return ETrue, if the WTLS names match; EFalse, otherwise.
188 IMPORT_C TBool ExactMatchL(const CWTLSName& aName) const;
191 * Gets the type of the WTLS name.
193 * @return Type of WTLS name form.
195 IMPORT_C TWTLSNameType NameType() const;
198 * Gets the encoding of the underlying type of WTLS name.
200 * @return Pointer descriptor representing the encoding of the WTLS name type.
202 IMPORT_C TPtrC8 NameData() const;
205 * Gets the decoded value for the common or organisation name.
207 * Provides the functionality required by the CCertificate::IssuerL() and SubjectL() functions.
209 * @return A heap descriptor containing the decoded value of the common or organisation name.
211 IMPORT_C HBufC* DisplayNameL() const;
214 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
215 void ConstructL(const CWTLSName& aName);
216 void AllocNameDataL(const TDesC8& aBinaryData, TInt& aPos);
217 void AllocTextDataL(const TDesC8& aBinaryData, TInt& aPos);
218 TWTLSNameType iNameType;
226 class CWTLSText : public CBase
230 * Creates a new CWTLSText object from the specified buffer containing the binary coded representation.
232 * @param aBinaryData The encoded binary representation.
233 * @return The new CWTLSText object.
235 IMPORT_C static CWTLSText* NewL(const TDesC8& aBinaryData);
238 * Creates a new CWTLSText object from the specified buffer containing the binary coded representation,
239 * and puts a pointer to it onto the cleanup stack.
241 * @param aBinaryData The encoded binary representation.
242 * @return The new CWTLSText object.
244 IMPORT_C static CWTLSText* NewLC(const TDesC8& aBinaryData);
247 * Creates a new CWTLSText object from the specified buffer containing the binary coded representation,
248 * starting at the specified offset.
250 * @param aBinaryData The encoded binary representation.
251 * @param aPos The offset position from which to start decoding. It specifies an offset into the descriptor,
252 * and is updated to the position at the end of the object.
253 * @return The new CWTLSText object.
255 IMPORT_C static CWTLSText* NewL(const TDesC8& aBinaryData, TInt& aPos);
258 * Creates a new CWTLSText object from the specified buffer containing the binary coded representation,
259 * starting at the specified offset, and puts a pointer to it onto the cleanup stack.
261 * @param aBinaryData The encoded binary representation.
262 * @param aPos The offset position from which to start decoding. It specifies an offset into the descriptor,
263 * and is updated to the position at the end of the object.
264 * @return The new CWTLSText object.
266 IMPORT_C static CWTLSText* NewLC(const TDesC8& aBinaryData, TInt& aPos);
271 * Frees all resources owned by the object, prior to its destruction.
273 IMPORT_C ~CWTLSText();
276 * Performs a simple byte compare between this CWTLSText object and a specified CWTLSText object.
278 * There is a subtle difference between this byte-match and CWTLSName::ExactMatchL().
279 * As opposed to the latter, this function should successfully match two names that
280 * are the same that were encoded using different character sets.
282 * @param aName An existing CWTLSText object.
283 * @return ETrue, if the CWTLSText objects match; EFalse, otherwise.
285 IMPORT_C TBool ExactMatchL(const CWTLSText& aName) const;
288 * Gets the name of the CWTLSText object.
290 * @return A pointer to the name of the CWTLSText object.
292 IMPORT_C TPtrC Name() const;
295 * Gets the character set of the CWTLSText object.
297 * @return The character set
299 IMPORT_C TWTLSCharSet CharacterSet() const;
308 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
314 //this class implements the 'structured' variant of the text type defined in the WTLS spec, section 10.5.2:
315 //<servicename>; <organization>; <country>[; <commonname>[; <extension>[; <extension>[ …. ]]]]
316 _LIT(KWTLSCountryName,"C");
317 _LIT(KWTLSOrganizationName,"O");
318 _LIT(KWTLSServiceName,"OU");
319 _LIT(KWTLSTitle,"T");
320 _LIT(KWTLSCommonName,"CN");
326 class TWTLSStructuredTextField
332 TWTLSStructuredTextField(const TDesC& aType, const TDesC& aValue);
338 IMPORT_C TPtrC Type() const;
344 IMPORT_C TPtrC Value() const;
355 class CWTLSStructuredText : public CWTLSText
359 * Creates a new CWTLSStructuredText object from the specified buffer containing the binary coded representation.
361 * @param aBinaryData The encoded binary representation.
362 * @return The new CWTLSStructuredText object.
364 IMPORT_C static CWTLSStructuredText* NewL(const TDesC8& aBinaryData);
367 * Creates a new CWTLSStructuredText object from the specified buffer containing the binary coded representation,
368 * and puts a pointer to it onto the cleanup stack.
370 * @param aBinaryData The encoded binary representation.
371 * @return The new CWTLSStructuredText object.
373 IMPORT_C static CWTLSStructuredText* NewLC(const TDesC8& aBinaryData);
376 * Creates a new CWTLSStructuredText object from the specified buffer containing the binary coded representation,
377 * starting at the specified offset.
379 * @param aBinaryData The encoded binary representation.
380 * @param aPos The offset position from which to start decoding. It specifies an offset into the descriptor,
381 * and is updated to the position at the end of the object.
382 * @return The new CWTLSStructuredText object.
384 IMPORT_C static CWTLSStructuredText* NewL(const TDesC8& aBinaryData, TInt& aPos);
387 * Creates a new CWTLSStructuredText object from the specified buffer containing the binary coded representation,
388 * starting at the specified offset, and puts a pointer to it onto the cleanup stack.
390 * @param aBinaryData The encoded binary representation.
391 * @param aPos The offset position from which to start decoding. It specifies an offset into the descriptor,
392 * and is updated to the position at the end of the object.
393 * @return The new CWTLSStructuredText object.
395 IMPORT_C static CWTLSStructuredText* NewLC(const TDesC8& aBinaryData, TInt& aPos);
400 * Frees all resources owned by the object, prior to its destruction.
402 IMPORT_C ~CWTLSStructuredText();
409 IMPORT_C HBufC* DisplayNameL() const;
411 //accessors for defined fields
418 IMPORT_C TPtrC ServiceName() const;
425 IMPORT_C TPtrC Organization() const;
432 IMPORT_C TPtrC Country() const;
439 IMPORT_C TInt Count() const;
448 * @return A pointer to a TWTLSStructuredTextField object; NULL if field not found.
449 * The returned object remains the property of the structured text object
450 * (so don't delete it).
452 IMPORT_C const TWTLSStructuredTextField* FieldByName(const TDesC& aType) const;
459 IMPORT_C const TWTLSStructuredTextField& FieldByIndex(TInt aIndex) const;
461 CWTLSStructuredText();
462 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
463 void AddFieldValueL(const TDesC& aFieldName, TInt& aPos);
464 void AddFieldL(TInt& aPos);
465 TPtrC GetFieldL(TDesC& aString, TInt& aPos);
466 TBool GetSubFieldL(TDesC& aString, TInt& aPos);
467 CArrayFixFlat<TWTLSStructuredTextField>* iFields;