First public contribution.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * CCheckedCertStore class implementation
25 #ifndef __CCHECKEDCERTSTORE_H__
26 #define __CCHECKEDCERTSTORE_H__
30 #include <e32property.h>
31 #include <mctwritablecertstore.h>
32 #include "unifiedkeystore.h"
34 NONSHARABLE_CLASS(CCheckedCertStore) : public CActive, public MCTWritableCertStore
37 static CCheckedCertStore* NewCheckedCertStoreL(MCTTokenInterface*, RProperty&);
38 static CCheckedCertStore* NewCheckedWritableCertStoreL(MCTTokenInterface*, RProperty&);
41 public: // MCTTokenInterface
42 virtual MCTToken& Token();
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();
65 public: // MCTWritableCertStore
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);
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,
80 const TBool aDeletable,
81 TRequestStatus& aStatus);
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();
95 virtual TInt RunError(TInt aError);
101 EAdd, // attempts using new Add() with aDeletable param
103 EInitKeyStoreForList,
106 EOldAdd, // uses original Add() w/o aDeletable param
107 // if the new Add is not supported
113 CCheckedCertStore(MCTCertStore&, RProperty&);
114 CCheckedCertStore(MCTWritableCertStore&, RProperty&);
115 virtual ~CCheckedCertStore();
117 void Complete(TInt aError);
119 void InitialiseKeyStoreL(TState aNextState);
120 void BuildCheckedCertificateListL();
121 void ComputeAndCheckSubjectKeyIdL();
123 void DoAddL( const TDesC& aLabel,
124 TCertificateFormat aFormat,
125 TCertificateOwnerType aCertificateOwnerType,
126 const TKeyIdentifier* aSubjectKeyId,
127 const TKeyIdentifier* aIssuerKeyId,
129 const TBool aDeletable,
130 TRequestStatus& aStatus
133 void CancelOutstandingRequest();
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
143 /// Unified keystore, created and destroyed on demand
144 CUnifiedKeyStore* iUnifiedKeyStore;
145 /// Current state of the active object
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;
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
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
173 /// Certificate data to add, owned by us
174 HBufC8* iCertificate;
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;
187 #endif // __CCHECKEDCERTSTORE_H__