os/security/cryptoservices/certificateandkeymgmt/certstore/CCheckedCertStore.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
* CCheckedCertStore class implementation
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file 
sl@0
    22
 @internalComponent 
sl@0
    23
*/
sl@0
    24
 
sl@0
    25
#ifndef __CCHECKEDCERTSTORE_H__
sl@0
    26
#define __CCHECKEDCERTSTORE_H__
sl@0
    27
sl@0
    28
#include <e32std.h>
sl@0
    29
#include <ct.h>
sl@0
    30
#include <e32property.h>
sl@0
    31
#include <mctwritablecertstore.h>
sl@0
    32
#include "unifiedkeystore.h"
sl@0
    33
sl@0
    34
NONSHARABLE_CLASS(CCheckedCertStore) : public CActive, public MCTWritableCertStore
sl@0
    35
{
sl@0
    36
public:
sl@0
    37
 	static CCheckedCertStore* NewCheckedCertStoreL(MCTTokenInterface*, RProperty&);
sl@0
    38
 	static CCheckedCertStore* NewCheckedWritableCertStoreL(MCTTokenInterface*, RProperty&);
sl@0
    39
public:
sl@0
    40
	void ConstructL();
sl@0
    41
public:	//	MCTTokenInterface
sl@0
    42
	virtual MCTToken& Token();
sl@0
    43
sl@0
    44
public:	//	MCTCertStore
sl@0
    45
	virtual void List(RMPointerArray<CCTCertInfo>& aCerts, const CCertAttributeFilter& aFilter,
sl@0
    46
						TRequestStatus& aStatus);
sl@0
    47
	virtual void CancelList();
sl@0
    48
	virtual void GetCert(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle, 
sl@0
    49
						TRequestStatus& aStatus);
sl@0
    50
	virtual void CancelGetCert();
sl@0
    51
	virtual void Applications(const CCTCertInfo& aCertInfo, RArray<TUid>& aApplications,
sl@0
    52
						TRequestStatus& aStatus);
sl@0
    53
	virtual void CancelApplications();
sl@0
    54
	virtual void IsApplicable(const CCTCertInfo& aCertInfo, TUid aApplication, 
sl@0
    55
						TBool& aIsApplicable, TRequestStatus& aStatus);
sl@0
    56
	virtual void CancelIsApplicable();
sl@0
    57
	virtual void Trusted(const CCTCertInfo& aCertInfo, TBool& aTrusted, 
sl@0
    58
						TRequestStatus& aStatus);
sl@0
    59
	virtual void CancelTrusted();
sl@0
    60
	virtual void Retrieve(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert, 
sl@0
    61
						TRequestStatus& aStatus);
sl@0
    62
	virtual void CancelRetrieve();
sl@0
    63
sl@0
    64
	
sl@0
    65
public:	//	MCTWritableCertStore
sl@0
    66
sl@0
    67
	virtual void Add( const TDesC& aLabel, TCertificateFormat aFormat,
sl@0
    68
						TCertificateOwnerType aCertificateOwnerType, 
sl@0
    69
						const TKeyIdentifier* aSubjectKeyId,
sl@0
    70
						const TKeyIdentifier* aIssuerKeyId,
sl@0
    71
						const TDesC8& aCert, TRequestStatus& aStatus);
sl@0
    72
	
sl@0
    73
	// new Add(.., TBool aDeletable, ..) method from MCTWritableCertStore
sl@0
    74
	virtual void Add( const TDesC& aLabel, 
sl@0
    75
						TCertificateFormat aFormat,
sl@0
    76
						TCertificateOwnerType aCertificateOwnerType, 
sl@0
    77
						const TKeyIdentifier* aSubjectKeyId,
sl@0
    78
						const TKeyIdentifier* aIssuerKeyId,
sl@0
    79
						const TDesC8& aCert, 
sl@0
    80
						const TBool aDeletable,
sl@0
    81
						TRequestStatus& aStatus);
sl@0
    82
												
sl@0
    83
	virtual void CancelAdd();
sl@0
    84
	virtual void Remove(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus);
sl@0
    85
	virtual void CancelRemove();
sl@0
    86
	virtual void SetApplicability(const CCTCertInfo& aCertInfo, 
sl@0
    87
						const RArray<TUid>& aApplications, TRequestStatus &aStatus);
sl@0
    88
	virtual void CancelSetApplicability();
sl@0
    89
	virtual void SetTrust(const CCTCertInfo& aCertInfo, TBool aTrusted, 
sl@0
    90
						TRequestStatus& aStatus);
sl@0
    91
	virtual void CancelSetTrust();
sl@0
    92
protected:	//	From CActive
sl@0
    93
	virtual void DoCancel();
sl@0
    94
	virtual void RunL();
sl@0
    95
	virtual TInt RunError(TInt aError);
sl@0
    96
private:
sl@0
    97
	enum TState
sl@0
    98
	{
sl@0
    99
		EIdleState = 0,
sl@0
   100
		EList,
sl@0
   101
		EAdd,					// attempts using new Add() with aDeletable param
sl@0
   102
		EInitKeyStoreForAdd,
sl@0
   103
		EInitKeyStoreForList,
sl@0
   104
		EGetKeyInfosForAdd,
sl@0
   105
		EGetKeyInfosForList,
sl@0
   106
		EOldAdd,				// uses original Add() w/o aDeletable param
sl@0
   107
								// if the new Add is not supported
sl@0
   108
		ERemove,
sl@0
   109
		ESetApplicability,
sl@0
   110
		ESetTrust
sl@0
   111
	};
sl@0
   112
private:
sl@0
   113
 	CCheckedCertStore(MCTCertStore&, RProperty&);
sl@0
   114
 	CCheckedCertStore(MCTWritableCertStore&, RProperty&);
sl@0
   115
	virtual ~CCheckedCertStore();
sl@0
   116
private:
sl@0
   117
    void Complete(TInt aError);
sl@0
   118
	void Cleanup();
sl@0
   119
	void InitialiseKeyStoreL(TState aNextState);
sl@0
   120
	void BuildCheckedCertificateListL();
sl@0
   121
	void ComputeAndCheckSubjectKeyIdL();
sl@0
   122
	
sl@0
   123
	void DoAddL( const TDesC& aLabel, 
sl@0
   124
    				TCertificateFormat aFormat,
sl@0
   125
                	TCertificateOwnerType aCertificateOwnerType, 
sl@0
   126
                	const TKeyIdentifier* aSubjectKeyId,
sl@0
   127
                	const TKeyIdentifier* aIssuerKeyId,
sl@0
   128
                	const TDesC8& aCert,
sl@0
   129
                	const TBool aDeletable,
sl@0
   130
                	TRequestStatus& aStatus
sl@0
   131
                	);
sl@0
   132
sl@0
   133
	void CancelOutstandingRequest();
sl@0
   134
sl@0
   135
private:  // Generic
sl@0
   136
    
sl@0
   137
    /// The certificate store we wrap, owned by us
sl@0
   138
	MCTCertStore& iCertStore;
sl@0
   139
    /// Pointer to the same object as iCertStore if it's writable, otherwise NULL
sl@0
   140
	MCTWritableCertStore* iWritableCertStore;
sl@0
   141
    /// File server session, used by unified key store
sl@0
   142
	RFs iFs;
sl@0
   143
    /// Unified keystore, created and destroyed on demand
sl@0
   144
	CUnifiedKeyStore* iUnifiedKeyStore;
sl@0
   145
    /// Current state of the active object
sl@0
   146
	TState iState;
sl@0
   147
    /// Request status of client request
sl@0
   148
	TRequestStatus* iCallerStatus;
sl@0
   149
    /// Key filter used for listing and adding certs
sl@0
   150
	TCTKeyAttributeFilter iKeyFilter;
sl@0
   151
    /// List of key infos returned by keystore
sl@0
   152
	RMPointerArray<CCTKeyInfo> iKeyInfos;
sl@0
   153
sl@0
   154
    //	For Add requests
sl@0
   155
sl@0
   156
    /// Format of cert to add
sl@0
   157
	TCertificateFormat iFormat;
sl@0
   158
    /// Owner type of cert to add
sl@0
   159
	TCertificateOwnerType iCertificateOwnerType;
sl@0
   160
    /// Subject key id of cert to add, not owned by us
sl@0
   161
	const TKeyIdentifier* iSubjectKeyId;
sl@0
   162
    /// Issuer key id of cert to add, not owned by us
sl@0
   163
	const TKeyIdentifier* iIssuerKeyId;
sl@0
   164
	//  Deletable flag of cert to add	
sl@0
   165
	TBool iDeletable;
sl@0
   166
sl@0
   167
sl@0
   168
    /// Holds the subject key id extracted from the cert - used if the caller
sl@0
   169
    /// doesn't supply it
sl@0
   170
	TKeyIdentifier iComputedSubjectKeyId;
sl@0
   171
    /// Label of the cert to add, owned by us
sl@0
   172
	HBufC* iCertLabel;
sl@0
   173
    /// Certificate data to add, owned by us
sl@0
   174
	HBufC8* iCertificate;
sl@0
   175
sl@0
   176
    // For List requests
sl@0
   177
    
sl@0
   178
    /// Pointer to client's cert list, used to return certs, not owned by us
sl@0
   179
	RMPointerArray<CCTCertInfo>* iCallerCerts;
sl@0
   180
    /// Pointer to client's cert filter, not owned by us
sl@0
   181
	const CCertAttributeFilter* iCallerFilter;
sl@0
   182
    // Reference for the certstore change notification property.
sl@0
   183
	RProperty& iPSCertstoreChangePropertyRef;
sl@0
   184
sl@0
   185
};
sl@0
   186
sl@0
   187
#endif	//	__CCHECKEDCERTSTORE_H__