sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * CCheckedCertStore class implementation sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __CCHECKEDCERTSTORE_H__ sl@0: #define __CCHECKEDCERTSTORE_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "unifiedkeystore.h" sl@0: sl@0: NONSHARABLE_CLASS(CCheckedCertStore) : public CActive, public MCTWritableCertStore sl@0: { sl@0: public: sl@0: static CCheckedCertStore* NewCheckedCertStoreL(MCTTokenInterface*, RProperty&); sl@0: static CCheckedCertStore* NewCheckedWritableCertStoreL(MCTTokenInterface*, RProperty&); sl@0: public: sl@0: void ConstructL(); sl@0: public: // MCTTokenInterface sl@0: virtual MCTToken& Token(); sl@0: sl@0: public: // MCTCertStore sl@0: virtual void List(RMPointerArray& aCerts, const CCertAttributeFilter& aFilter, sl@0: TRequestStatus& aStatus); sl@0: virtual void CancelList(); sl@0: virtual void GetCert(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle, sl@0: TRequestStatus& aStatus); sl@0: virtual void CancelGetCert(); sl@0: virtual void Applications(const CCTCertInfo& aCertInfo, RArray& aApplications, sl@0: TRequestStatus& aStatus); sl@0: virtual void CancelApplications(); sl@0: virtual void IsApplicable(const CCTCertInfo& aCertInfo, TUid aApplication, sl@0: TBool& aIsApplicable, TRequestStatus& aStatus); sl@0: virtual void CancelIsApplicable(); sl@0: virtual void Trusted(const CCTCertInfo& aCertInfo, TBool& aTrusted, sl@0: TRequestStatus& aStatus); sl@0: virtual void CancelTrusted(); sl@0: virtual void Retrieve(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert, sl@0: TRequestStatus& aStatus); sl@0: virtual void CancelRetrieve(); sl@0: sl@0: sl@0: public: // MCTWritableCertStore sl@0: sl@0: virtual void Add( const TDesC& aLabel, TCertificateFormat aFormat, sl@0: TCertificateOwnerType aCertificateOwnerType, sl@0: const TKeyIdentifier* aSubjectKeyId, sl@0: const TKeyIdentifier* aIssuerKeyId, sl@0: const TDesC8& aCert, TRequestStatus& aStatus); sl@0: sl@0: // new Add(.., TBool aDeletable, ..) method from MCTWritableCertStore sl@0: virtual void Add( const TDesC& aLabel, sl@0: TCertificateFormat aFormat, sl@0: TCertificateOwnerType aCertificateOwnerType, sl@0: const TKeyIdentifier* aSubjectKeyId, sl@0: const TKeyIdentifier* aIssuerKeyId, sl@0: const TDesC8& aCert, sl@0: const TBool aDeletable, sl@0: TRequestStatus& aStatus); sl@0: sl@0: virtual void CancelAdd(); sl@0: virtual void Remove(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus); sl@0: virtual void CancelRemove(); sl@0: virtual void SetApplicability(const CCTCertInfo& aCertInfo, sl@0: const RArray& aApplications, TRequestStatus &aStatus); sl@0: virtual void CancelSetApplicability(); sl@0: virtual void SetTrust(const CCTCertInfo& aCertInfo, TBool aTrusted, sl@0: TRequestStatus& aStatus); sl@0: virtual void CancelSetTrust(); sl@0: protected: // From CActive sl@0: virtual void DoCancel(); sl@0: virtual void RunL(); sl@0: virtual TInt RunError(TInt aError); sl@0: private: sl@0: enum TState sl@0: { sl@0: EIdleState = 0, sl@0: EList, sl@0: EAdd, // attempts using new Add() with aDeletable param sl@0: EInitKeyStoreForAdd, sl@0: EInitKeyStoreForList, sl@0: EGetKeyInfosForAdd, sl@0: EGetKeyInfosForList, sl@0: EOldAdd, // uses original Add() w/o aDeletable param sl@0: // if the new Add is not supported sl@0: ERemove, sl@0: ESetApplicability, sl@0: ESetTrust sl@0: }; sl@0: private: sl@0: CCheckedCertStore(MCTCertStore&, RProperty&); sl@0: CCheckedCertStore(MCTWritableCertStore&, RProperty&); sl@0: virtual ~CCheckedCertStore(); sl@0: private: sl@0: void Complete(TInt aError); sl@0: void Cleanup(); sl@0: void InitialiseKeyStoreL(TState aNextState); sl@0: void BuildCheckedCertificateListL(); sl@0: void ComputeAndCheckSubjectKeyIdL(); sl@0: sl@0: void DoAddL( const TDesC& aLabel, sl@0: TCertificateFormat aFormat, sl@0: TCertificateOwnerType aCertificateOwnerType, sl@0: const TKeyIdentifier* aSubjectKeyId, sl@0: const TKeyIdentifier* aIssuerKeyId, sl@0: const TDesC8& aCert, sl@0: const TBool aDeletable, sl@0: TRequestStatus& aStatus sl@0: ); sl@0: sl@0: void CancelOutstandingRequest(); sl@0: sl@0: private: // Generic sl@0: sl@0: /// The certificate store we wrap, owned by us sl@0: MCTCertStore& iCertStore; sl@0: /// Pointer to the same object as iCertStore if it's writable, otherwise NULL sl@0: MCTWritableCertStore* iWritableCertStore; sl@0: /// File server session, used by unified key store sl@0: RFs iFs; sl@0: /// Unified keystore, created and destroyed on demand sl@0: CUnifiedKeyStore* iUnifiedKeyStore; sl@0: /// Current state of the active object sl@0: TState iState; sl@0: /// Request status of client request sl@0: TRequestStatus* iCallerStatus; sl@0: /// Key filter used for listing and adding certs sl@0: TCTKeyAttributeFilter iKeyFilter; sl@0: /// List of key infos returned by keystore sl@0: RMPointerArray iKeyInfos; sl@0: sl@0: // For Add requests sl@0: sl@0: /// Format of cert to add sl@0: TCertificateFormat iFormat; sl@0: /// Owner type of cert to add sl@0: TCertificateOwnerType iCertificateOwnerType; sl@0: /// Subject key id of cert to add, not owned by us sl@0: const TKeyIdentifier* iSubjectKeyId; sl@0: /// Issuer key id of cert to add, not owned by us sl@0: const TKeyIdentifier* iIssuerKeyId; sl@0: // Deletable flag of cert to add sl@0: TBool iDeletable; sl@0: sl@0: sl@0: /// Holds the subject key id extracted from the cert - used if the caller sl@0: /// doesn't supply it sl@0: TKeyIdentifier iComputedSubjectKeyId; sl@0: /// Label of the cert to add, owned by us sl@0: HBufC* iCertLabel; sl@0: /// Certificate data to add, owned by us sl@0: HBufC8* iCertificate; sl@0: sl@0: // For List requests sl@0: sl@0: /// Pointer to client's cert list, used to return certs, not owned by us sl@0: RMPointerArray* iCallerCerts; sl@0: /// Pointer to client's cert filter, not owned by us sl@0: const CCertAttributeFilter* iCallerFilter; sl@0: // Reference for the certstore change notification property. sl@0: RProperty& iPSCertstoreChangePropertyRef; sl@0: sl@0: }; sl@0: sl@0: #endif // __CCHECKEDCERTSTORE_H__