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