Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 1998-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 * X509 general name class
34 /** A general name type.
39 typedef TUint TGNType;
49 EX509DirectoryName = 4,
53 //specific name forms we support...
54 //we should probably put these in a file of their own,
55 //but they can stay here for now
59 class CX509DomainName : public CBase
60 /** An X.509 domain name.
62 * Base class for email address and DNS names.
71 * Frees all resources owned by the object, prior to its destruction. */
72 IMPORT_C ~CX509DomainName();
74 /** Tests whether every sub domain in the specified domain name is the same as
75 * the corresponding sub domain in this object, starting at the end.
77 * For example, 'john.doe@symbian.com' is within the subtree 'symbian.com' but
78 * is not within the subtree 'john' or 'symbian'.
80 * @param aName The domain name.
81 * @return ETrue, if every sub domain in the specified domain name is the same
82 as the corresponding sub domain in this object; EFalse, otherwise. */
83 IMPORT_C TBool IsWithinSubtree(const CX509DomainName& aName) const;
85 /** Gets the full domain name.
87 * @return A pointer descriptor representing the full domain name. */
88 IMPORT_C TPtrC Name() const;
90 /** Adds a domain by its subdomains to an array of pointer descriptors.
92 * @param aPos The position within the domain name.
93 * @return ETrue if the domain has been added; EFalse, otherwise.
96 TBool AddDomainL(TInt& aPos);
98 /** Adds a subdomain to an array of pointer descriptors.
100 * @param aPos The position within the domain name.
101 * @return ETrue if the subdomain has been added; EFalse, otherwise.
104 TBool AddSubdomainL(TInt& aPos);
106 /** Adds a subdomain separator after each subdomain entry in an array of pointer
107 * descriptors that represent the subdomains of the domain name.
109 * @param aPos The position within the domain name.
110 * @return ETrue if the subdomain separator has been added; EFalse, otherwise.
113 TBool AddSubdomainSeparatorL(TInt& aPos);
115 /** Validates a string.
117 * @param aStr The string to be verified.
118 * @return ETrue if the string is valid; EFalse, otherwise.*/
119 virtual TBool IsValidString(const TDesC& aStr) const;
121 /** Validates a character.
123 * @param aChar The character to be validated.
124 * @return ETrue if the character is valid; EFalse, otherwise. */
125 virtual TBool IsValidChar(const TChar& aChar) const;
127 /** Tests whether a character is a letter or a numeral.
129 * @param aChar The character to be tested.
130 * @return ETrue if the character is a letter or a numeral; EFalse, otherwise.
133 TBool IsAlphaOrNum(const TChar& aChar) const;
135 /** Tests whether the character is a letter.
137 * @param aChar The character to be tested.
138 * @return ETrue if the character is a letter; EFalse, otherwise.
141 TBool IsAlpha(const TChar& aChar) const;
143 /** Default constructor.
148 /** An array of pointer descriptors representing the subdomains of the DSN name. */
150 /** A heap descriptor representing the full domain name. */
154 //rfc822 email address has the form localpart@domain
156 class CX509RFC822NameSubtree : public CX509DomainName
157 /** A full or partial RFC 822 email address.
159 * The address may not contain the local host name as this is optional.
161 * The object is initialised with 8-bit encoded binary data, which is parsed
162 * into a series of sub domains and an optional local host.
168 /** Creates an RFC 822 email address object from the specified buffer containing
169 * the binary coded representation.
171 * The data is parsed into a series of sub domains and an optional local host.
173 * @param aBinaryData The encoded binary representation.
174 * @return The new RFC 822 email address object. */
175 IMPORT_C static CX509RFC822NameSubtree* NewL(const TDesC8& aBinaryData);
177 /** Creates an RFC 822 email address object from the specified buffer containing
178 * the binary coded representation, and puts a pointer to it onto the cleanup stack.
179 * The data is parsed into a series of sub domains and an optional local host.
181 * @param aBinaryData The encoded binary representation.
182 * @return The new RFC 822 email address object. */
183 IMPORT_C static CX509RFC822NameSubtree* NewLC(const TDesC8& aBinaryData);
185 /** Gets a reference to the array of pointer descriptors representing the subdomains
186 * of the RFC 822 email address.
188 * @return The array of pointer descriptors. */
189 IMPORT_C const RArray<TPtrC>& Rep() const;
192 /** Second-phase constructor.
194 * @param aBinaryData The encoded binary representation. */
195 virtual void ConstructL(const TDesC8& aBinaryData);
197 /** Adds a local host.
199 * @param aPos The position from which to start decoding.
200 * @return ETrue, if the host has been found and added; EFalse, otherwise.
203 TBool AddLocalHostL(TInt& aPos);
205 /** Tests whether the character is valid.
207 * @param aChar The character to be tested.
208 * @return ETrue, if the character is valid; EFalse, otherwise.
211 TBool IsValidChar(const TChar& aChar) const;
214 class CX509RFC822Name : public CX509RFC822NameSubtree
215 /** A full RFC 822 email address.
217 * Exactly as subtree, but requires local host and full domain name.
223 /** Creates a full RFC 822 email address object from the specified buffer containing
224 * the binary coded representation.
226 * The data is parsed into a series of sub domains.
228 * The data must represent a full RFC 822 email address, otherwise this function leaves.
230 * @param aBinaryData The encoded binary representation.
231 * @return The new full RFC 822 email address object. */
232 IMPORT_C static CX509RFC822Name* NewL(const TDesC8& aBinaryData);
234 /** Creates a full RFC 822 email address object from the specified buffer containing
235 * the binary coded representation, and puts a pointer to it onto the cleanup stack.
237 * The data is parsed into a series of sub domains.
239 * The data must represent a full RFC 822 email address, otherwise this function leaves.
241 * @param aBinaryData The encoded binary representation.
242 * @return The new full RFC 822 email address object. */
243 IMPORT_C static CX509RFC822Name* NewLC(const TDesC8& aBinaryData);
245 virtual void ConstructL(const TDesC8& aBinaryData);
248 class CX509DNSNameSubtree : public CX509DomainName
249 /** A Domain Name System (DNS) name subtree.
251 * Initialised with 8-bit encoded binary data, which is parsed into a series
254 * Because it is a subtree it may start with a period. For example, '.symbian.com',
255 * indicating that 'symbian.com' does not lie within the subtree.
261 /** Creates a DNS name object from the specified buffer containing the binary coded
264 * The data is parsed into a series of sub domains.
266 * @param aBinaryData The encoded binary representation.
267 * @return The new DNS name object. */
268 IMPORT_C static CX509DNSNameSubtree* NewL(const TDesC8& aBinaryData);
270 /** Creates a DNS name object from the specified buffer containing the binary coded
271 * representation, and puts a pointer to it onto the cleanup stack.
273 * The data is parsed into a series of sub domains.
275 * @param aBinaryData The encoded binary representation.
276 * @return The new DNS name object. */
277 IMPORT_C static CX509DNSNameSubtree* NewLC(const TDesC8& aBinaryData);
279 // IMPORT_C static CX509DNSNameSubtree* NewL(const CX509DNSNameSubtree& aName);
280 // IMPORT_C static CX509DNSNameSubtree* NewLC(const CX509DNSNameSubtree& aName);
282 /** Gets a reference to the array of pointer descriptors representing the subdomains
285 * @return The array of pointer descriptors. */
286 IMPORT_C const RArray<TPtrC>& Rep() const;
289 void ConstructL(const CX509DNSNameSubtree& aName);
290 void ConstructL(const TDesC8& aBinaryData);
291 TBool IsValidString(const TDesC& aStr) const;
294 class CX509DNSName : public CX509DNSNameSubtree
295 /** A Domain Name System (DNS) name.
297 * The name must begin with a valid sub domain and not a period.
303 /** Creates a DNS name object from the specified buffer containing the binary coded
306 * @param aBinaryData The encoded binary representation.
307 * @return The new DNS name object. */
308 IMPORT_C static CX509DNSName* NewL(const TDesC8& aBinaryData);
310 /** Creates a DNS name object from the specified buffer containing the binary coded
311 * representation, and puts a pointer to it onto the cleanup stack.
313 * @param aBinaryData The encoded binary representation.
314 * @return The new DSN name object. */
315 IMPORT_C static CX509DNSName* NewLC(const TDesC8& aBinaryData);
317 /** Creates a new DSN name object from an existing object.
319 * This is equivalent to a copy constructor.
321 * @param aName The DSN name object to be copied.
322 * @return The DSN name object. */
323 IMPORT_C static CX509DNSName* NewL(const CX509DNSName& aName);
325 /** Creates a new DSN name object from an existing object, and puts a pointer to
326 * it onto the clean up stack.
328 * This is equivalent to a copy constructor.
330 * @param aName The DNS name object to be copied.
331 * @return The new DSN name object. */
332 IMPORT_C static CX509DNSName* NewLC(const CX509DNSName& aName);
334 /** Constructs a new DSN name object from a name string.
336 * @param aNameString The name string.
337 * @return The new DSN name object. */
338 IMPORT_C static CX509DNSName* NewL(const TDesC& aNameString);
340 /** Creates a DSN name object from a name string, and puts a pointer to it onto
343 * @param aNameString The name string.
344 * @return The new DSN name object. */
345 IMPORT_C static CX509DNSName* NewLC(const TDesC& aNameString);
347 void ConstructL(const TDesC8& aBinaryData);
348 void ConstructL(const TDesC& aNameString);
349 void ConstructL(const CX509DNSName& aName);
353 class CX509IPBasedURI : public CBase
356 * The class extracts a DNS name, i.e. the host part of the URI.
358 * Note that it must be of 'ip-based' form (see RFC 1738 section 3.1) and contain
359 * a domain name (not an IP address).
365 /** Creates an IP based URI name object from the specified buffer containing the
366 * binary coded representation.
368 * @param aBinaryData The encoded binary representation.
369 * @return The new URI name object. */
370 IMPORT_C static CX509IPBasedURI* NewL(const TDesC8& aBinaryData);
372 /** Creates a URI name object from the specified buffer containing the binary coded
373 * representation, and puts a pointer to it onto the clean up stack.
375 * @param aBinaryData The encoded binary representation.
376 * @return The new URI name object. */
377 IMPORT_C static CX509IPBasedURI* NewLC(const TDesC8& aBinaryData);
381 * Frees all resources owned by the object, prior to its destruction. */
382 IMPORT_C ~CX509IPBasedURI();
384 /** Gets the host part.
386 * @return The host part. */
387 IMPORT_C const CX509DNSName& Host() const;
389 /** Gets the whole name.
391 * @return A pointer descriptor representing the whole name. */
392 IMPORT_C TPtrC Name() const;
394 /** Default constructor.
399 void ConstructL(const TDesC8& aBinaryData);
400 TPtrC ExtractHostNameL() const;
405 class CX509IPSubnetMask : public CBase
406 /** An IP subnet mask.
408 * Input data is parsed into an 8-bit base address and an 8-bit mask.
413 friend class CX509IPAddress;
415 /** Creates an IP subnet mask object from the specified buffer containing the binary
416 * coded representation.
418 * The data is parsed into an 8-bit base address and an 8-bit mask.
420 * @param aBinaryData The encoded binary representation.
421 * @return The new IP subnet mask object. */
422 IMPORT_C static CX509IPSubnetMask* NewL(const TDesC8& aBinaryData);
424 /** Creates an IP subnet mask object from the specified buffer containing the binary
425 * coded representation, and puts a pointer to it onto the cleanup stack.
427 * The data is parsed into an 8-bit base address and an 8-bit mask.
429 * @param aBinaryData The encoded binary representation.
430 * @return The new IP subnet mask object. */
431 IMPORT_C static CX509IPSubnetMask* NewLC(const TDesC8& aBinaryData);
435 * Frees all resources owned by the object, prior to its destruction. */
436 IMPORT_C ~CX509IPSubnetMask();
438 /** Gets the base IP address.
440 * @return A pointer descriptor representing the base IP address. */
441 IMPORT_C TPtrC8 BaseAddress() const;
443 /** Gets the subnet mask.
445 * @return A pointer descriptor representing the subnet mask. */
446 IMPORT_C TPtrC8 Mask() const;
453 void ConstructL(const TDesC8& aBinaryData);
457 class CX509IPAddress : public CBase
458 /** A single IP address.
464 /** Creates a single IP address object from the specified buffer containing the
465 * binary coded representation.
467 * @param aBinaryData The encoded binary representation.
468 * @return The new single IP addres. */
469 IMPORT_C static CX509IPAddress* NewL(const TDesC8& aBinaryData);
471 /** Creates a single IP address object from the specified buffer containing the
472 * binary coded representation, and puts a pointer to it onto the cleanup stack.
474 * @param aBinaryData The encoded binary representation.
475 * @return The new single IP addres object. */
476 IMPORT_C static CX509IPAddress* NewLC(const TDesC8& aBinaryData);
478 /** Tests whether the IP address lies within the specified subnet address.
480 * @param aName The subnet mask name.
481 * @return ETrue, if the IP address lies within the specified subnet address;
482 * EFalse, otherwise. */
483 IMPORT_C TBool IsWithinSubtree(const CX509IPSubnetMask& aName) const;
487 * Frees all resources owned by the object, prior to its destruction. */
488 IMPORT_C ~CX509IPAddress();
490 /** Gets the IP address.
492 * @return A pointer descriptor representing the single IP address. */
493 IMPORT_C TPtrC8 Address() const;
500 void ConstructL(const TDesC8& aBinaryData);
501 HBufC8* iName;//4 octets for v4, 16 for v6
506 class CX509GeneralName : public CBase
507 /** Defines a general name.
509 * The class contains a tag and a name whose form depends on the value of that tag.
511 * When a General Name is included as part of a Name Constraints Extension, the
512 * values need not be complete names but may be simply subtrees.
514 * For example, 'symbian.com' instead of john.doe@symbian.com'. Both names are
515 * valid subtrees but only the second is a valid RFC822 name.
521 /** Creates a new general name object from the specified buffer containing the
522 * binary coded representation.
524 * @param aBinaryData The encoded binary representation.
525 * @return The new general name object. */
526 IMPORT_C static CX509GeneralName* NewL(const TDesC8& aBinaryData);
528 /** Creates a new general name object from the specified buffer containing the
529 * binary coded representation, and puts a pointer to it onto the cleanup stack.
531 * Initialises the object from its encoded binary form into an internal representation.
533 * @param aBinaryData The encoded binary representation.
534 * @return The new general name object. */
535 IMPORT_C static CX509GeneralName* NewLC(const TDesC8& aBinaryData);
537 /** Creates a new general name object from the specified buffer containing the
538 * binary coded representation,starting at the specified offset.
540 * @param aBinaryData The encoded binary representation.
541 * @param aPos The offset position from which to start decoding.
542 * @return The new general name object. */
543 IMPORT_C static CX509GeneralName* NewL(const TDesC8& aBinaryData, TInt& aPos);
545 /** Creates a new general name object from the specified buffer containing the
546 * binary coded representation, starting at the specified offset, and puts a
547 * pointer to it onto the cleanup stack.
549 * Initialises the object from its encoded binary form into an internal representation.
551 * @param aBinaryData The encoded binary representation.
552 * @param aPos The offset position from which to start decoding.
553 * @return The new general name object. */
554 IMPORT_C static CX509GeneralName* NewLC(const TDesC8& aBinaryData, TInt& aPos);
556 /** Creates a new general name object from an existing object.
558 * This is equivalent to a copy constructor.
560 * @param aName The general name object to be copied.
561 * @return The new general name object. */
562 IMPORT_C static CX509GeneralName* NewL(const CX509GeneralName& aName);
564 /** Creates a new general name object from an existing object, and puts a pointer
565 * to it onto the cleanup stack.
567 * This is equivalent to a copy constructor.
569 * @param aName The general name object to be copied.
570 * @return The new general name object. */
571 IMPORT_C static CX509GeneralName* NewLC(const CX509GeneralName& aName);
573 /** Gets the type tag.
575 * @return The type tag. */
576 IMPORT_C TGNType Tag() const;
580 * @return A pointer descriptor representing the name. */
581 IMPORT_C TPtrC8 Data() const;
585 * Frees all resources owned by the object, prior to its destruction. */
586 IMPORT_C ~CX509GeneralName();
588 /** Dummy Function which always returns EFalse.
589 * @param aName The general name object to be copied.
592 IMPORT_C TBool ExactMatch(const CX509GeneralName& aName) const;
595 CX509GeneralName(TGNType aType);
597 void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
598 void ConstructL(const TDesC8& aData);