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". |
764 ); |
764 ); |
765 } |
765 } |
766 return manager; |
766 return manager; |
767 } |
767 } |
768 |
768 |
|
769 |
|
770 /* |
|
771 * The below function selects correct NTLM connection manger. Connection manager is associate with a socket. |
|
772 * NTLM protocol needs all authentication messages Negotiate(->),Challenge(<-) and Authorise(->) packets |
|
773 * to be sent on the same port. In this function, the connection manager is identified by NTLM id which is set |
|
774 * when CHttpResponseParser when 401 unauthorised message is received from ntlm enabled server. |
|
775 * The same iNtlmConnId will be maintained until authentication is successful. |
|
776 */ |
|
777 CHttpConnectionManager* CHttpClientHandler::SelectNtlmConnectionL(const CHttpConnectionInfo& aConnectionInfo,RHTTPTransaction aTrans) |
|
778 { |
|
779 |
|
780 TInt ntlmConnId; |
|
781 CHttpConnectionManager* fourthChoice=NULL; |
|
782 _LIT8( KNtlmId, "NTLMConnId" ); |
|
783 RStringPool stringPool = aTrans.Session().StringPool(); |
|
784 RStringF ntlmId = stringPool.OpenFStringL( KNtlmId ); |
|
785 THTTPHdrVal value; |
|
786 |
|
787 if (aTrans.PropertySet().Property(ntlmId,value)) |
|
788 { |
|
789 ntlmConnId = value.Int(); |
|
790 for (TInt i=0;i<iConnectionManagers.Count();i++) |
|
791 { |
|
792 const CHttpConnectionInfo& connectionInfo = iConnectionManagers[i]->ConnectionInfo(); |
|
793 if( connectionInfo.HostAndPortMatches(aConnectionInfo) ) |
|
794 { |
|
795 if (iConnectionManagers[i]->GetNtlmConnId() == ntlmConnId) |
|
796 { |
|
797 ntlmId.Close(); |
|
798 return iConnectionManagers[i]; |
|
799 } |
|
800 } |
|
801 else |
|
802 { |
|
803 fourthChoice = iConnectionManagers[i]; |
|
804 } |
|
805 } |
|
806 } |
|
807 ntlmId.Close(); |
|
808 return fourthChoice; |
|
809 } |
|
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" ); |
|
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); |
935 } |
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 |