applayerpluginsandutils/httpprotocolplugins/httpclient/chttpclienthandler.cpp
branchRCL_3
changeset 53 c59bddbfd7b9
parent 40 a0da872af3fa
equal deleted inserted replaced
40:a0da872af3fa 53:c59bddbfd7b9
   651 			aManager = fourthChoice;
   651 			aManager = fourthChoice;
   652 			}
   652 			}
   653 		}
   653 		}
   654 	return newConnection;
   654 	return newConnection;
   655 	}
   655 	}
   656 
   656 	
       
   657 /*
       
   658 *	The below function selects correct NTLM connection manger. Connection manager is associate with a socket.
       
   659 *	NTLM protocol needs all authentication messages Negotiate(->),Challenge(<-) and Authorise(->) packets
       
   660 *	to be sent on the same port.  In this function, the connection manager is identified by NTLM id which is set
       
   661 *	when CHttpResponseParser when 401 unauthorised message is received from ntlm enabled server.
       
   662 *	The same iNtlmConnId will be maintained until authentication is successful.	
       
   663 */
       
   664 CHttpConnectionManager* CHttpClientHandler::SelectNtlmConnectionL(const CHttpConnectionInfo& aConnectionInfo,RHTTPTransaction aTrans)
       
   665     {
       
   666     
       
   667     TInt ntlmConnId;
       
   668     CHttpConnectionManager* fourthChoice=NULL;
       
   669     _LIT8( KNtlmId, "NTLMConnId" );
       
   670     RStringPool stringPool = aTrans.Session().StringPool();
       
   671     RStringF ntlmId = stringPool.OpenFStringL( KNtlmId );
       
   672    	CleanupClosePushL(ntlmId);
       
   673     THTTPHdrVal value;
       
   674     if (aTrans.PropertySet().Property(ntlmId,value))
       
   675         {
       
   676         ntlmConnId = value.Int();
       
   677         for (TInt i=0;i<iConnectionManagers.Count();i++)
       
   678             {
       
   679             const CHttpConnectionInfo& connectionInfo = iConnectionManagers[i]->ConnectionInfo();
       
   680             if( connectionInfo.HostAndPortMatches(aConnectionInfo) )
       
   681                 {
       
   682                 if (iConnectionManagers[i]->GetNtlmConnId() ==  ntlmConnId)
       
   683                     {
       
   684                     CleanupStack::PopAndDestroy(&ntlmId);
       
   685 										return iConnectionManagers[i];
       
   686                     }
       
   687                 }
       
   688             else
       
   689                 {
       
   690                 fourthChoice = iConnectionManagers[i];
       
   691                 }
       
   692             }
       
   693         }
       
   694     CleanupStack::PopAndDestroy(&ntlmId);
       
   695     return fourthChoice;
       
   696     }
   657 
   697 
   658 CHttpConnectionManager* CHttpClientHandler::SelectTunnelConnectionL(const CHttpConnectionInfo& aConnectionInfo, RHTTPTransaction aTrans, TBool aCanPipeline)
   698 CHttpConnectionManager* CHttpClientHandler::SelectTunnelConnectionL(const CHttpConnectionInfo& aConnectionInfo, RHTTPTransaction aTrans, TBool aCanPipeline)
   659 	{
   699 	{
   660 	// Look for connection manager that is a tunnel connection via appropriate
   700 	// Look for connection manager that is a tunnel connection via appropriate
   661 	// proxy to appropriate host. If the transaction can be pipelined, then the
   701 	// proxy to appropriate host. If the transaction can be pipelined, then the
   765 						 );
   805 						 );
   766 		}
   806 		}
   767 	return manager;
   807 	return manager;
   768 	}
   808 	}
   769 
   809 
   770 
       
   771 /*
       
   772 *   The below function selects correct NTLM connection manger. Connection manager is associate with a socket.
       
   773 *   NTLM protocol needs all authentication messages Negotiate(->),Challenge(<-) and Authorise(->) packets
       
   774 *   to be sent on the same port.  In this function, the connection manager is identified by NTLM id which is set
       
   775 *   when CHttpResponseParser when 401 unauthorised message is received from ntlm enabled server.
       
   776 *   The same iNtlmConnId will be maintained until authentication is successful. 
       
   777 */
       
   778 CHttpConnectionManager* CHttpClientHandler::SelectNtlmConnectionL(const CHttpConnectionInfo& aConnectionInfo,RHTTPTransaction aTrans)
       
   779     {
       
   780     
       
   781     TInt ntlmConnId;
       
   782     CHttpConnectionManager* fourthChoice=NULL;
       
   783     _LIT8( KNtlmId, "NTLMConnId" );
       
   784     RStringPool stringPool = aTrans.Session().StringPool();
       
   785     RStringF ntlmId = stringPool.OpenFStringL( KNtlmId );
       
   786     THTTPHdrVal value;
       
   787     
       
   788     if (aTrans.PropertySet().Property(ntlmId,value))
       
   789         {
       
   790         ntlmConnId = value.Int();
       
   791         for (TInt i=0;i<iConnectionManagers.Count();i++)
       
   792             {
       
   793             const CHttpConnectionInfo& connectionInfo = iConnectionManagers[i]->ConnectionInfo();
       
   794             if( connectionInfo.HostAndPortMatches(aConnectionInfo) )
       
   795                 {
       
   796                 if (iConnectionManagers[i]->GetNtlmConnId() ==  ntlmConnId)
       
   797                     {
       
   798                     ntlmId.Close();
       
   799                     return iConnectionManagers[i];
       
   800                     }
       
   801                 }
       
   802             else
       
   803                 {
       
   804                 fourthChoice = iConnectionManagers[i];
       
   805                 }
       
   806             }
       
   807         }
       
   808     ntlmId.Close();
       
   809     return fourthChoice;
       
   810     }
       
   811 
       
   812 TInt CHttpClientHandler::MaxNumConnectionManagers() const
   810 TInt CHttpClientHandler::MaxNumConnectionManagers() const
   813 	{
   811 	{
   814 	// Has this value been previously cached?
   812 	// Has this value been previously cached?
   815 	if( iMaxNumConnectionManagers == 0 )
   813 	if( iMaxNumConnectionManagers == 0 )
   816 		{
   814 		{
   969 		{
   967 		{
   970 		// Find a connection that is tunnelling via appropriate proxy to the
   968 		// Find a connection that is tunnelling via appropriate proxy to the
   971 		// appropriate host.
   969 		// appropriate host.
   972 		manager = SelectTunnelConnectionL(*info, aTrans.Transaction(), canPipeline);
   970 		manager = SelectTunnelConnectionL(*info, aTrans.Transaction(), canPipeline);
   973 		}
   971 		}
   974 	else
   972 	else  
   975 		{
   973 		{
   976         THTTPHdrVal value;
   974         THTTPHdrVal value;
   977         _LIT8( KNtlmStateStr, "NTLMState" );
   975         _LIT8( KNtlmStateStr, "NTLMState" );
   978         RStringPool stringPool = iSession.StringPool();
   976         RStringPool stringPool = iSession.StringPool();
   979         RStringF strF = stringPool.OpenFStringL( KNtlmStateStr );
   977         RStringF strF = stringPool.OpenFStringL( KNtlmStateStr );
   980         CleanupClosePushL(strF);
   978         CleanupClosePushL(strF);
   981         if ( aTrans.Transaction().PropertySet().Property( strF, value ) && (value.Int() == ENtlmNegotiate || value.Int() == ENtlmAuthenticate) )
   979  				if ( aTrans.Transaction().PropertySet().Property( strF, value ) && (value.Int() == ENtlmNegotiate || value.Int() == ENtlmAuthenticate) )
   982             {
   980             {
   983             manager = SelectNtlmConnectionL(*info,aTrans.Transaction());
   981             manager = SelectNtlmConnectionL(*info,aTrans.Transaction());
   984             if (manager == NULL)
   982             if (manager == NULL)
   985                 {
   983                 {
   986                 __FLOG_0(_T8("No NTLM connection manger!!!"));
   984                 __FLOG_0(_T8("No NTLM connection manger!!!"));
   995             }
   993             }
   996         else// Look for a normal connection.
   994         else// Look for a normal connection.
   997             {
   995             {
   998             isNewConnection = SelectConnectionManagerL(*info, aTrans.Transaction(), canPipeline, manager);
   996             isNewConnection = SelectConnectionManagerL(*info, aTrans.Transaction(), canPipeline, manager);
   999             }
   997             }
  1000         CleanupStack::PopAndDestroy(&strF);
   998 				CleanupStack::PopAndDestroy(&strF);
  1001         }
   999 		}
  1002 
  1000 
  1003 	if( manager != NULL )
  1001 	if( manager != NULL )
  1004 		{
  1002 		{
  1005 		// Pass the connection manager to the transaction - need to do this 
  1003 		// Pass the connection manager to the transaction - need to do this 
  1006 		// before creating tx- and rx- data objects.
  1004 		// before creating tx- and rx- data objects.
  1178 		// The default value - the client will be prompted
  1176 		// The default value - the client will be prompted
  1179 		aDialogPrompt = ETrue;
  1177 		aDialogPrompt = ETrue;
  1180 		}
  1178 		}
  1181 	}
  1179 	}
  1182 
  1180 
  1183 void CHttpClientHandler::GetSecurityPrefs(MSecurityPolicy*& aSecurityPolicy, TInt& aDialogPref)
       
  1184 	{
       
  1185 	// Set the security policy
       
  1186 	aSecurityPolicy = iSecurityPolicy;
       
  1187 
       
  1188 	// Set the dialog info - check the session properties
       
  1189 	THTTPHdrVal value;
       
  1190 	RStringF secureDialog = iSession.StringPool().StringF(HTTP::ESecureDialog, iStringTable);
       
  1191 	TBool hasValue = iSession.ConnectionInfo().Property(secureDialog, value);
       
  1192 	if( hasValue && value.Type() == THTTPHdrVal::KStrFVal && 
       
  1193 		value.StrF().Index(iStringTable) == HTTP::EDialogNoPrompt )
       
  1194 		{
       
  1195 		// Client has requested to not be prompted
       
  1196 		aDialogPref = CHttpTransportLayer::ETHttpDialogModeUnattended;
       
  1197 		}
       
  1198 	else if ( hasValue && value.Type() == THTTPHdrVal::KStrFVal && 
       
  1199 	        value.StrF().Index(RHTTPSession::GetTable()) == HTTP::EDialogAutomaticAllowed )
       
  1200 		{
       
  1201         aDialogPref = CHttpTransportLayer::ETHttpDialogModeAllowAutomatic;
       
  1202 		}
       
  1203 	else
       
  1204 		{
       
  1205 		// The default value - the client will be prompted
       
  1206 		aDialogPref = CHttpTransportLayer::ETHttpDialogModeAttended;
       
  1207 		}
       
  1208 	}
       
  1209 TBool CHttpClientHandler::ImmediateSocketShutdown()
  1181 TBool CHttpClientHandler::ImmediateSocketShutdown()
  1210 	{
  1182 	{
  1211 	TBool immediateSocketShutdown = EFalse;
  1183 	TBool immediateSocketShutdown = EFalse;
  1212 	if( *iSessionClosingPtr ) // iSessionClosingPtr cannot be NULL as its is set in ConstructL
  1184 	if( *iSessionClosingPtr ) // iSessionClosingPtr cannot be NULL as its is set in ConstructL
  1213 		{
  1185 		{
  1240 			result = KErrNotFound;
  1212 			result = KErrNotFound;
  1241 			}
  1213 			}
  1242 		}
  1214 		}
  1243 	return result;
  1215 	return result;
  1244 	}
  1216 	}
       
  1217 
  1245 
  1218 
  1246 TInt CHttpClientHandler::GetSocketImmediateCloseTimeout()
  1219 TInt CHttpClientHandler::GetSocketImmediateCloseTimeout()
  1247     {
  1220     {
  1248     THTTPHdrVal value;
  1221     THTTPHdrVal value;
  1249     TInt result = KErrNotFound;
  1222     TInt result = KErrNotFound;