epoc32/include/cctcertinfo.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2001-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
* CCTCertInfo.H
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
/**
williamr@2
    23
 @file 
williamr@2
    24
 @internalTechnology
williamr@2
    25
*/
williamr@2
    26
 
williamr@2
    27
#ifndef __CCTCERTINFO_H__
williamr@2
    28
#define __CCTCERTINFO_H__
williamr@2
    29
williamr@2
    30
#include <e32base.h>
williamr@2
    31
#include <s32strm.h>
williamr@2
    32
williamr@2
    33
#include <securitydefs.h>
williamr@2
    34
#include <ct/mcttokentype.h>
williamr@2
    35
#include <ct/mcttoken.h>
williamr@2
    36
#include <ct/mcttokenobject.h>
williamr@2
    37
williamr@2
    38
/** Mask constants used for serializing iDeletable and iFormat attributes 
williamr@2
    39
*/
williamr@2
    40
const TUint KReadOnlyFlagMask = 128;
williamr@2
    41
const TUint KFormatMask = 127;
williamr@2
    42
williamr@2
    43
/** The UID of a CertInfo MCTTokenObject. */
williamr@2
    44
const TInt KCTObjectCertInfo = 0x101F50E6;
williamr@2
    45
williamr@2
    46
/** The maximum length of a certificate label. */
williamr@2
    47
const TUint32 KMaxCertLabelLength = 64;
williamr@2
    48
williamr@2
    49
/** Defines a modifiable buffer descriptor to contain a human-readable certificate label. 
williamr@2
    50
*
williamr@2
    51
* @publishedAll
williamr@2
    52
* @released */
williamr@2
    53
typedef TBuf<KMaxCertLabelLength> TCertLabel;
williamr@2
    54
williamr@2
    55
/**
williamr@2
    56
 * Mix-in class representnig data about a stored certificate.  Provides
williamr@2
    57
 * implementation of serialization.
williamr@2
    58
 * 
williamr@2
    59
 * Note that for backward compatibility reasons, the issuer hash is not serialised.
williamr@2
    60
 *
williamr@2
    61
 * @internalTechnology
williamr@2
    62
 */
williamr@2
    63
class MCertInfo
williamr@2
    64
	{
williamr@2
    65
 public:
williamr@2
    66
	// Internalization/Externalization
williamr@2
    67
	// Externalize. Writes the data out to a stream
williamr@2
    68
	
williamr@2
    69
  /** Externalises an object of this class to a write stream.
williamr@2
    70
	* 
williamr@2
    71
	* The presence of this function means that the standard templated operator<<() 
williamr@2
    72
	* can be used to externalise objects of this class.
williamr@2
    73
	* 
williamr@2
    74
	* @param aStream	Stream to which the object should be externalised. */
williamr@2
    75
	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
williamr@2
    76
williamr@2
    77
	// Internalize. Reads the data from a stream 
williamr@2
    78
	/** Internalises an object of this class from a read stream.
williamr@2
    79
	* 
williamr@2
    80
	* The presence of this function means that the standard templated operator>>() 
williamr@2
    81
	* can be used to internalise objects of this class.
williamr@2
    82
	* 
williamr@2
    83
	* Note that this function has assignment semantics: it replaces the old value 
williamr@2
    84
	* of the object with a new value read from the read stream.	
williamr@2
    85
	* 
williamr@2
    86
	* @param aStream	Stream from which the object should be internalised. */
williamr@2
    87
	IMPORT_C void InternalizeL(RReadStream& aStream);
williamr@2
    88
	
williamr@2
    89
 protected:
williamr@2
    90
	IMPORT_C MCertInfo();
williamr@2
    91
	IMPORT_C MCertInfo(const TDesC& aLabel,
williamr@2
    92
					   TCertificateFormat aFormat,
williamr@2
    93
					   TCertificateOwnerType aCertificateOwnerType, 
williamr@2
    94
					   TInt aSize,
williamr@2
    95
					   const TKeyIdentifier* aSubjectKeyId,
williamr@2
    96
					   const TKeyIdentifier* aIssuerKeyId, 
williamr@2
    97
					   TInt aCertificateId,
williamr@2
    98
					   TBool aDeletable);
williamr@2
    99
	IMPORT_C MCertInfo(const MCertInfo& aOther);
williamr@2
   100
	IMPORT_C ~MCertInfo();
williamr@2
   101
williamr@2
   102
	IMPORT_C void ConstructL(const TDesC8* aIssuerHash);
williamr@2
   103
williamr@2
   104
	const TDesC8* IssuerHash() const;
williamr@2
   105
williamr@2
   106
 private:
williamr@2
   107
	TBool Valid() const;
williamr@2
   108
	const MCertInfo& operator=(const MCertInfo& aOther);
williamr@2
   109
williamr@2
   110
 protected:
williamr@2
   111
	TCertLabel iLabel;
williamr@2
   112
	TInt iCertificateId;
williamr@2
   113
	TCertificateFormat iFormat;
williamr@2
   114
	TCertificateOwnerType iCertificateOwnerType;
williamr@2
   115
	TInt iSize;
williamr@2
   116
	TKeyIdentifier iSubjectKeyId;
williamr@2
   117
	TKeyIdentifier iIssuerKeyId;
williamr@2
   118
	TBool iDeletable;
williamr@2
   119
williamr@2
   120
 private:
williamr@2
   121
	HBufC8* iIssuerHash;
williamr@2
   122
	};
williamr@2
   123
williamr@2
   124
/** Encapsulates information about a stored certificate.
williamr@2
   125
 * 
williamr@2
   126
 * Objects of this type are usually returned by a certificate store, to allow 
williamr@2
   127
 * a client to query the contents of the store.
williamr@2
   128
 * 
williamr@2
   129
 * Note that these objects are normally constructed by certificate stores, not 
williamr@2
   130
 * by clients. 
williamr@2
   131
 *
williamr@2
   132
 * @publishedAll
williamr@2
   133
 * @released
williamr@2
   134
 */
williamr@2
   135
class CCTCertInfo : protected CBase, public MCTTokenObject, public MCertInfo
williamr@2
   136
	{
williamr@2
   137
public:
williamr@2
   138
	/** Construction -- Note that these objects are normally constructed by certificate stores, not by clients. */
williamr@2
   139
williamr@2
   140
	/** 
williamr@2
   141
	* @publishedPartner
williamr@2
   142
	* @released
williamr@2
   143
	*
williamr@2
   144
	* Creates the certificate information object by copying from an existing object.
williamr@2
   145
	* 
williamr@2
   146
	* @param aCertInfo			The source certificate information.
williamr@2
   147
	* @return					A pointer to the new certificate information object.
williamr@2
   148
	* @leave KErrNoMemory	There is no memory to construct it. */
williamr@2
   149
	IMPORT_C static CCTCertInfo* NewL(const CCTCertInfo& aCertInfo);
williamr@2
   150
williamr@2
   151
	/** 
williamr@2
   152
	* @publishedPartner
williamr@2
   153
	* @released
williamr@2
   154
	*
williamr@2
   155
	* Creates the certificate information object by copying from an existing object, 
williamr@2
   156
	* and puts a pointer to the new object onto the cleanup stack.
williamr@2
   157
	* 
williamr@2
   158
	* @param aCertInfo			The source certificate information.
williamr@2
   159
	* @return					A pointer to the new certificate information object.
williamr@2
   160
	* @leave KErrNoMemory	There is no memory to construct it. */
williamr@2
   161
	IMPORT_C static CCTCertInfo* NewLC(const CCTCertInfo& aCertInfo);
williamr@2
   162
williamr@2
   163
	/** 
williamr@2
   164
	* @publishedPartner
williamr@2
   165
	* @released
williamr@2
   166
	*
williamr@2
   167
	* Creates the certificate information object from its constituent parts.
williamr@2
   168
	* 
williamr@2
   169
	* @param aLabel					The certificate's label.
williamr@2
   170
	* @param aFormat				The certificate's format.
williamr@2
   171
	* @param aCertificateOwnerType	The owner type.
williamr@2
   172
	* @param aSize					The size of the certificate.
williamr@2
   173
	* @param aSubjectKeyId			The subject key ID.
williamr@2
   174
	* @param aIssuerKeyId			The issuer key ID.
williamr@2
   175
	* @param aToken					The token that the certificate is within.
williamr@2
   176
	* @param aCertificateId			The ID within the object handle.
williamr@2
   177
	* @param aDeletable				The certificate is deletable.
williamr@2
   178
	* @param aIssuerHash			The hash of the DN of the issuer.
williamr@2
   179
	* @return						A pointer to the new certificate information object. 
williamr@2
   180
	* @leave KErrNoMemory		There is no memory to construct it.*/
williamr@2
   181
	IMPORT_C static CCTCertInfo* NewL(const TDesC& aLabel, TCertificateFormat aFormat,
williamr@2
   182
		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
williamr@2
   183
		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
williamr@2
   184
		MCTToken& aToken, TInt aCertificateId, TBool aDeletable, 
williamr@2
   185
									  const TDesC8* aIssuerHash = NULL);
williamr@2
   186
williamr@2
   187
	/** 
williamr@2
   188
	* @publishedPartner
williamr@2
   189
	* @released
williamr@2
   190
	*
williamr@2
   191
	* Creates the certificate information object from its constituent parts.	
williamr@2
   192
	* 
williamr@2
   193
	* @param aLabel					The certificate's label.
williamr@2
   194
	* @param aFormat 				The certificate's format.
williamr@2
   195
	* @param aCertificateOwnerType	The owner type.
williamr@2
   196
	* @param aSize					The size of the certificate.
williamr@2
   197
	* @param aSubjectKeyId			The subject key ID.
williamr@2
   198
	* @param aIssuerKeyId			The issuer key ID.
williamr@2
   199
	* @param aToken					The token that the certificate is within.
williamr@2
   200
	* @param aCertificateId			The ID within the object handle.
williamr@2
   201
	* @return 						A pointer to the new certificate information object.
williamr@2
   202
	* @leave KErrNoMemory		There is no memory to construct it.*/
williamr@2
   203
	IMPORT_C static CCTCertInfo* NewL(const TDesC& aLabel, TCertificateFormat aFormat,
williamr@2
   204
		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
williamr@2
   205
		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
williamr@2
   206
		MCTToken& aToken, TInt aCertificateId);
williamr@2
   207
williamr@2
   208
	/** 
williamr@2
   209
	* @publishedPartner
williamr@2
   210
	* @released
williamr@2
   211
	* 
williamr@2
   212
	* Creates the certificate information object from its constituent parts, 
williamr@2
   213
	* and puts a pointer to the new object onto the cleanup stack.
williamr@2
   214
	* 
williamr@2
   215
	* @param aLabel					The certificate's label.
williamr@2
   216
	* @param aFormat				The certificate's format.
williamr@2
   217
	* @param aCertificateOwnerType	The owner type.
williamr@2
   218
	* @param aSize					The size of the certificate.
williamr@2
   219
	* @param aSubjectKeyId			The subject key ID.
williamr@2
   220
	* @param aIssuerKeyId			The issuer key ID.
williamr@2
   221
	* @param aToken					The token that the certificate is within.
williamr@2
   222
	* @param aCertificateId			The ID within the object handle.
williamr@2
   223
	* @param aDeletable				The certificate is deletable.
williamr@2
   224
	* @param aIssuerHash			The hash of the issuer's DN.
williamr@2
   225
	* @return						A pointer to the new certificate information object. 
williamr@2
   226
	* @leave KErrNoMemory		There is no memory to construct it.*/
williamr@2
   227
	IMPORT_C static CCTCertInfo* NewLC(const TDesC& aLabel, TCertificateFormat aFormat,
williamr@2
   228
		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
williamr@2
   229
		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
williamr@2
   230
		MCTToken& aToken, TInt aCertificateId, TBool aDeletable, 
williamr@2
   231
									   const TDesC8* aIssuerHash = NULL);
williamr@2
   232
williamr@2
   233
	/**
williamr@2
   234
	* @publishedPartner
williamr@2
   235
	* @released
williamr@2
   236
	*
williamr@2
   237
	* Creates the certificate information object from its constituent parts, and puts 
williamr@2
   238
	* a pointer to the new object onto the cleanup stack.
williamr@2
   239
	* 
williamr@2
   240
	* @param aLabel					The certificate's label.
williamr@2
   241
	* @param aFormat				The certificate's format.
williamr@2
   242
	* @param aCertificateOwnerType	The owner type.
williamr@2
   243
	* @param aSize					The size of the certificate.
williamr@2
   244
	* @param aSubjectKeyId			The subject key ID.
williamr@2
   245
	* @param aIssuerKeyId			The issuer key ID.
williamr@2
   246
	* @param aToken					The token that the certificate is within.
williamr@2
   247
	* @param aCertificateId			The ID within the object handle.
williamr@2
   248
	* @return						A pointer to the new certificate information object.
williamr@2
   249
	* @leave KErrNoMemory		There is no memory to construct it.*/
williamr@2
   250
	IMPORT_C static CCTCertInfo* NewLC(const TDesC& aLabel, TCertificateFormat aFormat,
williamr@2
   251
		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
williamr@2
   252
		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
williamr@2
   253
		MCTToken& aToken, TInt aCertificateId);
williamr@2
   254
williamr@2
   255
	/** 
williamr@2
   256
	* @publishedPartner
williamr@2
   257
	* @released
williamr@2
   258
	* 
williamr@2
   259
	* Creates the certificate information object by internalising a previously externalised 
williamr@2
   260
	* one.
williamr@2
   261
	* 
williamr@2
   262
	* @param aStream			The stream from which the object is to be internalised.
williamr@2
   263
	* @param aToken				The token that it is within.
williamr@2
   264
	* @return					A pointer to the new certificate information object. 
williamr@2
   265
	* @leave KErrNoMemory	There is no memory to construct it.
williamr@2
   266
	* @see ExternalizeL
williamr@2
   267
	* @see InternalizeL */
williamr@2
   268
	IMPORT_C static CCTCertInfo* NewL(RReadStream& aStream, MCTToken& aToken);
williamr@2
   269
williamr@2
   270
	/** 
williamr@2
   271
	* @publishedPartner
williamr@2
   272
	* @released
williamr@2
   273
	* 
williamr@2
   274
	* Creates the certificate information object, by internalising a previously externalised 
williamr@2
   275
	* one, and puts a pointer to the new object onto the cleanup stack.	
williamr@2
   276
	* 
williamr@2
   277
	* @param aStream			The stream from which the object is to be internalised.
williamr@2
   278
	* @param aToken				The token that it is within.
williamr@2
   279
	* @return					A pointer to the new certificate information object. 
williamr@2
   280
	* @leave KErrNoMemory	There is no memory to construct it.
williamr@2
   281
	* @see ExternalizeL
williamr@2
   282
	* @see InternalizeL */
williamr@2
   283
	IMPORT_C static CCTCertInfo* NewLC(RReadStream& aStream, MCTToken& aToken);
williamr@2
   284
williamr@2
   285
	/** Gets the subject key ID.	
williamr@2
   286
	* 
williamr@2
   287
	* @return A reference to a key identifier object. */
williamr@2
   288
	IMPORT_C const TKeyIdentifier& SubjectKeyId() const;
williamr@2
   289
williamr@2
   290
	/** Gets the issuer key ID.
williamr@2
   291
	* 
williamr@2
   292
	* @return A reference to a key identifier object. */
williamr@2
   293
	IMPORT_C const TKeyIdentifier& IssuerKeyId() const;
williamr@2
   294
williamr@2
   295
	/** Gets the certificate format.
williamr@2
   296
	* 
williamr@2
   297
	* @return The certificate format. */
williamr@2
   298
	IMPORT_C TCertificateFormat CertificateFormat() const;
williamr@2
   299
williamr@2
   300
	/** Gets the owner type.
williamr@2
   301
	* 
williamr@2
   302
	* @return The owner type. */
williamr@2
   303
	IMPORT_C TCertificateOwnerType CertificateOwnerType() const;
williamr@2
   304
williamr@2
   305
	/** Gets the size of the certificate.
williamr@2
   306
	* 
williamr@2
   307
	* Note that this function must be called so that the correct size of descriptor 
williamr@2
   308
	* can be allocated when retrieving the certificate (with MCertStore::Retrieve()).
williamr@2
   309
	* 
williamr@2
   310
	* @return The size of the certificate. */
williamr@2
   311
	IMPORT_C TInt Size() const;
williamr@2
   312
williamr@2
   313
	/** Gets a handle for the object.
williamr@2
   314
	* 
williamr@2
   315
	* The primary purpose of the handle is to allow token objects to be 'passed' 
williamr@2
   316
	* between processes.
williamr@2
   317
	* 
williamr@2
   318
	* @return	A handle for the object. 
williamr@2
   319
	* @see TCTTokenObjectHandle */
williamr@2
   320
	IMPORT_C TCTTokenObjectHandle Handle() const;
williamr@2
   321
williamr@2
   322
	/** Whether the certificate is deletable.
williamr@2
   323
	* 
williamr@2
   324
	* @return	ETrue if it is possible to delete the certificate; EFalse, otherwise. */
williamr@2
   325
	IMPORT_C TBool IsDeletable() const;
williamr@2
   326
williamr@2
   327
	/** Gets the hash of the issuer's DN.
williamr@2
   328
	* 
williamr@2
   329
	* @return	The hash of the issuer's DN, or NULL if not known. */
williamr@2
   330
	IMPORT_C const TDesC8* IssuerHash() const;
williamr@2
   331
williamr@2
   332
 public:	
williamr@2
   333
  // from MCTTokenObject
williamr@2
   334
	/** Gets the object's human-readable label.
williamr@2
   335
	* 
williamr@2
   336
	* @return	The object's human-readable label.
williamr@2
   337
	* @see MCTTokenObject::Label()*/
williamr@2
   338
	virtual const TDesC& Label() const;
williamr@2
   339
williamr@2
   340
	/** Gets a reference to the associated token.
williamr@2
   341
	* 
williamr@2
   342
	* @return	A reference to the associated token.
williamr@2
   343
	* @see MCTTokenObject::Token()*/
williamr@2
   344
	virtual MCTToken& Token() const;
williamr@2
   345
williamr@2
   346
	/** Gets a UID representing the type of the token object.
williamr@2
   347
	* 
williamr@2
   348
	* The function overrides MCTTokenObject::Type().
williamr@2
   349
	* 
williamr@2
   350
	* The meanings of possible UIDs should be documented in the documentation for 
williamr@2
   351
	* the interface that returns them.
williamr@2
   352
	* 
williamr@2
   353
	* @return	A UID representing the type of the token object; this implementation 
williamr@2
   354
	* 			returns KCTObjectCertInfo.
williamr@2
   355
	* @see MCTTokenObject::Type() */
williamr@2
   356
	virtual TUid Type() const;
williamr@2
   357
	
williamr@2
   358
	// Compares 2 cert infos
williamr@2
   359
	/** Compares this certificate information object with a specified Certificate 
williamr@2
   360
	* Information object for equality.
williamr@2
   361
	* 
williamr@2
   362
	* @param aCertInfo	The certificate information object to be compared.
williamr@2
   363
	* @return			ETrue, if they are the same; EFalse, otherwise. */
williamr@2
   364
	IMPORT_C TBool operator ==(const CCTCertInfo& aCertInfo) const;
williamr@2
   365
williamr@2
   366
	/** Sets the certificate Id.
williamr@2
   367
	* 
williamr@2
   368
	* @param aCertId The certificate Id.*/
williamr@2
   369
	IMPORT_C void SetCertificateId(TInt aCertId);
williamr@2
   370
williamr@2
   371
 protected:
williamr@2
   372
	IMPORT_C virtual ~CCTCertInfo();
williamr@2
   373
	
williamr@2
   374
 private:
williamr@2
   375
	CCTCertInfo(MCTToken& aToken);
williamr@2
   376
	CCTCertInfo(const TDesC& aLabel, TCertificateFormat aFormat,
williamr@2
   377
				TCertificateOwnerType aCertificateOwnerType, 
williamr@2
   378
				TInt aSize,
williamr@2
   379
				const TKeyIdentifier* aSubjectKeyId,
williamr@2
   380
				const TKeyIdentifier* aIssuerKeyId,
williamr@2
   381
				MCTToken& aToken, TInt aCertificateId,
williamr@2
   382
				TBool aDeletable);
williamr@2
   383
	CCTCertInfo(const CCTCertInfo& aCertInfo);
williamr@2
   384
	void ConstructL(RReadStream& aStream);
williamr@2
   385
	void ConstructL(const TDesC8* aIssuerHash);
williamr@2
   386
	
williamr@2
   387
 private:
williamr@2
   388
	const CCTCertInfo& operator=(const CCTCertInfo& aOther);
williamr@2
   389
	
williamr@2
   390
 private:	
williamr@2
   391
	MCTToken& iToken;
williamr@2
   392
	};
williamr@2
   393
williamr@2
   394
#endif