epoc32/include/unifiedcertstore.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) 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
* UNIFIEDCERTSTORE.H
williamr@2
    16
* The unified certificate store implementation
williamr@2
    17
*
williamr@2
    18
*/
williamr@2
    19
williamr@2
    20
williamr@2
    21
/**
williamr@2
    22
 @file 
williamr@4
    23
 @publishedAll
williamr@2
    24
 @released
williamr@2
    25
*/
williamr@2
    26
 
williamr@2
    27
#ifndef __UNIFIEDCERTSTORE_H__
williamr@2
    28
#define __UNIFIEDCERTSTORE_H__
williamr@2
    29
williamr@2
    30
class CCertificate;
williamr@2
    31
williamr@2
    32
#include <signed.h>
williamr@2
    33
#include <e32std.h>
williamr@2
    34
#include <f32file.h>
williamr@2
    35
#include <e32property.h>
williamr@2
    36
#include <sacls.h>
williamr@2
    37
#include <mcertstore.h>
williamr@2
    38
#include <ct/rmpointerarray.h>
williamr@2
    39
#include <ct/rcpointerarray.h>
williamr@2
    40
williamr@2
    41
williamr@2
    42
williamr@2
    43
williamr@2
    44
/**  
williamr@2
    45
 *
williamr@2
    46
 * Publish and Subscribe - UnifiedCertSTore Category
williamr@2
    47
 * Aliased here to System Category to prevent SC break.
williamr@2
    48
 *
williamr@2
    49
 */
williamr@2
    50
const TUid KUnifiedCertStorePropertyCat = {KUidSystemCategoryValue};
williamr@2
    51
williamr@2
    52
/**  
williamr@2
    53
 *
williamr@2
    54
 * Publish and subscribe key for UnifiedCertSTore.
williamr@2
    55
 */
williamr@2
    56
enum TUnifiedCertStoreKey
williamr@2
    57
	{
williamr@2
    58
	/**  
williamr@2
    59
 	 *
williamr@2
    60
 	 * The Publish and subscribe key for the certstore changes.
williamr@2
    61
	 * If the client of the UnifiedCertstore needs to be notified when
williamr@2
    62
	 * certificate addition, removal and trust&application setting occurs,
williamr@2
    63
	 * the client needs to subscribe to KUnifiedCertStorePropertyCat and
williamr@2
    64
	 * EUnifiedCertStoreFlag.
williamr@2
    65
	 *
williamr@2
    66
	 * Aliased here to KUidUnifiedCertstore flag to avoid SC break.
williamr@2
    67
 	 */
williamr@2
    68
 	EUnifiedCertStoreFlag = KUidUnifiedCertstoreFlag
williamr@2
    69
 	};
williamr@2
    70
williamr@2
    71
/**
williamr@2
    72
 *
williamr@2
    73
 * The Unique ID for unknown hardware certstore, used as the input parameter when it is to be filtered.
williamr@2
    74
 * @deprecated. Used only for Data compatibility.
williamr@2
    75
 */
williamr@2
    76
williamr@2
    77
const TInt KUnknownHardwareCertStore = 0;
williamr@2
    78
williamr@2
    79
williamr@2
    80
/**
williamr@2
    81
 *
williamr@2
    82
 * The Unique ID for mutable software certstore, used as the input parameter when it is to be filtered.
williamr@2
    83
 *
williamr@2
    84
 */
williamr@2
    85
williamr@2
    86
const TInt KThirdPartyCertStore = 1;
williamr@2
    87
williamr@2
    88
williamr@2
    89
/**
williamr@2
    90
 *
williamr@2
    91
 * The Unique ID for SIM certstore, used as the input parameter when it is to be filtered.
williamr@2
    92
 *
williamr@2
    93
 */
williamr@2
    94
williamr@2
    95
const TInt KSIMCertStore  = 2;
williamr@2
    96
williamr@2
    97
/**
williamr@2
    98
 *
williamr@2
    99
 * The Unique ID for WIM certstore, used as the input parameter when it is to be filtered.
williamr@2
   100
 *  
williamr@2
   101
 */
williamr@2
   102
williamr@2
   103
const TInt KWIMCertStore  = 3;
williamr@2
   104
williamr@2
   105
/**  
williamr@2
   106
 *
williamr@2
   107
 * The Unique ID for UICC certstore, used as the input parameter when it is to be filtered.
williamr@2
   108
 *  
williamr@2
   109
 */
williamr@2
   110
const TInt KUICCCertStore = 4;
williamr@2
   111
williamr@2
   112
/**  
williamr@2
   113
 *
williamr@2
   114
 * The Unique ID for immutable software certstore, used as the input parameter when it is to be filtered.
williamr@2
   115
 *  
williamr@2
   116
 */
williamr@2
   117
williamr@2
   118
const TInt KManufactureCertStore = 5;
williamr@2
   119
williamr@2
   120
// Forward declarations
williamr@2
   121
class MCTCertStore;
williamr@2
   122
class MCTWritableCertStore;
williamr@2
   123
class MCTTokenInterface;
williamr@2
   124
class MCTToken;
williamr@2
   125
class MCTTokenType;
williamr@2
   126
class CCTCertInfo;
williamr@2
   127
class CCertAttributeFilter;
williamr@2
   128
class CCTTokenTypeInfo;
williamr@2
   129
class TCTTokenObjectHandle;
williamr@2
   130
class CCheckedCertStore;
williamr@2
   131
williamr@2
   132
// This class is forward declared to avoid including its definition in this
williamr@2
   133
// exported header file because it must only be used internally.
williamr@2
   134
class CUnifiedCertStoreWorkingVars;
williamr@2
   135
class CX500DistinguishedName;
williamr@2
   136
williamr@2
   137
/**
williamr@2
   138
 * The unified certificate store.
williamr@2
   139
 * 
williamr@2
   140
 * This class provides a certificate store whose contents are the sum of the
williamr@2
   141
 * contents of all certificate store implementations on the device.  It is
williamr@2
   142
 * intended as the single point of access for clients wishing to use certificate
williamr@2
   143
 * stores.
williamr@2
   144
 *
williamr@2
   145
 * Since this class is intended for widespread use, capability checks relating
williamr@2
   146
 * to certificate access are documented here even though the checks are actually
williamr@2
   147
 * made in the individual cert store implementations.
williamr@2
   148
 * 
williamr@2
   149
 */
williamr@2
   150
NONSHARABLE_CLASS(CUnifiedCertStore) : public CActive, public MCertStore
williamr@2
   151
	{
williamr@2
   152
public:
williamr@2
   153
	/** 
williamr@2
   154
	 * Creates a new CUnifiedCertStore
williamr@2
   155
	 *
williamr@2
   156
	 * @param aFs			A file server session. It must already be open.
williamr@2
   157
	 * @param aOpenForWrite	ETrue if the stores must be opened with write access
williamr@2
   158
	 *						(e.g. for adding certificates) and EFalse if the user 
williamr@2
   159
	 *						only needs read-only access.
williamr@2
   160
	 * @return				A pointer to an instance of the CUnifiedCertStore class.
williamr@2
   161
	 */
williamr@2
   162
	IMPORT_C static CUnifiedCertStore* NewL(RFs& aFs, TBool aOpenForWrite);
williamr@2
   163
	
williamr@2
   164
	/** 
williamr@2
   165
	 * Creates a new CUnifiedCertStore and pushes it on the cleanup stack.
williamr@2
   166
	 *
williamr@2
   167
	 * @param aFs			A file server session. It must already be open.
williamr@2
   168
	 * @param aOpenForWrite	ETrue if the stores must be opened with write access
williamr@2
   169
	 *						(e.g. for adding certificates) and EFalse if the user
williamr@2
   170
	 *						only needs read-only access.
williamr@2
   171
	 * @return				A pointer to an instance of the CUnifiedCertStore class.
williamr@2
   172
	 */
williamr@2
   173
	IMPORT_C static CUnifiedCertStore* NewLC(RFs& aFs, TBool aOpenForWrite);
williamr@2
   174
 	/** 
williamr@2
   175
 	 * Creates a new CUnifiedCertStore with the sequence filter, so that multiple certstores that are managed
williamr@2
   176
	 * by it will be filtered and ordered.
williamr@2
   177
 	 *
williamr@2
   178
 	 * @param aFs			A file server session. It must already be open.
williamr@2
   179
 	 * @param aOpenForWrite	ETrue if the stores must be opened with write access
williamr@2
   180
 	 *						(e.g. for adding certificates) and EFalse if the user
williamr@2
   181
 	 *						only needs read-only access. Ownership is taken.
williamr@2
   182
 	 * @param aOrderFilter  An array of the unique sequence IDs specifying CertStore ordering.
williamr@2
   183
 	 * @return				A pointer to an instance of the CUnifiedCertStore class.
williamr@2
   184
 	 */
williamr@2
   185
 	IMPORT_C static CUnifiedCertStore* NewL(RFs& aFs, 
williamr@2
   186
 	                                        TBool aOpenForWrite,
williamr@2
   187
 	                                        RArray<TInt>& aOrderFilter);
williamr@2
   188
 	/** 
williamr@2
   189
 	 * Creates a new CUnifiedCertStore with the sequence filter, so that multiple certstores that are managed
williamr@2
   190
	 * by it will be filtered and ordered, and it is pushed on the cleanup stack.
williamr@2
   191
 	 *
williamr@2
   192
 	 * @param aFs			A file server session. It must already be open.
williamr@2
   193
 	 * @param aOpenForWrite	ETrue if the stores must be opened with write access
williamr@2
   194
 	 *						(e.g. for adding certificates) and EFalse if the user
williamr@2
   195
 	 *						only needs read-only access. Ownership is taken.
williamr@2
   196
 	 * @param aOrderFilter  An array of the unique sequence IDs specifying CertStore ordering.
williamr@2
   197
 	 * @return				A pointer to an instance of the CUnifiedCertStore class.
williamr@2
   198
 	 */
williamr@2
   199
 	IMPORT_C static CUnifiedCertStore* NewLC(RFs& aFs, 
williamr@2
   200
 	                                         TBool aOpenForWrite,
williamr@2
   201
 	                                         RArray<TInt>& aOrderFilter);
williamr@2
   202
	
williamr@2
   203
	/**
williamr@2
   204
	 * The destructor destroys all the resources owned by this object.
williamr@2
   205
	 */
williamr@2
   206
	IMPORT_C ~CUnifiedCertStore();
williamr@2
   207
	
williamr@2
   208
	/**
williamr@2
   209
	 * Initializes the manager. 
williamr@2
   210
	 * 
williamr@2
   211
	 * It must be called after the manager has been constructed
williamr@2
   212
	 * and before any call to the manager functions.
williamr@2
   213
	 * 
williamr@2
   214
	 * This is an asynchronous request.
williamr@2
   215
	 * 
williamr@2
   216
	 * @param aStatus	The request status object; contains the result of the Initialize() 
williamr@2
   217
	 * 					request when complete. Set to KErrCancel if any outstanding request is cancelled.
williamr@2
   218
	 */
williamr@2
   219
	IMPORT_C void Initialize(TRequestStatus& aStatus);
williamr@2
   220
williamr@2
   221
	/** 
williamr@2
   222
	 * Cancels an ongoing Initialize() operation.
williamr@2
   223
	 *
williamr@2
   224
	 * The operation completes with KErrCancel.
williamr@2
   225
	 */
williamr@2
   226
	IMPORT_C void CancelInitialize();
williamr@2
   227
williamr@2
   228
public:	// Implementation of MCertStore interface
williamr@2
   229
williamr@2
   230
	/** Lists all certificates that satisfy the supplied filter.
williamr@2
   231
	*
williamr@2
   232
	* @param aCertInfos	An array that the returned certificates are added to .
williamr@2
   233
	* @param aFilter	A filter to restrict which certificates are returned.
williamr@2
   234
	* @param aStatus	The request status object.
williamr@2
   235
	* 
williamr@2
   236
	*/
williamr@2
   237
	virtual void List(RMPointerArray<CCTCertInfo>& aCertInfos,
williamr@2
   238
					  const CCertAttributeFilter& aFilter, TRequestStatus& aStatus);
williamr@2
   239
	virtual void CancelList();
williamr@2
   240
	virtual void GetCert(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle, 
williamr@2
   241
						 TRequestStatus& aStatus);
williamr@2
   242
	virtual void CancelGetCert();
williamr@2
   243
williamr@2
   244
	/** Gets the list of applications . Applications are represented by UIDs .
williamr@2
   245
	* 	
williamr@2
   246
	* @param aCertInfos		An array of certificates .
williamr@2
   247
	* @param aApplications	An array that the returned application UIDs are added to.
williamr@2
   248
	* @param aStatus		The request status object.
williamr@2
   249
	*
williamr@2
   250
	*/
williamr@2
   251
	virtual void Applications(const CCTCertInfo& aCertInfo, 
williamr@2
   252
							  RArray<TUid>& aApplications, TRequestStatus &aStatus);
williamr@2
   253
	virtual void CancelApplications();
williamr@2
   254
	virtual void IsApplicable(const CCTCertInfo& aCertInfo, TUid aApplication, 
williamr@2
   255
							  TBool& aIsApplicable, TRequestStatus& aStatus);
williamr@2
   256
	virtual void CancelIsApplicable();
williamr@2
   257
	virtual void Trusted(const CCTCertInfo& aCertInfo, TBool& aTrusted, 
williamr@2
   258
						 TRequestStatus& aStatus);
williamr@2
   259
	virtual void CancelTrusted();
williamr@2
   260
	virtual void Retrieve(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert,
williamr@2
   261
						  TRequestStatus& aStatus);
williamr@2
   262
	virtual void CancelRetrieve();
williamr@2
   263
williamr@2
   264
public:	// Functions defined in MCTWritableCertStore except Add functions
williamr@2
   265
williamr@2
   266
	/**
williamr@2
   267
	 * Removes a certificate.
williamr@2
   268
	 * 
williamr@2
   269
	 * @param aCertInfo				The certificate to be removed.
williamr@2
   270
	 * @param aStatus				The request status object; contains the result of the Remove() 
williamr@2
   271
	 * 								request when complete. Set to KErrCancel if an outstanding request is cancelled.
williamr@2
   272
	 *
williamr@2
   273
	 * @capability WriteUserData	This requires the WriteUserData capability when
williamr@2
   274
	 *								applied to user certificates.
williamr@2
   275
	 * @capability WriteDeviceData	This requires the WriteDeviceData capability
williamr@2
   276
	 *								when applied to CA certificates.
williamr@2
   277
	 * @leave KErrPermissionDenied	If the caller doesn't have the required
williamr@2
   278
	 *								capabilities.
williamr@2
   279
	 */
williamr@2
   280
	IMPORT_C void Remove(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus);
williamr@2
   281
	
williamr@2
   282
	/** 
williamr@2
   283
	 * Cancels an ongoing Remove() operation.
williamr@2
   284
	 *
williamr@2
   285
	 * The operation completes with KErrCancel.
williamr@2
   286
	 */
williamr@2
   287
	IMPORT_C void CancelRemove();
williamr@2
   288
	
williamr@2
   289
	/**
williamr@2
   290
	 * Replaces the current applicability settings with the settings in the
williamr@2
   291
	 * supplied array.
williamr@2
   292
	 * 
williamr@2
   293
	 * This should only be called for CA certificates - it has no meaning for
williamr@2
   294
	 * user certificates.
williamr@2
   295
	 * 
williamr@2
   296
	 * @param aCertInfo		The certificate whose applicability should be updated.
williamr@2
   297
	 * @param aApplications	The new applicability settings. Ownership of this
williamr@2
   298
	 * 						remains with the caller, and it must remain valid for the
williamr@2
   299
	 * 						lifetime of the call.
williamr@2
   300
	 * @param aStatus		The request status object; contains the result of the SetApplicability() 
williamr@2
   301
	 * 						request when complete. Set to KErrCancel, if an outstanding request is cancelled.
williamr@2
   302
	 *
williamr@2
   303
	 * @capability WriteDeviceData	This requires the WriteDeviceData capability.
williamr@2
   304
	 * @leave KErrPermissionDenied	If the caller doesn't have the required capabilities.
williamr@2
   305
	 */
williamr@2
   306
	IMPORT_C void SetApplicability(const CCTCertInfo& aCertInfo, 
williamr@2
   307
		const RArray<TUid>& aApplications, TRequestStatus &aStatus);
williamr@2
   308
	
williamr@2
   309
	/** 
williamr@2
   310
	 * Cancels an ongoing SetApplicability() operation.
williamr@2
   311
	 *
williamr@2
   312
	 * The operation completes with KErrCancel.
williamr@2
   313
	 */
williamr@2
   314
	IMPORT_C void CancelSetApplicability();
williamr@2
   315
	
williamr@2
   316
	/**
williamr@2
   317
	 * Changes the trust settings.
williamr@2
   318
	 * 
williamr@2
   319
	 * A CA certificate is trusted if the user is willing to use it for authenticating
williamr@2
   320
	 * servers. It has no meaning with other types of certificates.
williamr@2
   321
	 * 
williamr@2
   322
	 * @param aCertInfo	The certificate to be updated.
williamr@2
   323
	 * @param aTrusted	ETrue, if trusted; EFalse, otherwise.
williamr@2
   324
	 * @param aStatus	The request status object; contains the result of the SetTrust() 
williamr@2
   325
	 * 					request when complete. Set to KErrCancel, if an outstanding request is cancelled.
williamr@2
   326
	 *
williamr@2
   327
	 * @capability WriteDeviceData This requires the WriteDeviceData capability.
williamr@2
   328
	 * @leave KErrPermissionDenied If the caller doesn't have the required capabilities.
williamr@2
   329
	 */
williamr@2
   330
	IMPORT_C void SetTrust(const CCTCertInfo& aCertInfo, TBool aTrusted, 
williamr@2
   331
		TRequestStatus& aStatus);
williamr@2
   332
	
williamr@2
   333
	/** 
williamr@2
   334
	 * Cancels an ongoing SetTrust() operation.
williamr@2
   335
	 *
williamr@2
   336
	 * The operation completes with KErrCancel.
williamr@2
   337
	 */
williamr@2
   338
	IMPORT_C void CancelSetTrust();
williamr@2
   339
williamr@2
   340
public:
williamr@2
   341
	/**
williamr@2
   342
	 * Lists all certificates that have a particular subject DN.
williamr@2
   343
	 * 
williamr@2
   344
	 * @param aCertInfos	An array that the returned certificates are added to
williamr@2
   345
	 * @param aFilter		A filter to restrict which certificates are returned.
williamr@2
   346
	 * @param aIssuer		Only certificates with this issuer DN will be returned
williamr@2
   347
	 * @param aStatus		Asynchronous request status.
williamr@2
   348
	 */
williamr@2
   349
	IMPORT_C void List(RMPointerArray<CCTCertInfo>& aCertInfos,
williamr@2
   350
					   const CCertAttributeFilter& aFilter, 
williamr@2
   351
					   const TDesC8& aIssuer, 
williamr@2
   352
					   TRequestStatus& aStatus);
williamr@2
   353
williamr@2
   354
	/**
williamr@2
   355
	 * Lists all certificates that have a particular issuer.
williamr@2
   356
	 * 
williamr@2
   357
	 * @param aCertInfos	An array that the returned certificates are added to
williamr@2
   358
	 * @param aFilter		A filter to restrict which certificates are returned.
williamr@2
   359
	 * @param aIssuers		Only certificates with this issuer will be returned
williamr@2
   360
	 * @param aStatus		Asynchronous request status.
williamr@2
   361
	 */
williamr@2
   362
	IMPORT_C void List(RMPointerArray<CCTCertInfo>& aCertInfos,
williamr@2
   363
					   const CCertAttributeFilter& aFilter, 
williamr@2
   364
					   RPointerArray<const TDesC8> aIssuers, 
williamr@2
   365
					   TRequestStatus& aStatus);
williamr@2
   366
williamr@2
   367
	/**
williamr@2
   368
	 * Retrieves a certificate as a parsed object.
williamr@2
   369
	 *
williamr@2
   370
	 * This will only work for certificates that have a CCertificate-derived
williamr@2
   371
	 * representation, in other words X509 and WTLS certificates.  If called for
williamr@2
   372
	 * a URL certificate, KErrNotSupported is returned.
williamr@2
   373
	 * 
williamr@2
   374
	 * @param aCertInfo	The certificate to retrieve
williamr@2
   375
	 * @param aCert		The returned certificate.  This object can safely be up-cast
williamr@2
   376
	 *					to a CX509Certificate or CWTLSCertificate if it's known that
williamr@2
   377
	 *					that is the certificate format.
williamr@2
   378
	 * @param aStatus	Asynchronous request status.
williamr@2
   379
	 * 
williamr@2
   380
	 * @capability ReadUserData		This requires the ReadUserData capability when
williamr@2
   381
	 *								applied to user certificates, as these may contain
williamr@2
   382
	 *								sensitive user data.
williamr@2
   383
	 * @leave KErrPermissionDenied	If called for a user certificate when the
williamr@2
   384
	 *								caller doesn't have the ReadUserData capability.
williamr@2
   385
	 */
williamr@2
   386
	IMPORT_C void Retrieve(const CCTCertInfo& aCertInfo, CCertificate*& aCert,
williamr@2
   387
						   TRequestStatus& aStatus);
williamr@2
   388
	
williamr@2
   389
	/** 
williamr@2
   390
	 * Gets the number of certificate stores.
williamr@2
   391
	 *
williamr@2
   392
	 * @return	The total number of certificate stores.
williamr@2
   393
	 */
williamr@2
   394
	IMPORT_C TInt CertStoreCount() const;
williamr@2
   395
	
williamr@2
   396
	/**
williamr@2
   397
	 * Gets a particular certificate store.
williamr@2
   398
	 * 
williamr@2
   399
	 * @param aIndex	The index of the required certificate store.
williamr@2
   400
	 *					A number between 0 and CertStoreCount() - 1.
williamr@2
   401
	 * @return			The certificate store.
williamr@2
   402
	 */
williamr@2
   403
	IMPORT_C MCTCertStore& CertStore(TInt aIndex);
williamr@2
   404
	
williamr@2
   405
	/** 
williamr@2
   406
	 * Gets the number of writeable certificate stores.
williamr@2
   407
	 *
williamr@2
   408
	 * @return	The number of writeable certificate stores.
williamr@2
   409
	 */
williamr@2
   410
	IMPORT_C TInt WritableCertStoreCount() const;
williamr@2
   411
	
williamr@2
   412
	/**
williamr@2
   413
	 * Gets a particular writeable certificate store.
williamr@2
   414
	 *
williamr@2
   415
	 * @param aIndex	The index of the required certificate store.
williamr@2
   416
	 *					A number between 0 and WriteableCertStoreCount() - 1.
williamr@2
   417
	 * @return			The writeable certificate store.
williamr@2
   418
	 */
williamr@2
   419
	IMPORT_C MCTWritableCertStore& WritableCertStore(TInt aIndex);
williamr@2
   420
	
williamr@2
   421
	/** 
williamr@2
   422
	 * Gets the number of read-only certificate stores.
williamr@2
   423
	 *
williamr@2
   424
	 * @return	The number of read-only certificate stores.
williamr@2
   425
	 */
williamr@2
   426
	IMPORT_C TInt ReadOnlyCertStoreCount() const;
williamr@2
   427
	
williamr@2
   428
	/**
williamr@2
   429
	 * Gets a particular read-only certificate store.
williamr@2
   430
	 * 
williamr@2
   431
	 * @param aIndex	The index of the required certificate store.
williamr@2
   432
	 *					A number between 0 and ReadOnlyCertStoreCount() - 1.
williamr@2
   433
	 * @return			The read-only certificate store.
williamr@2
   434
	 */
williamr@2
   435
	IMPORT_C MCTCertStore& ReadOnlyCertStore(TInt aIndex);
williamr@2
   436
williamr@2
   437
private:
williamr@2
   438
	enum TState
williamr@2
   439
		{
williamr@2
   440
		EIdle,
williamr@2
   441
williamr@2
   442
		EInitializeGetTokenList,
williamr@2
   443
		EInitializeGetToken,
williamr@2
   444
		EInitializeGetWritableInterface,
williamr@2
   445
		EInitializeGetReadableInterface,
williamr@2
   446
		EInitializeGetReadableInterfaceFinished,
williamr@2
   447
		EInitializeFinished,
williamr@2
   448
williamr@2
   449
		EList,
williamr@2
   450
		ERetrieve,
williamr@2
   451
		ERetrieveForList,
williamr@2
   452
williamr@2
   453
		EGetCert,
williamr@2
   454
		EApplications,
williamr@2
   455
		EIsApplicable,
williamr@2
   456
		ETrusted,
williamr@2
   457
		ERetrieveData,
williamr@2
   458
		ERemove,
williamr@2
   459
		ESetApplicability,
williamr@2
   460
		ESetTrust
williamr@2
   461
		};
williamr@2
   462
	enum TCompareResults
williamr@2
   463
		{
williamr@2
   464
		ENo,
williamr@2
   465
		EYes,
williamr@2
   466
		EMaybe
williamr@2
   467
		};
williamr@2
   468
private:
williamr@2
   469
	CUnifiedCertStore(RFs& aFs, TBool aOpenForWrite);
williamr@2
   470
	void ConstructL(RArray<TInt>& aOrderFilter);
williamr@2
   471
	void DoCancel();
williamr@2
   472
	void RunL();
williamr@2
   473
	TInt RunError(TInt aError);
williamr@2
   474
williamr@2
   475
	// Implementations for asynchronous operations
williamr@2
   476
	void InitializeL();
williamr@2
   477
	void ListL(RMPointerArray<CCTCertInfo>& aCertInfos,
williamr@2
   478
			   const CCertAttributeFilter& aFilter);
williamr@2
   479
	void ListL(RMPointerArray<CCTCertInfo>& aCertInfos,
williamr@2
   480
			  const CCertAttributeFilter& aFilter, 
williamr@2
   481
			  RPointerArray<const TDesC8> aIssuers);
williamr@2
   482
	void RetrieveL(const CCTCertInfo& aCertInfo, CCertificate*& aCert);
williamr@2
   483
	void GetCertL(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle);
williamr@2
   484
	void ApplicationsL(const CCTCertInfo& aCertInfo, RArray<TUid>& aApplications);
williamr@2
   485
	void IsApplicableL(const CCTCertInfo& aCertInfo, TUid aApplication, 
williamr@2
   486
					   TBool& aIsApplicable);
williamr@2
   487
	void TrustedL(const CCTCertInfo& aCertInfo, TBool& aTrusted);
williamr@2
   488
	void RetrieveDataL(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert);
williamr@2
   489
	void RemoveL(const CCTCertInfo& aCertInfo);
williamr@2
   490
	void SetApplicabilityL(const CCTCertInfo& aCertInfo,
williamr@2
   491
						   const RArray<TUid>& aApplications);
williamr@2
   492
	void SetTrustL(const CCTCertInfo& aCertInfo, TBool aTrusted);
williamr@2
   493
williamr@2
   494
	// Helper functions
williamr@2
   495
	void AllocWorkingVarsL();
williamr@2
   496
	void BeginAsyncOp(TRequestStatus& aStatus, TState aState);	
williamr@2
   497
	void DestroyTemporaryMembers();
williamr@2
   498
	MCTCertStore* GetCertStore(const TCTTokenObjectHandle& aHandle);
williamr@2
   499
	void FindCertStoreL(const TCTTokenObjectHandle& aHandle);
williamr@2
   500
	void FindWritableCertStoreL(const TCTTokenObjectHandle& aHandle);
williamr@2
   501
	TCompareResults CompareCertInfoDN(const CCTCertInfo* aCertInfo);
williamr@2
   502
	TBool MatchL(const CX500DistinguishedName& aName) const;
williamr@2
   503
	void Complete(TInt aError);
williamr@2
   504
	void CancelOutstandingRequest();
williamr@2
   505
 	
williamr@2
   506
 	// Filters CertStores according to specified order.
williamr@2
   507
 	void ApplyOrderingL(RCPointerArray<CCTTokenTypeInfo>& aTokenTypes);
williamr@2
   508
 	
williamr@2
   509
 	void FilterTokenTypesL(RCPointerArray<CCTTokenTypeInfo>& aSearchTokenTypes,
williamr@2
   510
						RCPointerArray<CCTTokenTypeInfo>& aTempTokenTypes,
williamr@2
   511
						TInt aOrderAttribute);
williamr@2
   512
 
williamr@2
   513
private:
williamr@2
   514
	/**
williamr@2
   515
	 * A file server session, this is not logically a part of this class
williamr@2
   516
	 * but is needed for the client store and the file certstore.
williamr@2
   517
	 */
williamr@2
   518
	RFs& iFs;
williamr@2
   519
williamr@2
   520
	TBool iOpenedForWrite;
williamr@2
   521
williamr@2
   522
	RPointerArray<CCheckedCertStore> iReadOnlyCertStores;
williamr@2
   523
	RPointerArray<CCheckedCertStore> iWritableCertStores;
williamr@2
   524
	RPointerArray<CCheckedCertStore> iCertStores;
williamr@2
   525
williamr@2
   526
	TBool iCurrentlyDoingReadOnly;
williamr@2
   527
williamr@2
   528
	/**
williamr@2
   529
	 * This a TokenType retrieved from the iTokenTypes array.
williamr@2
   530
	 * We use this to get a list of Tokens and to open these Tokens.
williamr@2
   531
	 */
williamr@2
   532
	MCTTokenType* iTokenType;
williamr@2
   533
williamr@2
   534
	/**
williamr@2
   535
	 * This is the list of Tokens for one of the Token Types of iTokenTypes.
williamr@2
   536
	 */
williamr@2
   537
	RCPointerArray<HBufC> iTokens;
williamr@2
   538
williamr@2
   539
	/** All the UIDs of hardware token types */
williamr@2
   540
	RArray<TUid> iHardwareTypeUids;
williamr@2
   541
	/**
williamr@2
   542
	 * This is used as an index for the iTokens array when we try 
williamr@2
   543
	 * to get an interface to each of the tokens.
williamr@2
   544
	 */
williamr@2
   545
	TInt iIndexTokens;
williamr@2
   546
williamr@2
   547
	/**
williamr@2
   548
	 * A Token interface. We will use the interface to get a readable or writable
williamr@2
   549
	 * certstore interface. The value is updated at EInitializeGetToken and used
williamr@2
   550
	 * at EInitializeGetWritableInterface.
williamr@2
   551
	 */
williamr@2
   552
	MCTToken* iToken;
williamr@2
   553
williamr@2
   554
	/**
williamr@2
   555
	 * We use this to (temporarily) store the interface we obtained from iToken.
williamr@2
   556
	 * It will be inserted in iWritableCertStores or iCertStores.
williamr@2
   557
	 */
williamr@2
   558
	MCTTokenInterface* iTokenInterface;
williamr@2
   559
williamr@2
   560
 	/**
williamr@2
   561
 	The index of the plugin certstore that is being processed
williamr@2
   562
 	*/
williamr@2
   563
	TInt iIndex;
williamr@2
   564
williamr@2
   565
	/**
williamr@2
   566
	 * This is the status of the caller of an asynchronous function. It must be set
williamr@2
   567
	 * to KRequestPending by the function while doing the processing.
williamr@2
   568
	 */
williamr@2
   569
	TRequestStatus* iClientStatus;
williamr@2
   570
williamr@2
   571
	TState iState;
williamr@2
   572
williamr@2
   573
	TBool iIsInitialized;
williamr@2
   574
williamr@2
   575
	/**
williamr@2
   576
	 * This member holds all the variables that are only used to store temporary results
williamr@2
   577
	 * while performing a given operation. It must be initialized at the start of the
williamr@2
   578
	 * operation and deleted at the end of it whether the opeartion completes successfully
williamr@2
   579
	 * or not. When no operation is being performed it must be 0.
williamr@2
   580
	 */
williamr@2
   581
	CUnifiedCertStoreWorkingVars* iWorkingVars;
williamr@2
   582
williamr@2
   583
	/**
williamr@2
   584
	 * The cert store in use by an outstanding async operation.
williamr@2
   585
	 */
williamr@2
   586
	MCTCertStore *iCurrentCertStore;
williamr@2
   587
williamr@2
   588
	/**
williamr@2
   589
	 * The writable cert store in use by an outstanding async operation.
williamr@2
   590
	 */
williamr@2
   591
	MCTWritableCertStore *iCurrentWritableCertStore;
williamr@2
   592
williamr@2
   593
	// Padding to keep class size constant
williamr@2
   594
	TInt32 iUnused1;
williamr@2
   595
	TInt32 iUnused2;
williamr@2
   596
	                  
williamr@2
   597
 	// An array of Uids specifying Token Type ordering
williamr@2
   598
 	RArray<TInt> iOrderAttributes;
williamr@2
   599
 	
williamr@2
   600
 	// Publish and subscribe property which is used to notify the 
williamr@2
   601
	// cerificate addition,removal and application&trust setting.
williamr@2
   602
 	RProperty iPSCertstoreChangeProperty;
williamr@2
   603
williamr@2
   604
	};
williamr@2
   605
williamr@2
   606
#endif