Inheritance: System.Net.WebClient
コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: IOConnection.cs プロジェクト: haro-freezd/KeePass
        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;
        }
コード例 #5
0
ファイル: IOConnection.cs プロジェクト: pythe/wristpass
        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;
        }
コード例 #6
0
		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;
		}
コード例 #7
0
ファイル: CheckForUpdate.cs プロジェクト: amiryal/keepass2
        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();
        }
コード例 #8
0
ファイル: IOConnection.cs プロジェクト: 77rusa/README
        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);
        }