1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/certstore/CCheckedCertStore.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,187 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* CCheckedCertStore class implementation
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @internalComponent
1.26 +*/
1.27 +
1.28 +#ifndef __CCHECKEDCERTSTORE_H__
1.29 +#define __CCHECKEDCERTSTORE_H__
1.30 +
1.31 +#include <e32std.h>
1.32 +#include <ct.h>
1.33 +#include <e32property.h>
1.34 +#include <mctwritablecertstore.h>
1.35 +#include "unifiedkeystore.h"
1.36 +
1.37 +NONSHARABLE_CLASS(CCheckedCertStore) : public CActive, public MCTWritableCertStore
1.38 +{
1.39 +public:
1.40 + static CCheckedCertStore* NewCheckedCertStoreL(MCTTokenInterface*, RProperty&);
1.41 + static CCheckedCertStore* NewCheckedWritableCertStoreL(MCTTokenInterface*, RProperty&);
1.42 +public:
1.43 + void ConstructL();
1.44 +public: // MCTTokenInterface
1.45 + virtual MCTToken& Token();
1.46 +
1.47 +public: // MCTCertStore
1.48 + virtual void List(RMPointerArray<CCTCertInfo>& aCerts, const CCertAttributeFilter& aFilter,
1.49 + TRequestStatus& aStatus);
1.50 + virtual void CancelList();
1.51 + virtual void GetCert(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle,
1.52 + TRequestStatus& aStatus);
1.53 + virtual void CancelGetCert();
1.54 + virtual void Applications(const CCTCertInfo& aCertInfo, RArray<TUid>& aApplications,
1.55 + TRequestStatus& aStatus);
1.56 + virtual void CancelApplications();
1.57 + virtual void IsApplicable(const CCTCertInfo& aCertInfo, TUid aApplication,
1.58 + TBool& aIsApplicable, TRequestStatus& aStatus);
1.59 + virtual void CancelIsApplicable();
1.60 + virtual void Trusted(const CCTCertInfo& aCertInfo, TBool& aTrusted,
1.61 + TRequestStatus& aStatus);
1.62 + virtual void CancelTrusted();
1.63 + virtual void Retrieve(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert,
1.64 + TRequestStatus& aStatus);
1.65 + virtual void CancelRetrieve();
1.66 +
1.67 +
1.68 +public: // MCTWritableCertStore
1.69 +
1.70 + virtual void Add( const TDesC& aLabel, TCertificateFormat aFormat,
1.71 + TCertificateOwnerType aCertificateOwnerType,
1.72 + const TKeyIdentifier* aSubjectKeyId,
1.73 + const TKeyIdentifier* aIssuerKeyId,
1.74 + const TDesC8& aCert, TRequestStatus& aStatus);
1.75 +
1.76 + // new Add(.., TBool aDeletable, ..) method from MCTWritableCertStore
1.77 + virtual void Add( const TDesC& aLabel,
1.78 + TCertificateFormat aFormat,
1.79 + TCertificateOwnerType aCertificateOwnerType,
1.80 + const TKeyIdentifier* aSubjectKeyId,
1.81 + const TKeyIdentifier* aIssuerKeyId,
1.82 + const TDesC8& aCert,
1.83 + const TBool aDeletable,
1.84 + TRequestStatus& aStatus);
1.85 +
1.86 + virtual void CancelAdd();
1.87 + virtual void Remove(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus);
1.88 + virtual void CancelRemove();
1.89 + virtual void SetApplicability(const CCTCertInfo& aCertInfo,
1.90 + const RArray<TUid>& aApplications, TRequestStatus &aStatus);
1.91 + virtual void CancelSetApplicability();
1.92 + virtual void SetTrust(const CCTCertInfo& aCertInfo, TBool aTrusted,
1.93 + TRequestStatus& aStatus);
1.94 + virtual void CancelSetTrust();
1.95 +protected: // From CActive
1.96 + virtual void DoCancel();
1.97 + virtual void RunL();
1.98 + virtual TInt RunError(TInt aError);
1.99 +private:
1.100 + enum TState
1.101 + {
1.102 + EIdleState = 0,
1.103 + EList,
1.104 + EAdd, // attempts using new Add() with aDeletable param
1.105 + EInitKeyStoreForAdd,
1.106 + EInitKeyStoreForList,
1.107 + EGetKeyInfosForAdd,
1.108 + EGetKeyInfosForList,
1.109 + EOldAdd, // uses original Add() w/o aDeletable param
1.110 + // if the new Add is not supported
1.111 + ERemove,
1.112 + ESetApplicability,
1.113 + ESetTrust
1.114 + };
1.115 +private:
1.116 + CCheckedCertStore(MCTCertStore&, RProperty&);
1.117 + CCheckedCertStore(MCTWritableCertStore&, RProperty&);
1.118 + virtual ~CCheckedCertStore();
1.119 +private:
1.120 + void Complete(TInt aError);
1.121 + void Cleanup();
1.122 + void InitialiseKeyStoreL(TState aNextState);
1.123 + void BuildCheckedCertificateListL();
1.124 + void ComputeAndCheckSubjectKeyIdL();
1.125 +
1.126 + void DoAddL( const TDesC& aLabel,
1.127 + TCertificateFormat aFormat,
1.128 + TCertificateOwnerType aCertificateOwnerType,
1.129 + const TKeyIdentifier* aSubjectKeyId,
1.130 + const TKeyIdentifier* aIssuerKeyId,
1.131 + const TDesC8& aCert,
1.132 + const TBool aDeletable,
1.133 + TRequestStatus& aStatus
1.134 + );
1.135 +
1.136 + void CancelOutstandingRequest();
1.137 +
1.138 +private: // Generic
1.139 +
1.140 + /// The certificate store we wrap, owned by us
1.141 + MCTCertStore& iCertStore;
1.142 + /// Pointer to the same object as iCertStore if it's writable, otherwise NULL
1.143 + MCTWritableCertStore* iWritableCertStore;
1.144 + /// File server session, used by unified key store
1.145 + RFs iFs;
1.146 + /// Unified keystore, created and destroyed on demand
1.147 + CUnifiedKeyStore* iUnifiedKeyStore;
1.148 + /// Current state of the active object
1.149 + TState iState;
1.150 + /// Request status of client request
1.151 + TRequestStatus* iCallerStatus;
1.152 + /// Key filter used for listing and adding certs
1.153 + TCTKeyAttributeFilter iKeyFilter;
1.154 + /// List of key infos returned by keystore
1.155 + RMPointerArray<CCTKeyInfo> iKeyInfos;
1.156 +
1.157 + // For Add requests
1.158 +
1.159 + /// Format of cert to add
1.160 + TCertificateFormat iFormat;
1.161 + /// Owner type of cert to add
1.162 + TCertificateOwnerType iCertificateOwnerType;
1.163 + /// Subject key id of cert to add, not owned by us
1.164 + const TKeyIdentifier* iSubjectKeyId;
1.165 + /// Issuer key id of cert to add, not owned by us
1.166 + const TKeyIdentifier* iIssuerKeyId;
1.167 + // Deletable flag of cert to add
1.168 + TBool iDeletable;
1.169 +
1.170 +
1.171 + /// Holds the subject key id extracted from the cert - used if the caller
1.172 + /// doesn't supply it
1.173 + TKeyIdentifier iComputedSubjectKeyId;
1.174 + /// Label of the cert to add, owned by us
1.175 + HBufC* iCertLabel;
1.176 + /// Certificate data to add, owned by us
1.177 + HBufC8* iCertificate;
1.178 +
1.179 + // For List requests
1.180 +
1.181 + /// Pointer to client's cert list, used to return certs, not owned by us
1.182 + RMPointerArray<CCTCertInfo>* iCallerCerts;
1.183 + /// Pointer to client's cert filter, not owned by us
1.184 + const CCertAttributeFilter* iCallerFilter;
1.185 + // Reference for the certstore change notification property.
1.186 + RProperty& iPSCertstoreChangePropertyRef;
1.187 +
1.188 +};
1.189 +
1.190 +#endif // __CCHECKEDCERTSTORE_H__