|
1 /* |
|
2 * Copyright (c) 2006-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 |
|
20 #include <f32file.h> |
|
21 |
|
22 #include "tPinAuthPlugin.h" |
|
23 #include <e32svr.h> |
|
24 |
|
25 #ifndef __INIPARSER_H__ |
|
26 #include <cinidata.h> |
|
27 #endif // __INIPARSER_H__ |
|
28 |
|
29 |
|
30 CTPinAuthPlugin::~CTPinAuthPlugin() |
|
31 { |
|
32 delete iClientMessage; |
|
33 } |
|
34 |
|
35 CTPinAuthPlugin::CTPinAuthPlugin() |
|
36 { |
|
37 // See ConstructL() for initialisation completion. |
|
38 } |
|
39 |
|
40 /** |
|
41 Safely complete the initialization of the constructed object |
|
42 */ |
|
43 void CTPinAuthPlugin::ConstructL() |
|
44 { |
|
45 iName.Set(KPluginNamePin); |
|
46 iDescription.Set(KPluginDescriptionPin); |
|
47 iMinEntropy = KEntropyPin; |
|
48 iFalsePositiveRate = KFalsePosPin; |
|
49 iFalseNegativeRate = KFalseNegPin; |
|
50 iClientMessage = HBufC::NewL(2048); |
|
51 ReloadAllFromIniFile(); |
|
52 } |
|
53 |
|
54 /** |
|
55 Sets information like iActiveState and iSupportsDefaultData from |
|
56 the TEF ini file to the individual plugin database files |
|
57 */ |
|
58 void CTPinAuthPlugin::ReloadAllFromIniFile() |
|
59 { |
|
60 // Set the file to be read, based on the Id of the plugin |
|
61 |
|
62 _LIT(KFileText, "\\tAuth\\tAuthSvr\\testdata\\Pin"); |
|
63 _LIT(KFileSuffix, "Db.ini"); |
|
64 _LIT(KFormatFileName,"%S%x%S"); |
|
65 |
|
66 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
67 TBuf<64> fileText(sysDrive.Name()); |
|
68 fileText.Append(KFileText); |
|
69 iFileToRead.Format(KFormatFileName,&fileText, Id(), &KFileSuffix); |
|
70 |
|
71 //Read data from file to get initialisation information |
|
72 |
|
73 // Open and read in INI file |
|
74 // Default path to look for INI file is in 'c:\system\data' |
|
75 // on target filesystem |
|
76 |
|
77 CIniData* file=NULL; |
|
78 TRAPD(r,file=CIniData::NewL(iFileToRead)); |
|
79 |
|
80 //Put file on the cleanupstack if anything else in this function is going to leave, but nothing does. |
|
81 |
|
82 if(r!=KErrNone) |
|
83 { |
|
84 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &iFileToRead); |
|
85 } |
|
86 |
|
87 else |
|
88 { |
|
89 // Look for a key under a named section, retrieve text value |
|
90 TPtrC result; |
|
91 TBool ret; //return value from FindVar functions |
|
92 ret=file->FindVar(_L("SectionOne"),_L("iSupportsDefaultData"),result); |
|
93 if(!ret) |
|
94 { |
|
95 RDebug::Print(_L("Key or section not found. iSupportsDefaultData default value used.")); |
|
96 iSupportsDefaultData = ETrue; // Default value |
|
97 } |
|
98 else |
|
99 { |
|
100 _LIT(KFalse,"false"); |
|
101 // Create a lower case copy of the data that is read from the file |
|
102 TBuf<10> resultLowerCase; |
|
103 resultLowerCase.Copy(result); |
|
104 resultLowerCase.LowerCase(); |
|
105 iSupportsDefaultData = (resultLowerCase.FindF(KFalse) == KErrNotFound); |
|
106 } |
|
107 |
|
108 // Set the active state of the plugin depending on the contents of the |
|
109 // corresponding file, which has been set as a member variable |
|
110 ret =file->FindVar(_L("SectionOne"),_L("activeState"),result); |
|
111 if(!ret) |
|
112 { |
|
113 RDebug::Print(_L("Key or section not found. iActiveState default value of ETRUE used.")); |
|
114 iActiveState = ETrue; // Default value |
|
115 } |
|
116 else |
|
117 { |
|
118 _LIT(KFalse,"false"); |
|
119 // Create a lower case copy of the data that is read from the file |
|
120 TBuf<10> resultLowerCase; |
|
121 resultLowerCase.Copy(result); |
|
122 resultLowerCase.LowerCase(); |
|
123 |
|
124 // If the string 'false' was not found, we set the value to 'true' -the default value |
|
125 iActiveState = (resultLowerCase.FindF(KFalse) == KErrNotFound); |
|
126 } |
|
127 TRAPD(r,file->WriteToFileL()); |
|
128 |
|
129 if (KErrNone != r) |
|
130 { |
|
131 RDebug::Print(_L("Error occurred while writing to the file.")); |
|
132 TBuf<84> initInfoFile(sysDrive.Name()); |
|
133 initInfoFile.Append(KInitInfoFile); |
|
134 RDebug::Print(_L("Filename = %S, KeyName = iSupportsDefaultData,"), &initInfoFile); |
|
135 RDebug::Print(_L("value = %S."), &result); |
|
136 } |
|
137 |
|
138 delete file; |
|
139 TRAP(r,file=CIniData::NewL(KAuthSvrPolicyFile)); |
|
140 TPtrC displayMessage; |
|
141 ret=file->FindVar(_L("SectionOne"),_L("DisplayMessage"),displayMessage); |
|
142 if(displayMessage.Length() == 0) //Value = 0 |
|
143 { |
|
144 RDebug::Print(_L("DisplayMessage not passed.")); |
|
145 iClientMessage = iClientMessage->ReAllocL(0); // Default value |
|
146 TPtr ptr(iClientMessage->Des()); |
|
147 ptr = KNullDesC(); |
|
148 ret=file->SetValue(_L("SectionOne"),_L("DisplayMessage"),displayMessage); |
|
149 TRAP(r,file->WriteToFileL()); |
|
150 } |
|
151 else |
|
152 { |
|
153 iClientMessage = iClientMessage->ReAllocL(displayMessage.Length()); |
|
154 TPtr ptr(iClientMessage->Des()); |
|
155 ptr = displayMessage; |
|
156 ret=file->SetValue(_L("SectionOne"),_L("DisplayMessage"),displayMessage); |
|
157 TRAP(r,file->WriteToFileL()); |
|
158 } |
|
159 delete file; |
|
160 } |
|
161 |
|
162 } |
|
163 |
|
164 void CTPinAuthPlugin::ReloadActiveStateFromIniFile() const |
|
165 { |
|
166 // Set the file to be read, based on the Id of the plugin |
|
167 |
|
168 _LIT(KFileText, "\\tAuth\\tAuthSvr\\testdata\\Pin"); |
|
169 _LIT(KFileSuffix, "Db.ini"); |
|
170 |
|
171 _LIT(KFormatFileName,"%S%x%S"); |
|
172 |
|
173 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
174 TBuf<64> fileText(sysDrive.Name()); |
|
175 fileText.Append(KFileText); |
|
176 iFileToRead.Format(KFormatFileName,&fileText, Id(), &KFileSuffix); |
|
177 |
|
178 //Read data from file to get initialisation information |
|
179 |
|
180 // Open and read in INI file |
|
181 // Default path to look for INI file is in 'c:\system\data' |
|
182 // on target filesystem |
|
183 |
|
184 CIniData* file=NULL; |
|
185 TRAPD(r,file=CIniData::NewL(iFileToRead)); |
|
186 |
|
187 //Put file on the cleanupstack if anything else in this function is going to leave, but nothing does. |
|
188 |
|
189 if(r!=KErrNone) |
|
190 { |
|
191 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &iFileToRead); |
|
192 } |
|
193 |
|
194 else |
|
195 { |
|
196 // Look for a key under a named section, retrieve text value |
|
197 TPtrC result; |
|
198 TBool ret=EFalse; //return value from FindVar functions |
|
199 |
|
200 // Set the active state of the plugin depending on the contents of the |
|
201 // corresponding file, which has been set as a member variable |
|
202 ret =file->FindVar(_L("SectionOne"),_L("activeState"),result); |
|
203 if(!ret) |
|
204 { |
|
205 RDebug::Print(_L("Key or section not found. iActiveState default value of ETRUE used.")); |
|
206 iActiveState = ETrue; // Default value |
|
207 } |
|
208 else |
|
209 { |
|
210 _LIT(KFalse,"false"); |
|
211 // Create a lower case copy of the data that is read from the file |
|
212 TBuf<10> resultLowerCase; |
|
213 resultLowerCase.Copy(result); |
|
214 resultLowerCase.LowerCase(); |
|
215 if (resultLowerCase.FindF(KFalse) == KErrNotFound) |
|
216 iActiveState = ETrue; // The string 'false' was not found, so we set the value to 'true' -the default value |
|
217 else |
|
218 iActiveState = EFalse; |
|
219 } |
|
220 TRAPD(r,file->WriteToFileL()); |
|
221 |
|
222 if (KErrNone != r) |
|
223 { |
|
224 RDebug::Print(_L("Error occurred while writing to the file.")); |
|
225 TBuf<84> initInfoFile(sysDrive.Name()); |
|
226 initInfoFile.Append(KInitInfoFile); |
|
227 RDebug::Print(_L("Filename = %S, KeyName = activeState,"), &initInfoFile); |
|
228 RDebug::Print(_L("value = %S."), &result); |
|
229 } |
|
230 delete file; |
|
231 } |
|
232 } |
|
233 |
|
234 |
|
235 |
|
236 //Implement CAuthPluginInterface definitions |
|
237 |
|
238 /** |
|
239 Normally, this would ask the user to input a 4-digit pin and then compare it to |
|
240 the values that this plugin has been trained with. The result should be the |
|
241 user that this PIN corresponds to. |
|
242 'aResult' should be the 'hash' of the stored PIN (which corresponds to the freshly entered PIN) |
|
243 but in this case, it's returned as it was 'unhashed'. |
|
244 */ |
|
245 |
|
246 void CTPinAuthPlugin::Identify(TIdentityId& aId, const TDesC& aClientMessage, |
|
247 HBufC8*& aResult, TRequestStatus& aRequest) |
|
248 { |
|
249 ASSERT(IsActive()); |
|
250 |
|
251 // We are simulating user input by reading from a file |
|
252 // (The data contained in this file has been freshly written by the 'client part in TestExecute') |
|
253 |
|
254 if(aClientMessage != *ClientMessage()) |
|
255 { |
|
256 RDebug::Print(_L("Display String Mismatch !!!")); |
|
257 } |
|
258 else |
|
259 { |
|
260 RDebug::Print(_L("Display String at the plugin matches the string sent !! ")); |
|
261 } |
|
262 aRequest = KRequestPending; |
|
263 |
|
264 TBuf8<32> userInput; |
|
265 TRAPD(result1, IdReadUserInput(userInput)); //Get the data from the AuthSvrPolicy.ini file |
|
266 if (KErrNone != result1) |
|
267 { |
|
268 aRequest = result1; |
|
269 } |
|
270 else |
|
271 { |
|
272 // No errors, carry on |
|
273 //Convert the 8-bit string to a 16-bit string for printing in RDebug |
|
274 HBufC* buf = 0; |
|
275 buf = HBufC::NewLC(32); |
|
276 buf->Des().Copy(userInput); |
|
277 _LIT(KMsgDebug1,"Identifying Userinput read from file = %S"); |
|
278 RDebug::Print(KMsgDebug1, buf); |
|
279 CleanupStack::PopAndDestroy(buf); //Memory cleanup. This string was only needed for the above Print function |
|
280 |
|
281 // Possibly, to allow for the cancellation or quitting, allow that to be the input string |
|
282 _LIT8(KCancelText, "Cancel"); |
|
283 _LIT8(KQuitText, "Quit"); |
|
284 if (userInput == KCancelText) |
|
285 { |
|
286 TRequestStatus* status = &aRequest; |
|
287 User::RequestComplete(status, KErrAuthServPluginCancelled); |
|
288 //aResult will not be updated, as specified |
|
289 } |
|
290 else if (userInput == KQuitText) |
|
291 { |
|
292 TRequestStatus* status = &aRequest; |
|
293 User::RequestComplete(status, KErrAuthServPluginQuit); |
|
294 //aResult will not be updated, as specified |
|
295 } |
|
296 else |
|
297 { |
|
298 //compare with the known set of inputs and see if this is one of them. |
|
299 TInt result2 = CheckForStringPresence(aId, userInput, aRequest); |
|
300 if (KErrNone == result2) //The above function did not leave |
|
301 { |
|
302 //See if the string was found. |
|
303 TInt length = userInput.Length(); |
|
304 |
|
305 aResult = HBufC8::New(length); |
|
306 aResult->Des().Format(_L8("%S"), &userInput); |
|
307 |
|
308 RDebug::Printf("aResult has been updated. aResult = %S, userInput = %S", |
|
309 aResult, &userInput); |
|
310 TRequestStatus* status = &aRequest; |
|
311 User::RequestComplete(status, result2); |
|
312 |
|
313 //Note: aRequest has been updated by the CheckForStringPresence function |
|
314 } |
|
315 else if (KErrNotFound == result2) |
|
316 { |
|
317 RDebug::Printf("The data that the user input was not found (recognized)" |
|
318 "Error = %d", result2); |
|
319 |
|
320 TRequestStatus* status = &aRequest; |
|
321 aId = KUnknownIdentity; |
|
322 User::RequestComplete(status, KErrNone); |
|
323 } |
|
324 else |
|
325 { |
|
326 //Caters for file access errors etc |
|
327 RDebug::Printf("Error occurred while checking for the presence of the string" |
|
328 "in the list. Error = %d", result2); |
|
329 |
|
330 TRequestStatus* status = &aRequest; |
|
331 aId = KUnknownIdentity; |
|
332 User::RequestComplete(status, KErrNone); |
|
333 } |
|
334 } |
|
335 //End of 'else' where the user did not cancel or quit the 'identify' process |
|
336 } |
|
337 } |
|
338 |
|
339 void CTPinAuthPlugin::Cancel() |
|
340 { |
|
341 } |
|
342 |
|
343 void CTPinAuthPlugin::Train(TIdentityId aId, HBufC8*& aResult, TRequestStatus& aRequest) |
|
344 { |
|
345 |
|
346 //Accept user input and update the list of inputs along with IDs. |
|
347 |
|
348 ASSERT(IsActive()); |
|
349 |
|
350 aRequest = KRequestPending; |
|
351 //TInt result = KErrNone; |
|
352 |
|
353 TBuf8<32> userInput; |
|
354 TRAPD(result1, TrainReadUserInput(userInput)); |
|
355 if (KErrNone != result1) |
|
356 { |
|
357 _LIT(KMsgDebug2,"Training Userinput read Error: result = %d"); |
|
358 RDebug::Print(KMsgDebug2, result1); |
|
359 } |
|
360 else |
|
361 { |
|
362 // No errors, carry on |
|
363 //Convert the 8-bit string to a 16-bit string for printing in RDebug |
|
364 HBufC* buf = 0; |
|
365 TRAPD(err, buf = HBufC::NewL(32)); |
|
366 |
|
367 if(err == KErrNoMemory) |
|
368 { |
|
369 TRequestStatus* status = &aRequest; |
|
370 User::RequestComplete(status, KErrNoMemory); |
|
371 return; |
|
372 } |
|
373 buf->Des().Copy(userInput); |
|
374 _LIT(KMsgDebug3, "--Training Userinput read from file = %S"); |
|
375 RDebug::Print(KMsgDebug3, buf); |
|
376 delete buf; //Memory cleanup. This string was only needed for the above Print function |
|
377 |
|
378 // To allow for the cancellation or quitting, allow that to be the input string |
|
379 TRequestStatus aRequest2 = KRequestPending; |
|
380 _LIT8(KCancelText, "Cancel"); |
|
381 _LIT8(KQuitText, "Quit"); |
|
382 userInput.Trim(); |
|
383 if (userInput.CompareF(KCancelText) == 0) |
|
384 { aRequest2 = KErrAuthServPluginCancelled; } |
|
385 else if (userInput.CompareF(KQuitText) == 0) |
|
386 { aRequest2 = KErrAuthServPluginQuit; } |
|
387 else |
|
388 { |
|
389 //compare with the present set of inputs and see if this is one of them. |
|
390 // update this list with this new user input, tagged to the aId |
|
391 TRAPD(result2, CheckForNewStringPresenceL(aId, userInput, aRequest2)); |
|
392 if (KErrNone != result2) |
|
393 { |
|
394 _LIT(KMsgDebug4, "Training Userinput read Error: results = %d"); |
|
395 RDebug::Print(KMsgDebug4, result2); |
|
396 } |
|
397 else if(KErrNone == aRequest2.Int()) |
|
398 { |
|
399 // No errors, update aResult. |
|
400 // First allocate space for it since this variable will always be a |
|
401 // null pointer coming into this function |
|
402 |
|
403 TRAPD(err1,aResult = HBufC8::NewL(userInput.Size())); |
|
404 if(err1 == KErrNoMemory) |
|
405 { |
|
406 TRequestStatus* status = &aRequest; |
|
407 RDebug::Printf("User::request complete with kerr no memory"); |
|
408 User::RequestComplete(status, KErrNoMemory); |
|
409 return; |
|
410 } |
|
411 *aResult = userInput; |
|
412 aRequest2 = KErrNone; |
|
413 } |
|
414 else |
|
415 { |
|
416 _LIT(KMsgDebug5, "Error occurred during training. aRequest.Int() = %d"); |
|
417 RDebug::Print(KMsgDebug5, aRequest2.Int()); |
|
418 //aResult is not updated, nor is aId |
|
419 } |
|
420 } |
|
421 // Complete the asynchronous function |
|
422 TRequestStatus* status = &aRequest; |
|
423 User::RequestComplete(status, aRequest2.Int()); |
|
424 } |
|
425 } |
|
426 |
|
427 TBool CTPinAuthPlugin::IsActive () const |
|
428 { |
|
429 // There is never any user intervention required |
|
430 //return true; |
|
431 // As a future development note, this value may be read from a file (or a section in a file) |
|
432 |
|
433 ReloadActiveStateFromIniFile(); |
|
434 return iActiveState; |
|
435 } |
|
436 |
|
437 TInt CTPinAuthPlugin::Forget(TIdentityId aId) |
|
438 { |
|
439 // Open the list of userInputs that have been stored by this plugin |
|
440 // Then find the one that corresponds to this id |
|
441 // Then remove this string from the list and return the correct status value |
|
442 |
|
443 //Open the file |
|
444 TRAPD(result3, FindStringAndRemoveL(aId)); |
|
445 return result3; |
|
446 |
|
447 } |
|
448 |
|
449 TInt CTPinAuthPlugin::DefaultData(TIdentityId aId, HBufC8*& aOutputBuf) |
|
450 { |
|
451 |
|
452 // This implementation of the PIN plugin does support default data. |
|
453 // There will be cases where i don't want this available. Hence the addition of a |
|
454 // new class member iSupportsDefaultData |
|
455 ReloadAllFromIniFile(); |
|
456 |
|
457 TInt result = KErrNotSupported; |
|
458 TRequestStatus aRequest2 = KRequestPending; |
|
459 |
|
460 if (iSupportsDefaultData) //Class member initialised in the constructor |
|
461 { |
|
462 TBufC8<16> defaultBuf(KDefaultData); |
|
463 //compare with the present set of inputs and see if this is one of them. |
|
464 // update this list with this new user input, tagged to the aId |
|
465 TRAPD(result2, CheckForNewStringPresenceL(aId, defaultBuf, aRequest2)); |
|
466 if (KErrNone != result2) |
|
467 { |
|
468 _LIT(KMsgDebug4, "Training Userinput read Error: results = %d"); |
|
469 RDebug::Print(KMsgDebug4, result2); |
|
470 } |
|
471 else if(KErrNone == aRequest2.Int()) |
|
472 { |
|
473 // No errors, update aOutputBuf. |
|
474 // First allocate space for it since this variable will always be a |
|
475 // null pointer coming into this function |
|
476 |
|
477 TRAPD(resAlloc, (aOutputBuf = HBufC8::NewL(KDefaultData().Size())) ); |
|
478 if (KErrNone != resAlloc) |
|
479 { |
|
480 _LIT(KMsgAllocFailed2,"Failed to allocate memory for updating aOutputBuf"); |
|
481 RDebug::Print(KMsgAllocFailed2); |
|
482 result = resAlloc; |
|
483 } |
|
484 else |
|
485 { |
|
486 *aOutputBuf = KDefaultData; |
|
487 result = KErrNone; |
|
488 } |
|
489 } |
|
490 else |
|
491 { |
|
492 _LIT(KMsgDebug5, "Error occurred during training. aRequest2.Int() = %d"); |
|
493 RDebug::Print(KMsgDebug5, aRequest2.Int()); |
|
494 //aOutputBuf is not updated, nor is aId |
|
495 } |
|
496 } |
|
497 |
|
498 return result; |
|
499 } |
|
500 |
|
501 TInt CTPinAuthPlugin::Reset(TIdentityId aId, const TDesC& aRegistrationData, HBufC8*& aResult) |
|
502 { |
|
503 // To enable testing return KErrNotSupported for one of the knowledge-based incarnations of this class |
|
504 if (Id() == 0x11113102) |
|
505 { |
|
506 return KErrNotSupported; |
|
507 } |
|
508 |
|
509 // If no registration data is supplied or if this plugin is configured as non-knowledge |
|
510 // type plugin then reset is simply a forget operation else the registration data is |
|
511 // used to retrain the plugin |
|
512 if ((aRegistrationData == KNullDesC) || (Id() == 0x11113101) || (Type() == EAuthBiometric) || (Type() == EAuthToken)) |
|
513 { |
|
514 aResult = NULL; |
|
515 TRAPD(err, FindStringAndRemoveL(aId)); |
|
516 return err; |
|
517 } |
|
518 |
|
519 // For EAuthKnowledge type |
|
520 // Convert the 16-bit string to a 8-bit string (pin) |
|
521 // Note that no unicode conversion is being done here since a pin cannot be in unicode |
|
522 RBuf8 pinBuf; |
|
523 TBuf8<32> newPin; |
|
524 TRAPD(err, pinBuf.CreateL(32);\ |
|
525 CleanupClosePushL(pinBuf);\ |
|
526 pinBuf.Copy(aRegistrationData.Left(32));\ |
|
527 newPin = pinBuf;\ |
|
528 CleanupStack::PopAndDestroy(&pinBuf)); |
|
529 if (err != KErrNone) |
|
530 { |
|
531 return err; |
|
532 } |
|
533 |
|
534 // Log a message |
|
535 TBuf8<32> userInput; |
|
536 _LIT(KMsgDebug3, "Reset with registration data = %S"); |
|
537 RDebug::Print(KMsgDebug3, &aRegistrationData); |
|
538 |
|
539 // Compare with the present set of inputs and see if this is one of them. |
|
540 // update this list with this new user input, tagged to the aId |
|
541 TRequestStatus request = KRequestPending; |
|
542 TRAP(err, CheckForNewStringPresenceL(aId, newPin, request)); |
|
543 |
|
544 if( KErrNoMemory == err) |
|
545 { |
|
546 User::LeaveNoMemory(); |
|
547 } |
|
548 if (err != KErrNone) |
|
549 { |
|
550 RDebug::Print(_L("Reset error = %d"), err); |
|
551 return err; |
|
552 } |
|
553 else if (request.Int() == KErrNone) |
|
554 { |
|
555 // No errors, update aResult. |
|
556 TRAP(err, aResult = HBufC8::NewL(newPin.Size())); |
|
557 if (err != KErrNone) |
|
558 { |
|
559 return err; |
|
560 } |
|
561 *aResult = newPin; |
|
562 } |
|
563 else |
|
564 { |
|
565 _LIT(KMsgDebug5, "Error occurred during reset. request.Int() = %d"); |
|
566 RDebug::Print(KMsgDebug5, request.Int()); |
|
567 return request.Int(); |
|
568 } |
|
569 |
|
570 return KErrNone; |
|
571 } |
|
572 |
|
573 //-------------------------------------------------------------------------------- |
|
574 |
|
575 /** |
|
576 Utility method to capture the data that the user has input |
|
577 (in the form of data stored in a file) |
|
578 */ |
|
579 TInt CTPinAuthPlugin::IdReadUserInput(TBuf8<32>& aInputValue) |
|
580 { |
|
581 |
|
582 TInt retValue; |
|
583 CIniData* file=NULL; |
|
584 TRAPD(r,file=CIniData::NewL(iFileToRead)); |
|
585 if(r!=KErrNone) |
|
586 { |
|
587 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &iFileToRead); |
|
588 retValue = r; |
|
589 } |
|
590 |
|
591 else |
|
592 { |
|
593 // Look for a key under a named section, retrieve text value |
|
594 TPtrC result; |
|
595 TBool ret=EFalse; //return value from FindVar functions |
|
596 |
|
597 ret=file->FindVar(_L("SectionOne"),_L("IdEnteredPinValue"),result); |
|
598 if(!ret) |
|
599 { |
|
600 RDebug::Print(_L("Unable to find the key in the file %S. IdEnteredPinValue is not known, 9999 used. Error = %d"), &iFileToRead, ret); |
|
601 _LIT8(KEnteredPinValueErr, "9999"); |
|
602 aInputValue = KEnteredPinValueErr; // Default value |
|
603 retValue = KErrNotFound; |
|
604 } |
|
605 else |
|
606 { |
|
607 //Later,include a check to ensure that only digits were entered |
|
608 aInputValue.Copy(result); |
|
609 aInputValue.Trim(); |
|
610 retValue = KErrNone; //Not necessary |
|
611 } |
|
612 delete file; //memory cleanup |
|
613 } |
|
614 |
|
615 return retValue; |
|
616 } |
|
617 |
|
618 TInt CTPinAuthPlugin::TrainReadUserInput(TBuf8<32>& aInputValue) |
|
619 { |
|
620 |
|
621 TInt retValue; |
|
622 CIniData* file=NULL; |
|
623 TRAPD(r,file=CIniData::NewL(iFileToRead)); |
|
624 if(r!=KErrNone) |
|
625 { |
|
626 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &iFileToRead); |
|
627 retValue = r; |
|
628 } |
|
629 |
|
630 else |
|
631 { |
|
632 // Look for a key under a named section, retrieve text value |
|
633 TPtrC result; |
|
634 TBool ret=EFalse; //return value from FindVar functions |
|
635 |
|
636 ret=file->FindVar(_L("SectionOne"),_L("TrainEnteredPinValue"),result); |
|
637 if(!ret) |
|
638 { |
|
639 RDebug::Print(_L("Unable to find the key in the file %S. TrainEnteredPinValue is not known, 9999 used. Error = %d"), &iFileToRead, ret); |
|
640 _LIT8(KEnteredPinValueErr, "9999"); |
|
641 aInputValue = KEnteredPinValueErr; // Default value |
|
642 retValue = KErrNotFound; |
|
643 } |
|
644 else |
|
645 { |
|
646 aInputValue.Copy(result); |
|
647 aInputValue.Trim(); |
|
648 retValue = KErrNone; //Not necessary |
|
649 } |
|
650 delete file; //memory cleanup |
|
651 } |
|
652 |
|
653 return retValue; |
|
654 } |
|
655 |
|
656 /** |
|
657 Utility method to compare the data that the user has input |
|
658 with all the data that has been stored for users |
|
659 Called by Identify() |
|
660 @return - success or failure value |
|
661 */ |
|
662 TInt CTPinAuthPlugin::CheckForStringPresence(TIdentityId& aId, TBuf8<32> aInputValue, TRequestStatus& aRequestValue) |
|
663 { |
|
664 |
|
665 TInt retValue = KErrNone; |
|
666 // First format the aInputValue string so that it starts with a ':' and ends with a ','. |
|
667 _LIT8(KFormatValue2, ":%S,"); |
|
668 TBuf8<32> aInputValue2; |
|
669 aInputValue2.Format(KFormatValue2, &aInputValue); |
|
670 |
|
671 //Convert the 8-bit string to a 16-bit string for printing in RDebug |
|
672 HBufC* buf = 0; |
|
673 buf = HBufC::New(32); |
|
674 buf->Des().Copy(aInputValue); |
|
675 RDebug::Print(_L("Formatted string: %S"), buf); |
|
676 delete buf; //Memory cleanup. This string was only needed for the above Print function |
|
677 |
|
678 TBuf8<500> pinFileContents1, pinFileContents2; |
|
679 // Read the contents of the file that contains all the ID/PIN combinations |
|
680 |
|
681 CIniData* file=NULL; |
|
682 TRAPD(r,file=CIniData::NewL(iFileToRead)); |
|
683 if(KErrNoMemory == r) |
|
684 { |
|
685 delete file; |
|
686 RDebug::Print(_L("Unable to create CIniData object - No memory !! ")); |
|
687 User::LeaveNoMemory(); |
|
688 |
|
689 } |
|
690 if(r!=KErrNone) |
|
691 { |
|
692 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &iFileToRead); |
|
693 retValue = r; |
|
694 } |
|
695 else |
|
696 { |
|
697 // Look for a key under a named section, retrieve text value |
|
698 TPtrC result; |
|
699 TBool ret=EFalse; //return value from FindVar functions |
|
700 |
|
701 ret=file->FindVar(_L("SectionOne"),_L("Identity&PinValues"),result); |
|
702 if(!ret) |
|
703 { |
|
704 RDebug::Print(_L("Unable to find the Identity&PinValues key in the file %S."), &iFileToRead); |
|
705 retValue = KErrNotFound; |
|
706 aRequestValue =KErrNotFound; |
|
707 } |
|
708 else |
|
709 { |
|
710 pinFileContents1.Copy(result); |
|
711 |
|
712 TInt searchResult; |
|
713 searchResult = pinFileContents1.Find(aInputValue2); |
|
714 |
|
715 if (KErrNotFound == searchResult) |
|
716 { |
|
717 RDebug::Print(_L("Userinput not found in the pinFile %S. Identification error"), &iFileToRead); |
|
718 aRequestValue= KErrAuthServIdentityNotFound; |
|
719 retValue = searchResult; |
|
720 } |
|
721 else if (searchResult) // a positive value |
|
722 { |
|
723 // Now find the userID by searching back through the string for the "," marker |
|
724 pinFileContents2 = pinFileContents1.Left(searchResult); |
|
725 TInt userIdStartPos = pinFileContents2.LocateReverse(','); |
|
726 |
|
727 //Extract this userId for use by the calling function |
|
728 TBuf8<50> p1 = pinFileContents2.Right(searchResult - userIdStartPos - 1); |
|
729 TLex8 input (p1); |
|
730 TRadix aRadix = EDecimal; |
|
731 input.Val(aId, aRadix); |
|
732 RDebug::Print(_L("UserId that is stored = %u"), aId); |
|
733 aRequestValue = KErrNone; |
|
734 retValue = KErrNone; |
|
735 } |
|
736 else |
|
737 { |
|
738 RDebug::Print(_L("Unexpected error in the 'Find' function. Searchresult = %d"), searchResult); |
|
739 aRequestValue = searchResult; |
|
740 retValue = searchResult; |
|
741 }//End check for key§ion search in file |
|
742 }//End check for safe file access |
|
743 delete file; |
|
744 } |
|
745 |
|
746 return retValue; |
|
747 } |
|
748 |
|
749 /** |
|
750 Utility method to compare the data that the user has input |
|
751 with all the data that has been stored for users |
|
752 Used to find out if the input is unique. |
|
753 -since KIdAmbiguous is no longer used, KIdCancel will be returned if the input is non-unique |
|
754 Called by Train() and DefaultData() |
|
755 */ |
|
756 TInt CTPinAuthPlugin::CheckForNewStringPresenceL(TIdentityId aId, TBuf8<32> aInputValue, TRequestStatus& aRequestValue) |
|
757 { |
|
758 TBuf8<500> pinFileContents, pinFileContents2; |
|
759 TInt retValue = KErrNone; |
|
760 |
|
761 CIniData* file=NULL; |
|
762 TRAPD(r,file=CIniData::NewL(iFileToRead)); |
|
763 if(KErrNoMemory == r) |
|
764 { |
|
765 User::LeaveNoMemory(); |
|
766 } |
|
767 if(r!=KErrNone) |
|
768 { |
|
769 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &iFileToRead); |
|
770 return r; |
|
771 } |
|
772 |
|
773 |
|
774 // Look for a key under a named section, retrieve text value |
|
775 TPtrC result; |
|
776 TBool ret=EFalse; //return value from FindVar functions |
|
777 aRequestValue = KErrAuthServIdentityNotFound; //Initialisation |
|
778 |
|
779 ret=file->FindVar(KPluginIniSection, KPinDbTag,result); |
|
780 if(!ret) |
|
781 { |
|
782 RDebug::Print(_L("Unable to find the %S key in the file %S."), &KPinDbTag, &iFileToRead); |
|
783 delete file; |
|
784 return KErrNotFound; |
|
785 } |
|
786 |
|
787 //Copy the data from the named section in the file, and see if any previous user has used this input string |
|
788 pinFileContents.Copy(result); |
|
789 |
|
790 TInt searchResultPin; |
|
791 TBuf8<50> searchStringPin; |
|
792 _LIT8(KFormat3, ":%S,"); |
|
793 searchStringPin.Format(KFormat3, &aInputValue); |
|
794 searchResultPin = pinFileContents.Find(searchStringPin); |
|
795 |
|
796 if (KErrNotFound == searchResultPin) |
|
797 { |
|
798 //check that the identity is unique, if so, update the Db |
|
799 // with the new Id-PIN pair, as is done already |
|
800 // else update the PIN only, ie training data for that identity |
|
801 TInt searchResultId; |
|
802 TBuf8<50> searchStringId; |
|
803 _LIT8(KFormat4, ",%u:"); |
|
804 searchStringId.Format(KFormat4, aId); |
|
805 |
|
806 searchResultId = pinFileContents.Find(searchStringId); |
|
807 |
|
808 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
809 TBuf<80> policyFile; |
|
810 if (KErrNotFound == searchResultId) |
|
811 { |
|
812 // Add this entry to the file |
|
813 // This is a simple system, expecting a format as below: |
|
814 // ",aId:inputPin,aId:inputPin,aId:inputPin," |
|
815 |
|
816 _LIT8(KFormat2, "%S%u:%S,"); |
|
817 if (pinFileContents.Size() == 0) |
|
818 { |
|
819 pinFileContents.Append(','); //Initialisation |
|
820 } |
|
821 pinFileContents2.Format(KFormat2, &pinFileContents, aId, &aInputValue); |
|
822 |
|
823 //For the purpose of writing the data to a file, i'll create a 16-bit version of pinFileContents |
|
824 TInt ret2 = 0; |
|
825 HBufC* buf = 0; |
|
826 TRAPD(err,buf = HBufC::NewL(pinFileContents2.Length())); |
|
827 |
|
828 if(err == KErrNoMemory) |
|
829 { |
|
830 delete file; |
|
831 User::LeaveNoMemory(); |
|
832 } |
|
833 buf->Des().Copy(pinFileContents2); |
|
834 ret2 = file->SetValue(_L("SectionOne"),_L("Identity&PinValues"), *buf); |
|
835 |
|
836 TRAPD(r,file->WriteToFileL()); |
|
837 |
|
838 |
|
839 if (KErrNone != r) |
|
840 { |
|
841 policyFile.Copy(sysDrive.Name()); |
|
842 policyFile.Append(KPolicyFile); |
|
843 RDebug::Print(_L("Error occurred while writing to the file. Filename = %S, KeyName = AllUserID&PinValues, value = %S."), &policyFile, buf); |
|
844 } |
|
845 delete buf; //Memory cleanup. This string was only needed for the above Print function |
|
846 |
|
847 if(KErrNone == ret2) |
|
848 { |
|
849 aRequestValue = KErrNone; |
|
850 |
|
851 //Update the global database |
|
852 AddToGlobalDb(aId, aInputValue); |
|
853 } |
|
854 else |
|
855 { |
|
856 RDebug::Print(_L("Error occurred while writing data to file. Error = %d"), ret2); |
|
857 aRequestValue = ret2; |
|
858 } |
|
859 |
|
860 } |
|
861 |
|
862 else |
|
863 { |
|
864 //The Identity has already been trained with this plugin, |
|
865 // update the PIN (training data) |
|
866 |
|
867 //extract the string to the right of the end of the aId |
|
868 pinFileContents2 = pinFileContents.Mid(searchResultId + searchStringId.Size()); |
|
869 |
|
870 //Find the end of the PIN (Training data) |
|
871 _LIT8(KPinEndMarker, ","); |
|
872 TBufC8<5> bufPinEndMarker(KPinEndMarker); |
|
873 TInt pinEndPos = pinFileContents2.Find(bufPinEndMarker); |
|
874 |
|
875 //Replace this with the new PIN |
|
876 pinFileContents.Replace((searchResultId + searchStringId.Size()), |
|
877 pinEndPos, aInputValue); |
|
878 |
|
879 //For the purpose of writing the data to a file, i'll create a 16-bit version of pinFileContents |
|
880 TInt ret2 = 0; |
|
881 HBufC* buf = 0; |
|
882 TRAPD(err1,buf = HBufC::NewL(pinFileContents.Length())); |
|
883 if(err1 == KErrNoMemory) |
|
884 { |
|
885 delete file; |
|
886 User::LeaveNoMemory(); |
|
887 } |
|
888 buf->Des().Copy(pinFileContents); |
|
889 |
|
890 ret2 = file->SetValue(_L("SectionOne"),_L("Identity&PinValues"), *buf); |
|
891 |
|
892 TRAPD(r,file->WriteToFileL()); |
|
893 |
|
894 if (KErrNone != r) |
|
895 { |
|
896 policyFile.Copy(sysDrive.Name()); |
|
897 policyFile.Append(KPolicyFile); |
|
898 RDebug::Print(_L("Error occurred while writing to the file. Filename = %S, KeyName = AllUserID&PinValues, value = %S."), &policyFile, buf); |
|
899 } |
|
900 delete buf; //Memory cleanup. This string was only needed for the above Print function |
|
901 |
|
902 if(KErrNone ==ret2) |
|
903 { |
|
904 aRequestValue = KErrNone; |
|
905 |
|
906 //Update the global database |
|
907 AddToGlobalDb(aId, aInputValue); |
|
908 } |
|
909 else |
|
910 { |
|
911 RDebug::Print(_L("Error occurred while writing data to file. Error = %d"), ret2); |
|
912 aRequestValue = ret2; |
|
913 } |
|
914 } |
|
915 delete file; |
|
916 return ret; |
|
917 } |
|
918 if (searchResultPin) // a positive value |
|
919 { |
|
920 // A user has already tried to train this plugin using the given data. |
|
921 // The pinFileContents are not updated, to avoid duplication |
|
922 |
|
923 aRequestValue = KErrAuthServPluginCancelled; |
|
924 delete file; |
|
925 return searchResultPin; |
|
926 } |
|
927 |
|
928 RDebug::Print(_L("Unexpected error in the 'Find' function. SearchresultPin = %d"), searchResultPin); |
|
929 retValue = searchResultPin; |
|
930 |
|
931 delete file; |
|
932 |
|
933 return retValue; |
|
934 } |
|
935 |
|
936 |
|
937 /** |
|
938 Utility function to remove the training data that is associated with a given Id |
|
939 Called by the Forget function |
|
940 @return - KIdSuccess, KIdUnknown or some error code |
|
941 */ |
|
942 TInt CTPinAuthPlugin::FindStringAndRemoveL (TIdentityId aId) |
|
943 { |
|
944 TBuf8<500> pinFileContents, pinFileContents2; |
|
945 TInt retValue = KErrAuthServNoSuchIdentity; //init |
|
946 CIniData* file=NULL; |
|
947 //First read the list of userId and PIN combinations from a file |
|
948 TRAPD(r,file=CIniData::NewL(iFileToRead)); |
|
949 if(r!=KErrNone) |
|
950 { |
|
951 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &iFileToRead); |
|
952 retValue = r; |
|
953 } |
|
954 else |
|
955 { |
|
956 // Look for a key under a named section, retrieve text value |
|
957 TPtrC result; |
|
958 TBool ret=EFalse; //return value from FindVar functions |
|
959 |
|
960 ret=file->FindVar(KPluginIniSection, KPinDbTag,result); |
|
961 if(!ret) |
|
962 { |
|
963 RDebug::Print(_L("Config error: Unable to find the %S key in the file %S."), &KPinDbTag, &iFileToRead); |
|
964 retValue = KErrNotFound; |
|
965 } |
|
966 else |
|
967 { |
|
968 //Copy the data from the named section in the file, and see if any previous user has used this input string |
|
969 pinFileContents.Copy(result); |
|
970 |
|
971 //Format the searchstring as defined in the file so that it starts with a ',' and ends with a ':'. |
|
972 _LIT8(KFormatValue3, ",%u:"); |
|
973 |
|
974 TBuf8<32> searchString; |
|
975 searchString.Format(KFormatValue3, aId); |
|
976 |
|
977 //For the purpose of printing the data to a file, i'll create a 16-bit version of pinFileContents |
|
978 HBufC* buf = 0; |
|
979 buf = HBufC::NewL(searchString.Length()); |
|
980 buf->Des().Copy(searchString); |
|
981 RDebug::Print(_L("Formatted searchString used in 'FindStringAndRemove(): %S"), buf); |
|
982 delete buf; |
|
983 |
|
984 TInt userIdStartPos; //The offset of the searchString within pinFileContents |
|
985 //i.e the position of the '.' just before the identityId |
|
986 userIdStartPos = pinFileContents.Find(searchString); |
|
987 if (KErrNotFound == userIdStartPos) |
|
988 { |
|
989 RDebug::Print(_L("FindStringAndRemoveL: The specified ID was not found in the pinFile")); |
|
990 retValue = KErrAuthServNoSuchIdentity; //KIdUnknown; |
|
991 } |
|
992 else |
|
993 { |
|
994 |
|
995 //Find where the string (including PIN) ends |
|
996 TLex8 aLex = TLex8(pinFileContents); |
|
997 TInt length(0); |
|
998 aLex.Inc(userIdStartPos+1); |
|
999 while(aLex.Peek() != ',') |
|
1000 { |
|
1001 aLex.Inc(); |
|
1002 length++; |
|
1003 } |
|
1004 |
|
1005 //remove the found (total) string from the list (including the starting ',') |
|
1006 pinFileContents.Delete(userIdStartPos,length+1); |
|
1007 |
|
1008 //Update the file |
|
1009 //For the purpose of writing the data to a file, i'll create a 16-bit version of pinFileContents |
|
1010 TInt ret2 = 0; |
|
1011 HBufC* buf; |
|
1012 buf = HBufC::NewL(pinFileContents.Length()); |
|
1013 buf->Des().Copy(pinFileContents); |
|
1014 |
|
1015 ret2 = file->SetValue(KPluginIniSection, KPinDbTag, *buf); |
|
1016 |
|
1017 TRAPD(r,file->WriteToFileL()); |
|
1018 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
1019 TBuf<2> sysDriveName (sysDrive.Name()); |
|
1020 TBuf<84> policyFile; |
|
1021 |
|
1022 if (KErrNone != r) |
|
1023 { |
|
1024 policyFile.Copy(sysDriveName); |
|
1025 policyFile.Append(KPolicyFile); |
|
1026 RDebug::Print(_L("Error occurred while writing to the file. Filename = %S, KeyName = AllUserID&PinValues, value = %S."), &policyFile, buf); |
|
1027 } |
|
1028 delete buf; //Memory cleanup. This string was only needed for the above Print function |
|
1029 |
|
1030 if (KErrNone !=ret2) |
|
1031 { |
|
1032 policyFile .Copy(sysDriveName); |
|
1033 policyFile.Append(KAuthSvrPolicyFile); |
|
1034 RDebug::Print(_L("Error occurred in WriteToFileL(). Error = %d. Filename= %S"), ret2, &policyFile); |
|
1035 retValue = ret2; |
|
1036 } |
|
1037 else |
|
1038 { |
|
1039 retValue = KErrNone; |
|
1040 } |
|
1041 } |
|
1042 }//End check for key§ion search in file |
|
1043 delete file; |
|
1044 }//End check for safe file access |
|
1045 |
|
1046 return retValue; |
|
1047 } |
|
1048 |
|
1049 |
|
1050 /** |
|
1051 Utility function to Update the Global Db with the training data |
|
1052 that is associated with a given Id. The update will not happen if |
|
1053 the identity is already present in this list, i.e. it's been pu in |
|
1054 by another plugin |
|
1055 Called by the CheckForNewStringPresence function |
|
1056 @return - KErrNone, or some error code |
|
1057 */ |
|
1058 TInt CTPinAuthPlugin::AddToGlobalDb (TIdentityId aId, TBuf8<32> aInputValue) |
|
1059 { |
|
1060 |
|
1061 TBuf8<500> totalDbFileContents, totalDbFileContents2; |
|
1062 TInt retValue = KErrNone; |
|
1063 CIniData* file=NULL; |
|
1064 |
|
1065 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
1066 TDriveName sysDriveName (sysDrive.Name()); |
|
1067 TBuf<128> authSvrPolicyFile(sysDriveName); |
|
1068 authSvrPolicyFile.Append(KAuthSvrPolicyFile); |
|
1069 |
|
1070 TRAPD(r,file=CIniData::NewL(authSvrPolicyFile)); |
|
1071 if(r!=KErrNone) |
|
1072 { |
|
1073 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &authSvrPolicyFile); |
|
1074 retValue = r; |
|
1075 } |
|
1076 else |
|
1077 { |
|
1078 // Look for a key under a named section, retrieve text value |
|
1079 TPtrC result; |
|
1080 TBool ret=EFalse; //return value from FindVar functions |
|
1081 |
|
1082 ret=file->FindVar(KPluginIniSection, KTotalDbTag,result); |
|
1083 if(!ret) |
|
1084 { |
|
1085 RDebug::Print(_L("Unable to find the %S key in the file %S."), &KTotalDbTag, &authSvrPolicyFile); |
|
1086 retValue = KErrNotFound; |
|
1087 } |
|
1088 else |
|
1089 { |
|
1090 //Copy the data from the named section in the file, and see if any previous user has used this input string |
|
1091 totalDbFileContents.Copy(result); |
|
1092 TBuf8<20> aidString; |
|
1093 aidString.Num(aId, EDecimal); |
|
1094 TInt searchResult; |
|
1095 searchResult = totalDbFileContents.Find(aidString); |
|
1096 |
|
1097 if (KErrNotFound == searchResult) |
|
1098 { |
|
1099 // Add this entry to the file |
|
1100 // This is a simple system, expecting a format as below: |
|
1101 // ",aId:inputPin,aId:inputPin,aId:inputPin," |
|
1102 _LIT8(KFormat2, "%S%u:%S,"); |
|
1103 if (totalDbFileContents.Size() == 0) |
|
1104 { |
|
1105 totalDbFileContents.Append(','); //Initialisation |
|
1106 } |
|
1107 totalDbFileContents2.Format(KFormat2, &totalDbFileContents, aId, &aInputValue); |
|
1108 |
|
1109 //For the purpose of writing the data to a file, i'll create a 16-bit version of pinFileContents |
|
1110 TInt ret2 = 0; |
|
1111 HBufC* buf = 0; |
|
1112 TRAPD(err,buf = HBufC::NewL(totalDbFileContents2.Length())); |
|
1113 if(err == KErrNoMemory) |
|
1114 { |
|
1115 delete file; |
|
1116 return KErrNoMemory; |
|
1117 } |
|
1118 buf->Des().Copy(totalDbFileContents2); |
|
1119 ret2 = file->SetValue(KPluginIniSection, KTotalDbTag, *buf); |
|
1120 |
|
1121 TRAPD(r,file->WriteToFileL()); |
|
1122 |
|
1123 if (KErrNone != r) |
|
1124 { |
|
1125 TBuf<80> policyFile(sysDriveName); |
|
1126 policyFile.Append(KPolicyFile); |
|
1127 RDebug::Print(_L("Error occurred while writing to the file. Filename = %S, KeyName = AllUserID&PinValues, value = %S."), &policyFile, buf); |
|
1128 } |
|
1129 delete buf; //Memory cleanup. This string was only needed for the above Print function |
|
1130 |
|
1131 if (KErrNone !=ret2) |
|
1132 { |
|
1133 RDebug::Print(_L("Error occurred in SetValue(). Error = %d. Filename= %S"), ret2, &authSvrPolicyFile); |
|
1134 retValue = ret2; |
|
1135 } |
|
1136 } |
|
1137 else |
|
1138 { |
|
1139 // A user has already tried to train this plugin using the given data. |
|
1140 // The pinFileContents are not updated, to avoid duplication |
|
1141 retValue = KErrNone; |
|
1142 }//End aidString search in the totalDbFileContents string (Find()) |
|
1143 }//End check for key§ion search in file (FindVar()) |
|
1144 delete file; |
|
1145 }//End check for safe file access |
|
1146 return retValue; |
|
1147 } |
|
1148 |
|
1149 const HBufC* CTPinAuthPlugin::ClientMessage() |
|
1150 { |
|
1151 return iClientMessage; |
|
1152 } |
|
1153 |
|
1154 const TPtrC& CTPinAuthPlugin::Name() const |
|
1155 { |
|
1156 return iName; |
|
1157 } |
|
1158 const TPtrC& CTPinAuthPlugin::Description() const |
|
1159 { |
|
1160 return iDescription; |
|
1161 } |
|
1162 AuthServer::TAuthPluginType CTPinAuthPlugin::Type() const |
|
1163 { |
|
1164 return iType; |
|
1165 } |
|
1166 |
|
1167 AuthServer::TEntropy CTPinAuthPlugin::MinEntropy() const |
|
1168 { |
|
1169 return iMinEntropy; |
|
1170 } |
|
1171 |
|
1172 AuthServer::TPercentage CTPinAuthPlugin::FalsePositiveRate() const |
|
1173 { |
|
1174 return iFalsePositiveRate; |
|
1175 } |
|
1176 |
|
1177 AuthServer::TPercentage CTPinAuthPlugin::FalseNegativeRate() const |
|
1178 { |
|
1179 return iFalseNegativeRate; |
|
1180 } |
|
1181 |
|
1182 |