sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include "tupsclientstep.h" sl@0: #include "tupsintegdefs.h" sl@0: #include "tupsproperty.h" sl@0: #include sl@0: sl@0: sl@0: TServiceRequestParameters::TServiceRequestParameters() sl@0: :iServiceUID(0), iServerName(0),iDestination(0), iExpectedError(0), sl@0: iOpaqueData(0), iSelectDialogOption(0), iButtonsDisplayed(0), sl@0: iDialogCreatorInvoked(0), iPolicyEvaluatorInvoked(0), iAccessGranted(0), sl@0: iCloseSession(EFalse), iHoldEvaluatorOpen(EFalse), iHoldPrepareDialogOpen(EFalse), iHoldDisplayDialogOpen(EFalse), sl@0: iRequestDurationThreshold(0), iLeaveDialog(EFalse), iLeaveEvaluator(EFalse), iCancelUpsRequest(EFalse), sl@0: iPlatSecPass(EFalse),iForcePrompt(EFalse),iExpectedEvaluatorInfo(0),iSelectFingerprint(0), sl@0: iWaitUntilFileAppears(0) sl@0: { sl@0: }; sl@0: sl@0: COpenSession* COpenSession::NewL(const TPtrC& aServerName) sl@0: { sl@0: COpenSession * self = new (ELeave) COpenSession(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aServerName); sl@0: CleanupStack::Pop(self); sl@0: return(self); sl@0: } // End of function sl@0: sl@0: void COpenSession::ConstructL(const TPtrC& aServerName) sl@0: { sl@0: iServerName = aServerName; sl@0: iPointerToServer = new RUpsTestServ; sl@0: User::LeaveIfError(iPointerToServer->Connect(iServerName, ETrue)); sl@0: iPointerToSession = new RUpsTestSession; sl@0: User::LeaveIfError(iPointerToSession->Open(*iPointerToServer)); sl@0: } // End of function sl@0: sl@0: COpenSession::~COpenSession() sl@0: { sl@0: if (iPointerToSession) sl@0: iPointerToSession->Close(); sl@0: if (iPointerToServer) sl@0: iPointerToServer->Close(); sl@0: delete iPointerToSession; sl@0: delete iPointerToServer; sl@0: } // End of function sl@0: sl@0: CUpsClientStep::~CUpsClientStep() sl@0: /** sl@0: * Destructor sl@0: */ sl@0: { sl@0: iArraySersToRequest.Close(); sl@0: sl@0: CloseAllOpenSessions(); sl@0: delete iPropertyReader; sl@0: __UHEAP_MARKEND; sl@0: } // End of function sl@0: sl@0: sl@0: CUpsClientStep::CUpsClientStep() sl@0: /** sl@0: * Constructor sl@0: */ sl@0: { sl@0: SetTestStepName(KUPSClientStep); sl@0: } // End of function sl@0: sl@0: sl@0: TVerdict CUpsClientStep::doTestStepPreambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: // Read values to config servers from INI file. (ARRAY of values) sl@0: sl@0: // Read how many times the test step needs to be repeated. sl@0: TName fStepRepeat(_L("StepRepeat")); sl@0: TInt repeats; sl@0: sl@0: if(GetIntFromConfig(ConfigSection(),fStepRepeat,repeats)) sl@0: { sl@0: iStepRepeat=repeats; sl@0: } sl@0: else sl@0: { sl@0: iStepRepeat=1; sl@0: } sl@0: sl@0: // Read values for test sequence from INI file. (ARRAY of values) sl@0: TInt index=0; sl@0: TName fUseServiceUID; sl@0: fUseServiceUID.Format(_L("UseServiceUID_%d"),index); sl@0: TName fUseServerName; sl@0: fUseServerName.Format(_L("UseServerName_%d"),index); sl@0: TName fDestination; sl@0: fDestination.Format(_L("Destination_%d"),index); sl@0: TName fExpectedError; sl@0: fExpectedError.Format(_L("ExpectedError_%d"),index); sl@0: TName fUseOpaqueData; sl@0: fUseOpaqueData.Format(_L("UseOpaqueData_%d"),index); sl@0: TName fSelectDialogOption; sl@0: fSelectDialogOption.Format(_L("SelectDialogOption_%d"),index); sl@0: TName fButtonsDisplayed; sl@0: fButtonsDisplayed.Format(_L("ButtonsDisplayed_%d"),index); sl@0: TName fDialogCreatorInvoked; sl@0: fDialogCreatorInvoked.Format(_L("DialogCreatorInvoked_%d"),index); sl@0: TName fPolicyEvaluatorInvoked; sl@0: fPolicyEvaluatorInvoked.Format(_L("PolicyEvaluatorInvoked_%d"),index); sl@0: TName fAccessGranted; sl@0: fAccessGranted.Format(_L("AccessGranted_%d"), index); sl@0: TName fCloseSession; sl@0: fCloseSession.Format(_L("CloseSession_%d"), index); sl@0: TName fHoldEvaluatorOpen; sl@0: fHoldEvaluatorOpen.Format(_L("HoldEvaluatorOpen_%d"), index); sl@0: TName fHoldPrepareDialogOpen; sl@0: fHoldPrepareDialogOpen.Format(_L("HoldPrepareDialogOpen_%d"), index); sl@0: TName fHoldDisplayDialogOpen; sl@0: fHoldDisplayDialogOpen.Format(_L("HoldDisplayDialogOpen_%d"), index); sl@0: TName fRequestDurationThreshold; sl@0: fRequestDurationThreshold.Format(_L("RequestDurationThreshold_%d"), index); sl@0: TName fLeaveDialog; sl@0: fLeaveDialog.Format(_L("LeaveDialog_%d"), index); sl@0: TName fLeaveEvaluator; sl@0: fLeaveEvaluator.Format(_L("LeaveEvaluator_%d"), index); sl@0: TName fCancelUpsRequest; sl@0: fCancelUpsRequest.Format(_L("CancelUpsRequest_%d"), index); sl@0: TName fPlatSecPass; sl@0: fPlatSecPass.Format(_L("PlatSecPass_%d"), index); sl@0: TName fForcePrompt; sl@0: fForcePrompt.Format(_L("ForcePrompt_%d"), index); sl@0: TName fExpectedEvaInfo; sl@0: fExpectedEvaInfo.Format(_L("ExpectedEvaluatorInfo_%d"), index); sl@0: TName fSelectFingerprint; sl@0: fSelectFingerprint.Format(_L("SelectFingerprint_%d"), index); sl@0: TName fWaitUntilFileAppears; sl@0: fWaitUntilFileAppears.Format(_L("WaitUntilFileAppears_%d"), index); sl@0: sl@0: TInt useServiceUID; sl@0: TPtrC useServerName; sl@0: TPtrC destination; sl@0: TInt expectedError; sl@0: TPtrC useOpaqueData; sl@0: TPtrC selectDialogOption; sl@0: TInt buttonsDisplayed; sl@0: TInt dialogCreatorInvoked; sl@0: TInt policyEvaluatorInvoked; sl@0: TPtrC accessGranted; sl@0: TBool closeSession; sl@0: TBool holdEvaluatorOpen; sl@0: TBool holdPrepareDialogOpen; sl@0: TBool holdDisplayDialogOpen; sl@0: TInt requestDurationThreshold; sl@0: TBool leaveDialog; sl@0: TBool leaveEvaluator; sl@0: TBool cancelUpsRequest; sl@0: TBool platSecPass; sl@0: TBool forcePrompt; sl@0: TInt expectedEvaInfo; sl@0: TInt selectFingerprint; sl@0: TPtrC waitUntilFileAppears; sl@0: sl@0: while (GetHexFromConfig(ConfigSection(), fUseServiceUID,useServiceUID) sl@0: && GetStringFromConfig(ConfigSection(),fUseServerName,useServerName) sl@0: && GetStringFromConfig(ConfigSection(),fDestination,destination) sl@0: && GetStringFromConfig(ConfigSection(),fAccessGranted,accessGranted)) sl@0: { sl@0: TServiceRequestParameters newSerReq; sl@0: newSerReq.iServiceUID = useServiceUID; sl@0: newSerReq.iServerName = useServerName; sl@0: newSerReq.iDestination = destination; sl@0: newSerReq.iAccessGranted = accessGranted; sl@0: sl@0: // Close session is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fCloseSession,closeSession)) sl@0: { sl@0: newSerReq.iCloseSession = closeSession; sl@0: } sl@0: sl@0: // use of dialog creator is optional. sl@0: if(GetStringFromConfig(ConfigSection(),fSelectDialogOption,selectDialogOption) sl@0: && GetIntFromConfig(ConfigSection(),fButtonsDisplayed,buttonsDisplayed) sl@0: && GetIntFromConfig(ConfigSection(),fDialogCreatorInvoked,dialogCreatorInvoked)) sl@0: { sl@0: newSerReq.iSelectDialogOption = selectDialogOption; sl@0: newSerReq.iButtonsDisplayed = buttonsDisplayed; sl@0: newSerReq.iDialogCreatorInvoked = dialogCreatorInvoked; sl@0: } sl@0: sl@0: // use of policy evaluator is optional. sl@0: if(GetIntFromConfig(ConfigSection(),fPolicyEvaluatorInvoked,policyEvaluatorInvoked)) sl@0: { sl@0: newSerReq.iPolicyEvaluatorInvoked = policyEvaluatorInvoked; sl@0: } sl@0: sl@0: // Opaque data is optional sl@0: if(GetStringFromConfig(ConfigSection(),fUseOpaqueData,useOpaqueData)) sl@0: { sl@0: HBufC8* converter = HBufC8::NewLC(useOpaqueData.Length()); sl@0: converter->Des().Copy(useOpaqueData); sl@0: sl@0: newSerReq.iOpaqueData = converter->Ptr() ; sl@0: CleanupStack::PopAndDestroy(); //converter sl@0: } sl@0: sl@0: // Expected error is optional. sl@0: if(GetIntFromConfig(ConfigSection(),fExpectedError,expectedError)) sl@0: { sl@0: newSerReq.iExpectedError = expectedError; sl@0: } sl@0: sl@0: // hold policy evaluator open is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fHoldEvaluatorOpen, holdEvaluatorOpen)) sl@0: { sl@0: newSerReq.iHoldEvaluatorOpen = holdEvaluatorOpen; sl@0: } sl@0: sl@0: // hold prepare dialog open is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fHoldPrepareDialogOpen, holdPrepareDialogOpen)) sl@0: { sl@0: newSerReq.iHoldPrepareDialogOpen = holdPrepareDialogOpen; sl@0: } sl@0: sl@0: // hold display dialog open is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fHoldDisplayDialogOpen, holdDisplayDialogOpen)) sl@0: { sl@0: newSerReq.iHoldDisplayDialogOpen = holdDisplayDialogOpen; sl@0: } sl@0: sl@0: // request duration threshold - if a request takes sl@0: // longer than this threshold it will fail the test sl@0: if(GetIntFromConfig(ConfigSection(),fRequestDurationThreshold, requestDurationThreshold)) sl@0: { sl@0: newSerReq.iRequestDurationThreshold = requestDurationThreshold; sl@0: } sl@0: sl@0: // leave dialog is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fLeaveDialog,leaveDialog)) sl@0: { sl@0: newSerReq.iLeaveDialog = leaveDialog; sl@0: } sl@0: sl@0: // leave Evaluator is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fLeaveEvaluator,leaveEvaluator)) sl@0: { sl@0: newSerReq.iLeaveEvaluator = leaveEvaluator; sl@0: } sl@0: sl@0: // Cancel ups request is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fCancelUpsRequest,cancelUpsRequest)) sl@0: { sl@0: newSerReq.iCancelUpsRequest = cancelUpsRequest; sl@0: } sl@0: sl@0: // plat sec pass is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fPlatSecPass,platSecPass)) sl@0: { sl@0: newSerReq.iPlatSecPass = platSecPass; sl@0: } sl@0: sl@0: // Force prompt is optional. sl@0: if(GetBoolFromConfig(ConfigSection(),fForcePrompt,forcePrompt)) sl@0: { sl@0: newSerReq.iForcePrompt = forcePrompt; sl@0: } sl@0: sl@0: // use of policy evaluator is optional. sl@0: if(GetIntFromConfig(ConfigSection(),fExpectedEvaInfo,expectedEvaInfo)) sl@0: { sl@0: newSerReq.iExpectedEvaluatorInfo = expectedEvaInfo; sl@0: } sl@0: sl@0: // Fingerprint selection is optional. sl@0: if(GetIntFromConfig(ConfigSection(),fSelectFingerprint,selectFingerprint)) sl@0: { sl@0: newSerReq.iSelectFingerprint = selectFingerprint; sl@0: } sl@0: sl@0: // iRepeatUntilFileAppears is optional. sl@0: if(GetStringFromConfig(ConfigSection(),fWaitUntilFileAppears,waitUntilFileAppears)) sl@0: { sl@0: newSerReq.iWaitUntilFileAppears = waitUntilFileAppears; sl@0: } sl@0: sl@0: // Add the new service to be requested to array. sl@0: iArraySersToRequest.Append(newSerReq); sl@0: sl@0: index++; sl@0: fUseServiceUID.Format(_L("UseServiceUID_%d"),index); sl@0: fUseServerName.Format(_L("UseServerName_%d"),index); sl@0: fDestination.Format(_L("Destination_%d"),index); sl@0: fExpectedError.Format(_L("ExpectedError_%d"),index); sl@0: fUseOpaqueData.Format(_L("UseOpaqueData_%d"),index); sl@0: fSelectDialogOption.Format(_L("SelectDialogOption_%d"),index); sl@0: fButtonsDisplayed.Format(_L("ButtonsDisplayed_%d"),index); sl@0: fDialogCreatorInvoked.Format(_L("DialogCreatorInvoked_%d"),index); sl@0: fPolicyEvaluatorInvoked.Format(_L("PolicyEvaluatorInvoked_%d"),index); sl@0: fAccessGranted.Format(_L("AccessGranted_%d"), index); sl@0: fCloseSession.Format(_L("CloseSession_%d"), index); sl@0: fHoldEvaluatorOpen.Format(_L("HoldEvaluatorOpen_%d"), index); sl@0: fHoldPrepareDialogOpen.Format(_L("HoldPrepareDialogOpen_%d"), index); sl@0: fHoldDisplayDialogOpen.Format(_L("HoldDisplayDialogOpen_%d"), index); sl@0: fRequestDurationThreshold.Format(_L("RequestDurationThreshold_%d"), index); sl@0: fLeaveDialog.Format(_L("LeaveDialog_%d"), index); sl@0: fLeaveEvaluator.Format(_L("LeaveEvaluator_%d"), index); sl@0: fCancelUpsRequest.Format(_L("CancelUpsRequest_%d"), index); sl@0: fPlatSecPass.Format(_L("PlatSecPass_%d"), index); sl@0: fForcePrompt.Format(_L("ForcePrompt_%d"), index); sl@0: fExpectedEvaInfo.Format(_L("ExpectedEvaluatorInfo_%d"), index); sl@0: fSelectFingerprint.Format(_L("SelectFingerprint_%d"), index); sl@0: fWaitUntilFileAppears.Format(_L("WaitUntilFileAppears_%d"), index); sl@0: } sl@0: sl@0: // now try for some clientStep specific stuff sl@0: // this ini file entry specifies the property key value for the hold flag sl@0: // If the hold flag property is true then monitor it until it becomes false sl@0: // then continue sl@0: TInt holdKey; sl@0: if(GetIntFromConfig(ConfigSection(),_L("HoldClientStepKey"), holdKey)) sl@0: { sl@0: iHoldClientStepKey = holdKey; sl@0: sl@0: // as this property is present then set it to true using a direct call to p&s api because sl@0: // the ups p&s api only handles policy evaluators and dialog creators and not test steps sl@0: User::LeaveIfError(RProperty::Set(KPropertyCreatorUid, iHoldClientStepKey, 2)); sl@0: } sl@0: sl@0: // Instantiates property reader and seter sl@0: iPropertyReader= CUpsProperty::NewL(KPropertyCreatorUid); sl@0: sl@0: // reads client name and SID sl@0: TParse clientFullName; sl@0: RThread client; sl@0: clientFullName.Set(client.FullName(),NULL, NULL); sl@0: iTEFServerName=clientFullName.Name(); sl@0: iExpectedClientSid = client.SecureId() ; sl@0: client.Close(); sl@0: sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TVerdict CUpsClientStep::doTestStepL() sl@0: { sl@0: // loop to request for different test services. sl@0: TVerdict testResult= EPass; sl@0: TInt numServicesToRequest = iArraySersToRequest.Count(); sl@0: sl@0: if(numServicesToRequest > 0) sl@0: { sl@0: // check if the test step needs to hold until another step allows it to continue sl@0: if (iHoldClientStepKey) sl@0: { sl@0: HoldClientL(); sl@0: } sl@0: sl@0: // repeats the sequence of test services request as many times as specified in iStepRepeat sl@0: for(TInt repeatTimes = 0;repeatTimesUseTestService(iRequestData,iReturnData); sl@0: sl@0: iServerId=sessionToBeUsed->GetServerSid(); sl@0: // Check results. sl@0: if(CheckResultsL(index) == EFalse) sl@0: { sl@0: ERR_PRINTF2(_L("%S: Incorrect results"),&iTEFServerName); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: sl@0: // Checks from config value if session need to be closed. sl@0: if(iArraySersToRequest[index].iCloseSession) sl@0: { sl@0: INFO_PRINTF3(_L("%S :Closing session to server: %S"),&iTEFServerName, &iArraySersToRequest[index].iServerName ); sl@0: CloseSessionL(iArraySersToRequest[index].iServerName); sl@0: } sl@0: } // End of second loop sl@0: }// End of first loop sl@0: sl@0: // Sets the status of the first instance of policy evaluator and dialog creator to sl@0: // completed so that the coordinator step can progress in concurrent mode sl@0: SetClientStatusCompleteL(); sl@0: } sl@0: else sl@0: { sl@0: testResult= EFail; sl@0: ERR_PRINTF2(_L("%S :Problem reading ini file"),&iTEFServerName); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: sl@0: return testResult; sl@0: } // End of function sl@0: sl@0: sl@0: TVerdict CUpsClientStep::doTestStepPostambleL() sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: void CUpsClientStep::HoldClientL(void) sl@0: { sl@0: RProperty checkIfStillNeedtoHold; sl@0: User::LeaveIfError(checkIfStillNeedtoHold.Attach(KPropertyCreatorUid, iHoldClientStepKey)); sl@0: CleanupClosePushL(checkIfStillNeedtoHold); sl@0: checkIfStillNeedtoHold.Set(KPropertyCreatorUid, iHoldClientStepKey, 1); sl@0: TRequestStatus holdStatus; sl@0: checkIfStillNeedtoHold.Subscribe(holdStatus); sl@0: sl@0: TInt holdState; sl@0: sl@0: checkIfStillNeedtoHold.Get(KPropertyCreatorUid, iHoldClientStepKey, holdState); sl@0: if(!holdState) sl@0: { sl@0: checkIfStillNeedtoHold.Cancel(); sl@0: } sl@0: else sl@0: { sl@0: User::WaitForRequest(holdStatus); sl@0: } sl@0: sl@0: RDebug::Printf("[UPS ClientStep 0x%x] HoldClient() stopped holding\n", this); sl@0: sl@0: // set the hold state back to 1 for future holds sl@0: checkIfStillNeedtoHold.Set(KPropertyCreatorUid, iHoldClientStepKey, 2); sl@0: CleanupStack::PopAndDestroy(&checkIfStillNeedtoHold); sl@0: } sl@0: sl@0: sl@0: TBool CUpsClientStep::FindOpenSession(const TDesC& aServerName,TInt &position) sl@0: { sl@0: TBool sessionFound = EFalse; sl@0: TInt sessionsCount = iArraySessionsInUse.Count(); sl@0: for(TInt index = 0;index < sessionsCount; ++index) sl@0: { sl@0: if(!aServerName.CompareF(iArraySessionsInUse[index]->iServerName)) sl@0: { sl@0: position = index; sl@0: sessionFound = ETrue; sl@0: break; sl@0: } sl@0: } sl@0: return sessionFound; sl@0: } // End of function sl@0: sl@0: sl@0: RUpsTestSession* CUpsClientStep::GetSessionToServerL(const TDesC& aServerName) sl@0: { sl@0: // Finds out if a session is already open for server requested sl@0: TInt foundPos; sl@0: RUpsTestSession* sessionToReturn; sl@0: if(!FindOpenSession(aServerName,foundPos)) sl@0: { sl@0: // if open session for intended server not found it creates a new one sl@0: COpenSession* sessionToAppend=COpenSession::NewL(aServerName); sl@0: iArraySessionsInUse.AppendL(sessionToAppend); sl@0: foundPos = iArraySessionsInUse.Count()-1; // position of new session is last one in array. sl@0: } sl@0: sessionToReturn = iArraySessionsInUse[foundPos]->iPointerToSession; sl@0: sl@0: return sessionToReturn; sl@0: } // End of function sl@0: sl@0: sl@0: void CUpsClientStep::CloseSessionL(const TDesC& aServerName) sl@0: { sl@0: // Finds out if a session is already open for server requested sl@0: TInt foundPos; sl@0: sl@0: if(!FindOpenSession(aServerName,foundPos)) sl@0: { sl@0: // if a session for this server was not found it leaves. sl@0: ERR_PRINTF2(_L("%S: The server to be closed was not found"),&iTEFServerName); sl@0: User::Leave(KErrGeneral); sl@0: } sl@0: delete iArraySessionsInUse[foundPos]; // deletes instance. sl@0: iArraySessionsInUse.Remove(foundPos); // removes empty slot sl@0: sl@0: } // End of function sl@0: sl@0: sl@0: void CUpsClientStep::CloseAllOpenSessions() sl@0: { sl@0: while(iArraySessionsInUse.Count()>0) sl@0: { // delete and remove first session of array. sl@0: delete iArraySessionsInUse[0]; sl@0: iArraySessionsInUse.Remove(0); sl@0: } sl@0: iArraySessionsInUse.Close(); sl@0: } // End of function sl@0: sl@0: sl@0: void CUpsClientStep::SetTestDataL(TInt aIndex) sl@0: { sl@0: // Set data for request. sl@0: iReturnData.iError=KErrNone; sl@0: iServerId=0; sl@0: iRequestData.iMeasureResponceTime = EFalse; sl@0: iRequestData.iServiceUid = TUid::Uid(iArraySersToRequest[aIndex].iServiceUID); sl@0: sl@0: if(iArraySersToRequest[aIndex].iOpaqueData.CompareF(_L8(""))==0) sl@0: { sl@0: iRequestData.iOpaquePresent = EFalse; sl@0: } sl@0: else sl@0: { sl@0: iRequestData.iOpaquePresent = ETrue; sl@0: iRequestData.iOpaqueData =iArraySersToRequest[aIndex].iOpaqueData; sl@0: } sl@0: sl@0: iRequestData.iDestination = iArraySersToRequest[aIndex].iDestination; sl@0: iRequestData.iCancelRequest = iArraySersToRequest[aIndex].iCancelUpsRequest; sl@0: iRequestData.iPlatSecPass = iArraySersToRequest[aIndex].iPlatSecPass; sl@0: sl@0: // set properties for policy evaluator. sl@0: if (iArraySersToRequest[aIndex].iPolicyEvaluatorInvoked != 0) sl@0: { sl@0: //Reset various publisher and suscribe properties for policy evaluator. sl@0: TInt instance = iArraySersToRequest[aIndex].iPolicyEvaluatorInvoked; sl@0: iPropertyReader->SetL(instance,KPe_Status,CUpsProperty::EPolicyEvaluator, KUpsPeStatusReset); sl@0: iPropertyReader->SetL(instance,KPe_ClientSid,CUpsProperty::EPolicyEvaluator, 0); sl@0: iPropertyReader->SetL(instance,KPe_ServerSid,CUpsProperty::EPolicyEvaluator, 0); sl@0: TBool leaveEvaluator = iArraySersToRequest[aIndex].iLeaveEvaluator; sl@0: iPropertyReader->SetL(instance,KPe_Leave,CUpsProperty::EPolicyEvaluator, leaveEvaluator); sl@0: iPropertyReader->SetL(instance,KPe_Error,CUpsProperty::EPolicyEvaluator, KErrNone); sl@0: TBool holdEvaluatorOpen = iArraySersToRequest[aIndex].iHoldEvaluatorOpen; sl@0: iPropertyReader->SetL(instance,KPe_HoldEvaluatorOpen,CUpsProperty::EPolicyEvaluator, holdEvaluatorOpen); sl@0: TBool forcePrompt = iArraySersToRequest[aIndex].iForcePrompt; sl@0: iPropertyReader->SetL(instance,KPe_ForcePrompt,CUpsProperty::EPolicyEvaluator, forcePrompt); sl@0: iPropertyReader->SetL(instance,KPe_EvaluatorInfo,CUpsProperty::EPolicyEvaluator, 0); sl@0: } sl@0: sl@0: // set properties for dialog creator. sl@0: if (iArraySersToRequest[aIndex].iDialogCreatorInvoked != 0) sl@0: { sl@0: //Reset various publisher and suscribe properties for dialog creator. sl@0: TInt instance = iArraySersToRequest[aIndex].iDialogCreatorInvoked; sl@0: iPropertyReader->SetL(instance,KDc_Status,CUpsProperty::EDialogCreator, KUpsDcStatusReset); sl@0: iPropertyReader->SetL(instance,KDc_ClientSid,CUpsProperty::EDialogCreator, 0); sl@0: iPropertyReader->SetL(instance,KDc_ServerSid,CUpsProperty::EDialogCreator, 0); sl@0: TBool dialogLeave = iArraySersToRequest[aIndex].iLeaveDialog ; sl@0: iPropertyReader->SetL(instance,KDc_Leave,CUpsProperty::EDialogCreator, dialogLeave); sl@0: iPropertyReader->SetL(instance,KDc_Error,CUpsProperty::EDialogCreator, KErrNone); sl@0: iPropertyReader->SetL(instance,KDc_UpsRequestedButtons,CUpsProperty::EDialogCreator, 0); sl@0: TInt buttonToPress = ButtonToInt(iArraySersToRequest[aIndex].iSelectDialogOption); sl@0: iPropertyReader->SetL(instance,KDc_WhichButtonToPress,CUpsProperty::EDialogCreator, buttonToPress); sl@0: TBool holdPrepareDialogOpen = iArraySersToRequest[aIndex].iHoldPrepareDialogOpen; sl@0: iPropertyReader->SetL(instance,KDc_HoldPrepareDialogOpen,CUpsProperty::EDialogCreator, holdPrepareDialogOpen); sl@0: TBool holdDisplayDialogOpen = iArraySersToRequest[aIndex].iHoldDisplayDialogOpen; sl@0: iPropertyReader->SetL(instance,KDc_HoldDisplayDialogOpen,CUpsProperty::EDialogCreator, holdDisplayDialogOpen); sl@0: TBool selectFingerprint = iArraySersToRequest[aIndex].iSelectFingerprint ; sl@0: iPropertyReader->SetL(instance,KDc_SelectFingerprint,CUpsProperty::EDialogCreator, selectFingerprint); sl@0: } sl@0: sl@0: } // End of function. sl@0: sl@0: sl@0: void CUpsClientStep::SetClientStatusCompleteL() sl@0: /** sl@0: * Sets the status of the first policy evaluator invoked by the client to "KUpsClientCompleted" so that sl@0: * the coordinator step can determine when the step has completely finish and progress in Concurrent mode sl@0: * sl@0: * NOTE: When using the Coordinator in this manner, ALL requests made to UPS must invoke the same instance sl@0: * of the Policy Evaluator and Dialog Creator! e.g. Policy Evalutor 1 and Dialog Creator 1 sl@0: */ sl@0: { sl@0: TInt requestCount = iArraySersToRequest.Count(); sl@0: sl@0: for(TInt i=0; iSetL(instance,KPe_Status,CUpsProperty::EPolicyEvaluator, KUpsClientCompleted); sl@0: iPropertyReader->SetL(instance,KDc_Status,CUpsProperty::EDialogCreator, KUpsClientCompleted); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: TUpsDecision CUpsClientStep::StringToTUpsDecision(const TPtrC& aString) sl@0: { sl@0: if(aString.CompareF(_L("Yes"))==0) sl@0: { sl@0: return TUpsDecision(EUpsDecYes); sl@0: } sl@0: else if(aString.CompareF(_L("No"))==0) sl@0: { sl@0: return TUpsDecision(EUpsDecNo); sl@0: } sl@0: else if(aString.CompareF(_L("SessionYes"))==0) sl@0: { sl@0: return TUpsDecision(EUpsDecSessionYes); sl@0: } sl@0: else sl@0: { sl@0: return TUpsDecision(EUpsDecSessionNo); sl@0: } sl@0: } // End of function. sl@0: sl@0: sl@0: TPtrC CUpsClientStep::TUpsDecisionToString(TUpsDecision aDecision) sl@0: { sl@0: if(aDecision == EUpsDecYes) sl@0: { sl@0: return _L("Yes"); sl@0: } sl@0: else if(aDecision == EUpsDecNo) sl@0: { sl@0: return _L("No"); sl@0: } sl@0: else if(aDecision == EUpsDecSessionYes) sl@0: { sl@0: return _L("SessionYes"); sl@0: } sl@0: else if(aDecision == EUpsDecSessionNo) sl@0: { sl@0: return _L("SessionNo"); sl@0: } sl@0: else sl@0: { sl@0: return _L("Undefined"); sl@0: } sl@0: } // End of function. sl@0: sl@0: sl@0: TInt CUpsClientStep::ButtonToInt(const TPtrC& aButton) sl@0: { sl@0: if(aButton.CompareF(_L("Yes"))==0) sl@0: { sl@0: return KYes; sl@0: } sl@0: else if(aButton.CompareF(_L("No"))==0) sl@0: { sl@0: return KNo; sl@0: } sl@0: else if(aButton.CompareF(_L("Always"))==0) sl@0: { sl@0: return KAlways; sl@0: } sl@0: else if(aButton.CompareF(_L("SessionYes"))==0) sl@0: { sl@0: return KSessionYes; sl@0: } sl@0: else if(aButton.CompareF(_L("SessionNo"))==0) sl@0: { sl@0: return KSessionNo; sl@0: } sl@0: else if(aButton.CompareF(_L("Never"))==0) sl@0: { sl@0: return KNever; sl@0: } sl@0: else return KNone; sl@0: sl@0: } // End of function. sl@0: sl@0: sl@0: TBool CUpsClientStep::CheckResultsL(TInt aIndex) sl@0: { sl@0: TBool theReturn = ETrue; sl@0: sl@0: if(iArraySersToRequest[aIndex].iExpectedError == KErrNone) sl@0: { sl@0: TUpsDecision expectedDecision = StringToTUpsDecision(iArraySersToRequest[aIndex].iAccessGranted); sl@0: if(expectedDecision != iReturnData.iDecision) sl@0: { sl@0: TPtrC decisionReceived(TUpsDecisionToString(iReturnData.iDecision)); sl@0: ERR_PRINTF4(_L("%S: Decision expected: %S ,Decision received: %S"),&iTEFServerName, &iArraySersToRequest[aIndex].iAccessGranted, &decisionReceived); sl@0: theReturn=EFalse; sl@0: } sl@0: } sl@0: sl@0: if(iArraySersToRequest[aIndex].iExpectedError != iReturnData.iError) sl@0: { sl@0: // Incorrect error code returned. sl@0: theReturn=EFalse; sl@0: ERR_PRINTF3(_L("%S: Error code expected: %d"),&iTEFServerName,iArraySersToRequest[aIndex].iExpectedError); sl@0: ERR_PRINTF3(_L("%S: Error code Received: %d"),&iTEFServerName,iReturnData.iError); sl@0: } sl@0: sl@0: // checks returned properties from dialog creator & policy evaluator. sl@0: if ( CheckDialogCreatorResultsL(aIndex) == EFalse || CheckPolicyEvaluatorResultsL(aIndex) == EFalse) sl@0: { sl@0: theReturn = EFalse; sl@0: } sl@0: sl@0: // display the request duration and check against the ini file value, if supplied sl@0: INFO_PRINTF3(_L("%S: UPS decision request duration: %u milliseconds"),&iTEFServerName, iReturnData.iRequestDuration); sl@0: if (iArraySersToRequest[aIndex].iRequestDurationThreshold > 0) sl@0: { sl@0: // check whether the request duration was too long sl@0: if (static_cast(iReturnData.iRequestDuration) > iArraySersToRequest[aIndex].iRequestDurationThreshold) sl@0: { sl@0: ERR_PRINTF3(_L("%S: UPS decision request took too long: %u"), &iTEFServerName, iArraySersToRequest[aIndex].iRequestDurationThreshold); sl@0: theReturn = EFalse; sl@0: } sl@0: } sl@0: sl@0: return theReturn; sl@0: } // End of function. sl@0: sl@0: sl@0: TBool CUpsClientStep::CheckDialogCreatorResultsL(TInt aIndex) sl@0: { sl@0: TBool checkPassed = ETrue; sl@0: sl@0: // checks return properties from dialog creator. sl@0: if (iArraySersToRequest[aIndex].iDialogCreatorInvoked != 0) sl@0: { sl@0: TInt instanceDia = iArraySersToRequest[aIndex].iDialogCreatorInvoked; sl@0: TInt dialogError = 0; sl@0: iPropertyReader->GetL(instanceDia,KDc_Error,CUpsProperty::EDialogCreator, dialogError); sl@0: sl@0: // Checks that any error encountered by dialog creator is transmited by UPS to system server sl@0: if(dialogError != iReturnData.iError && dialogError!=KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("%S: Dialog creator found an error: %d"),&iTEFServerName,dialogError); sl@0: checkPassed = EFalse; sl@0: } sl@0: sl@0: TInt clientSidDia=0; sl@0: iPropertyReader->GetL(instanceDia,KDc_ClientSid,CUpsProperty::EDialogCreator, clientSidDia); sl@0: sl@0: if(iExpectedClientSid != clientSidDia) sl@0: { sl@0: ERR_PRINTF2(_L("%S: Client SID returned by dialog creator is not what is expected"),&iTEFServerName); sl@0: checkPassed = EFalse; sl@0: } sl@0: sl@0: TInt buttonsDisplayed=0; sl@0: iPropertyReader->GetL(instanceDia,KDc_UpsRequestedButtons,CUpsProperty::EDialogCreator, buttonsDisplayed); sl@0: TInt32 expectedButtonsDisplayed=iArraySersToRequest[aIndex].iButtonsDisplayed; sl@0: if(expectedButtonsDisplayed != buttonsDisplayed) sl@0: { sl@0: ERR_PRINTF2(_L("%S: Incorrect buttons displayed."),&iTEFServerName); sl@0: ERR_PRINTF3(_L("%S: Buttons displayed expected: %d"),&iTEFServerName,expectedButtonsDisplayed); sl@0: ERR_PRINTF3(_L("%S: Buttons displayed received: %d"),&iTEFServerName,buttonsDisplayed); sl@0: checkPassed = EFalse; sl@0: } sl@0: sl@0: TInt serverSidDia=0; sl@0: iPropertyReader->GetL(instanceDia,KDc_ServerSid,CUpsProperty::EDialogCreator, serverSidDia); sl@0: sl@0: if(iServerId != serverSidDia) sl@0: { sl@0: ERR_PRINTF2(_L("%S: Server SID returned by dialog creator is not what is expected"),&iTEFServerName); sl@0: checkPassed = EFalse; sl@0: } sl@0: sl@0: TInt serviceSidDia=0; sl@0: iPropertyReader->GetL(instanceDia,KDc_ServiceId,CUpsProperty::EDialogCreator, serviceSidDia); sl@0: if(serviceSidDia != iArraySersToRequest[aIndex].iServiceUID) sl@0: { sl@0: ERR_PRINTF3(_L("%S: Service ID reported by dialog creator is not what is expected: %d"),&iTEFServerName,serviceSidDia); sl@0: checkPassed = EFalse; sl@0: } sl@0: } sl@0: sl@0: return checkPassed; sl@0: } // End of function. sl@0: sl@0: sl@0: TBool CUpsClientStep::CheckPolicyEvaluatorResultsL(TInt aIndex) sl@0: { sl@0: TBool checkPassed = ETrue; sl@0: sl@0: if (iArraySersToRequest[aIndex].iPolicyEvaluatorInvoked != 0) sl@0: { sl@0: TInt instanceEva = iArraySersToRequest[aIndex].iPolicyEvaluatorInvoked; sl@0: TInt evaluatorError = 0; sl@0: sl@0: // Checks that any error encountered by policy evaluator is transmited by UPS to system server sl@0: iPropertyReader->GetL(instanceEva,KPe_Error,CUpsProperty::EPolicyEvaluator, evaluatorError); sl@0: if(evaluatorError != iReturnData.iError && evaluatorError!=KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("%S: Policy evaluator found an error: %d"),&iTEFServerName,evaluatorError); sl@0: checkPassed = EFalse; sl@0: } sl@0: sl@0: TInt clientSidEva=0; sl@0: iPropertyReader->GetL(instanceEva,KPe_ClientSid,CUpsProperty::EPolicyEvaluator, clientSidEva); sl@0: sl@0: if(iExpectedClientSid != clientSidEva) sl@0: { sl@0: ERR_PRINTF2(_L("%S: Client SID returned by policy evaluator is not what is expected"),&iTEFServerName); sl@0: checkPassed = EFalse; sl@0: } sl@0: sl@0: TInt serverSidEva=0; sl@0: iPropertyReader->GetL(instanceEva,KPe_ServerSid,CUpsProperty::EPolicyEvaluator, serverSidEva); sl@0: sl@0: if(iServerId != serverSidEva) sl@0: { sl@0: ERR_PRINTF2(_L("%S: Server SID returned by policy evaluator is not what is expected"),&iTEFServerName); sl@0: checkPassed = EFalse; sl@0: } sl@0: sl@0: TInt serviceSidEva = 0; sl@0: iPropertyReader->GetL(instanceEva,KPe_ServiceId,CUpsProperty::EPolicyEvaluator, serviceSidEva); sl@0: if(serviceSidEva != iArraySersToRequest[aIndex].iServiceUID) sl@0: { sl@0: ERR_PRINTF3(_L("%S: Service ID reported by policy evaluator is not what is expected: %d"),&iTEFServerName,serviceSidEva); sl@0: checkPassed = EFalse; sl@0: } sl@0: if( iArraySersToRequest[aIndex].iForcePrompt) sl@0: { sl@0: // Read evaluator info sl@0: TInt evaluatorInfo = 0; sl@0: iPropertyReader->GetL(instanceEva,KPe_EvaluatorInfo,CUpsProperty::EPolicyEvaluator, evaluatorInfo); sl@0: if(evaluatorInfo != iArraySersToRequest[aIndex].iExpectedEvaluatorInfo) sl@0: { sl@0: ERR_PRINTF4(_L("%S: incorrect evaluator info:Expected: %d Received: %d"),&iTEFServerName,iArraySersToRequest[aIndex].iExpectedEvaluatorInfo,evaluatorInfo); sl@0: checkPassed = EFalse; sl@0: } sl@0: } sl@0: } sl@0: sl@0: return checkPassed; sl@0: } // End of function.