epoc32/include/x509gn.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
* X509 general name class
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
williamr@2
    26
#ifndef __X509GN_H__
williamr@2
    27
#define __X509GN_H__
williamr@2
    28
williamr@2
    29
#include <e32std.h>
williamr@2
    30
#include <badesca.h>
williamr@2
    31
williamr@2
    32
/** A general name type.
williamr@2
    33
 * 
williamr@2
    34
 * @publishedAll
williamr@2
    35
 * @released
williamr@2
    36
 */
williamr@2
    37
typedef TUint TGNType;
williamr@2
    38
williamr@2
    39
/**
williamr@2
    40
 * @publishedAll
williamr@2
    41
 * @released
williamr@2
    42
 */
williamr@2
    43
enum 
williamr@2
    44
	{
williamr@2
    45
	EX509RFC822Name = 1,
williamr@2
    46
	EX509DNSName = 2,
williamr@2
    47
	EX509DirectoryName = 4,
williamr@2
    48
	EX509URI = 6,
williamr@2
    49
	EX509IPAddress = 7
williamr@2
    50
	};
williamr@2
    51
//specific name forms we support...
williamr@2
    52
//we should probably put these in a file of their own,
williamr@2
    53
//but they can stay here for now
williamr@2
    54
williamr@2
    55
//superclass
williamr@2
    56
williamr@2
    57
class CX509DomainName : public CBase
williamr@2
    58
/** An X.509 domain name.
williamr@2
    59
* 
williamr@2
    60
* Base class for email address and DNS names. 
williamr@2
    61
* 
williamr@2
    62
* @publishedAll
williamr@2
    63
* @released
williamr@2
    64
* @since v6.0 */
williamr@2
    65
	{
williamr@2
    66
public:
williamr@2
    67
	/** Destructor.
williamr@2
    68
	* 
williamr@2
    69
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
    70
	IMPORT_C ~CX509DomainName();
williamr@2
    71
	
williamr@2
    72
	/** Tests whether every sub domain in the specified domain name is the same as 
williamr@2
    73
	* the corresponding sub domain in this object, starting at the end.
williamr@2
    74
	* 
williamr@2
    75
	* For example, 'john.doe@symbian.com' is within the subtree 'symbian.com' but 
williamr@2
    76
	* is not within the subtree 'john' or 'symbian'.
williamr@2
    77
	* 
williamr@2
    78
	* @param aName	The domain name.
williamr@2
    79
	* @return		ETrue, if every sub domain in the specified domain name is the same 
williamr@2
    80
					as the corresponding sub domain in this object; EFalse, otherwise. */
williamr@2
    81
	IMPORT_C TBool IsWithinSubtree(const CX509DomainName& aName) const;
williamr@2
    82
	
williamr@2
    83
	/** Gets the full domain name.
williamr@2
    84
	* 
williamr@2
    85
	* @return	A pointer descriptor representing the full domain name. */
williamr@2
    86
	IMPORT_C TPtrC Name() const;
williamr@2
    87
protected:
williamr@2
    88
	/** Adds a domain by its subdomains to an array of pointer descriptors.
williamr@2
    89
	* 
williamr@2
    90
	* @param aPos	The position within the domain name.
williamr@2
    91
	* @return		ETrue if the domain has been added; EFalse, otherwise. 
williamr@2
    92
	* @internalAll
williamr@2
    93
	*/
williamr@2
    94
	TBool AddDomainL(TInt& aPos);
williamr@2
    95
	
williamr@2
    96
	/** Adds a subdomain to an array of pointer descriptors.
williamr@2
    97
	* 
williamr@2
    98
	* @param aPos	The position within the domain name.
williamr@2
    99
	* @return		ETrue if the subdomain has been added; EFalse, otherwise. 
williamr@2
   100
	* @internalAll
williamr@2
   101
	*/
williamr@2
   102
	TBool AddSubdomainL(TInt& aPos);
williamr@2
   103
	
williamr@2
   104
	/** Adds a subdomain separator after each subdomain entry in an array of pointer 
williamr@2
   105
	* descriptors that represent the subdomains of the domain name.
williamr@2
   106
	* 
williamr@2
   107
	* @param aPos	The position within the domain name.
williamr@2
   108
	* @return		ETrue if the subdomain separator has been added; EFalse, otherwise. 
williamr@2
   109
	* @internalAll
williamr@2
   110
	*/
williamr@2
   111
	TBool AddSubdomainSeparatorL(TInt& aPos);
williamr@2
   112
	
williamr@2
   113
	/** Validates a string.
williamr@2
   114
	* 
williamr@2
   115
	* @param aStr	The string to be verified.
williamr@2
   116
	* @return		ETrue if the string is valid; EFalse, otherwise.*/
williamr@2
   117
	virtual TBool IsValidString(const TDesC& aStr) const;
williamr@2
   118
	
williamr@2
   119
	/** Validates a character.
williamr@2
   120
	* 
williamr@2
   121
	* @param aChar	The character to be validated.
williamr@2
   122
	* @return		ETrue if the character is valid; EFalse, otherwise. */
williamr@2
   123
	virtual TBool IsValidChar(const TChar& aChar) const;
williamr@2
   124
	
williamr@2
   125
	/** Tests whether a character is a letter or a numeral.
williamr@2
   126
	* 
williamr@2
   127
	* @param aChar	The character to be tested.
williamr@2
   128
	* @return		ETrue if the character is a letter or a numeral; EFalse, otherwise. 
williamr@2
   129
	* @internalAll
williamr@2
   130
	*/
williamr@2
   131
	TBool IsAlphaOrNum(const TChar& aChar) const;
williamr@2
   132
	
williamr@2
   133
	/** Tests whether the character is a letter.
williamr@2
   134
	* 
williamr@2
   135
	* @param aChar	The character to be tested.
williamr@2
   136
	* @return		ETrue if the character is a letter; EFalse, otherwise. 
williamr@2
   137
	* @internalAll
williamr@2
   138
	*/
williamr@2
   139
	TBool IsAlpha(const TChar& aChar) const;
williamr@2
   140
	
williamr@2
   141
	/** Default constructor. 
williamr@2
   142
	 * @internalAll
williamr@2
   143
	 */
williamr@2
   144
	CX509DomainName();
williamr@2
   145
protected:
williamr@2
   146
	/** An array of pointer descriptors representing the subdomains of the DSN name. */
williamr@2
   147
	RArray<TPtrC> iRep;
williamr@2
   148
	/** A heap descriptor representing the full domain name. */
williamr@2
   149
	HBufC* iName;
williamr@2
   150
	};
williamr@2
   151
williamr@2
   152
//rfc822 email address has the form localpart@domain
williamr@2
   153
williamr@2
   154
class CX509RFC822NameSubtree : public CX509DomainName
williamr@2
   155
/** A full or partial RFC 822 email address.
williamr@2
   156
* 
williamr@2
   157
* The address may not contain the local host name as this is optional.
williamr@2
   158
* 
williamr@2
   159
* The object is initialised with 8-bit encoded binary data, which is parsed 
williamr@2
   160
* into a series of sub domains and an optional local host. 
williamr@2
   161
*
williamr@2
   162
* @publishedAll
williamr@2
   163
* @released */
williamr@2
   164
	{
williamr@2
   165
public:
williamr@2
   166
	/** Creates an RFC 822 email address object from the specified buffer containing 
williamr@2
   167
	* the binary coded representation.
williamr@2
   168
	* 
williamr@2
   169
	* The data is parsed into a series of sub domains and an optional local host.
williamr@2
   170
	* 
williamr@2
   171
	* @param aBinaryData	The encoded binary representation.
williamr@2
   172
	* @return				The new RFC 822 email address object. */
williamr@2
   173
	IMPORT_C static CX509RFC822NameSubtree* NewL(const TDesC8& aBinaryData);
williamr@2
   174
	
williamr@2
   175
	/** Creates an RFC 822 email address object from the specified buffer containing 
williamr@2
   176
	* the binary coded representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   177
	* The data is parsed into a series of sub domains and an optional local host.
williamr@2
   178
	* 
williamr@2
   179
	* @param aBinaryData	The encoded binary representation.
williamr@2
   180
	* @return				The new RFC 822 email address object. */
williamr@2
   181
	IMPORT_C static CX509RFC822NameSubtree* NewLC(const TDesC8& aBinaryData);
williamr@2
   182
	
williamr@2
   183
	/** Gets a reference to the array of pointer descriptors representing the subdomains 
williamr@2
   184
	* of the RFC 822 email address.
williamr@2
   185
	* 
williamr@2
   186
	* @return	The array of pointer descriptors. */
williamr@2
   187
	IMPORT_C const RArray<TPtrC>& Rep() const;
williamr@2
   188
williamr@2
   189
protected:
williamr@2
   190
	/** Second-phase constructor.
williamr@2
   191
	* 
williamr@2
   192
	* @param aBinaryData	The encoded binary representation. */
williamr@2
   193
	virtual void ConstructL(const TDesC8& aBinaryData);
williamr@2
   194
	
williamr@2
   195
	/** Adds a local host.
williamr@2
   196
	* 
williamr@2
   197
	* @param aPos	The position from which to start decoding.
williamr@2
   198
	* @return		ETrue, if the host has been found and added; EFalse, otherwise. 
williamr@2
   199
	* @internalAll
williamr@2
   200
	*/
williamr@2
   201
	TBool AddLocalHostL(TInt& aPos);
williamr@2
   202
	
williamr@2
   203
	/** Tests whether the character is valid.
williamr@2
   204
	* 
williamr@2
   205
	* @param aChar	The character to be tested.
williamr@2
   206
	* @return		ETrue, if the character is valid; EFalse, otherwise. 
williamr@2
   207
	* @internalAll
williamr@2
   208
	*/
williamr@2
   209
	TBool IsValidChar(const TChar& aChar) const;
williamr@2
   210
	};
williamr@2
   211
williamr@2
   212
class CX509RFC822Name : public CX509RFC822NameSubtree
williamr@2
   213
/** A full RFC 822 email address.
williamr@2
   214
* 
williamr@2
   215
* Exactly as subtree, but requires local host and full domain name. 
williamr@2
   216
*
williamr@2
   217
* @publishedAll
williamr@2
   218
* @released */
williamr@2
   219
	{
williamr@2
   220
public:
williamr@2
   221
	/** Creates a full RFC 822 email address object from the specified buffer containing 
williamr@2
   222
	* the binary coded representation.
williamr@2
   223
	* 
williamr@2
   224
	* The data is parsed into a series of sub domains.
williamr@2
   225
	* 
williamr@2
   226
	* The data must represent a full RFC 822 email address, otherwise this function leaves.
williamr@2
   227
	* 
williamr@2
   228
	* @param aBinaryData	The encoded binary representation.
williamr@2
   229
	* @return				The new full RFC 822 email address object. */
williamr@2
   230
	IMPORT_C static CX509RFC822Name* NewL(const TDesC8& aBinaryData);
williamr@2
   231
	
williamr@2
   232
	/** Creates a full RFC 822 email address object from the specified buffer containing 
williamr@2
   233
	* the binary coded representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   234
	* 
williamr@2
   235
	* The data is parsed into a series of sub domains.
williamr@2
   236
	* 
williamr@2
   237
	* The data must represent a full RFC 822 email address, otherwise this function leaves.
williamr@2
   238
	* 
williamr@2
   239
	* @param aBinaryData	The encoded binary representation.
williamr@2
   240
	* @return				The new full RFC 822 email address object. */
williamr@2
   241
	IMPORT_C static CX509RFC822Name* NewLC(const TDesC8& aBinaryData);
williamr@2
   242
private:
williamr@2
   243
	virtual void ConstructL(const TDesC8& aBinaryData);
williamr@2
   244
	};
williamr@2
   245
williamr@2
   246
class CX509DNSNameSubtree : public CX509DomainName
williamr@2
   247
/** A Domain Name System (DNS) name subtree.
williamr@2
   248
* 
williamr@2
   249
* Initialised with 8-bit encoded binary data, which is parsed into a series 
williamr@2
   250
* of sub domains.
williamr@2
   251
* 
williamr@2
   252
* Because it is a subtree it may start with a period. For example, '.symbian.com', 
williamr@2
   253
* indicating that 'symbian.com' does not lie within the subtree. 
williamr@2
   254
*
williamr@2
   255
* @publishedAll
williamr@2
   256
* @released */
williamr@2
   257
	{
williamr@2
   258
public:
williamr@2
   259
	/** Creates a DNS name object from the specified buffer containing the binary coded 
williamr@2
   260
	* representation.
williamr@2
   261
	* 
williamr@2
   262
	* The data is parsed into a series of sub domains.
williamr@2
   263
	* 
williamr@2
   264
	* @param aBinaryData	The encoded binary representation.
williamr@2
   265
	* @return				The new DNS name object. */
williamr@2
   266
	IMPORT_C static CX509DNSNameSubtree* NewL(const TDesC8& aBinaryData);
williamr@2
   267
	
williamr@2
   268
	/** Creates a DNS name object from the specified buffer containing the binary coded 
williamr@2
   269
	* representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   270
	* 
williamr@2
   271
	* The data is parsed into a series of sub domains.
williamr@2
   272
	* 
williamr@2
   273
	* @param aBinaryData	The encoded binary representation.
williamr@2
   274
	* @return				The new DNS name object. */
williamr@2
   275
	IMPORT_C static CX509DNSNameSubtree* NewLC(const TDesC8& aBinaryData);
williamr@2
   276
williamr@2
   277
//	IMPORT_C static CX509DNSNameSubtree* NewL(const CX509DNSNameSubtree& aName);
williamr@2
   278
//	IMPORT_C static CX509DNSNameSubtree* NewLC(const CX509DNSNameSubtree& aName);
williamr@2
   279
	
williamr@2
   280
	/** Gets a reference to the array of pointer descriptors representing the subdomains 
williamr@2
   281
	* of the DSN name.
williamr@2
   282
	* 
williamr@2
   283
	* @return	The array of pointer descriptors. */
williamr@2
   284
	IMPORT_C const RArray<TPtrC>& Rep() const;
williamr@2
   285
	
williamr@2
   286
private:
williamr@2
   287
	void ConstructL(const CX509DNSNameSubtree& aName);
williamr@2
   288
	void ConstructL(const TDesC8& aBinaryData);
williamr@2
   289
	TBool IsValidString(const TDesC& aStr) const;
williamr@2
   290
	};
williamr@2
   291
williamr@2
   292
class CX509DNSName : public CX509DNSNameSubtree
williamr@2
   293
/** A Domain Name System (DNS) name.
williamr@2
   294
* 
williamr@2
   295
* The name must begin with a valid sub domain and not a period. 
williamr@2
   296
*
williamr@2
   297
* @publishedAll
williamr@2
   298
* @released */
williamr@2
   299
	{
williamr@2
   300
public:
williamr@2
   301
	/** Creates a DNS name object from the specified buffer containing the binary coded 
williamr@2
   302
	* representation.
williamr@2
   303
	* 
williamr@2
   304
	* @param aBinaryData	The encoded binary representation.
williamr@2
   305
	* @return				The new DNS name object. */
williamr@2
   306
	IMPORT_C static CX509DNSName* NewL(const TDesC8& aBinaryData);
williamr@2
   307
	
williamr@2
   308
	/** Creates a DNS name object from the specified buffer containing the binary coded 
williamr@2
   309
	* representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   310
	* 
williamr@2
   311
	* @param aBinaryData	The encoded binary representation.
williamr@2
   312
	* @return				The new DSN name object. */
williamr@2
   313
	IMPORT_C static CX509DNSName* NewLC(const TDesC8& aBinaryData);
williamr@2
   314
	
williamr@2
   315
	/** Creates a new DSN name object from an existing object.
williamr@2
   316
	* 
williamr@2
   317
	* This is equivalent to a copy constructor.
williamr@2
   318
	* 
williamr@2
   319
	* @param aName	The DSN name object to be copied.
williamr@2
   320
	* @return		The DSN name object. */
williamr@2
   321
	IMPORT_C static CX509DNSName* NewL(const CX509DNSName& aName);
williamr@2
   322
	
williamr@2
   323
	/** Creates a new DSN name object from an existing object, and puts a pointer to 
williamr@2
   324
	* it onto the clean up stack.
williamr@2
   325
	* 
williamr@2
   326
	* This is equivalent to a copy constructor.
williamr@2
   327
	* 
williamr@2
   328
	* @param aName	The DNS name object to be copied.
williamr@2
   329
	* @return		The new DSN name object. */
williamr@2
   330
	IMPORT_C static CX509DNSName* NewLC(const CX509DNSName& aName);
williamr@2
   331
	
williamr@2
   332
	/** Constructs a new DSN name object from a name string.
williamr@2
   333
	* 
williamr@2
   334
	* @param aNameString	The name string.
williamr@2
   335
	* @return				The new DSN name object. */
williamr@2
   336
	IMPORT_C static CX509DNSName* NewL(const TDesC& aNameString);
williamr@2
   337
	
williamr@2
   338
	/** Creates a DSN name object from a name string, and puts a pointer to it onto 
williamr@2
   339
	* the cleanup stack.
williamr@2
   340
	* 
williamr@2
   341
	* @param aNameString	The name string.
williamr@2
   342
	* @return				The new DSN name object. */
williamr@2
   343
	IMPORT_C static CX509DNSName* NewLC(const TDesC& aNameString);
williamr@2
   344
private:
williamr@2
   345
	void ConstructL(const TDesC8& aBinaryData);
williamr@2
   346
	void ConstructL(const TDesC& aNameString);
williamr@2
   347
	void ConstructL(const CX509DNSName& aName);
williamr@2
   348
	void ParseNameL();
williamr@2
   349
	};
williamr@2
   350
williamr@2
   351
class CX509IPBasedURI : public CBase
williamr@2
   352
/** A URI.
williamr@2
   353
* 
williamr@2
   354
* The class extracts a DNS name, i.e. the host part of the URI.
williamr@2
   355
* 
williamr@2
   356
* Note that it must be of 'ip-based' form (see RFC 1738 section 3.1) and contain 
williamr@2
   357
* a domain name (not an IP address). 
williamr@2
   358
*
williamr@2
   359
* @publishedAll
williamr@2
   360
* @released */
williamr@2
   361
	{
williamr@2
   362
public:
williamr@2
   363
	/** Creates an IP based URI name object from the specified buffer containing the 
williamr@2
   364
	* binary coded representation.
williamr@2
   365
	* 
williamr@2
   366
	* @param aBinaryData	The encoded binary representation.
williamr@2
   367
	* @return				The new URI name object. */
williamr@2
   368
	IMPORT_C static CX509IPBasedURI* NewL(const TDesC8& aBinaryData);
williamr@2
   369
	
williamr@2
   370
	/** Creates a URI name object from the specified buffer containing the binary coded 
williamr@2
   371
	* representation, and puts a pointer to it onto the clean up stack.
williamr@2
   372
	* 
williamr@2
   373
	* @param aBinaryData	The encoded binary representation.
williamr@2
   374
	* @return				The new URI name object. */
williamr@2
   375
	IMPORT_C static CX509IPBasedURI* NewLC(const TDesC8& aBinaryData);
williamr@2
   376
	
williamr@2
   377
	/** Destructor.
williamr@2
   378
	* 
williamr@2
   379
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
   380
	IMPORT_C ~CX509IPBasedURI();
williamr@2
   381
	
williamr@2
   382
	/** Gets the host part.
williamr@2
   383
	* 
williamr@2
   384
	* @return	The host part. */
williamr@2
   385
	IMPORT_C const CX509DNSName& Host() const;
williamr@2
   386
	
williamr@2
   387
	/** Gets the whole name.
williamr@2
   388
	* 
williamr@2
   389
	* @return	A pointer descriptor representing the whole name. */
williamr@2
   390
	IMPORT_C TPtrC Name() const;
williamr@2
   391
	
williamr@2
   392
	/** Default constructor.
williamr@2
   393
	 * @internalAll
williamr@2
   394
	 */
williamr@2
   395
	CX509IPBasedURI();
williamr@2
   396
private:
williamr@2
   397
	void ConstructL(const TDesC8& aBinaryData);
williamr@2
   398
	TPtrC ExtractHostNameL() const;
williamr@2
   399
	CX509DNSName* iHost;
williamr@2
   400
	HBufC* iName;
williamr@2
   401
	};
williamr@2
   402
williamr@2
   403
class CX509IPSubnetMask : public CBase
williamr@2
   404
/** An IP subnet mask.
williamr@2
   405
* 
williamr@2
   406
* Input data is parsed into an 8-bit base address and an 8-bit mask. 
williamr@2
   407
*
williamr@2
   408
* @publishedAll
williamr@2
   409
* @released */
williamr@2
   410
	{
williamr@2
   411
	friend class CX509IPAddress;
williamr@2
   412
public:
williamr@2
   413
	/** Creates an IP subnet mask object from the specified buffer containing the binary 
williamr@2
   414
	* coded representation.
williamr@2
   415
	* 
williamr@2
   416
	* The data is parsed into an 8-bit base address and an 8-bit mask.
williamr@2
   417
	* 
williamr@2
   418
	* @param aBinaryData	The encoded binary representation.
williamr@2
   419
	* @return				The new IP subnet mask object. */
williamr@2
   420
	IMPORT_C static CX509IPSubnetMask* NewL(const TDesC8& aBinaryData);
williamr@2
   421
	
williamr@2
   422
	/** Creates an IP subnet mask object from the specified buffer containing the binary 
williamr@2
   423
	* coded representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   424
	* 
williamr@2
   425
	* The data is parsed into an 8-bit base address and an 8-bit mask.
williamr@2
   426
	* 
williamr@2
   427
	* @param aBinaryData	The encoded binary representation.
williamr@2
   428
	* @return				The new IP subnet mask object. */
williamr@2
   429
	IMPORT_C static CX509IPSubnetMask* NewLC(const TDesC8& aBinaryData);
williamr@2
   430
	
williamr@2
   431
	/** Destructor.
williamr@2
   432
	* 
williamr@2
   433
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
   434
	IMPORT_C ~CX509IPSubnetMask();
williamr@2
   435
	
williamr@2
   436
	/** Gets the base IP address.
williamr@2
   437
	* 
williamr@2
   438
	* @return	A pointer descriptor representing the base IP address. */
williamr@2
   439
	IMPORT_C TPtrC8 BaseAddress() const;
williamr@2
   440
	
williamr@2
   441
	/** Gets the subnet mask.
williamr@2
   442
	* 
williamr@2
   443
	* @return	A pointer descriptor representing the subnet mask. */
williamr@2
   444
	IMPORT_C TPtrC8 Mask() const;
williamr@2
   445
	
williamr@2
   446
	/** Constructor. 
williamr@2
   447
	 * @internalAll
williamr@2
   448
	 */
williamr@2
   449
	CX509IPSubnetMask();
williamr@2
   450
private:
williamr@2
   451
	void ConstructL(const TDesC8& aBinaryData);
williamr@2
   452
	HBufC8* iName;
williamr@2
   453
	};
williamr@2
   454
williamr@2
   455
class CX509IPAddress : public CBase
williamr@2
   456
/** A single IP address. 
williamr@2
   457
*
williamr@2
   458
* @publishedAll
williamr@2
   459
* @released */
williamr@2
   460
	{
williamr@2
   461
public:
williamr@2
   462
	/** Creates a single IP address object from the specified buffer containing the 
williamr@2
   463
	* binary coded representation.
williamr@2
   464
	* 
williamr@2
   465
	* @param aBinaryData	The encoded binary representation.
williamr@2
   466
	* @return				The new single IP addres. */
williamr@2
   467
	IMPORT_C static CX509IPAddress* NewL(const TDesC8& aBinaryData);
williamr@2
   468
	
williamr@2
   469
	/** Creates a single IP address object from the specified buffer containing the 
williamr@2
   470
	* binary coded representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   471
	* 
williamr@2
   472
	* @param aBinaryData	The encoded binary representation.
williamr@2
   473
	* @return				The new single IP addres object. */
williamr@2
   474
	IMPORT_C static CX509IPAddress* NewLC(const TDesC8& aBinaryData);
williamr@2
   475
	
williamr@2
   476
	/** Tests whether the IP address lies within the specified subnet address.
williamr@2
   477
	* 
williamr@2
   478
	* @param aName	The subnet mask name.
williamr@2
   479
	* @return		ETrue, if the IP address lies within the specified subnet address; 
williamr@2
   480
	* EFalse, otherwise. */
williamr@2
   481
	IMPORT_C TBool IsWithinSubtree(const CX509IPSubnetMask& aName) const;
williamr@2
   482
	
williamr@2
   483
	/** Destructor.
williamr@2
   484
	* 
williamr@2
   485
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
   486
	IMPORT_C ~CX509IPAddress();
williamr@2
   487
	
williamr@2
   488
	/** Gets the IP address.
williamr@2
   489
	* 
williamr@2
   490
	* @return	A pointer descriptor representing the single IP address. */
williamr@2
   491
	IMPORT_C TPtrC8 Address() const;
williamr@2
   492
	
williamr@2
   493
	/** Constructor. 
williamr@2
   494
	 * @internalAll
williamr@2
   495
	 */
williamr@2
   496
	CX509IPAddress();
williamr@2
   497
private:
williamr@2
   498
	void ConstructL(const TDesC8& aBinaryData);
williamr@2
   499
	HBufC8* iName;//4 octets for v4, 16 for v6
williamr@2
   500
	};
williamr@2
   501
williamr@2
   502
//general name...
williamr@2
   503
williamr@2
   504
class CX509GeneralName : public CBase
williamr@2
   505
/** Defines a general name.
williamr@2
   506
* 
williamr@2
   507
* The class contains a tag and a name whose form depends on the value of that tag.
williamr@2
   508
* 
williamr@2
   509
* When a General Name is included as part of a Name Constraints Extension, the 
williamr@2
   510
* values need not be complete names but may be simply subtrees.
williamr@2
   511
* 
williamr@2
   512
* For example, 'symbian.com' instead of john.doe@symbian.com'. Both names are 
williamr@2
   513
* valid subtrees but only the second is a valid RFC822 name. 
williamr@2
   514
*
williamr@2
   515
* @publishedAll
williamr@2
   516
* @released */
williamr@2
   517
	{
williamr@2
   518
public:
williamr@2
   519
	/** Creates a new general name object from the specified buffer containing the 
williamr@2
   520
	* binary coded representation.	
williamr@2
   521
	* 
williamr@2
   522
	* @param aBinaryData	The encoded binary representation.
williamr@2
   523
	* @return				The new general name object. */
williamr@2
   524
	IMPORT_C static CX509GeneralName* NewL(const TDesC8& aBinaryData);
williamr@2
   525
	
williamr@2
   526
	/** Creates a new general name object from the specified buffer containing the 
williamr@2
   527
	* binary coded representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   528
	* 
williamr@2
   529
	* Initialises the object from its encoded binary form into an internal representation.
williamr@2
   530
	* 
williamr@2
   531
	* @param aBinaryData	The encoded binary representation.
williamr@2
   532
	* @return				The new general name object. */
williamr@2
   533
	IMPORT_C static CX509GeneralName* NewLC(const TDesC8& aBinaryData);
williamr@2
   534
	
williamr@2
   535
	/** Creates a new general name object from the specified buffer containing the 
williamr@2
   536
	* binary coded representation,starting at the specified offset.
williamr@2
   537
	* 
williamr@2
   538
	* @param aBinaryData	The encoded binary representation.
williamr@2
   539
	* @param aPos			The offset position from which to start decoding.
williamr@2
   540
	* @return				The new general name object. */
williamr@2
   541
	IMPORT_C static CX509GeneralName* NewL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   542
	
williamr@2
   543
	/** Creates a new general name object from the specified buffer containing the 
williamr@2
   544
	* binary coded representation, starting at the specified offset, and puts a 
williamr@2
   545
	* pointer to it onto the cleanup stack.
williamr@2
   546
	* 
williamr@2
   547
	* Initialises the object from its encoded binary form into an internal representation.
williamr@2
   548
	* 
williamr@2
   549
	* @param aBinaryData	The encoded binary representation.
williamr@2
   550
	* @param aPos			The offset position from which to start decoding.
williamr@2
   551
	* @return				The new general name object. */
williamr@2
   552
	IMPORT_C static CX509GeneralName* NewLC(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   553
williamr@2
   554
	/** Creates a new general name object from an existing object.
williamr@2
   555
	* 
williamr@2
   556
	* This is equivalent to a copy constructor.
williamr@2
   557
	* 
williamr@2
   558
	* @param aName			The general name object to be copied.
williamr@2
   559
	* @return				The new general name object. */
williamr@2
   560
	IMPORT_C static CX509GeneralName* NewL(const CX509GeneralName& aName);
williamr@2
   561
	
williamr@2
   562
	/** Creates a new general name object from an existing object, and puts a pointer 
williamr@2
   563
	* to it onto the cleanup stack.
williamr@2
   564
	* 
williamr@2
   565
	* This is equivalent to a copy constructor.
williamr@2
   566
	* 
williamr@2
   567
	* @param aName			The general name object to be copied.
williamr@2
   568
	* @return				The new general name object. */
williamr@2
   569
	IMPORT_C static CX509GeneralName* NewLC(const CX509GeneralName& aName);
williamr@2
   570
williamr@2
   571
	/** Gets the type tag.
williamr@2
   572
	* 
williamr@2
   573
	* @return	The type tag. */
williamr@2
   574
	IMPORT_C TGNType Tag() const;
williamr@2
   575
	
williamr@2
   576
	/** Gets the name.
williamr@2
   577
	* 
williamr@2
   578
	* @return	A pointer descriptor representing the name. */
williamr@2
   579
	IMPORT_C TPtrC8 Data() const;
williamr@2
   580
	
williamr@2
   581
	/** Destructor.
williamr@2
   582
	* 
williamr@2
   583
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
   584
	IMPORT_C ~CX509GeneralName(); 
williamr@2
   585
	
williamr@2
   586
	/** Dummy Function which always returns EFalse.
williamr@2
   587
	* @param aName	The general name object to be copied.
williamr@2
   588
	* @return		EFalse.
williamr@2
   589
	*/
williamr@2
   590
	IMPORT_C TBool ExactMatch(const CX509GeneralName& aName) const;
williamr@2
   591
private:
williamr@2
   592
	CX509GeneralName();
williamr@2
   593
	CX509GeneralName(TGNType aType);
williamr@2
   594
	void ConstructL();
williamr@2
   595
	void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   596
	void ConstructL(const TDesC8& aData);
williamr@2
   597
	TGNType iTag;
williamr@2
   598
	HBufC8* iData;
williamr@2
   599
	};
williamr@2
   600
williamr@2
   601
#endif