public Authorization Authenticate(string challenge, WebRequest webRequest, ICredentials credentials)
        {
            if (credentials == null || challenge == null)
            {
                return(null);
            }

            string header = challenge.Trim();
            int    idx    = header.ToLower().IndexOf("ntlm");

            if (idx == -1)
            {
                return(null);
            }

            idx = header.IndexOfAny(new char [] { ' ', '\t' });
            if (idx != -1)
            {
                header = header.Substring(idx).Trim();
            }
            else
            {
                header = null;
            }

            HttpWebRequest request = webRequest as HttpWebRequest;

            if (request == null)
            {
                return(null);
            }

            lock (cache)
            {
                NtlmSession ds = (NtlmSession)cache [request.RequestUri];
                if (ds == null)
                {
                    ds = new NtlmSession();
                    cache.Add(request.RequestUri, ds);
                }

                return(ds.Authenticate(header, webRequest, credentials));
            }
        }
		public Authorization Authenticate (string challenge, WebRequest webRequest, ICredentials credentials) 
		{
			if (credentials == null || challenge == null)
				return null;
	
			string header = challenge.Trim ();
			int idx = header.ToLower ().IndexOf ("ntlm");
			if (idx == -1)
				return null;

			idx = header.IndexOfAny (new char [] {' ', '\t'});
			if (idx != -1) {
				header = header.Substring (idx).Trim ();
			} else {
				header = null;
			}

			HttpWebRequest request = webRequest as HttpWebRequest;
			if (request == null)
				return null;

			lock (cache) {
				NtlmSession ds = (NtlmSession) cache [request];
				if (ds == null) {
					ds = new NtlmSession ();
					cache.Add (request, ds);
				}

				return ds.Authenticate (header, webRequest, credentials);
			}
		}