|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __KEYTOOL_COMMANDS_H_ |
|
20 #define __KEYTOOL_COMMANDS_H_ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <ct/rmpointerarray.h> |
|
24 #include <mctkeystore.h> |
|
25 #include <unifiedkeystore.h> |
|
26 #include <badesca.h> |
|
27 //#include <e32cmn.h> |
|
28 |
|
29 |
|
30 class CController; |
|
31 class CKeyToolController; |
|
32 |
|
33 |
|
34 /** |
|
35 * This class wraps up the command line parameters |
|
36 * which affect the keystore command to be executed. |
|
37 * E.g. the key label we refer to, the key store to use, etc. |
|
38 */ |
|
39 class CKeyToolParameters : public CBase |
|
40 { |
|
41 public: |
|
42 static CKeyToolParameters* NewLC(); |
|
43 ~CKeyToolParameters(); |
|
44 enum TSetPolicy |
|
45 { |
|
46 ENone =0, |
|
47 ESetUserPolicy, |
|
48 ESetManagerPolicy, |
|
49 ERemoveUserPolicy, |
|
50 ESetAllUsersPolicy, |
|
51 }; |
|
52 protected: |
|
53 void ConstructL(); |
|
54 |
|
55 private: |
|
56 CKeyToolParameters(); |
|
57 |
|
58 public: |
|
59 TBool iIsDetailed; |
|
60 HBufC* iPrivate; |
|
61 HBufC* iLabel; |
|
62 HBufC* iDefault; |
|
63 TInt iKeystoreIndex; |
|
64 TInt iCertstoreIndex; |
|
65 TKeyUsagePKCS15 iUsage; |
|
66 CKeyInfoBase::EKeyAccess iAccess; |
|
67 TTime iEndDate; |
|
68 RArray<TUid> iUIDs; |
|
69 HBufC* iOwnerType; |
|
70 TBool iPageWise; |
|
71 TBool iRemoveKey; |
|
72 TSetPolicy iPolicy; |
|
73 }; |
|
74 |
|
75 |
|
76 /** |
|
77 * Interface that every keytool command class must implement. |
|
78 */ |
|
79 class CKeyToolCommand : public CActive |
|
80 { |
|
81 public: |
|
82 virtual void DoCommandL(CUnifiedKeyStore& aKeyStore, CKeyToolParameters* aParam) = 0; |
|
83 |
|
84 protected: |
|
85 CKeyToolCommand(CController* aController); |
|
86 |
|
87 protected: |
|
88 CController* iController; |
|
89 CKeyToolParameters* iParams; // we do not own this! |
|
90 }; |
|
91 |
|
92 |
|
93 /** |
|
94 * Implements the keytool list action. This is an active object as listing is asynchronous. |
|
95 */ |
|
96 class CKeytoolUsage : public CKeyToolCommand |
|
97 { |
|
98 public: |
|
99 static CKeytoolUsage* NewLC(CKeyToolController* aController); |
|
100 static CKeytoolUsage* NewL(CKeyToolController* aController); |
|
101 ~CKeytoolUsage(); |
|
102 void ConstructL(); |
|
103 |
|
104 public: // From CKeyToolCommand |
|
105 void DoCommandL(CUnifiedKeyStore& aKeyStore, CKeyToolParameters* aParam); |
|
106 |
|
107 public: // From CActive |
|
108 void RunL(); |
|
109 void DoCancel(); |
|
110 |
|
111 protected: |
|
112 CKeytoolUsage(CKeyToolController* aController); |
|
113 }; |
|
114 |
|
115 |
|
116 /** |
|
117 * Implements the keytool list action. This is an active object as listing is asynchronous. |
|
118 */ |
|
119 class CKeytoolList : public CKeyToolCommand |
|
120 { |
|
121 public: |
|
122 static CKeytoolList* NewLC(CKeyToolController* aController); |
|
123 static CKeytoolList* NewL(CKeyToolController* aController); |
|
124 ~CKeytoolList(); |
|
125 void ConstructL(); |
|
126 |
|
127 public: // From CKeyToolCommand |
|
128 void DoCommandL(CUnifiedKeyStore& aKeyStore, CKeyToolParameters* aParam); |
|
129 |
|
130 public: // From CActive |
|
131 void RunL(); |
|
132 void DoCancel(); |
|
133 TInt RunError(TInt aError); |
|
134 |
|
135 protected: |
|
136 CKeytoolList(CKeyToolController* aController); |
|
137 |
|
138 protected: |
|
139 RMPointerArray<CCTKeyInfo> iKeys; |
|
140 CUnifiedKeyStore* iKeyStore; |
|
141 TCTKeyAttributeFilter iFilter; |
|
142 MKeyStore* iKeyStoreImp; |
|
143 |
|
144 enum TState |
|
145 { |
|
146 EListKeys, |
|
147 EFinished, |
|
148 EIntermediate |
|
149 } iState; |
|
150 }; |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 /** |
|
156 * Implements the keytool import action. |
|
157 */ |
|
158 class CKeytoolImport : public CKeyToolCommand |
|
159 { |
|
160 public: |
|
161 static CKeytoolImport* NewLC(CController* aController); |
|
162 static CKeytoolImport* NewL(CController* aController); |
|
163 ~CKeytoolImport(); |
|
164 void ConstructL(); |
|
165 |
|
166 public: // From CKeyToolCommand |
|
167 void DoCommandL(CUnifiedKeyStore& aKeyStore, CKeyToolParameters* aParam); |
|
168 |
|
169 public: // From CActive |
|
170 void RunL(); |
|
171 void DoCancel(); |
|
172 TInt RunError(TInt aError); |
|
173 |
|
174 protected: |
|
175 /** |
|
176 * Given some (supposed) pkcs8 data, tells you whether we are dealing with |
|
177 * a PrivateKeyInfo or EncryptedPrivateKeyInfo ASN1 type. |
|
178 */ |
|
179 TBool IsPkcs8EncryptedL(TDesC8& aBinaryData); |
|
180 |
|
181 private: |
|
182 CKeytoolImport(CController* aController); |
|
183 void Pkcs8PreprocessorL(); |
|
184 |
|
185 private: |
|
186 HBufC8* iKeyData; |
|
187 CCTKeyInfo* iKeyInfo; |
|
188 }; |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 /** |
|
194 * Implements the keytool remove action. |
|
195 */ |
|
196 class CKeytoolRemove : public CKeytoolList |
|
197 { |
|
198 public: |
|
199 static CKeytoolRemove* NewLC(CKeyToolController* aController); |
|
200 static CKeytoolRemove* NewL(CKeyToolController* aController); |
|
201 ~CKeytoolRemove(); |
|
202 |
|
203 public: // From CActive |
|
204 void RunL(); |
|
205 |
|
206 protected: |
|
207 |
|
208 private: |
|
209 CKeytoolRemove(CKeyToolController* aController); |
|
210 |
|
211 private: |
|
212 RArray<CCTKeyInfo*> iKeyList; |
|
213 TInt idx; |
|
214 }; |
|
215 |
|
216 |
|
217 |
|
218 /** |
|
219 */ |
|
220 class CKeyToolListStores : public CKeyToolCommand |
|
221 { |
|
222 public: |
|
223 static CKeyToolListStores* NewLC(CKeyToolController* aController); |
|
224 static CKeyToolListStores* NewL(CKeyToolController* aController); |
|
225 ~CKeyToolListStores(); |
|
226 void ConstructL(); |
|
227 |
|
228 public: // From CCertToolCommand |
|
229 void DoCommandL(CUnifiedKeyStore& aKeyStore, CKeyToolParameters* aParam); |
|
230 |
|
231 public: // From CActive |
|
232 void RunL(); |
|
233 void DoCancel(); |
|
234 |
|
235 protected: |
|
236 CKeyToolListStores(CKeyToolController* aController); |
|
237 |
|
238 private: |
|
239 RArray<MCTKeyStore> iCertStoreList; |
|
240 }; |
|
241 |
|
242 |
|
243 /** |
|
244 * Implements the keytool set policy action. |
|
245 */ |
|
246 class CKeytoolSetPolicy : public CKeytoolList |
|
247 { |
|
248 public: |
|
249 static CKeytoolSetPolicy* NewLC(CKeyToolController* aController); |
|
250 static CKeytoolSetPolicy* NewL(CKeyToolController* aController); |
|
251 ~CKeytoolSetPolicy(); |
|
252 |
|
253 public: // From CActive |
|
254 void RunL(); |
|
255 TInt RunError(TInt aError); |
|
256 protected: |
|
257 |
|
258 private: |
|
259 CKeytoolSetPolicy(CKeyToolController* aController); |
|
260 |
|
261 private: |
|
262 CCTKeyInfo* iKey; |
|
263 TInt idx; |
|
264 }; |
|
265 |
|
266 |
|
267 #endif |