|
1 /* |
|
2 * Copyright (c) 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 "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 JAVAUTILS_H |
|
20 #define JAVAUTILS_H |
|
21 |
|
22 //INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 const TInt KPathMaxLength = 8; |
|
26 const TInt KLabelMaxLength = 24; |
|
27 const TInt KPINMaxLabelLength = 64; |
|
28 |
|
29 typedef TBuf<KPINMaxLabelLength> TPINLabel; |
|
30 |
|
31 //FORWARD DECLARATIONS |
|
32 class RWimCertMgmt; |
|
33 class RWimMgmt; |
|
34 |
|
35 |
|
36 struct TJavaPINParams |
|
37 { |
|
38 TPINLabel iPINLabel; |
|
39 TInt iFlags; |
|
40 TInt iAuthId; |
|
41 TInt iPinNumber; |
|
42 TInt iMinLength; |
|
43 TInt iMaxLength; |
|
44 TInt iPinType; |
|
45 TInt iStoredLength; |
|
46 TInt iPinReference; |
|
47 TInt iPadChar; |
|
48 }; |
|
49 |
|
50 /** |
|
51 * Reads Java provisioning information from Smart Card |
|
52 * |
|
53 * @lib WimClient.lib |
|
54 * @since S60 3.2 |
|
55 */ |
|
56 class CWimJavaUtils : public CActive |
|
57 { |
|
58 public: |
|
59 |
|
60 /** |
|
61 * Two-phased constructor. |
|
62 * |
|
63 * @param |
|
64 * @return |
|
65 */ |
|
66 IMPORT_C static CWimJavaUtils* NewL(); |
|
67 |
|
68 /** |
|
69 * Destructor |
|
70 */ |
|
71 IMPORT_C virtual ~CWimJavaUtils(); |
|
72 |
|
73 /** |
|
74 * Initializes the WIM Server cache. This is the most time consuming call. |
|
75 * |
|
76 * @param aStatus Indicates the result of this call. Values: |
|
77 * KErrNone, call was successull |
|
78 * KErrNotFound, no WIM was found |
|
79 * KErrNoMemory, no memory |
|
80 * KErrGeneral, any other error |
|
81 * @return void |
|
82 */ |
|
83 IMPORT_C void Initialize( TRequestStatus& aStatus ); |
|
84 |
|
85 /** |
|
86 * Cancels outgoing Initialize operation. |
|
87 * |
|
88 * @param |
|
89 * @return void |
|
90 */ |
|
91 IMPORT_C void CancelInitialize(); |
|
92 |
|
93 /** |
|
94 * Fetches the size of ACIF. |
|
95 * This information can be used as a notification of existing of provisioning |
|
96 * information. If the size is not included in Smart Card's |
|
97 * DODF-JavaPROV file then the full length of the file containing the |
|
98 * provisioning information is returned. |
|
99 * |
|
100 * @param aSize The length of ACIF |
|
101 * @param aStatus Indicates the result of this call. |
|
102 * KErrNone, no errors. NOTE: size can still be 0 indicating |
|
103 * that no provisioning information was found. |
|
104 * If aSize > 0 it means that provisioning information |
|
105 * was found. |
|
106 * KErrNoMemory, No memory |
|
107 * KErrGeneral, any other error |
|
108 * @return void |
|
109 */ |
|
110 IMPORT_C void GetACIFSize( TInt& aSize, |
|
111 TRequestStatus& aStatus ); |
|
112 |
|
113 /** |
|
114 * Fetches the size of ACF |
|
115 * |
|
116 * @param aSize The lenght of ACF |
|
117 * @param aACFPath The path of ACF on smart card |
|
118 * @param aStatus Indicates the result of this call. |
|
119 * @return void |
|
120 */ |
|
121 IMPORT_C void GetACFSize( TInt& aSize, |
|
122 const TDesC8& aACFPath, |
|
123 TRequestStatus& aStatus ); |
|
124 |
|
125 /** |
|
126 * Get the Authobj information |
|
127 * |
|
128 * @param aAuthIdList List of AuthObject ID |
|
129 * @param aAuthObjsInfoList List of AuthObject Info |
|
130 * @param aStatus Indicates the result of this call. |
|
131 * @return void |
|
132 */ |
|
133 IMPORT_C void GetAuthObjsInfo( const RArray<TInt>& aAuthIdList, |
|
134 RArray<TJavaPINParams>& aAuthObjsInfoList, |
|
135 TRequestStatus& aStatus ); |
|
136 |
|
137 /** |
|
138 * Cancels outgoing GetACIFSize operation. |
|
139 * |
|
140 * @param |
|
141 * @return void |
|
142 */ |
|
143 IMPORT_C void CancelGetACIFSize(); |
|
144 |
|
145 /** |
|
146 * Cancels outgoing GetACFSize operation. |
|
147 * |
|
148 * @param |
|
149 * @return void |
|
150 */ |
|
151 IMPORT_C void CancelGetACFSize(); |
|
152 |
|
153 /** |
|
154 * Cancel outgoing GetAuthObjsInfo |
|
155 * |
|
156 * @param |
|
157 * @return void |
|
158 */ |
|
159 IMPORT_C void CancelGetAuthObjsInfo(); |
|
160 |
|
161 /** |
|
162 * Fetches the whole data of ACIF file. |
|
163 * |
|
164 * @param aACIFData ACIF binary data from smart card |
|
165 * @param aStatus Indicates the result of this call. |
|
166 * KErrNone, no errors. |
|
167 * KErrNoMemory, No memory |
|
168 * KErrGeneral, any other error |
|
169 * @return void |
|
170 */ |
|
171 IMPORT_C void RetrieveACIFContent( TDes8& aACIFData, |
|
172 TRequestStatus& aStatus ); |
|
173 |
|
174 |
|
175 /** |
|
176 * Fetches the whole data of ACF file |
|
177 * |
|
178 * @param aACFData ACF binary data from smart card |
|
179 * @param aACFPath ACF file path on smart card |
|
180 * @param aStatus Indicates the result of this call. |
|
181 * @return void |
|
182 */ |
|
183 IMPORT_C void RetrieveACFContent( TDes8& aACFData, |
|
184 const TDesC8& aACFPath, |
|
185 TRequestStatus& aStatus ); |
|
186 |
|
187 /** |
|
188 * Fetches the wim label and path |
|
189 * |
|
190 * @param aWimLabel |
|
191 * @param aPath |
|
192 * @param aStatus Indicates the result of this call. |
|
193 * @return void |
|
194 */ |
|
195 IMPORT_C void RetrieveWimLabelAndPath( TDes8& aWimLabel, |
|
196 TDes8& aPath, |
|
197 TRequestStatus& aStatus ); |
|
198 |
|
199 |
|
200 /** |
|
201 * Cancels outgoing Retrieve operation. |
|
202 * |
|
203 * @return void |
|
204 */ |
|
205 IMPORT_C void CancelRetrieveACIFContent(); |
|
206 |
|
207 /** |
|
208 * Cancels outgoing Retrieve operation. |
|
209 * |
|
210 * @return void |
|
211 */ |
|
212 IMPORT_C void CancelRetrieveACFContent(); |
|
213 |
|
214 /** |
|
215 * Cancel outgoing Retrieve operation |
|
216 * |
|
217 * @return void |
|
218 */ |
|
219 IMPORT_C void CancelRetrieveWimLabelAndPath(); |
|
220 |
|
221 private: |
|
222 |
|
223 /** |
|
224 * Symbian constructor |
|
225 * @return void |
|
226 */ |
|
227 void ConstructL(); |
|
228 |
|
229 /** |
|
230 * C++ default constructor. |
|
231 */ |
|
232 CWimJavaUtils(); |
|
233 |
|
234 private: //from CActive |
|
235 |
|
236 /** |
|
237 * Different phases are handled here. |
|
238 * @return void |
|
239 */ |
|
240 void RunL(); |
|
241 |
|
242 /** |
|
243 * Cancellation function |
|
244 * Deallocates member variables and completes client status with |
|
245 * KErrCancel error code. |
|
246 * @return void |
|
247 */ |
|
248 void DoCancel(); |
|
249 |
|
250 /** |
|
251 * The active scheduler calls this function if this active |
|
252 * object's RunL() function leaves. |
|
253 * Handles necessary cleanup and completes request with |
|
254 * received error code. |
|
255 * @param aError -The error code which caused this function call. |
|
256 * @return TInt -Error code to active scheduler, is always KErrNone. |
|
257 */ |
|
258 TInt RunError( TInt aError ); |
|
259 |
|
260 private: |
|
261 |
|
262 /** |
|
263 * Sets own iStatus to KRequestPending, and signals it |
|
264 * with User::RequestComplete() -request. This gives chance |
|
265 * active scheduler to run other active objects. After a quick |
|
266 * visit in active scheduler, signal returns to RunL() and starts next |
|
267 * phase of operation. |
|
268 * @return void |
|
269 */ |
|
270 void SignalOwnStatusAndComplete(); |
|
271 |
|
272 /** |
|
273 * Allocates memory for member variables, which are needed |
|
274 * in Java Provisioning struct. |
|
275 * @param aDataLength -The length of the data to be allocated |
|
276 * @return void |
|
277 */ |
|
278 void AllocMemoryForJavaProvStructL( const TInt aDataLength ); |
|
279 |
|
280 /** |
|
281 * Allocates memory for path and label |
|
282 * @return void |
|
283 */ |
|
284 void AllocMemoryForPathAndLabelL(); |
|
285 /** |
|
286 * Deallocates memory from member variables |
|
287 * @return void |
|
288 */ |
|
289 void DeallocMemoryFromJavaProvStruct(); |
|
290 |
|
291 /** |
|
292 * Deallocates memory from path and label |
|
293 * @return void |
|
294 */ |
|
295 void DeallocMemoryFromPathAndLabel(); |
|
296 |
|
297 private: |
|
298 |
|
299 enum TJavaUtilPhase |
|
300 { |
|
301 EInitialize, |
|
302 EConnectClientSession, |
|
303 EInitializeWim, |
|
304 EInitializeDone, |
|
305 EGetACIFSize, |
|
306 EGetACIFSizeDone, |
|
307 ERetrieveACIFContent, |
|
308 ERetrieveACIFContentDone, |
|
309 EGetACFSize, |
|
310 EGetACFSizeDone, |
|
311 ERetrieveACFContent, |
|
312 ERetrieveACFContentDone, |
|
313 EGetAuthObjsInfo, |
|
314 EGetAuthObjsInfoDone, |
|
315 ERetrieveWimLabelAndPath, |
|
316 ERetrieveWimLabelAndPathDone |
|
317 }; |
|
318 |
|
319 //Indicator for different phases |
|
320 TJavaUtilPhase iPhase; |
|
321 |
|
322 //Client status is stored here while operation |
|
323 //on the server side is done. |
|
324 TRequestStatus* iClientStatus; |
|
325 |
|
326 //Handle to connection with server. Owned. |
|
327 RWimCertMgmt* iConnectionHandle; |
|
328 |
|
329 // Pointer to Client Session. Owned. |
|
330 RWimMgmt* iClientSession; |
|
331 |
|
332 //Informs the size of provisioning string. Not owned. |
|
333 TInt* iSize; |
|
334 |
|
335 //Descriptor to hold provisioning data. Not owned. |
|
336 TDes8* iData; |
|
337 |
|
338 //Buffer to hold Java provisioning data for server. Owned. |
|
339 HBufC8* iJavaProvBuf; |
|
340 |
|
341 //Pointer to iJavaProvBuf. Owned. |
|
342 TPtr8* iJavaProvBufPtr; |
|
343 |
|
344 //Flag to indicate errors during WIM -initialization. |
|
345 TInt iWimStartErr; |
|
346 |
|
347 TBuf8<KPathMaxLength> iACFPath; |
|
348 |
|
349 RArray<TInt>* iAuthIdList; //owed |
|
350 |
|
351 //saves pointer to user's array |
|
352 RArray<TJavaPINParams>* iClientsAuthObjsInfoList;//not owned |
|
353 |
|
354 //Array to hold authOjbectInfo data |
|
355 RArray<TJavaPINParams>* iAuthObjsInfoList; //owed |
|
356 |
|
357 TDes8* iLabel; |
|
358 |
|
359 TDes8* iPath; |
|
360 |
|
361 //Buffer to hold Label. Owned. |
|
362 HBufC8* iLabelBuf; |
|
363 |
|
364 //Pointer to Label. Owned. |
|
365 TPtr8* iLabelBufPtr; |
|
366 |
|
367 //Buffer to hold path. Owned. |
|
368 HBufC8* iPathBuf; |
|
369 |
|
370 //Pointer to path. Owned. |
|
371 TPtr8* iPathBufPtr; |
|
372 |
|
373 |
|
374 }; |
|
375 |
|
376 |
|
377 #endif // JAVAUTILS_H |
|
378 |
|
379 // End of File |