os/security/authorisation/userpromptservice/test/tups/src/tupsdbmanagementstep.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/authorisation/userpromptservice/test/tups/src/tupsdbmanagementstep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,667 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "tupsdbmanagementstep.h"
1.23 +#include "tupsintegdefs.h"
1.24 +#include <ups/upstypes.h>
1.25 +
1.26 +using namespace UserPromptService;
1.27 +
1.28 +_LIT(KOperationCreateView, "CreateView");
1.29 +_LIT(KOperationCancelCloseView, "CancelCloseView");
1.30 +_LIT(KOperationNextMatch, "NextMatch");
1.31 +_LIT(KOperationRemoveDecision, "RemoveDecision");
1.32 +_LIT(KOperationUpdateDecisionAllow, "UpdateDecisionAllow");
1.33 +_LIT(KOperationUpdateDecisionDeny, "UpdateDecisionDeny");
1.34 +_LIT(KOperationCancelUpdate, "CancelUpdate");
1.35 +_LIT(KOperationDeleteDatabase, "DeleteDatabase");
1.36 +_LIT(KOperationDecisionCount, "DecisionCount");
1.37 +
1.38 +
1.39 +CUpsDbRequest* CUpsDbRequest::NewL()
1.40 + {
1.41 + CUpsDbRequest* me = new (ELeave) CUpsDbRequest();
1.42 + CleanupStack::PushL(me);
1.43 + me->ConstructL();
1.44 + CleanupStack::Pop(me);
1.45 + return me;
1.46 + }
1.47 +
1.48 +CUpsDbRequest::~CUpsDbRequest()
1.49 + {
1.50 + delete iDecisionFilter;
1.51 + }
1.52 +
1.53 +CUpsDbRequest::CUpsDbRequest()
1.54 + :iOperation(0), iClientSid(0), iEvaluatorId(0), iServiceId(0), iServerSid(0), iFingerprint(0),
1.55 + iClientEntity(0), iDescription(0), iDecisionResult(0), iMajorPolicyVersion(0), iRecordId(0), iEvaluatorInfo(0), iExpectedDecisionCount(0)
1.56 + {
1.57 + }
1.58 +
1.59 +void CUpsDbRequest::ConstructL()
1.60 + {
1.61 + iDecisionFilter = CDecisionFilter::NewL();
1.62 + }
1.63 +
1.64 +CUPSDbManagementStep::CUPSDbManagementStep()
1.65 + {
1.66 + SetTestStepName(KUPSDbManagementStep);
1.67 + }
1.68 +
1.69 +CUPSDbManagementStep::~CUPSDbManagementStep()
1.70 + {
1.71 + iUpsManager.CancelAndCloseView();
1.72 + iUpsManager.Close();
1.73 + iArraySersToRequest.ResetAndDestroy();
1.74 + INFO_PRINTF2(_L("END CELLS: %d"), User::CountAllocCells());
1.75 + __UHEAP_MARKEND;
1.76 + }
1.77 +
1.78 +TVerdict CUPSDbManagementStep::doTestStepPreambleL()
1.79 +/**
1.80 + * @return - TVerdict code
1.81 + * Override of base class virtual
1.82 + */
1.83 + {
1.84 + __UHEAP_MARK;
1.85 +
1.86 + INFO_PRINTF2(_L("START CELLS: %d"), User::CountAllocCells());
1.87 +
1.88 + // reads client name and SID
1.89 + TParse clientFullName;
1.90 + RThread client;
1.91 + clientFullName.Set(client.FullName(),NULL, NULL);
1.92 + iTEFServerName=clientFullName.Name();
1.93 + iExpectedClientSid = client.SecureId() ;
1.94 + client.Close();
1.95 +
1.96 + // Read how many times the test step needs to be repeated.
1.97 + TName fStepRepeat(_L("StepRepeat"));
1.98 + TInt repeats;
1.99 +
1.100 + if(GetIntFromConfig(ConfigSection(),fStepRepeat,repeats))
1.101 + {
1.102 + iStepRepeat=repeats;
1.103 + }
1.104 + else
1.105 + {
1.106 + iStepRepeat=1;
1.107 + }
1.108 +
1.109 + // Read values for test sequence from INI file. (ARRAY of values)
1.110 + TInt index=0;
1.111 + TName fOperation;
1.112 + fOperation.Format(_L("Operation_%d"), index);
1.113 + TName fClientSid;
1.114 + fClientSid.Format(_L("ClientSid_%d"),index);
1.115 + TName fEvaluatorId;
1.116 + fEvaluatorId.Format(_L("EvaluatorId_%d"),index);
1.117 + TName fServiceId;
1.118 + fServiceId.Format(_L("ServiceId_%d"),index);
1.119 + TName fServerSid;
1.120 + fServerSid.Format(_L("ServerSid_%d"),index);
1.121 + TName fFingerprint;
1.122 + fFingerprint.Format(_L("Fingerprint_%d"),index);
1.123 + TName fClientEntity;
1.124 + fClientEntity.Format(_L("ClientEntity_%d"),index);
1.125 + TName fDescription;
1.126 + fDescription.Format(_L("Description_%d"),index);
1.127 + TName fDecisionResult;
1.128 + fDecisionResult.Format(_L("DecisionResult_%d"),index);
1.129 + TName fMajorPolicyVersion;
1.130 + fMajorPolicyVersion.Format(_L("MajorPolicyVersion_%d"),index);
1.131 + TName fRecordId;
1.132 + fRecordId.Format(_L("RecordId_%d"),index);
1.133 + TName fEvaluatorInfo;
1.134 + fEvaluatorInfo.Format(_L("EvaluatorInfo_%d"),index);
1.135 + TName fExpectedDecisionCount;
1.136 + fExpectedDecisionCount.Format(_L("ExpectedDecisionCount_%d"),index);
1.137 +
1.138 + TPtrC operation;
1.139 + TInt clientSid;
1.140 + TInt evaluatorId;
1.141 + TInt serviceId;
1.142 + TInt serverSid;
1.143 + TPtrC fingerprint;
1.144 + TPtrC clientEntity;
1.145 + TPtrC description;
1.146 + TPtrC decisionResult;
1.147 + TInt majorPolicyVersion;
1.148 + TInt recordId;
1.149 + TInt evaluatorInfo;
1.150 + TInt expectedDecisionCount;
1.151 +
1.152 + while (GetStringFromConfig(ConfigSection(),fOperation,operation))
1.153 + {
1.154 +
1.155 + // Create an instance of a new request
1.156 + CUpsDbRequest* newRequest = CUpsDbRequest::NewL();
1.157 + CleanupStack::PushL(newRequest);
1.158 +
1.159 + // Set the operation to be performed
1.160 + newRequest->iOperation = operation;
1.161 +
1.162 + if(GetHexFromConfig(ConfigSection(),fClientSid,clientSid))
1.163 + {
1.164 + newRequest->iClientSid = clientSid;
1.165 + newRequest->iDecisionFilter->SetClientSid(TSecureId(clientSid),EEqual);
1.166 + }
1.167 +
1.168 + if(GetHexFromConfig(ConfigSection(),fEvaluatorId,evaluatorId))
1.169 + {
1.170 + newRequest->iEvaluatorId = evaluatorId;
1.171 + newRequest->iDecisionFilter->SetEvaluatorId(TUid::Uid(evaluatorId),EEqual);
1.172 + }
1.173 +
1.174 + if(GetHexFromConfig(ConfigSection(),fServiceId,serviceId))
1.175 + {
1.176 + newRequest->iServiceId = serviceId;
1.177 + newRequest->iDecisionFilter->SetServiceId(TUid::Uid(serviceId),EEqual);
1.178 + }
1.179 +
1.180 + if(GetHexFromConfig(ConfigSection(),fServerSid,serverSid))
1.181 + {
1.182 + newRequest->iServerSid = serverSid;
1.183 + newRequest->iDecisionFilter->SetServerSid(TSecureId(serverSid),EEqual);
1.184 + }
1.185 +
1.186 + if(GetStringFromConfig(ConfigSection(),fFingerprint,fingerprint))
1.187 + {
1.188 + HBufC8* fingerprintConverter = HBufC8::NewLC(fingerprint.Length());
1.189 + TPtr8 fingerprintPtr = fingerprintConverter->Des();
1.190 + fingerprintPtr.Copy(fingerprint);
1.191 +
1.192 + newRequest->iFingerprint = fingerprintPtr;
1.193 +
1.194 + HBufC8* binaryFingerprint = StringToBinaryLC(fingerprintPtr);
1.195 +
1.196 + newRequest->iDecisionFilter->SetFingerprintL(*binaryFingerprint,EEqual);
1.197 + CleanupStack::PopAndDestroy(binaryFingerprint);
1.198 + CleanupStack::PopAndDestroy(fingerprintConverter);
1.199 + }
1.200 +
1.201 + if(GetStringFromConfig(ConfigSection(),fClientEntity,clientEntity))
1.202 + {
1.203 + HBufC8* clientEntityConverter = HBufC8::NewLC(clientEntity.Length());
1.204 + TPtr8 clientEntityPtr = clientEntityConverter->Des();
1.205 + clientEntityPtr.Copy(clientEntity);
1.206 +
1.207 + newRequest->iClientEntity = clientEntityPtr;
1.208 + newRequest->iDecisionFilter->SetClientEntityL(clientEntityPtr,EEqual);
1.209 + CleanupStack::PopAndDestroy(clientEntityConverter);
1.210 + }
1.211 +
1.212 + if(GetStringFromConfig(ConfigSection(),fDescription,description))
1.213 + {
1.214 + newRequest->iDescription = description;
1.215 + }
1.216 +
1.217 + if(GetStringFromConfig(ConfigSection(),fDecisionResult,decisionResult))
1.218 + {
1.219 + if(decisionResult.CompareF(_L("Yes"))==0 || decisionResult.CompareF(_L("No"))==0 || decisionResult.CompareF(_L(""))==0 )
1.220 + {
1.221 + newRequest->iDecisionResult = decisionResult;
1.222 + }
1.223 + else
1.224 + {
1.225 + ERR_PRINTF3(_L("%S: Unexpected Decision Result - %S"),&iTEFServerName, &decisionResult);
1.226 + }
1.227 + }
1.228 +
1.229 + if(GetIntFromConfig(ConfigSection(),fMajorPolicyVersion,majorPolicyVersion))
1.230 + {
1.231 + newRequest->iMajorPolicyVersion = majorPolicyVersion;
1.232 + newRequest->iDecisionFilter->SetMajorPolicyVersion(majorPolicyVersion,EEqual);
1.233 + }
1.234 +
1.235 + if(GetIntFromConfig(ConfigSection(),fRecordId,recordId))
1.236 + {
1.237 + newRequest->iRecordId = recordId;
1.238 + newRequest->iDecisionFilter->SetRecordId(recordId,EEqual);
1.239 + }
1.240 +
1.241 + if(GetIntFromConfig(ConfigSection(),fEvaluatorInfo,evaluatorInfo))
1.242 + {
1.243 + newRequest->iEvaluatorInfo = evaluatorInfo;
1.244 + }
1.245 +
1.246 + if(GetIntFromConfig(ConfigSection(),fExpectedDecisionCount,expectedDecisionCount))
1.247 + {
1.248 + newRequest->iExpectedDecisionCount = expectedDecisionCount;
1.249 + }
1.250 +
1.251 + // Add the new service to be requested to array.
1.252 + iArraySersToRequest.AppendL(newRequest);
1.253 +
1.254 + CleanupStack::Pop(newRequest);
1.255 +
1.256 + index++;
1.257 + fOperation.Format(_L("Operation_%d"), index);
1.258 + fClientSid.Format(_L("ClientSid_%d"),index);
1.259 + fEvaluatorId.Format(_L("EvaluatorId_%d"),index);
1.260 + fServiceId.Format(_L("ServiceId_%d"),index);
1.261 + fServerSid.Format(_L("ServerSid_%d"),index);
1.262 + fFingerprint.Format(_L("Fingerprint_%d"),index);
1.263 + fClientEntity.Format(_L("ClientEntity_%d"),index);
1.264 + fDescription.Format(_L("Description_%d"),index);
1.265 + fDecisionResult.Format(_L("DecisionResult_%d"),index);
1.266 + fMajorPolicyVersion.Format(_L("MajorPolicyVersion_%d"),index);
1.267 + fRecordId.Format(_L("RecordId_%d"),index);
1.268 + fEvaluatorInfo.Format(_L("EvaluatorInfo_%d"),index);
1.269 + fExpectedDecisionCount.Format(_L("ExpectedDecisionCount_%d"),index);
1.270 + }
1.271 +
1.272 + SetTestStepResult(EPass);
1.273 + return TestStepResult();
1.274 + }
1.275 +
1.276 +TVerdict CUPSDbManagementStep::doTestStepL()
1.277 + {
1.278 + // Connect to the UPS Manager
1.279 + User::LeaveIfError(iUpsManager.Connect());
1.280 +
1.281 + // loop to request for different test services.
1.282 + SetTestStepResult(EPass);
1.283 + TInt numServicesToRequest = iArraySersToRequest.Count();
1.284 +
1.285 + if(numServicesToRequest > 0)
1.286 + {
1.287 + // repeats the sequence of test services request as many times as specified in iStepRepeat
1.288 + for(TInt repeatTimes = 0;repeatTimes<iStepRepeat;++repeatTimes)
1.289 + {
1.290 +
1.291 + INFO_PRINTF3(_L("%S: Repeat number: %d"),&iTEFServerName,repeatTimes);
1.292 +
1.293 + for(TInt index=0;index < numServicesToRequest; ++index )
1.294 + {
1.295 +
1.296 + INFO_PRINTF4(_L("%S: Database Request: %d, Command: %S"),&iTEFServerName, index, &iArraySersToRequest[index]->iOperation);
1.297 +
1.298 + TRequestStatus requestStatus;
1.299 +
1.300 + TPtrC op(iArraySersToRequest[index]->iOperation);
1.301 +
1.302 + // *** CREATE VIEW ***
1.303 + if (!op.CompareF(KOperationCreateView))
1.304 + {
1.305 + // Create view using the Decision Filter for the Request
1.306 + iUpsManager.CreateView(*iArraySersToRequest[index]->iDecisionFilter,requestStatus);
1.307 +
1.308 + User::WaitForRequest(requestStatus);
1.309 +
1.310 + if(requestStatus != KErrNone)
1.311 + {
1.312 + SetTestStepResult(EFail);
1.313 + ERR_PRINTF3(_L("%S: Create View Failure - %d"),&iTEFServerName,requestStatus.Int());
1.314 + User::Leave(requestStatus.Int());
1.315 + }
1.316 + }
1.317 + // *** CANCEL CLOSE VIEW ***
1.318 + else if (!op.CompareF(KOperationCancelCloseView))
1.319 + {
1.320 + iUpsManager.CancelAndCloseView();
1.321 +
1.322 + INFO_PRINTF2(_L("%S: UPS DB Management - Current View Cancelled and Closed"),&iTEFServerName);
1.323 + }
1.324 + // *** NEXT MATCH ***
1.325 + else if (!op.CompareF(KOperationNextMatch))
1.326 + {
1.327 + CDecisionRecord* record = NULL;
1.328 +
1.329 + // Retrieve the Next Decision according to the Current View
1.330 + record = iUpsManager.NextMatchL();
1.331 + CleanupStack::PushL(record);
1.332 +
1.333 + // If a record is found, check that the record matches any data specified in the INI
1.334 + if(record != NULL)
1.335 + {
1.336 + if(CheckDecisionRecordL(index,*record) == EFalse)
1.337 + {
1.338 + iUpsManager.CancelAndCloseView();
1.339 + ERR_PRINTF2(_L("%S: Incorrect Results"),&iTEFServerName);
1.340 + User::Leave(KErrGeneral);
1.341 + }
1.342 + }
1.343 + else
1.344 + {
1.345 + iUpsManager.CancelAndCloseView();
1.346 + SetTestStepResult(EFail);
1.347 + ERR_PRINTF2(_L("%S: NextMatchL - No Decision Retrieved"),&iTEFServerName);
1.348 + User::Leave(KErrEof);
1.349 + }
1.350 +
1.351 + CleanupStack::PopAndDestroy(record);
1.352 +
1.353 + }
1.354 + // *** REMOVE DECISION ***
1.355 + else if (!op.CompareF(KOperationRemoveDecision))
1.356 + {
1.357 + // Remove decisions from the database based on the contents of the Decision Filter
1.358 + TRAPD(err, iUpsManager.RemoveDecisionsL(*iArraySersToRequest[index]->iDecisionFilter));
1.359 +
1.360 + if(err == KErrNone)
1.361 + {
1.362 + INFO_PRINTF2(_L("%S: Remove Decision - Decision(s) Successfully Removed"),&iTEFServerName);
1.363 + }
1.364 + else
1.365 + {
1.366 + SetTestStepResult(EFail);
1.367 + ERR_PRINTF3(_L("%S: ** Error ** Remove Decision Failure - %d"),&iTEFServerName,err);
1.368 + User::Leave(err);
1.369 + }
1.370 + }
1.371 + // *** UPDATE DECISION ALLOW ***
1.372 + else if (!op.CompareF(KOperationUpdateDecisionAllow))
1.373 + {
1.374 + iUpsManager.UpdateDecision(iArraySersToRequest[index]->iRecordId, ETrue, requestStatus);
1.375 +
1.376 + User::WaitForRequest(requestStatus);
1.377 +
1.378 + if(requestStatus != KErrNone)
1.379 + {
1.380 + SetTestStepResult(EFail);
1.381 + ERR_PRINTF3(_L("%S: Update Decision 'Allow' Failure - %d"),&iTEFServerName,requestStatus.Int());
1.382 + User::Leave(requestStatus.Int());
1.383 + }
1.384 + }
1.385 + // *** UPDATE DECISION DENY ***
1.386 + else if (!op.CompareF(KOperationUpdateDecisionDeny))
1.387 + {
1.388 + iUpsManager.UpdateDecision(iArraySersToRequest[index]->iRecordId, EFalse, requestStatus);
1.389 +
1.390 + User::WaitForRequest(requestStatus);
1.391 +
1.392 + if(requestStatus != KErrNone)
1.393 + {
1.394 + SetTestStepResult(EFail);
1.395 + ERR_PRINTF3(_L("%S: Update Decision 'Deny' Failure - %d"),&iTEFServerName,requestStatus.Int());
1.396 + User::Leave(requestStatus.Int());
1.397 + }
1.398 + }
1.399 + // *** CANCEL DECISION UPDATE ***
1.400 + else if (!op.CompareF(KOperationCancelUpdate))
1.401 + {
1.402 + iUpsManager.CancelUpdateDecision();
1.403 +
1.404 + INFO_PRINTF2(_L("%S: UPS DB Management - Current Decision Update Cancelled"),&iTEFServerName);
1.405 + }
1.406 + // *** DELETE DATABASE ***
1.407 + else if (!op.CompareF(KOperationDeleteDatabase))
1.408 + {
1.409 + // Delete the contents of the Decision Database
1.410 + TRAPD(err, iUpsManager.DeleteDatabaseL());
1.411 +
1.412 + if(err == KErrNone)
1.413 + {
1.414 + INFO_PRINTF2(_L("%S: UPS DB Management - Database Deleted"),&iTEFServerName);
1.415 + }
1.416 + else
1.417 + {
1.418 + SetTestStepResult(EFail);
1.419 + ERR_PRINTF3(_L("%S: ** Error ** Database Deletion Failure - %d"),&iTEFServerName,err);
1.420 + User::Leave(err);
1.421 + }
1.422 + }
1.423 + // *** DECISION COUNT ***
1.424 + else if (!op.CompareF(KOperationDecisionCount))
1.425 + {
1.426 + iUpsManager.CancelAndCloseView();
1.427 +
1.428 + // Create a new view using the constructed decision filter for the request
1.429 + iUpsManager.CreateView(*iArraySersToRequest[index]->iDecisionFilter,requestStatus);
1.430 +
1.431 + User::WaitForRequest(requestStatus);
1.432 +
1.433 + if(requestStatus.Int() == KErrNone)
1.434 + {
1.435 + TInt decisionCount = 0;
1.436 + CDecisionRecord* record = NULL;
1.437 +
1.438 + TInt result = KErrNone;
1.439 +
1.440 + // Whilst records located using the "NextMatchL" method, increment the record count
1.441 + while(result == KErrNone)
1.442 + {
1.443 + TRAP(result, record = iUpsManager.NextMatchL());
1.444 +
1.445 + if(record == NULL)
1.446 + {
1.447 + break;
1.448 + }
1.449 + else
1.450 + {
1.451 + ++decisionCount;
1.452 + }
1.453 +
1.454 + delete record;
1.455 + record = NULL;
1.456 + }
1.457 +
1.458 + iUpsManager.CancelAndCloseView();
1.459 +
1.460 + if(decisionCount != iArraySersToRequest[index]->iExpectedDecisionCount)
1.461 + {
1.462 + SetTestStepResult(EFail);
1.463 + ERR_PRINTF2(_L("%S: Decision Count - Unexpected Number of Database Decisions"),&iTEFServerName);
1.464 + ERR_PRINTF3(_L("%S: Decisions expected: %d"),&iTEFServerName,iArraySersToRequest[index]->iExpectedDecisionCount);
1.465 + ERR_PRINTF3(_L("%S: Decisions in Database: %d"),&iTEFServerName,decisionCount);
1.466 + User::Leave(KErrNotFound);
1.467 + }
1.468 +
1.469 + }
1.470 + else
1.471 + {
1.472 + SetTestStepResult(EFail);
1.473 + ERR_PRINTF3(_L("%S: Decision Count - Create View Failure - %d"),&iTEFServerName,requestStatus.Int());
1.474 + User::Leave(requestStatus.Int());
1.475 + }
1.476 + }
1.477 + else
1.478 + {
1.479 + SetTestStepResult(EFail);
1.480 + ERR_PRINTF2(_L("%S: Invalid operation"),&iTEFServerName);
1.481 + User::Leave(KErrNotSupported);
1.482 + }
1.483 +
1.484 + } // End of second loop
1.485 + }// End of first loop
1.486 +
1.487 + }
1.488 + else
1.489 + {
1.490 + SetTestStepResult(EFail);
1.491 + ERR_PRINTF2(_L("%S: Problem reading ini file"),&iTEFServerName);
1.492 + User::Leave(KErrGeneral);
1.493 + }
1.494 +
1.495 + return TestStepResult();
1.496 + } // End of function
1.497 +
1.498 +
1.499 +TVerdict CUPSDbManagementStep::doTestStepPostambleL()
1.500 + {
1.501 + return TestStepResult();
1.502 + }
1.503 +
1.504 +
1.505 +TBool CUPSDbManagementStep::CheckDecisionRecordL(TInt aIndex, const CDecisionRecord& aRecord)
1.506 +/**
1.507 + * Checks the expected record values against those stored within CDecisionRecord retrieved from the database
1.508 + *
1.509 + * @param - TInt aIndex: Database request index used to access the required instance of CUpsDbRequest held
1.510 + * within the request array
1.511 + * @param - const CDecisionRecord& aRecord: Decision Record retrieved from the database
1.512 + * @return - TBool: Boolean to determine the result of the value checks (ETrue = Pass, EFalse = Fail)
1.513 + **/
1.514 + {
1.515 +
1.516 + TBool checkPassed = ETrue;
1.517 +
1.518 +
1.519 + if(iArraySersToRequest[aIndex]->iClientSid != aRecord.iClientSid)
1.520 + {
1.521 + ERR_PRINTF2(_L("%S: 'Client SID' value mismatch"),&iTEFServerName);
1.522 + checkPassed = EFalse;
1.523 + }
1.524 +
1.525 + if(iArraySersToRequest[aIndex]->iEvaluatorId != aRecord.iEvaluatorId.iUid)
1.526 + {
1.527 + ERR_PRINTF2(_L("%S: 'Evaluator ID' value mismatch"),&iTEFServerName);
1.528 + checkPassed = EFalse;
1.529 + }
1.530 +
1.531 + if(iArraySersToRequest[aIndex]->iServiceId != aRecord.iServiceId.iUid)
1.532 + {
1.533 + ERR_PRINTF2(_L("%S: 'Service ID' value mismatch"),&iTEFServerName);
1.534 + checkPassed = EFalse;
1.535 + }
1.536 +
1.537 + if(iArraySersToRequest[aIndex]->iServerSid != aRecord.iServerSid)
1.538 + {
1.539 + ERR_PRINTF2(_L("%S: 'Server SID' value mismatch"),&iTEFServerName);
1.540 + checkPassed = EFalse;
1.541 + }
1.542 +
1.543 + HBufC8* recordFingerprint = StringToHexLC(aRecord.iFingerprint);
1.544 +
1.545 + if(iArraySersToRequest[aIndex]->iFingerprint != *recordFingerprint)
1.546 + {
1.547 + HBufC* expectedFingerprint = HBufC::NewLC(iArraySersToRequest[aIndex]->iFingerprint.Length());
1.548 + HBufC* receivedFingerprint = HBufC::NewLC(recordFingerprint->Length());
1.549 +
1.550 + expectedFingerprint->Des().Copy(iArraySersToRequest[aIndex]->iFingerprint);
1.551 + receivedFingerprint->Des().Copy(*recordFingerprint);
1.552 +
1.553 + ERR_PRINTF2(_L("%S: 'Fingerprint' value mismatch."),&iTEFServerName);
1.554 + ERR_PRINTF3(_L("%S: Fingerprint expected: %S"),&iTEFServerName,expectedFingerprint);
1.555 + ERR_PRINTF3(_L("%S: Fingerprint received: %S"),&iTEFServerName,receivedFingerprint);
1.556 +
1.557 + CleanupStack::PopAndDestroy(receivedFingerprint);
1.558 + CleanupStack::PopAndDestroy(expectedFingerprint);
1.559 + checkPassed = EFalse;
1.560 + }
1.561 +
1.562 + CleanupStack::PopAndDestroy(recordFingerprint);
1.563 +
1.564 + if(iArraySersToRequest[aIndex]->iClientEntity != aRecord.iClientEntity)
1.565 + {
1.566 + HBufC* expectedClientEntity = HBufC::NewLC(iArraySersToRequest[aIndex]->iClientEntity.Length());
1.567 + HBufC* receivedClientEntity = HBufC::NewLC(aRecord.iClientEntity.Length());
1.568 +
1.569 + expectedClientEntity->Des().Copy(iArraySersToRequest[aIndex]->iClientEntity);
1.570 + receivedClientEntity->Des().Copy(aRecord.iClientEntity);
1.571 +
1.572 + ERR_PRINTF2(_L("%S: 'Client Entity' value mismatch."),&iTEFServerName);
1.573 +
1.574 + CleanupStack::PopAndDestroy(receivedClientEntity);
1.575 + CleanupStack::PopAndDestroy(expectedClientEntity);
1.576 + checkPassed = EFalse;
1.577 + }
1.578 +
1.579 + if(iArraySersToRequest[aIndex]->iDescription.CompareF(aRecord.iDescription) != 0)
1.580 + {
1.581 + TPtrC retrievedDescription(aRecord.iDescription);
1.582 + ERR_PRINTF2(_L("%S: 'Description' value mismatch."),&iTEFServerName);
1.583 + checkPassed = EFalse;
1.584 + }
1.585 +
1.586 + TInt expectedDecisionResult = 0;
1.587 +
1.588 + if(iArraySersToRequest[aIndex]->iDecisionResult.CompareF(_L("Yes")) == 0)
1.589 + {
1.590 + expectedDecisionResult = 1;
1.591 + }
1.592 +
1.593 + if(expectedDecisionResult != aRecord.iResult)
1.594 + {
1.595 + ERR_PRINTF2(_L("%S: 'Decision Result' value mismatch."),&iTEFServerName);
1.596 + checkPassed = EFalse;
1.597 + }
1.598 +
1.599 + if(iArraySersToRequest[aIndex]->iMajorPolicyVersion != aRecord.iMajorPolicyVersion)
1.600 + {
1.601 + ERR_PRINTF2(_L("%S: 'Major Policy Version' value mismatch."),&iTEFServerName);
1.602 + checkPassed = EFalse;
1.603 + }
1.604 +
1.605 + if(iArraySersToRequest[aIndex]->iEvaluatorInfo != aRecord.iEvaluatorInfo)
1.606 + {
1.607 + ERR_PRINTF2(_L("%S: 'Evaluator Info' value mismatch."),&iTEFServerName);
1.608 + checkPassed = EFalse;
1.609 + }
1.610 +
1.611 + if(iArraySersToRequest[aIndex]->iRecordId != aRecord.iRecordId)
1.612 + {
1.613 + ERR_PRINTF2(_L("%S: 'Record ID' value mismatch."),&iTEFServerName);
1.614 + checkPassed = EFalse;
1.615 + }
1.616 +
1.617 + return checkPassed;
1.618 + }
1.619 +
1.620 +
1.621 +
1.622 +HBufC8* CUPSDbManagementStep::StringToHexLC(const TDes8 &aString)
1.623 +/**
1.624 + * Function to convert the contents of a TDes8 into a Hexadecimal format
1.625 + *
1.626 + * @param - cosnt TDes8 aString: String to convert into Hexadecimal
1.627 + * @return - HBufC8*: Converted Hexadecial string representation
1.628 + **/
1.629 + {
1.630 + HBufC8* parsedString = HBufC8::NewLC(aString.Length()*2);
1.631 + TBuf8<2> pair;
1.632 + _LIT8(KFormatHex,"%02x");
1.633 +
1.634 + TPtr8 ptr(parsedString->Des());
1.635 + for(TInt i = 0; i<aString.Length() ; i++)
1.636 + {
1.637 + TInt num = (aString)[i];
1.638 + pair.Format(KFormatHex,num);
1.639 + ptr.Append(pair);
1.640 + }
1.641 +
1.642 + return parsedString;
1.643 + }
1.644 +
1.645 +
1.646 +HBufC8* CUPSDbManagementStep::StringToBinaryLC(const TDes8 &aString)
1.647 +/**
1.648 + * Function to convert the contents of a TDes8 into a Binary format
1.649 + *
1.650 + * @param - cosnt TDes8 aString: String to convert into Hexadecimal
1.651 + * @return - HBufC8*: Converted Binary string representation
1.652 + **/
1.653 + {
1.654 + HBufC8* parsedString = HBufC8::NewLC(aString.Length()/2);
1.655 + TBuf8<1> binChar;
1.656 + _LIT8(KFormatBinary,"%c");
1.657 +
1.658 + TPtr8 ptr(parsedString->Des());
1.659 + for(TInt i = 0; i<aString.Length()/2 ; i++)
1.660 + {
1.661 + TPtrC8 tempPtr(aString.Mid(i*2,2));
1.662 + TLex8 lex(tempPtr);
1.663 + TUint val=0;
1.664 + lex.Val(val, EHex);
1.665 + binChar.Format(KFormatBinary,val);
1.666 + ptr.Append(binChar);
1.667 + }
1.668 +
1.669 + return parsedString;
1.670 + }