applayerprotocols/httptransportfw/Test/Acceptance/Iter2/SingleTrans.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // SingleTrans..cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <x509cert.h>
       
    19 
       
    20 #include "SingleTrans.h"
       
    21 #include <http.h>
       
    22 
       
    23 void CHttpTestSingleTrans::CreateSingleTransactionL()
       
    24 	{
       
    25 	iTransaction = CreateTransactionL(0);
       
    26 	}
       
    27 
       
    28 void CHttpTestSingleTrans::OpenTestSessionL()
       
    29 	{
       
    30 	iSession.OpenL();
       
    31 	CleanupClosePushL ( iSession );
       
    32 	SetProxyL(0); // 0 is the start item to look for it in the param list for the test in the ini file
       
    33 	SetMaxRedirectsL(0);
       
    34 	MHTTPAuthenticationCallback::InstallAuthenticationL(iSession);
       
    35 	iMyStrP = iSession.StringPool();
       
    36 	TPtrC testName = CHttpTestTransactions::TestName();
       
    37 	if (testName.CompareF(_L("SSL9"))==0)
       
    38 		{
       
    39 		RHTTPConnectionInfo	connInfo = iSession.ConnectionInfo();
       
    40 		connInfo.SetPropertyL( 
       
    41 							 iMyStrP.StringF(HTTP::ESecureDialog, RHTTPSession::GetTable() ),
       
    42 							 iMyStrP.StringF(HTTP::EDialogNoPrompt, RHTTPSession::GetTable() )
       
    43 							 );
       
    44 		iEngine->Utils().LogIt(_L("Secure Dialog session property set\n"));
       
    45 		}
       
    46 	CreateSingleTransactionL();
       
    47 	CleanupStack::Pop (&iSession);
       
    48 	}
       
    49 
       
    50 void CHttpTestSingleTrans::CloseTestSession()
       
    51 	{
       
    52 	LogCertificate();
       
    53 	// Allow the base class to do any closing
       
    54 	CHttpTestTransactions::CloseTestSession();
       
    55 	// Close strings used in this session before closing the session
       
    56 	//close Transaction and session
       
    57 	iTransaction.Close();
       
    58 	iEngine->Utils().LogIt(_L("Transaction terminated\n"));
       
    59 	iSession.Close();
       
    60 	iEngine->Utils().LogIt(_L("Session terminated"));
       
    61 	}
       
    62 
       
    63 void CHttpTestSingleTrans::LogCertificate()
       
    64 	{
       
    65 	if(iLogCert)
       
    66 		{
       
    67 		TRAPD(error, LogCertL());
       
    68 		if(error != KErrNone)
       
    69 			iEngine->Utils().LogIt(_L("Unable to log server certificate.  Error code=%d\n"), error);
       
    70 		}
       
    71 	}
       
    72 
       
    73 void CHttpTestSingleTrans::LogCertL()
       
    74 	{
       
    75 	TCertInfo certInfo;
       
    76 	User::LeaveIfError(iTransaction.ServerCert(certInfo));
       
    77 
       
    78 	LogCertificateL(certInfo);
       
    79 
       
    80 	const CX509Certificate* cert = static_cast<const CX509Certificate*>(iTransaction.ServerCert());
       
    81 	LogCertificateL(cert);
       
    82 
       
    83 	}
       
    84 
       
    85 CHttpTestSingleTrans* CHttpTestSingleTrans::NewL(CScriptFile& aIniFile, CScriptFile* aIniSettingsFile, const TInt aSectionNumber)
       
    86 	{
       
    87 	CHttpTestSingleTrans* self= new(ELeave) CHttpTestSingleTrans;
       
    88 	CleanupStack::PushL(self);
       
    89 	self->ConstructL(aIniFile, aIniSettingsFile, aSectionNumber);
       
    90 	CleanupStack::Pop();
       
    91 	return self;
       
    92 	}
       
    93 
       
    94 void CHttpTestSingleTrans::ConstructL(CScriptFile& aIniFile, CScriptFile* aIniSettingsFile, const TInt aSectionNumber)
       
    95 	{
       
    96 	CHttpTestTransactions::ConstructL(aIniFile, aIniSettingsFile, aSectionNumber);
       
    97 
       
    98 	_LIT(KLogCipherSuite, "LogCipherSuite");
       
    99 	CScriptSectionItem* cipherSuiteItem = aIniFile.Section(aSectionNumber).Item(KLogCipherSuite);
       
   100 	_LIT(KItemSet, "1");
       
   101 	if(cipherSuiteItem && cipherSuiteItem->Value().Compare(KItemSet) == 0)
       
   102 		{
       
   103 		iLogCipherSuite = ETrue;
       
   104 		}
       
   105 	}
       
   106 	
       
   107 void CHttpTestSingleTrans::MHFRunL(RHTTPTransaction aTransaction,
       
   108 								   const THTTPEvent& aEvent)
       
   109 	{
       
   110 	// Handle the event
       
   111 	switch (aEvent.iStatus)
       
   112 		{
       
   113 	case THTTPEvent::EGotResponseHeaders:
       
   114 		{
       
   115 		if (iLogCipherSuite)
       
   116 			{
       
   117 			RString cipherSuite = aTransaction.CipherSuite();
       
   118 			
       
   119 			iEngine->Utils().LogIt(_L("Cipher Suite = %s\n"), &cipherSuite.DesC());
       
   120 			}
       
   121 		}
       
   122 		break;
       
   123 	default:
       
   124 		;
       
   125 		}
       
   126 	CHttpAcceptTestBase::MHFRunL(aTransaction,aEvent);
       
   127 	}
       
   128