Author: roeie
Date: 2007-09-09 07:28:40 -0400 (Sun, 09 Sep 2007)
New Revision: 85530

Modified:
   trunk/mcs/class/System/System.Net/VMWHttpProvider.jvm.cs
Log:
Add support for Negotiate (Kerberose) authentication scheme

Modified: trunk/mcs/class/System/System.Net/VMWHttpProvider.jvm.cs
===================================================================
--- trunk/mcs/class/System/System.Net/VMWHttpProvider.jvm.cs    2007-09-09 
09:18:01 UTC (rev 85529)
+++ trunk/mcs/class/System/System.Net/VMWHttpProvider.jvm.cs    2007-09-09 
11:28:40 UTC (rev 85530)
@@ -169,6 +169,18 @@
                                                new NTCredentials(nc.UserName, 
nc.Password, host, domain));
                                }
                        }
+                       else if (String.Compare (type, "negotiate", 
StringComparison.InvariantCultureIgnoreCase) == 0) {
+                               if (!proxyCredentials) {
+                                       _state.setCredentials (new AuthScope 
(AuthScope.ANY_HOST,
+                                               AuthScope.ANY_PORT, 
AuthScope.ANY_REALM, "negotiate"),
+                                               new NTCredentials (nc.UserName, 
nc.Password, host, domain));
+                               }
+                               else {
+                                       _state.setProxyCredentials (new 
AuthScope (AuthScope.ANY_HOST,
+                                               AuthScope.ANY_PORT, 
AuthScope.ANY_REALM, "negotiate"),
+                                               new NTCredentials (nc.UserName, 
nc.Password, host, domain));
+                               }
+                       }
                        else
                        {
                                if(!proxyCredentials)
@@ -184,8 +196,17 @@
                                                new 
UsernamePasswordCredentials(nc.UserName, nc.Password));
                                }
                        }
+                       SetAuthenticationScheme (Char.ToUpper (type [0]) + 
type.Substring (1));
 
                }
+
+               private void SetAuthenticationScheme (string type) {
+                       try {
+                               _method.getHostAuthState ().setAuthScheme 
(AuthPolicy.getAuthScheme (type));
+                       }
+                       catch (Exception) {//ignore no such scheme, will be 
selected by the chalenges order
+                       }
+               }
                private void InitProxyCredentials()
                {
                        if(this.Proxy == null)
@@ -212,6 +233,10 @@
                                        {
                                                type = "ntlm";
                                                nc = 
((CredentialCache)creds).GetCredential(proxy.Address, "ntlm");
+                                               if (nc == null) {
+                                                       nc = ((CredentialCache) 
_credentials).GetCredential (GetOriginalAddress (), "negotiate");
+                                                       type = "negotiate";
+                                               }
                                        }
                                }
                                if(nc != null)
@@ -243,6 +268,10 @@
                                        {
                                                nc = 
((CredentialCache)_credentials).GetCredential(GetOriginalAddress(), "ntlm");
                                                type = "ntlm";
+                                               if (nc == null) {
+                                                       nc = ((CredentialCache) 
_credentials).GetCredential (GetOriginalAddress (), "negotiate");
+                                                       type = "negotiate";
+                                               }
                                        }
                                }
                                if(nc != null)
@@ -392,6 +421,12 @@
                                        
_client.getParams().setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, 
new java.lang.Long(30000));
                                        
_client.getParams().setParameter(HttpClientParams.USER_AGENT, 
                                                        "VMW4J HttpClient 
(based on Jakarta Commons HttpClient)");
+                                       java.util.ArrayList schemas = new 
java.util.ArrayList ();
+                                       schemas.add ("Ntlm");
+                                       schemas.add ("Digest");
+                                       schemas.add ("Basic");                  
                
+                                       schemas.add ("Negotiate");
+                                       _client.getParams ().setParameter 
(AuthPolicy.AUTH_SCHEME_PRIORITY, schemas);
                                        if(!_disableHttpConnectionPooling) 
                                        {
                                                _sclient = _client;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to