sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* UNIFIEDCERTSTORE.H
|
sl@0
|
16 |
* The unified certificate store implementation
|
sl@0
|
17 |
*
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
@file
|
sl@0
|
23 |
@publishedAll
|
sl@0
|
24 |
@released
|
sl@0
|
25 |
*/
|
sl@0
|
26 |
|
sl@0
|
27 |
#ifndef __UNIFIEDCERTSTORE_H__
|
sl@0
|
28 |
#define __UNIFIEDCERTSTORE_H__
|
sl@0
|
29 |
|
sl@0
|
30 |
class CCertificate;
|
sl@0
|
31 |
|
sl@0
|
32 |
#include <signed.h>
|
sl@0
|
33 |
#include <e32std.h>
|
sl@0
|
34 |
#include <f32file.h>
|
sl@0
|
35 |
#include <e32property.h>
|
sl@0
|
36 |
#include <sacls.h>
|
sl@0
|
37 |
#include <mcertstore.h>
|
sl@0
|
38 |
#include <ct/rmpointerarray.h>
|
sl@0
|
39 |
#include <ct/rcpointerarray.h>
|
sl@0
|
40 |
|
sl@0
|
41 |
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
/**
|
sl@0
|
45 |
*
|
sl@0
|
46 |
* Publish and Subscribe - UnifiedCertSTore Category
|
sl@0
|
47 |
* Aliased here to System Category to prevent SC break.
|
sl@0
|
48 |
*
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
const TUid KUnifiedCertStorePropertyCat = {KUidSystemCategoryValue};
|
sl@0
|
51 |
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
*
|
sl@0
|
54 |
* Publish and subscribe key for UnifiedCertSTore.
|
sl@0
|
55 |
*/
|
sl@0
|
56 |
enum TUnifiedCertStoreKey
|
sl@0
|
57 |
{
|
sl@0
|
58 |
/**
|
sl@0
|
59 |
*
|
sl@0
|
60 |
* The Publish and subscribe key for the certstore changes.
|
sl@0
|
61 |
* If the client of the UnifiedCertstore needs to be notified when
|
sl@0
|
62 |
* certificate addition, removal and trust&application setting occurs,
|
sl@0
|
63 |
* the client needs to subscribe to KUnifiedCertStorePropertyCat and
|
sl@0
|
64 |
* EUnifiedCertStoreFlag.
|
sl@0
|
65 |
*
|
sl@0
|
66 |
* Aliased here to KUidUnifiedCertstore flag to avoid SC break.
|
sl@0
|
67 |
*/
|
sl@0
|
68 |
EUnifiedCertStoreFlag = KUidUnifiedCertstoreFlag
|
sl@0
|
69 |
};
|
sl@0
|
70 |
|
sl@0
|
71 |
/**
|
sl@0
|
72 |
*
|
sl@0
|
73 |
* The Unique ID for unknown hardware certstore, used as the input parameter when it is to be filtered.
|
sl@0
|
74 |
* @deprecated. Used only for Data compatibility.
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
|
sl@0
|
77 |
const TInt KUnknownHardwareCertStore = 0;
|
sl@0
|
78 |
|
sl@0
|
79 |
|
sl@0
|
80 |
/**
|
sl@0
|
81 |
*
|
sl@0
|
82 |
* The Unique ID for mutable software certstore, used as the input parameter when it is to be filtered.
|
sl@0
|
83 |
*
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
|
sl@0
|
86 |
const TInt KThirdPartyCertStore = 1;
|
sl@0
|
87 |
|
sl@0
|
88 |
|
sl@0
|
89 |
/**
|
sl@0
|
90 |
*
|
sl@0
|
91 |
* The Unique ID for SIM certstore, used as the input parameter when it is to be filtered.
|
sl@0
|
92 |
*
|
sl@0
|
93 |
*/
|
sl@0
|
94 |
|
sl@0
|
95 |
const TInt KSIMCertStore = 2;
|
sl@0
|
96 |
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
*
|
sl@0
|
99 |
* The Unique ID for WIM certstore, used as the input parameter when it is to be filtered.
|
sl@0
|
100 |
*
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
|
sl@0
|
103 |
const TInt KWIMCertStore = 3;
|
sl@0
|
104 |
|
sl@0
|
105 |
/**
|
sl@0
|
106 |
*
|
sl@0
|
107 |
* The Unique ID for UICC certstore, used as the input parameter when it is to be filtered.
|
sl@0
|
108 |
*
|
sl@0
|
109 |
*/
|
sl@0
|
110 |
const TInt KUICCCertStore = 4;
|
sl@0
|
111 |
|
sl@0
|
112 |
/**
|
sl@0
|
113 |
*
|
sl@0
|
114 |
* The Unique ID for immutable software certstore, used as the input parameter when it is to be filtered.
|
sl@0
|
115 |
*
|
sl@0
|
116 |
*/
|
sl@0
|
117 |
|
sl@0
|
118 |
const TInt KManufactureCertStore = 5;
|
sl@0
|
119 |
|
sl@0
|
120 |
// Forward declarations
|
sl@0
|
121 |
class MCTCertStore;
|
sl@0
|
122 |
class MCTWritableCertStore;
|
sl@0
|
123 |
class MCTTokenInterface;
|
sl@0
|
124 |
class MCTToken;
|
sl@0
|
125 |
class MCTTokenType;
|
sl@0
|
126 |
class CCTCertInfo;
|
sl@0
|
127 |
class CCertAttributeFilter;
|
sl@0
|
128 |
class CCTTokenTypeInfo;
|
sl@0
|
129 |
class TCTTokenObjectHandle;
|
sl@0
|
130 |
class CCheckedCertStore;
|
sl@0
|
131 |
|
sl@0
|
132 |
// This class is forward declared to avoid including its definition in this
|
sl@0
|
133 |
// exported header file because it must only be used internally.
|
sl@0
|
134 |
class CUnifiedCertStoreWorkingVars;
|
sl@0
|
135 |
class CX500DistinguishedName;
|
sl@0
|
136 |
|
sl@0
|
137 |
/**
|
sl@0
|
138 |
* The unified certificate store.
|
sl@0
|
139 |
*
|
sl@0
|
140 |
* This class provides a certificate store whose contents are the sum of the
|
sl@0
|
141 |
* contents of all certificate store implementations on the device. It is
|
sl@0
|
142 |
* intended as the single point of access for clients wishing to use certificate
|
sl@0
|
143 |
* stores.
|
sl@0
|
144 |
*
|
sl@0
|
145 |
* Since this class is intended for widespread use, capability checks relating
|
sl@0
|
146 |
* to certificate access are documented here even though the checks are actually
|
sl@0
|
147 |
* made in the individual cert store implementations.
|
sl@0
|
148 |
*
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
NONSHARABLE_CLASS(CUnifiedCertStore) : public CActive, public MCertStore
|
sl@0
|
151 |
{
|
sl@0
|
152 |
public:
|
sl@0
|
153 |
/**
|
sl@0
|
154 |
* Creates a new CUnifiedCertStore
|
sl@0
|
155 |
*
|
sl@0
|
156 |
* @param aFs A file server session. It must already be open.
|
sl@0
|
157 |
* @param aOpenForWrite ETrue if the stores must be opened with write access
|
sl@0
|
158 |
* (e.g. for adding certificates) and EFalse if the user
|
sl@0
|
159 |
* only needs read-only access.
|
sl@0
|
160 |
* @return A pointer to an instance of the CUnifiedCertStore class.
|
sl@0
|
161 |
*/
|
sl@0
|
162 |
IMPORT_C static CUnifiedCertStore* NewL(RFs& aFs, TBool aOpenForWrite);
|
sl@0
|
163 |
|
sl@0
|
164 |
/**
|
sl@0
|
165 |
* Creates a new CUnifiedCertStore and pushes it on the cleanup stack.
|
sl@0
|
166 |
*
|
sl@0
|
167 |
* @param aFs A file server session. It must already be open.
|
sl@0
|
168 |
* @param aOpenForWrite ETrue if the stores must be opened with write access
|
sl@0
|
169 |
* (e.g. for adding certificates) and EFalse if the user
|
sl@0
|
170 |
* only needs read-only access.
|
sl@0
|
171 |
* @return A pointer to an instance of the CUnifiedCertStore class.
|
sl@0
|
172 |
*/
|
sl@0
|
173 |
IMPORT_C static CUnifiedCertStore* NewLC(RFs& aFs, TBool aOpenForWrite);
|
sl@0
|
174 |
/**
|
sl@0
|
175 |
* Creates a new CUnifiedCertStore with the sequence filter, so that multiple certstores that are managed
|
sl@0
|
176 |
* by it will be filtered and ordered.
|
sl@0
|
177 |
*
|
sl@0
|
178 |
* @param aFs A file server session. It must already be open.
|
sl@0
|
179 |
* @param aOpenForWrite ETrue if the stores must be opened with write access
|
sl@0
|
180 |
* (e.g. for adding certificates) and EFalse if the user
|
sl@0
|
181 |
* only needs read-only access. Ownership is taken.
|
sl@0
|
182 |
* @param aOrderFilter An array of the unique sequence IDs specifying CertStore ordering.
|
sl@0
|
183 |
* @return A pointer to an instance of the CUnifiedCertStore class.
|
sl@0
|
184 |
*/
|
sl@0
|
185 |
IMPORT_C static CUnifiedCertStore* NewL(RFs& aFs,
|
sl@0
|
186 |
TBool aOpenForWrite,
|
sl@0
|
187 |
RArray<TInt>& aOrderFilter);
|
sl@0
|
188 |
/**
|
sl@0
|
189 |
* Creates a new CUnifiedCertStore with the sequence filter, so that multiple certstores that are managed
|
sl@0
|
190 |
* by it will be filtered and ordered, and it is pushed on the cleanup stack.
|
sl@0
|
191 |
*
|
sl@0
|
192 |
* @param aFs A file server session. It must already be open.
|
sl@0
|
193 |
* @param aOpenForWrite ETrue if the stores must be opened with write access
|
sl@0
|
194 |
* (e.g. for adding certificates) and EFalse if the user
|
sl@0
|
195 |
* only needs read-only access. Ownership is taken.
|
sl@0
|
196 |
* @param aOrderFilter An array of the unique sequence IDs specifying CertStore ordering.
|
sl@0
|
197 |
* @return A pointer to an instance of the CUnifiedCertStore class.
|
sl@0
|
198 |
*/
|
sl@0
|
199 |
IMPORT_C static CUnifiedCertStore* NewLC(RFs& aFs,
|
sl@0
|
200 |
TBool aOpenForWrite,
|
sl@0
|
201 |
RArray<TInt>& aOrderFilter);
|
sl@0
|
202 |
|
sl@0
|
203 |
/**
|
sl@0
|
204 |
* The destructor destroys all the resources owned by this object.
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
IMPORT_C ~CUnifiedCertStore();
|
sl@0
|
207 |
|
sl@0
|
208 |
/**
|
sl@0
|
209 |
* Initializes the manager.
|
sl@0
|
210 |
*
|
sl@0
|
211 |
* It must be called after the manager has been constructed
|
sl@0
|
212 |
* and before any call to the manager functions.
|
sl@0
|
213 |
*
|
sl@0
|
214 |
* This is an asynchronous request.
|
sl@0
|
215 |
*
|
sl@0
|
216 |
* @param aStatus The request status object; contains the result of the Initialize()
|
sl@0
|
217 |
* request when complete. Set to KErrCancel if any outstanding request is cancelled.
|
sl@0
|
218 |
*/
|
sl@0
|
219 |
IMPORT_C void Initialize(TRequestStatus& aStatus);
|
sl@0
|
220 |
|
sl@0
|
221 |
/**
|
sl@0
|
222 |
* Cancels an ongoing Initialize() operation.
|
sl@0
|
223 |
*
|
sl@0
|
224 |
* The operation completes with KErrCancel.
|
sl@0
|
225 |
*/
|
sl@0
|
226 |
IMPORT_C void CancelInitialize();
|
sl@0
|
227 |
|
sl@0
|
228 |
public: // Implementation of MCertStore interface
|
sl@0
|
229 |
|
sl@0
|
230 |
/** Lists all certificates that satisfy the supplied filter.
|
sl@0
|
231 |
*
|
sl@0
|
232 |
* @param aCertInfos An array that the returned certificates are added to .
|
sl@0
|
233 |
* @param aFilter A filter to restrict which certificates are returned.
|
sl@0
|
234 |
* @param aStatus The request status object.
|
sl@0
|
235 |
*
|
sl@0
|
236 |
*/
|
sl@0
|
237 |
virtual void List(RMPointerArray<CCTCertInfo>& aCertInfos,
|
sl@0
|
238 |
const CCertAttributeFilter& aFilter, TRequestStatus& aStatus);
|
sl@0
|
239 |
virtual void CancelList();
|
sl@0
|
240 |
virtual void GetCert(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle,
|
sl@0
|
241 |
TRequestStatus& aStatus);
|
sl@0
|
242 |
virtual void CancelGetCert();
|
sl@0
|
243 |
|
sl@0
|
244 |
/** Gets the list of applications . Applications are represented by UIDs .
|
sl@0
|
245 |
*
|
sl@0
|
246 |
* @param aCertInfos An array of certificates .
|
sl@0
|
247 |
* @param aApplications An array that the returned application UIDs are added to.
|
sl@0
|
248 |
* @param aStatus The request status object.
|
sl@0
|
249 |
*
|
sl@0
|
250 |
*/
|
sl@0
|
251 |
virtual void Applications(const CCTCertInfo& aCertInfo,
|
sl@0
|
252 |
RArray<TUid>& aApplications, TRequestStatus &aStatus);
|
sl@0
|
253 |
virtual void CancelApplications();
|
sl@0
|
254 |
virtual void IsApplicable(const CCTCertInfo& aCertInfo, TUid aApplication,
|
sl@0
|
255 |
TBool& aIsApplicable, TRequestStatus& aStatus);
|
sl@0
|
256 |
virtual void CancelIsApplicable();
|
sl@0
|
257 |
virtual void Trusted(const CCTCertInfo& aCertInfo, TBool& aTrusted,
|
sl@0
|
258 |
TRequestStatus& aStatus);
|
sl@0
|
259 |
virtual void CancelTrusted();
|
sl@0
|
260 |
virtual void Retrieve(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert,
|
sl@0
|
261 |
TRequestStatus& aStatus);
|
sl@0
|
262 |
virtual void CancelRetrieve();
|
sl@0
|
263 |
|
sl@0
|
264 |
public: // Functions defined in MCTWritableCertStore except Add functions
|
sl@0
|
265 |
|
sl@0
|
266 |
/**
|
sl@0
|
267 |
* Removes a certificate.
|
sl@0
|
268 |
*
|
sl@0
|
269 |
* @param aCertInfo The certificate to be removed.
|
sl@0
|
270 |
* @param aStatus The request status object; contains the result of the Remove()
|
sl@0
|
271 |
* request when complete. Set to KErrCancel if an outstanding request is cancelled.
|
sl@0
|
272 |
*
|
sl@0
|
273 |
* @capability WriteUserData This requires the WriteUserData capability when
|
sl@0
|
274 |
* applied to user certificates.
|
sl@0
|
275 |
* @capability WriteDeviceData This requires the WriteDeviceData capability
|
sl@0
|
276 |
* when applied to CA certificates.
|
sl@0
|
277 |
* @leave KErrPermissionDenied If the caller doesn't have the required
|
sl@0
|
278 |
* capabilities.
|
sl@0
|
279 |
*/
|
sl@0
|
280 |
IMPORT_C void Remove(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus);
|
sl@0
|
281 |
|
sl@0
|
282 |
/**
|
sl@0
|
283 |
* Cancels an ongoing Remove() operation.
|
sl@0
|
284 |
*
|
sl@0
|
285 |
* The operation completes with KErrCancel.
|
sl@0
|
286 |
*/
|
sl@0
|
287 |
IMPORT_C void CancelRemove();
|
sl@0
|
288 |
|
sl@0
|
289 |
/**
|
sl@0
|
290 |
* Replaces the current applicability settings with the settings in the
|
sl@0
|
291 |
* supplied array.
|
sl@0
|
292 |
*
|
sl@0
|
293 |
* This should only be called for CA certificates - it has no meaning for
|
sl@0
|
294 |
* user certificates.
|
sl@0
|
295 |
*
|
sl@0
|
296 |
* @param aCertInfo The certificate whose applicability should be updated.
|
sl@0
|
297 |
* @param aApplications The new applicability settings. Ownership of this
|
sl@0
|
298 |
* remains with the caller, and it must remain valid for the
|
sl@0
|
299 |
* lifetime of the call.
|
sl@0
|
300 |
* @param aStatus The request status object; contains the result of the SetApplicability()
|
sl@0
|
301 |
* request when complete. Set to KErrCancel, if an outstanding request is cancelled.
|
sl@0
|
302 |
*
|
sl@0
|
303 |
* @capability WriteDeviceData This requires the WriteDeviceData capability.
|
sl@0
|
304 |
* @leave KErrPermissionDenied If the caller doesn't have the required capabilities.
|
sl@0
|
305 |
*/
|
sl@0
|
306 |
IMPORT_C void SetApplicability(const CCTCertInfo& aCertInfo,
|
sl@0
|
307 |
const RArray<TUid>& aApplications, TRequestStatus &aStatus);
|
sl@0
|
308 |
|
sl@0
|
309 |
/**
|
sl@0
|
310 |
* Cancels an ongoing SetApplicability() operation.
|
sl@0
|
311 |
*
|
sl@0
|
312 |
* The operation completes with KErrCancel.
|
sl@0
|
313 |
*/
|
sl@0
|
314 |
IMPORT_C void CancelSetApplicability();
|
sl@0
|
315 |
|
sl@0
|
316 |
/**
|
sl@0
|
317 |
* Changes the trust settings.
|
sl@0
|
318 |
*
|
sl@0
|
319 |
* A CA certificate is trusted if the user is willing to use it for authenticating
|
sl@0
|
320 |
* servers. It has no meaning with other types of certificates.
|
sl@0
|
321 |
*
|
sl@0
|
322 |
* @param aCertInfo The certificate to be updated.
|
sl@0
|
323 |
* @param aTrusted ETrue, if trusted; EFalse, otherwise.
|
sl@0
|
324 |
* @param aStatus The request status object; contains the result of the SetTrust()
|
sl@0
|
325 |
* request when complete. Set to KErrCancel, if an outstanding request is cancelled.
|
sl@0
|
326 |
*
|
sl@0
|
327 |
* @capability WriteDeviceData This requires the WriteDeviceData capability.
|
sl@0
|
328 |
* @leave KErrPermissionDenied If the caller doesn't have the required capabilities.
|
sl@0
|
329 |
*/
|
sl@0
|
330 |
IMPORT_C void SetTrust(const CCTCertInfo& aCertInfo, TBool aTrusted,
|
sl@0
|
331 |
TRequestStatus& aStatus);
|
sl@0
|
332 |
|
sl@0
|
333 |
/**
|
sl@0
|
334 |
* Cancels an ongoing SetTrust() operation.
|
sl@0
|
335 |
*
|
sl@0
|
336 |
* The operation completes with KErrCancel.
|
sl@0
|
337 |
*/
|
sl@0
|
338 |
IMPORT_C void CancelSetTrust();
|
sl@0
|
339 |
|
sl@0
|
340 |
public:
|
sl@0
|
341 |
/**
|
sl@0
|
342 |
* Lists all certificates that have a particular subject DN.
|
sl@0
|
343 |
*
|
sl@0
|
344 |
* @param aCertInfos An array that the returned certificates are added to
|
sl@0
|
345 |
* @param aFilter A filter to restrict which certificates are returned.
|
sl@0
|
346 |
* @param aIssuer Only certificates with this issuer DN will be returned
|
sl@0
|
347 |
* @param aStatus Asynchronous request status.
|
sl@0
|
348 |
*/
|
sl@0
|
349 |
IMPORT_C void List(RMPointerArray<CCTCertInfo>& aCertInfos,
|
sl@0
|
350 |
const CCertAttributeFilter& aFilter,
|
sl@0
|
351 |
const TDesC8& aIssuer,
|
sl@0
|
352 |
TRequestStatus& aStatus);
|
sl@0
|
353 |
|
sl@0
|
354 |
/**
|
sl@0
|
355 |
* Lists all certificates that have a particular issuer.
|
sl@0
|
356 |
*
|
sl@0
|
357 |
* @param aCertInfos An array that the returned certificates are added to
|
sl@0
|
358 |
* @param aFilter A filter to restrict which certificates are returned.
|
sl@0
|
359 |
* @param aIssuers Only certificates with this issuer will be returned
|
sl@0
|
360 |
* @param aStatus Asynchronous request status.
|
sl@0
|
361 |
*/
|
sl@0
|
362 |
IMPORT_C void List(RMPointerArray<CCTCertInfo>& aCertInfos,
|
sl@0
|
363 |
const CCertAttributeFilter& aFilter,
|
sl@0
|
364 |
RPointerArray<const TDesC8> aIssuers,
|
sl@0
|
365 |
TRequestStatus& aStatus);
|
sl@0
|
366 |
|
sl@0
|
367 |
/**
|
sl@0
|
368 |
* Retrieves a certificate as a parsed object.
|
sl@0
|
369 |
*
|
sl@0
|
370 |
* This will only work for certificates that have a CCertificate-derived
|
sl@0
|
371 |
* representation, in other words X509 and WTLS certificates. If called for
|
sl@0
|
372 |
* a URL certificate, KErrNotSupported is returned.
|
sl@0
|
373 |
*
|
sl@0
|
374 |
* @param aCertInfo The certificate to retrieve
|
sl@0
|
375 |
* @param aCert The returned certificate. This object can safely be up-cast
|
sl@0
|
376 |
* to a CX509Certificate or CWTLSCertificate if it's known that
|
sl@0
|
377 |
* that is the certificate format.
|
sl@0
|
378 |
* @param aStatus Asynchronous request status.
|
sl@0
|
379 |
*
|
sl@0
|
380 |
* @capability ReadUserData This requires the ReadUserData capability when
|
sl@0
|
381 |
* applied to user certificates, as these may contain
|
sl@0
|
382 |
* sensitive user data.
|
sl@0
|
383 |
* @leave KErrPermissionDenied If called for a user certificate when the
|
sl@0
|
384 |
* caller doesn't have the ReadUserData capability.
|
sl@0
|
385 |
*/
|
sl@0
|
386 |
IMPORT_C void Retrieve(const CCTCertInfo& aCertInfo, CCertificate*& aCert,
|
sl@0
|
387 |
TRequestStatus& aStatus);
|
sl@0
|
388 |
|
sl@0
|
389 |
/**
|
sl@0
|
390 |
* Gets the number of certificate stores.
|
sl@0
|
391 |
*
|
sl@0
|
392 |
* @return The total number of certificate stores.
|
sl@0
|
393 |
*/
|
sl@0
|
394 |
IMPORT_C TInt CertStoreCount() const;
|
sl@0
|
395 |
|
sl@0
|
396 |
/**
|
sl@0
|
397 |
* Gets a particular certificate store.
|
sl@0
|
398 |
*
|
sl@0
|
399 |
* @param aIndex The index of the required certificate store.
|
sl@0
|
400 |
* A number between 0 and CertStoreCount() - 1.
|
sl@0
|
401 |
* @return The certificate store.
|
sl@0
|
402 |
*/
|
sl@0
|
403 |
IMPORT_C MCTCertStore& CertStore(TInt aIndex);
|
sl@0
|
404 |
|
sl@0
|
405 |
/**
|
sl@0
|
406 |
* Gets the number of writeable certificate stores.
|
sl@0
|
407 |
*
|
sl@0
|
408 |
* @return The number of writeable certificate stores.
|
sl@0
|
409 |
*/
|
sl@0
|
410 |
IMPORT_C TInt WritableCertStoreCount() const;
|
sl@0
|
411 |
|
sl@0
|
412 |
/**
|
sl@0
|
413 |
* Gets a particular writeable certificate store.
|
sl@0
|
414 |
*
|
sl@0
|
415 |
* @param aIndex The index of the required certificate store.
|
sl@0
|
416 |
* A number between 0 and WriteableCertStoreCount() - 1.
|
sl@0
|
417 |
* @return The writeable certificate store.
|
sl@0
|
418 |
*/
|
sl@0
|
419 |
IMPORT_C MCTWritableCertStore& WritableCertStore(TInt aIndex);
|
sl@0
|
420 |
|
sl@0
|
421 |
/**
|
sl@0
|
422 |
* Gets the number of read-only certificate stores.
|
sl@0
|
423 |
*
|
sl@0
|
424 |
* @return The number of read-only certificate stores.
|
sl@0
|
425 |
*/
|
sl@0
|
426 |
IMPORT_C TInt ReadOnlyCertStoreCount() const;
|
sl@0
|
427 |
|
sl@0
|
428 |
/**
|
sl@0
|
429 |
* Gets a particular read-only certificate store.
|
sl@0
|
430 |
*
|
sl@0
|
431 |
* @param aIndex The index of the required certificate store.
|
sl@0
|
432 |
* A number between 0 and ReadOnlyCertStoreCount() - 1.
|
sl@0
|
433 |
* @return The read-only certificate store.
|
sl@0
|
434 |
*/
|
sl@0
|
435 |
IMPORT_C MCTCertStore& ReadOnlyCertStore(TInt aIndex);
|
sl@0
|
436 |
|
sl@0
|
437 |
private:
|
sl@0
|
438 |
enum TState
|
sl@0
|
439 |
{
|
sl@0
|
440 |
EIdle,
|
sl@0
|
441 |
|
sl@0
|
442 |
EInitializeGetTokenList,
|
sl@0
|
443 |
EInitializeGetToken,
|
sl@0
|
444 |
EInitializeGetWritableInterface,
|
sl@0
|
445 |
EInitializeGetReadableInterface,
|
sl@0
|
446 |
EInitializeGetReadableInterfaceFinished,
|
sl@0
|
447 |
EInitializeFinished,
|
sl@0
|
448 |
|
sl@0
|
449 |
EList,
|
sl@0
|
450 |
ERetrieve,
|
sl@0
|
451 |
ERetrieveForList,
|
sl@0
|
452 |
|
sl@0
|
453 |
EGetCert,
|
sl@0
|
454 |
EApplications,
|
sl@0
|
455 |
EIsApplicable,
|
sl@0
|
456 |
ETrusted,
|
sl@0
|
457 |
ERetrieveData,
|
sl@0
|
458 |
ERemove,
|
sl@0
|
459 |
ESetApplicability,
|
sl@0
|
460 |
ESetTrust
|
sl@0
|
461 |
};
|
sl@0
|
462 |
enum TCompareResults
|
sl@0
|
463 |
{
|
sl@0
|
464 |
ENo,
|
sl@0
|
465 |
EYes,
|
sl@0
|
466 |
EMaybe
|
sl@0
|
467 |
};
|
sl@0
|
468 |
private:
|
sl@0
|
469 |
CUnifiedCertStore(RFs& aFs, TBool aOpenForWrite);
|
sl@0
|
470 |
void ConstructL(RArray<TInt>& aOrderFilter);
|
sl@0
|
471 |
void DoCancel();
|
sl@0
|
472 |
void RunL();
|
sl@0
|
473 |
TInt RunError(TInt aError);
|
sl@0
|
474 |
|
sl@0
|
475 |
// Implementations for asynchronous operations
|
sl@0
|
476 |
void InitializeL();
|
sl@0
|
477 |
void ListL(RMPointerArray<CCTCertInfo>& aCertInfos,
|
sl@0
|
478 |
const CCertAttributeFilter& aFilter);
|
sl@0
|
479 |
void ListL(RMPointerArray<CCTCertInfo>& aCertInfos,
|
sl@0
|
480 |
const CCertAttributeFilter& aFilter,
|
sl@0
|
481 |
RPointerArray<const TDesC8> aIssuers);
|
sl@0
|
482 |
void RetrieveL(const CCTCertInfo& aCertInfo, CCertificate*& aCert);
|
sl@0
|
483 |
void GetCertL(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle);
|
sl@0
|
484 |
void ApplicationsL(const CCTCertInfo& aCertInfo, RArray<TUid>& aApplications);
|
sl@0
|
485 |
void IsApplicableL(const CCTCertInfo& aCertInfo, TUid aApplication,
|
sl@0
|
486 |
TBool& aIsApplicable);
|
sl@0
|
487 |
void TrustedL(const CCTCertInfo& aCertInfo, TBool& aTrusted);
|
sl@0
|
488 |
void RetrieveDataL(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert);
|
sl@0
|
489 |
void RemoveL(const CCTCertInfo& aCertInfo);
|
sl@0
|
490 |
void SetApplicabilityL(const CCTCertInfo& aCertInfo,
|
sl@0
|
491 |
const RArray<TUid>& aApplications);
|
sl@0
|
492 |
void SetTrustL(const CCTCertInfo& aCertInfo, TBool aTrusted);
|
sl@0
|
493 |
|
sl@0
|
494 |
// Helper functions
|
sl@0
|
495 |
void AllocWorkingVarsL();
|
sl@0
|
496 |
void BeginAsyncOp(TRequestStatus& aStatus, TState aState);
|
sl@0
|
497 |
void DestroyTemporaryMembers();
|
sl@0
|
498 |
MCTCertStore* GetCertStore(const TCTTokenObjectHandle& aHandle);
|
sl@0
|
499 |
void FindCertStoreL(const TCTTokenObjectHandle& aHandle);
|
sl@0
|
500 |
void FindWritableCertStoreL(const TCTTokenObjectHandle& aHandle);
|
sl@0
|
501 |
TCompareResults CompareCertInfoDN(const CCTCertInfo* aCertInfo);
|
sl@0
|
502 |
TBool MatchL(const CX500DistinguishedName& aName) const;
|
sl@0
|
503 |
void Complete(TInt aError);
|
sl@0
|
504 |
void CancelOutstandingRequest();
|
sl@0
|
505 |
|
sl@0
|
506 |
// Filters CertStores according to specified order.
|
sl@0
|
507 |
void ApplyOrderingL(RCPointerArray<CCTTokenTypeInfo>& aTokenTypes);
|
sl@0
|
508 |
|
sl@0
|
509 |
void FilterTokenTypesL(RCPointerArray<CCTTokenTypeInfo>& aSearchTokenTypes,
|
sl@0
|
510 |
RCPointerArray<CCTTokenTypeInfo>& aTempTokenTypes,
|
sl@0
|
511 |
TInt aOrderAttribute);
|
sl@0
|
512 |
|
sl@0
|
513 |
private:
|
sl@0
|
514 |
/**
|
sl@0
|
515 |
* A file server session, this is not logically a part of this class
|
sl@0
|
516 |
* but is needed for the client store and the file certstore.
|
sl@0
|
517 |
*/
|
sl@0
|
518 |
RFs& iFs;
|
sl@0
|
519 |
|
sl@0
|
520 |
TBool iOpenedForWrite;
|
sl@0
|
521 |
|
sl@0
|
522 |
RPointerArray<CCheckedCertStore> iReadOnlyCertStores;
|
sl@0
|
523 |
RPointerArray<CCheckedCertStore> iWritableCertStores;
|
sl@0
|
524 |
RPointerArray<CCheckedCertStore> iCertStores;
|
sl@0
|
525 |
|
sl@0
|
526 |
TBool iCurrentlyDoingReadOnly;
|
sl@0
|
527 |
|
sl@0
|
528 |
/**
|
sl@0
|
529 |
* This a TokenType retrieved from the iTokenTypes array.
|
sl@0
|
530 |
* We use this to get a list of Tokens and to open these Tokens.
|
sl@0
|
531 |
*/
|
sl@0
|
532 |
MCTTokenType* iTokenType;
|
sl@0
|
533 |
|
sl@0
|
534 |
/**
|
sl@0
|
535 |
* This is the list of Tokens for one of the Token Types of iTokenTypes.
|
sl@0
|
536 |
*/
|
sl@0
|
537 |
RCPointerArray<HBufC> iTokens;
|
sl@0
|
538 |
|
sl@0
|
539 |
/** All the UIDs of hardware token types */
|
sl@0
|
540 |
RArray<TUid> iHardwareTypeUids;
|
sl@0
|
541 |
/**
|
sl@0
|
542 |
* This is used as an index for the iTokens array when we try
|
sl@0
|
543 |
* to get an interface to each of the tokens.
|
sl@0
|
544 |
*/
|
sl@0
|
545 |
TInt iIndexTokens;
|
sl@0
|
546 |
|
sl@0
|
547 |
/**
|
sl@0
|
548 |
* A Token interface. We will use the interface to get a readable or writable
|
sl@0
|
549 |
* certstore interface. The value is updated at EInitializeGetToken and used
|
sl@0
|
550 |
* at EInitializeGetWritableInterface.
|
sl@0
|
551 |
*/
|
sl@0
|
552 |
MCTToken* iToken;
|
sl@0
|
553 |
|
sl@0
|
554 |
/**
|
sl@0
|
555 |
* We use this to (temporarily) store the interface we obtained from iToken.
|
sl@0
|
556 |
* It will be inserted in iWritableCertStores or iCertStores.
|
sl@0
|
557 |
*/
|
sl@0
|
558 |
MCTTokenInterface* iTokenInterface;
|
sl@0
|
559 |
|
sl@0
|
560 |
/**
|
sl@0
|
561 |
The index of the plugin certstore that is being processed
|
sl@0
|
562 |
*/
|
sl@0
|
563 |
TInt iIndex;
|
sl@0
|
564 |
|
sl@0
|
565 |
/**
|
sl@0
|
566 |
* This is the status of the caller of an asynchronous function. It must be set
|
sl@0
|
567 |
* to KRequestPending by the function while doing the processing.
|
sl@0
|
568 |
*/
|
sl@0
|
569 |
TRequestStatus* iClientStatus;
|
sl@0
|
570 |
|
sl@0
|
571 |
TState iState;
|
sl@0
|
572 |
|
sl@0
|
573 |
TBool iIsInitialized;
|
sl@0
|
574 |
|
sl@0
|
575 |
/**
|
sl@0
|
576 |
* This member holds all the variables that are only used to store temporary results
|
sl@0
|
577 |
* while performing a given operation. It must be initialized at the start of the
|
sl@0
|
578 |
* operation and deleted at the end of it whether the opeartion completes successfully
|
sl@0
|
579 |
* or not. When no operation is being performed it must be 0.
|
sl@0
|
580 |
*/
|
sl@0
|
581 |
CUnifiedCertStoreWorkingVars* iWorkingVars;
|
sl@0
|
582 |
|
sl@0
|
583 |
/**
|
sl@0
|
584 |
* The cert store in use by an outstanding async operation.
|
sl@0
|
585 |
*/
|
sl@0
|
586 |
MCTCertStore *iCurrentCertStore;
|
sl@0
|
587 |
|
sl@0
|
588 |
/**
|
sl@0
|
589 |
* The writable cert store in use by an outstanding async operation.
|
sl@0
|
590 |
*/
|
sl@0
|
591 |
MCTWritableCertStore *iCurrentWritableCertStore;
|
sl@0
|
592 |
|
sl@0
|
593 |
// Padding to keep class size constant
|
sl@0
|
594 |
TInt32 iUnused1;
|
sl@0
|
595 |
TInt32 iUnused2;
|
sl@0
|
596 |
|
sl@0
|
597 |
// An array of Uids specifying Token Type ordering
|
sl@0
|
598 |
RArray<TInt> iOrderAttributes;
|
sl@0
|
599 |
|
sl@0
|
600 |
// Publish and subscribe property which is used to notify the
|
sl@0
|
601 |
// cerificate addition,removal and application&trust setting.
|
sl@0
|
602 |
RProperty iPSCertstoreChangeProperty;
|
sl@0
|
603 |
|
sl@0
|
604 |
};
|
sl@0
|
605 |
|
sl@0
|
606 |
#endif
|