applayerpluginsandutils/httpprotocolplugins/httpclient/chttpclienthandler.cpp
branchRCL_3
changeset 18 5f1cd966e0d9
parent 7 2611c08ee28e
child 19 c0c2f28ace9c
equal deleted inserted replaced
17:a2a70ce3d4e8 18:5f1cd966e0d9
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   652 			}
   652 			}
   653 		}
   653 		}
   654 	return newConnection;
   654 	return newConnection;
   655 	}
   655 	}
   656 
   656 
       
   657 
   657 CHttpConnectionManager* CHttpClientHandler::SelectTunnelConnectionL(const CHttpConnectionInfo& aConnectionInfo, RHTTPTransaction aTrans, TBool aCanPipeline)
   658 CHttpConnectionManager* CHttpClientHandler::SelectTunnelConnectionL(const CHttpConnectionInfo& aConnectionInfo, RHTTPTransaction aTrans, TBool aCanPipeline)
   658 	{
   659 	{
   659 	// Look for connection manager that is a tunnel connection via appropriate
   660 	// Look for connection manager that is a tunnel connection via appropriate
   660 	// proxy to appropriate host. If the transaction can be pipelined, then the
   661 	// proxy to appropriate host. If the transaction can be pipelined, then the
   661 	// first choice is a connection manager that is connected and busy. 
   662 	// first choice is a connection manager that is connected and busy. 
   764 						 );
   765 						 );
   765 		}
   766 		}
   766 	return manager;
   767 	return manager;
   767 	}
   768 	}
   768 
   769 
       
   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 
   769 TInt CHttpClientHandler::MaxNumConnectionManagers() const
   812 TInt CHttpClientHandler::MaxNumConnectionManagers() const
   770 	{
   813 	{
   771 	// Has this value been previously cached?
   814 	// Has this value been previously cached?
   772 	if( iMaxNumConnectionManagers == 0 )
   815 	if( iMaxNumConnectionManagers == 0 )
   773 		{
   816 		{
   928 		// appropriate host.
   971 		// appropriate host.
   929 		manager = SelectTunnelConnectionL(*info, aTrans.Transaction(), canPipeline);
   972 		manager = SelectTunnelConnectionL(*info, aTrans.Transaction(), canPipeline);
   930 		}
   973 		}
   931 	else
   974 	else
   932 		{
   975 		{
   933 		// Look for a normal connection.
   976         THTTPHdrVal value;
   934 		isNewConnection = SelectConnectionManagerL(*info, aTrans.Transaction(), canPipeline, manager);
   977         _LIT8( KNtlmStateStr, "NTLMState" );
   935 		}
   978         RStringPool stringPool = iSession.StringPool();
       
   979         RStringF strF = stringPool.OpenFStringL( KNtlmStateStr );
       
   980         CleanupClosePushL(strF);
       
   981         if ( aTrans.Transaction().PropertySet().Property( strF, value ) && (value.Int() == ENtlmNegotiate || value.Int() == ENtlmAuthenticate) )
       
   982             {
       
   983             manager = SelectNtlmConnectionL(*info,aTrans.Transaction());
       
   984             if (manager == NULL)
       
   985                 {
       
   986                 __FLOG_0(_T8("No NTLM connection manger!!!"));
       
   987                 }
       
   988             else if (value.Int() == ENtlmAuthenticate)
       
   989                 {
       
   990 #if defined (_DEBUG) && defined (_LOGGING)
       
   991                 __FLOG_1(_T8(" NTLM AUTH msg Id %d and resetting to  -1"),manager->GetNtlmConnId());
       
   992 #endif
       
   993                 manager->SetNtlmConnId(KErrNotFound);//reset it
       
   994                 }
       
   995             }
       
   996         else// Look for a normal connection.
       
   997             {
       
   998             isNewConnection = SelectConnectionManagerL(*info, aTrans.Transaction(), canPipeline, manager);
       
   999             }
       
  1000         CleanupStack::PopAndDestroy(&strF);
       
  1001         }
   936 
  1002 
   937 	if( manager != NULL )
  1003 	if( manager != NULL )
   938 		{
  1004 		{
   939 		// Pass the connection manager to the transaction - need to do this 
  1005 		// Pass the connection manager to the transaction - need to do this 
   940 		// before creating tx- and rx- data objects.
  1006 		// before creating tx- and rx- data objects.
  1112 		// The default value - the client will be prompted
  1178 		// The default value - the client will be prompted
  1113 		aDialogPrompt = ETrue;
  1179 		aDialogPrompt = ETrue;
  1114 		}
  1180 		}
  1115 	}
  1181 	}
  1116 
  1182 
       
  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 	}
  1117 TBool CHttpClientHandler::ImmediateSocketShutdown()
  1209 TBool CHttpClientHandler::ImmediateSocketShutdown()
  1118 	{
  1210 	{
  1119 	TBool immediateSocketShutdown = EFalse;
  1211 	TBool immediateSocketShutdown = EFalse;
  1120 	if( *iSessionClosingPtr ) // iSessionClosingPtr cannot be NULL as its is set in ConstructL
  1212 	if( *iSessionClosingPtr ) // iSessionClosingPtr cannot be NULL as its is set in ConstructL
  1121 		{
  1213 		{
  1148 			result = KErrNotFound;
  1240 			result = KErrNotFound;
  1149 			}
  1241 			}
  1150 		}
  1242 		}
  1151 	return result;
  1243 	return result;
  1152 	}
  1244 	}
       
  1245 
       
  1246 TInt CHttpClientHandler::GetSocketImmediateCloseTimeout()
       
  1247     {
       
  1248     THTTPHdrVal value;
       
  1249     TInt result = KErrNotFound;
       
  1250     const TBool hasValue = iSession.ConnectionInfo().Property(iSession.StringPool().StringF(HTTP::EHttpSocketImmediateClosetTimeOutValue, iStringTable), value);
       
  1251     if( hasValue && value.Type()==THTTPHdrVal::KTIntVal) // silently ignore inappropriate types
       
  1252         {
       
  1253         result = value.Int();
       
  1254         if(result<0)
       
  1255             {
       
  1256             result = KErrNotFound;
       
  1257             }
       
  1258         }
       
  1259     return result;
       
  1260     }
  1153 
  1261 
  1154 
  1262 
  1155 /*
  1263 /*
  1156  *	Methods from MRxDataObserver
  1264  *	Methods from MRxDataObserver
  1157  */
  1265  */