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