sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004-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 |
#ifndef __CERTTOOL_COMMANDS_H_
|
sl@0
|
20 |
#define __CERTTOOL_COMMANDS_H_
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <e32base.h>
|
sl@0
|
23 |
#include <ct/rmpointerarray.h>
|
sl@0
|
24 |
#include <unifiedcertstore.h>
|
sl@0
|
25 |
#include <badesca.h>
|
sl@0
|
26 |
//#include <e32cmn.h>
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <keytool.rsg>
|
sl@0
|
29 |
|
sl@0
|
30 |
#include "keytool_commands.h"
|
sl@0
|
31 |
|
sl@0
|
32 |
class CCertToolController;
|
sl@0
|
33 |
|
sl@0
|
34 |
/**
|
sl@0
|
35 |
* Interface that every keytool command class must implement.
|
sl@0
|
36 |
*/
|
sl@0
|
37 |
class CCertToolCommand : public CActive
|
sl@0
|
38 |
{
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
virtual void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam) = 0;
|
sl@0
|
41 |
|
sl@0
|
42 |
protected:
|
sl@0
|
43 |
CCertToolCommand(CCertToolController* aController);
|
sl@0
|
44 |
|
sl@0
|
45 |
protected:
|
sl@0
|
46 |
CCertToolController* iController;
|
sl@0
|
47 |
CKeyToolParameters* iParams; // we do not own this!
|
sl@0
|
48 |
};
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
/**
|
sl@0
|
52 |
* Implements the certtool display usage action.
|
sl@0
|
53 |
*/
|
sl@0
|
54 |
class CCertToolUsage : public CCertToolCommand
|
sl@0
|
55 |
{
|
sl@0
|
56 |
public:
|
sl@0
|
57 |
static CCertToolUsage* NewLC(CCertToolController* aController);
|
sl@0
|
58 |
static CCertToolUsage* NewL(CCertToolController* aController);
|
sl@0
|
59 |
~CCertToolUsage();
|
sl@0
|
60 |
void ConstructL();
|
sl@0
|
61 |
|
sl@0
|
62 |
public: // From CCertToolCommand
|
sl@0
|
63 |
void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam);
|
sl@0
|
64 |
|
sl@0
|
65 |
public: // From CActive
|
sl@0
|
66 |
void RunL();
|
sl@0
|
67 |
void DoCancel();
|
sl@0
|
68 |
|
sl@0
|
69 |
protected:
|
sl@0
|
70 |
CCertToolUsage(CCertToolController* aController);
|
sl@0
|
71 |
};
|
sl@0
|
72 |
|
sl@0
|
73 |
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
* Implements the certtool display usage action.
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
class CCertToolListStores : public CCertToolCommand
|
sl@0
|
78 |
{
|
sl@0
|
79 |
public:
|
sl@0
|
80 |
static CCertToolListStores* NewLC(CCertToolController* aController);
|
sl@0
|
81 |
static CCertToolListStores* NewL(CCertToolController* aController);
|
sl@0
|
82 |
~CCertToolListStores();
|
sl@0
|
83 |
void ConstructL();
|
sl@0
|
84 |
|
sl@0
|
85 |
public: // From CCertToolCommand
|
sl@0
|
86 |
void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam);
|
sl@0
|
87 |
|
sl@0
|
88 |
public: // From CActive
|
sl@0
|
89 |
void RunL();
|
sl@0
|
90 |
void DoCancel();
|
sl@0
|
91 |
|
sl@0
|
92 |
protected:
|
sl@0
|
93 |
CCertToolListStores(CCertToolController* aController);
|
sl@0
|
94 |
|
sl@0
|
95 |
private:
|
sl@0
|
96 |
RArray<MCTCertStore> iCertStoreList;
|
sl@0
|
97 |
};
|
sl@0
|
98 |
|
sl@0
|
99 |
|
sl@0
|
100 |
typedef RArray<TUid> RUidArray;
|
sl@0
|
101 |
|
sl@0
|
102 |
/**
|
sl@0
|
103 |
* Implements the keytool list action. This is an active object as listing is asynchronous.
|
sl@0
|
104 |
*/
|
sl@0
|
105 |
class CCertToolList : public CCertToolCommand
|
sl@0
|
106 |
{
|
sl@0
|
107 |
public:
|
sl@0
|
108 |
static CCertToolList* NewLC(CCertToolController* aController);
|
sl@0
|
109 |
static CCertToolList* NewL(CCertToolController* aController);
|
sl@0
|
110 |
~CCertToolList();
|
sl@0
|
111 |
void ConstructL();
|
sl@0
|
112 |
void InitializeIterations();
|
sl@0
|
113 |
|
sl@0
|
114 |
public: // From CCertToolCommand
|
sl@0
|
115 |
void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam);
|
sl@0
|
116 |
|
sl@0
|
117 |
public: // From CActive
|
sl@0
|
118 |
void RunL();
|
sl@0
|
119 |
void DoCancel();
|
sl@0
|
120 |
TInt RunError(TInt aError);
|
sl@0
|
121 |
|
sl@0
|
122 |
protected:
|
sl@0
|
123 |
CCertToolList(CCertToolController* aController);
|
sl@0
|
124 |
|
sl@0
|
125 |
protected:
|
sl@0
|
126 |
CUnifiedCertStore* iCertStore;
|
sl@0
|
127 |
MCertStore* iCertStoreImp;
|
sl@0
|
128 |
|
sl@0
|
129 |
TInt iIndex;
|
sl@0
|
130 |
CCertificate* iCertificate;
|
sl@0
|
131 |
|
sl@0
|
132 |
RUidArray iApps;
|
sl@0
|
133 |
TBool iTrust;
|
sl@0
|
134 |
RArray<RUidArray> iCertApps;
|
sl@0
|
135 |
RArray<TBool> iCertTrust;
|
sl@0
|
136 |
RPointerArray<CCertificate> iParsedCerts;
|
sl@0
|
137 |
RMPointerArray<CCTCertInfo> iCertInfos;
|
sl@0
|
138 |
CCertAttributeFilter* iFilter;
|
sl@0
|
139 |
|
sl@0
|
140 |
enum TState
|
sl@0
|
141 |
{
|
sl@0
|
142 |
EListCerts,
|
sl@0
|
143 |
ERetrieve,
|
sl@0
|
144 |
EGetApps,
|
sl@0
|
145 |
ESetTrust,
|
sl@0
|
146 |
EFinished,
|
sl@0
|
147 |
EIntermediate,
|
sl@0
|
148 |
EGetTrust,
|
sl@0
|
149 |
} iState;
|
sl@0
|
150 |
|
sl@0
|
151 |
// Number of certificates that have to be listed up to the current iteration.
|
sl@0
|
152 |
TInt iCurrentListCount;
|
sl@0
|
153 |
// Keeps track of the number of iterations left.
|
sl@0
|
154 |
TInt iNumberOfIterationsLeft;
|
sl@0
|
155 |
// List offset for the last iteration if total number of certificates is not an exact
|
sl@0
|
156 |
// multiple of default LIST_COUNT.
|
sl@0
|
157 |
TInt iLastIterationOffset;
|
sl@0
|
158 |
// Default list offset for each iteration.
|
sl@0
|
159 |
TInt iCurrentListOffset;
|
sl@0
|
160 |
};
|
sl@0
|
161 |
|
sl@0
|
162 |
|
sl@0
|
163 |
|
sl@0
|
164 |
|
sl@0
|
165 |
/**
|
sl@0
|
166 |
* Implements the keytool import action.
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
class CCertToolAdd : public CCertToolCommand
|
sl@0
|
169 |
{
|
sl@0
|
170 |
public:
|
sl@0
|
171 |
static CCertToolAdd* NewLC(CCertToolController* aController);
|
sl@0
|
172 |
static CCertToolAdd* NewL(CCertToolController* aController);
|
sl@0
|
173 |
~CCertToolAdd();
|
sl@0
|
174 |
void ConstructL();
|
sl@0
|
175 |
|
sl@0
|
176 |
public: // From CKeyToolCommand
|
sl@0
|
177 |
void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam);
|
sl@0
|
178 |
|
sl@0
|
179 |
public: // From CActive
|
sl@0
|
180 |
void RunL();
|
sl@0
|
181 |
void DoCancel();
|
sl@0
|
182 |
TInt RunError(TInt aError);
|
sl@0
|
183 |
|
sl@0
|
184 |
private:
|
sl@0
|
185 |
CCertToolAdd(CCertToolController* aController);
|
sl@0
|
186 |
|
sl@0
|
187 |
TCertificateFormat DoRecognizeL(const TDesC8& iData);
|
sl@0
|
188 |
|
sl@0
|
189 |
protected:
|
sl@0
|
190 |
enum TState
|
sl@0
|
191 |
{
|
sl@0
|
192 |
EIntermediate,
|
sl@0
|
193 |
EFinish
|
sl@0
|
194 |
} iState;
|
sl@0
|
195 |
|
sl@0
|
196 |
private:
|
sl@0
|
197 |
HBufC8* iCertData;
|
sl@0
|
198 |
CUnifiedCertStore* iCertStore;
|
sl@0
|
199 |
TBool iIsDeletable;
|
sl@0
|
200 |
};
|
sl@0
|
201 |
|
sl@0
|
202 |
|
sl@0
|
203 |
|
sl@0
|
204 |
/**
|
sl@0
|
205 |
* Implements the certtool remove action.
|
sl@0
|
206 |
*/
|
sl@0
|
207 |
class CCertToolRemove : public CCertToolList
|
sl@0
|
208 |
{
|
sl@0
|
209 |
public:
|
sl@0
|
210 |
static CCertToolRemove* NewLC(CCertToolController* aController);
|
sl@0
|
211 |
static CCertToolRemove* NewL(CCertToolController* aController);
|
sl@0
|
212 |
~CCertToolRemove();
|
sl@0
|
213 |
|
sl@0
|
214 |
public: // From CActive
|
sl@0
|
215 |
void RunL();
|
sl@0
|
216 |
TInt RunError(TInt aError);
|
sl@0
|
217 |
protected:
|
sl@0
|
218 |
|
sl@0
|
219 |
private:
|
sl@0
|
220 |
CCertToolRemove(CCertToolController* aController);
|
sl@0
|
221 |
|
sl@0
|
222 |
private:
|
sl@0
|
223 |
|
sl@0
|
224 |
};
|
sl@0
|
225 |
|
sl@0
|
226 |
|
sl@0
|
227 |
/**
|
sl@0
|
228 |
*
|
sl@0
|
229 |
*/
|
sl@0
|
230 |
class CCertToolSetApps : public CCertToolList
|
sl@0
|
231 |
{
|
sl@0
|
232 |
public:
|
sl@0
|
233 |
static CCertToolSetApps* NewLC(CCertToolController* aController);
|
sl@0
|
234 |
static CCertToolSetApps* NewL(CCertToolController* aController);
|
sl@0
|
235 |
~CCertToolSetApps();
|
sl@0
|
236 |
|
sl@0
|
237 |
public: // From CActive
|
sl@0
|
238 |
void RunL();
|
sl@0
|
239 |
TInt RunError(TInt aError);
|
sl@0
|
240 |
protected:
|
sl@0
|
241 |
|
sl@0
|
242 |
private:
|
sl@0
|
243 |
CCertToolSetApps(CCertToolController* aController);
|
sl@0
|
244 |
TInt iCertIndex;
|
sl@0
|
245 |
};
|
sl@0
|
246 |
|
sl@0
|
247 |
|
sl@0
|
248 |
/**
|
sl@0
|
249 |
*
|
sl@0
|
250 |
*/
|
sl@0
|
251 |
class CCertToolAddApps : public CCertToolList
|
sl@0
|
252 |
{
|
sl@0
|
253 |
public:
|
sl@0
|
254 |
static CCertToolAddApps* NewLC(CCertToolController* aController);
|
sl@0
|
255 |
static CCertToolAddApps* NewL(CCertToolController* aController);
|
sl@0
|
256 |
~CCertToolAddApps();
|
sl@0
|
257 |
|
sl@0
|
258 |
public: // From CActive
|
sl@0
|
259 |
void RunL();
|
sl@0
|
260 |
TInt RunError(TInt aError);
|
sl@0
|
261 |
|
sl@0
|
262 |
protected:
|
sl@0
|
263 |
enum TState
|
sl@0
|
264 |
{
|
sl@0
|
265 |
EListCerts,
|
sl@0
|
266 |
ERetrieve,
|
sl@0
|
267 |
EGetApps,
|
sl@0
|
268 |
ESetApps,
|
sl@0
|
269 |
ESetTrust,
|
sl@0
|
270 |
EFinished,
|
sl@0
|
271 |
EIntermediate
|
sl@0
|
272 |
} iState;
|
sl@0
|
273 |
|
sl@0
|
274 |
private:
|
sl@0
|
275 |
CCertToolAddApps(CCertToolController* aController);
|
sl@0
|
276 |
TInt iCertIndex;
|
sl@0
|
277 |
};
|
sl@0
|
278 |
|
sl@0
|
279 |
/**
|
sl@0
|
280 |
*
|
sl@0
|
281 |
*/
|
sl@0
|
282 |
class CCertToolRemoveApps : public CCertToolList
|
sl@0
|
283 |
{
|
sl@0
|
284 |
public:
|
sl@0
|
285 |
static CCertToolRemoveApps* NewLC(CCertToolController* aController);
|
sl@0
|
286 |
static CCertToolRemoveApps* NewL(CCertToolController* aController);
|
sl@0
|
287 |
~CCertToolRemoveApps();
|
sl@0
|
288 |
|
sl@0
|
289 |
public: // From CActive
|
sl@0
|
290 |
void RunL();
|
sl@0
|
291 |
TInt RunError(TInt aError);
|
sl@0
|
292 |
|
sl@0
|
293 |
protected:
|
sl@0
|
294 |
enum TState
|
sl@0
|
295 |
{
|
sl@0
|
296 |
EListCerts,
|
sl@0
|
297 |
ERetrieve,
|
sl@0
|
298 |
EGetApps,
|
sl@0
|
299 |
ERemoveApps,
|
sl@0
|
300 |
EFinished,
|
sl@0
|
301 |
EIntermediate
|
sl@0
|
302 |
} iState;
|
sl@0
|
303 |
|
sl@0
|
304 |
private:
|
sl@0
|
305 |
CCertToolRemoveApps(CCertToolController* aController);
|
sl@0
|
306 |
|
sl@0
|
307 |
};
|
sl@0
|
308 |
|
sl@0
|
309 |
#endif
|
sl@0
|
310 |
|