internal static IOWebClient CreateWebClient(IOConnectionInfo ioc) { PrepareWebAccess(); IOWebClient wc = new IOWebClient(); wc.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); if ((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) { wc.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); } return(wc); }
private static IOWebClient CreateWebClient(IOConnectionInfo ioc) { PrepareWebAccess(ioc); IOWebClient wc = new IOWebClient(ioc); if ((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) { wc.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); } else if (MonoWorkarounds.IsRequired(688007)) { wc.Credentials = new NetworkCredential("anonymous", string.Empty); } ConfigureWebClient(wc); return(wc); }
private static IOWebClient CreateWebClient(IOConnectionInfo ioc) { PrepareWebAccess(ioc); IOWebClient wc = new IOWebClient(ioc); ConfigureWebClient(wc); if ((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) { wc.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); } else if (NativeLib.IsUnix()) // Mono requires credentials { wc.Credentials = new NetworkCredential("anonymous", string.Empty); } return(wc); }
private static IOWebClient CreateWebClient(IOConnectionInfo ioc) { PrepareWebAccess(); IOWebClient wc = new IOWebClient(); ConfigureWebClient(wc); if((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) wc.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); else if(NativeLib.IsUnix()) // Mono requires credentials wc.Credentials = new NetworkCredential("anonymous", string.Empty); return wc; }
private static IOWebClient CreateWebClient(IOConnectionInfo ioc, bool digestAuth) { PrepareWebAccess(); IOWebClient wc = new IOWebClient(); ConfigureWebClient(wc); if ((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) { //set the credentials without a cache (in case the cache below fails: //check for backslash to determine whether we need to specify the domain: int backslashPos = ioc.UserName.IndexOf("\\", StringComparison.Ordinal); if (backslashPos > 0) { string domain = ioc.UserName.Substring(0, backslashPos); string user = ioc.UserName.Substring(backslashPos + 1); wc.Credentials = new NetworkCredential(user, ioc.Password, domain); } else { wc.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); } if (digestAuth) { //try to use the credential cache to access with Digest support: try { var credentialCache = new CredentialCache(); credentialCache.Add( new Uri(new Uri(ioc.Path).GetLeftPart(UriPartial.Authority)), "Digest", new NetworkCredential(ioc.UserName, ioc.Password) ); credentialCache.Add( new Uri(new Uri(ioc.Path).GetLeftPart(UriPartial.Authority)), "NTLM", new NetworkCredential(ioc.UserName, ioc.Password) ); wc.Credentials = credentialCache; } catch (NotImplementedException e) { Kp2aLog.Log(e.ToString()); } catch (Exception e) { Kp2aLog.Log(e.ToString()); Debug.Assert(false); } } } else if(NativeLib.IsUnix()) // Mono requires credentials wc.Credentials = new NetworkCredential("anonymous", string.Empty); return wc; }
internal static IOWebClient CreateWebClient(IOConnectionInfo ioc) { PrepareWebAccess(); IOWebClient wc = new IOWebClient(); wc.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); if((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) wc.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); return wc; }
private static void OnStartCheck() { // NativeProgressDialog dlg = null; // if(m_tsResultsViewer == null) // { // dlg = new NativeProgressDialog(); // dlg.StartLogging(KPRes.Wait + "...", false); // } try { IOWebClient webClient = new IOWebClient(); IOConnection.ConfigureWebClient(webClient); Uri uri = new Uri(m_strVersionURL); webClient.DownloadDataCompleted += new DownloadDataCompletedEventHandler(OnDownloadCompleted); webClient.DownloadDataAsync(uri); } // catch(NotImplementedException) // { // ReportStatusEx(KLRes.FrameworkNotImplExcp, true); // } catch(Exception) { } // if(dlg != null) dlg.EndLogging(); }
private static IOWebClient CreateWebClient(IOConnectionInfo ioc, bool digestAuth) { PrepareWebAccess(); IOWebClient wc = new IOWebClient(); ConfigureWebClient(wc); if ((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) { //set the credentials without a cache (in case the cache below fails: //check for backslash to determine whether we need to specify the domain: int backslashPos = ioc.UserName.IndexOf("\\", StringComparison.Ordinal); if (backslashPos > 0) { string domain = ioc.UserName.Substring(0, backslashPos); string user = ioc.UserName.Substring(backslashPos + 1); wc.Credentials = new NetworkCredential(user, ioc.Password, domain); } else { wc.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); } if (digestAuth) { //try to use the credential cache to access with Digest support: try { var credentialCache = new CredentialCache(); credentialCache.Add( new Uri(new Uri(ioc.Path).GetLeftPart(UriPartial.Authority)), "Digest", new NetworkCredential(ioc.UserName, ioc.Password) ); credentialCache.Add( new Uri(new Uri(ioc.Path).GetLeftPart(UriPartial.Authority)), "NTLM", new NetworkCredential(ioc.UserName, ioc.Password) ); wc.Credentials = credentialCache; } catch (NotImplementedException e) { Kp2aLog.Log(e.ToString()); } catch (Exception e) { Kp2aLog.LogUnexpectedError(e); Debug.Assert(false); } } } else if (NativeLib.IsUnix()) // Mono requires credentials { wc.Credentials = new NetworkCredential("anonymous", string.Empty); } return(wc); }