sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1998-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 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@internalTechnology
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#ifndef __TEST1CERTSTORE_H__
|
sl@0
|
25 |
#define __TEST1CERTSTORE_H__
|
sl@0
|
26 |
|
sl@0
|
27 |
#include <s32file.h>
|
sl@0
|
28 |
#include <e32std.h>
|
sl@0
|
29 |
#include <ct.h>
|
sl@0
|
30 |
#include <mctwritablecertstore.h>
|
sl@0
|
31 |
#include <unifiedkeystore.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
#include "test1certstoretoken.h"
|
sl@0
|
34 |
|
sl@0
|
35 |
#define CACERTS2 0
|
sl@0
|
36 |
|
sl@0
|
37 |
class CFileCertStoreMapping;
|
sl@0
|
38 |
class CFileCertStoreMappings;
|
sl@0
|
39 |
|
sl@0
|
40 |
/**
|
sl@0
|
41 |
* This class implements a certificate store which is stored on a file on the device.
|
sl@0
|
42 |
*
|
sl@0
|
43 |
* CTest1CertStore initialization.
|
sl@0
|
44 |
* NewL and NewLC call the constructor and ConstructL. The constructor does nothing
|
sl@0
|
45 |
* except initializing to 0. ConstructL connects to fs, then calls
|
sl@0
|
46 |
* OpenStoreL, then RestoreL and then sets the values of iStoreInfo.
|
sl@0
|
47 |
* OpenStoreL opens the store ad copies it from the ROM if necessary.
|
sl@0
|
48 |
* RestoreL()
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
class CTest1CertStore : public CActive, public MCTWritableCertStore
|
sl@0
|
51 |
{
|
sl@0
|
52 |
public:
|
sl@0
|
53 |
static CTest1CertStore* NewL(RFs& aFs, CTest1CertStoreToken& aToken,
|
sl@0
|
54 |
const TDesC& aFileName, TFileMode aMode);
|
sl@0
|
55 |
|
sl@0
|
56 |
public: // from MCTTokenInterface
|
sl@0
|
57 |
virtual MCTToken& Token();
|
sl@0
|
58 |
protected: // from MCTTokenInterface
|
sl@0
|
59 |
virtual void DoRelease();
|
sl@0
|
60 |
|
sl@0
|
61 |
|
sl@0
|
62 |
public: // from MCTCertStore
|
sl@0
|
63 |
virtual void List(RMPointerArray<CCTCertInfo>& aCerts,
|
sl@0
|
64 |
const CCertAttributeFilter& aFilter, TRequestStatus& aStatus);
|
sl@0
|
65 |
virtual void CancelList();
|
sl@0
|
66 |
virtual void GetCert(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle,
|
sl@0
|
67 |
TRequestStatus& aStatus);
|
sl@0
|
68 |
virtual void CancelGetCert();
|
sl@0
|
69 |
virtual void Applications(const CCTCertInfo& aCertInfo, RArray<TUid>& aApplications,
|
sl@0
|
70 |
TRequestStatus& aStatus);
|
sl@0
|
71 |
virtual void CancelApplications();
|
sl@0
|
72 |
virtual void IsApplicable(const CCTCertInfo& aCertInfo, TUid aApplication,
|
sl@0
|
73 |
TBool& aIsApplicable, TRequestStatus& aStatus);
|
sl@0
|
74 |
virtual void CancelIsApplicable();
|
sl@0
|
75 |
virtual void Trusted(const CCTCertInfo& aCertInfo, TBool& aTrusted,
|
sl@0
|
76 |
TRequestStatus& aStatus);
|
sl@0
|
77 |
virtual void CancelTrusted();
|
sl@0
|
78 |
|
sl@0
|
79 |
// this could be asynch or sync depending on state of compile flag CERTSTORE_SOFTWARE_ASYNCH
|
sl@0
|
80 |
virtual void Retrieve(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert,
|
sl@0
|
81 |
TRequestStatus& aStatus);
|
sl@0
|
82 |
virtual void CancelRetrieve();
|
sl@0
|
83 |
virtual void Capabilities(const CCTCertInfo& aCertInfo, TCapabilitySet& aCapbilitiesOut,
|
sl@0
|
84 |
TRequestStatus& aStatus);
|
sl@0
|
85 |
virtual void CancelCapabilities();
|
sl@0
|
86 |
virtual void IsMandatory(const CCTCertInfo& aCertInfo, TBool& aMandatoryOut,
|
sl@0
|
87 |
TRequestStatus& aStatus);
|
sl@0
|
88 |
virtual void CancelIsMandatory();
|
sl@0
|
89 |
|
sl@0
|
90 |
public: // from MCTWritableCertStore
|
sl@0
|
91 |
virtual void Add(const TDesC& aLabel, TCertificateFormat aFormat,
|
sl@0
|
92 |
TCertificateOwnerType aCertificateOwnerType,
|
sl@0
|
93 |
const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
|
sl@0
|
94 |
const TDesC8& aCert, TRequestStatus& aStatus);
|
sl@0
|
95 |
virtual void CancelAdd();
|
sl@0
|
96 |
virtual void Remove(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus);
|
sl@0
|
97 |
virtual void CancelRemove();
|
sl@0
|
98 |
virtual void SetApplicability(const CCTCertInfo& aCertInfo,
|
sl@0
|
99 |
const RArray<TUid>& aApplications, TRequestStatus &aStatus);
|
sl@0
|
100 |
virtual void CancelSetApplicability();
|
sl@0
|
101 |
virtual void SetTrust(const CCTCertInfo& aCertInfo, TBool aTrusted,
|
sl@0
|
102 |
TRequestStatus& aStatus);
|
sl@0
|
103 |
virtual void CancelSetTrust();
|
sl@0
|
104 |
virtual void SetCapabilities(const CCTCertInfo& aCertInfo, const TCapabilitySet& aCapabilities,
|
sl@0
|
105 |
TRequestStatus& aStatus);
|
sl@0
|
106 |
virtual void CancelSetCapabilities();
|
sl@0
|
107 |
virtual void SetMandatory(const CCTCertInfo& aCertInfo, TBool aMandatory,
|
sl@0
|
108 |
TRequestStatus& aStatus);
|
sl@0
|
109 |
virtual void CancelSetMandatory();
|
sl@0
|
110 |
|
sl@0
|
111 |
private:
|
sl@0
|
112 |
virtual ~CTest1CertStore();
|
sl@0
|
113 |
void DoSetApplicabilityL(const CCTCertInfo& aCertInfo,
|
sl@0
|
114 |
const RArray<TUid>& aApplications);
|
sl@0
|
115 |
void DoSetTrustL(const CCTCertInfo& aCertInfo,
|
sl@0
|
116 |
TBool aTrusted);
|
sl@0
|
117 |
CTest1CertStore(CTest1CertStoreToken& aToken, RFs& aFs);
|
sl@0
|
118 |
void ConstructL(const TDesC& aFileName, TFileMode aMode);
|
sl@0
|
119 |
static void RevertStore(TAny* aStore);
|
sl@0
|
120 |
static void DeleteFile(TAny* aThis);
|
sl@0
|
121 |
void RestoreL();
|
sl@0
|
122 |
CPermanentFileStore* OpenStoreL(const TDesC& aFileName, TFileMode aMode);
|
sl@0
|
123 |
CPermanentFileStore* OpenStoreLC(const TDesC& aFileName, TFileMode aMode);
|
sl@0
|
124 |
|
sl@0
|
125 |
|
sl@0
|
126 |
//
|
sl@0
|
127 |
// void AddCACertL(const CCertificate& aCert, const TDesC& aLabel, TCertificateFormat aFormat);
|
sl@0
|
128 |
// void AddUserCertL(const CCertificate& aCert, const TDesC& aLabel, TCertificateFormat aFormat,
|
sl@0
|
129 |
// const TKeyIdentifier& aIssuerKeyHash, const TKeyIdentifier& aSubjectKeyHash);
|
sl@0
|
130 |
void AddUserCertURLL(const TDesC8& aCert, const TDesC& aLabel,
|
sl@0
|
131 |
const TKeyIdentifier& aIssuerKeyHash, const TKeyIdentifier& aSubjectKeyHash);
|
sl@0
|
132 |
// void AddCertL(CCTCertInfo* aCertInfo, const CCertificate& aCert, CFileCertStoreMappings& aMappings);
|
sl@0
|
133 |
void AddCertL(CCTCertInfo* aCertInfo, const TDesC8& aCert, CFileCertStoreMappings& aMappings);
|
sl@0
|
134 |
void DoRemoveL(const CCTCertInfo& aCertInfo);
|
sl@0
|
135 |
void DoLoadL(TDes8& aCertificate, CFileCertStoreMapping& aMapping) const;
|
sl@0
|
136 |
void DoGetUserCertsL(RPointerArray<CCTCertInfo>& aCertInfos,
|
sl@0
|
137 |
const CCertAttributeFilter& aFilter) const;
|
sl@0
|
138 |
void UpdateStoreL();
|
sl@0
|
139 |
void DoAddL(const TDesC& aLabel, TCertificateFormat aFormat,
|
sl@0
|
140 |
TCertificateOwnerType aCertificateOwnerType, const TKeyIdentifier* aSubjectKeyId,
|
sl@0
|
141 |
const TKeyIdentifier* aIssuerKeyId,const TDesC8& aCert);
|
sl@0
|
142 |
|
sl@0
|
143 |
// perform the retrieval synchronously
|
sl@0
|
144 |
void RetrieveNow(const CCTCertInfo& aCertInfo,TDes8& aCertificate,TRequestStatus& aStatus);
|
sl@0
|
145 |
|
sl@0
|
146 |
private:
|
sl@0
|
147 |
void RunL();
|
sl@0
|
148 |
void DoCancel();
|
sl@0
|
149 |
|
sl@0
|
150 |
private:
|
sl@0
|
151 |
enum TState
|
sl@0
|
152 |
{
|
sl@0
|
153 |
EGetKeyInfos,
|
sl@0
|
154 |
EList,
|
sl@0
|
155 |
ERetrieve
|
sl@0
|
156 |
};
|
sl@0
|
157 |
|
sl@0
|
158 |
//
|
sl@0
|
159 |
private:
|
sl@0
|
160 |
CTest1CertStoreToken& iToken;
|
sl@0
|
161 |
|
sl@0
|
162 |
RFile iFile;
|
sl@0
|
163 |
RFs& iFs;
|
sl@0
|
164 |
CPermanentFileStore* iStore;
|
sl@0
|
165 |
|
sl@0
|
166 |
/**
|
sl@0
|
167 |
* The list of certificates contained in the store.
|
sl@0
|
168 |
*/
|
sl@0
|
169 |
CFileCertStoreMappings* iCerts;
|
sl@0
|
170 |
|
sl@0
|
171 |
TState iState;
|
sl@0
|
172 |
TRequestStatus* iOriginalRequestStatus;
|
sl@0
|
173 |
RPointerArray<CCTCertInfo>* iCertInfos;
|
sl@0
|
174 |
const CCertAttributeFilter* iFilter;
|
sl@0
|
175 |
TCTKeyAttributeFilter iKeyFilter;
|
sl@0
|
176 |
RMPointerArray<CCTKeyInfo> iKeyInfos;
|
sl@0
|
177 |
CUnifiedKeyStore* iUnifiedKeyStore;
|
sl@0
|
178 |
|
sl@0
|
179 |
// used for asynchronous certificate retrieval
|
sl@0
|
180 |
const CCTCertInfo* iAsynchCertInfo;
|
sl@0
|
181 |
TDes8* iAsynchCertificate;
|
sl@0
|
182 |
};
|
sl@0
|
183 |
|
sl@0
|
184 |
#endif
|