Beispiel #1
0
        protected override bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            //NOTE: We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.

            //Example #1
            //Spawn a Task to execute our callback and return true;
            //Typical usage would see you invoke onto the UI thread to open a username/password dialog
            //Then execute the callback with the response username/password
            //You can cast the IWebBrowser param to ChromiumWebBrowser to easily access
            //control, from there you can invoke onto the UI thread, should be in an async fashion
            //Load https://httpbin.org/basic-auth/cefsharp/passwd in the browser to test
            Task.Run(() =>
            {
                using (callback)
                {
                    if (originUrl.Contains("https://httpbin.org/basic-auth/"))
                    {
                        var parts    = originUrl.Split('/');
                        var username = parts[parts.Length - 2];
                        var password = parts[parts.Length - 1];
                        callback.Continue(username, password);
                    }
                }
            });

            return(true);

            //Example #2
            //Return false to cancel the request
            //callback.Dispose();
            //return false;
        }
Beispiel #2
0
        protected override bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            const string user  = "******";
            const string passw = "passwd";

            callback.Continue(user, passw);
            return(true);
        }
Beispiel #3
0
 bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
 {
     if (this.OwnerWebView.ProxyAuthentication != null)
     {
         callback.Continue(this.OwnerWebView.ProxyAuthentication.UserName, this.OwnerWebView.ProxyAuthentication.Password);
     }
     return(true);
 }
    bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
    {
        //NOTE: If you do not wish to implement this method returning false is the default behaviour
        // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.

        callback.Continue(userName, password);

        return(true);
    }
 bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
 {
     if (isProxy == true)
     {
         callback.Continue("Username", "Password");
         return(true);
     }
     return(false);
 }
 protected override bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
 {
     using (callback) {
         if (OwnerWebView.ProxyAuthentication != null)
         {
             callback.Continue(OwnerWebView.ProxyAuthentication.UserName, OwnerWebView.ProxyAuthentication.Password);
         }
     }
     return(true);
 }
Beispiel #7
0
        // public GuangLianBrowser _main;

        //public frm_prompt _prompt = new frm_prompt();

        public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            if (isProxy)
            {
                // _prompt._ShowDialog(host, port+"", realm);

                callback.Continue("ww", "ww");
            }
            return(true);
        }
Beispiel #8
0
    public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy,
                                   string host, int port,
                                   string realm, string scheme, IAuthCallback callback)
    {
        if (isProxy)
        {
            callback.Continue(_instanceProxy.Username, _instanceProxy.Password);
            return(true);
        }

        return(false);
    }
Beispiel #9
0
 bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
 {
     if (this.string_0.Equals(string.Empty))
     {
         callback.Cancel();
     }
     else
     {
         callback.Continue(this.string_0, this.string_1);
     }
     return(true);
 }
        public bool GetAuthCredentials(
            IWebBrowser browserControl,
            IBrowser browser,
            IFrame frame,
            bool isProxy,
            string host,
            int port,
            string realm,
            string scheme,
            IAuthCallback callback)
        {
            bool flag = false;

            if (this._authCounter > 10 && !isProxy)
            {
                browser.MainFrame.LoadStringForUrl(string.Format("<h1>Нет логина и пароля для авторизации этого хоста: {0}:{1} </h1><h3>Если это БК Tennisi, то необходимо сначала авторизоваться, прежде чем открывать вилки!</h3>", (object)host, (object)port), browser.MainFrame.Url);
                callback.Dispose();
                return(false);
            }
            if (this._authCounter > 10 & isProxy)
            {
                browser.MainFrame.LoadStringForUrl("<h1>Похоже что для прокси " + host + " неверно указаны логин/пароль или они не рабочие!", browser.MainFrame.Url);
                callback.Dispose();
                return(false);
            }
            foreach (AuthCredentialsHost authData in this._authDatas)
            {
                if (authData.Host == host)
                {
                    if (authData.TryCounter < 5)
                    {
                        ++authData.TryCounter;
                        callback.Continue(authData.Login, authData.Password);
                        flag = true;
                        break;
                    }
                    callback.Dispose();
                    browser.MainFrame.LoadStringForUrl("<h1>Похоже что для хоста " + host + " неверно указаны логин или пароль!", browser.MainFrame.Url);
                    return(false);
                }
            }
            if (!flag && this._handler != null)
            {
                flag = this._handler.GetAuthCredentials(browserControl, browser, frame, isProxy, host, port, realm, scheme, callback);
            }
            if (!callback.IsDisposed)
            {
                callback.Dispose();
            }
            ++this._authCounter;
            return(flag);
        }
Beispiel #11
0
 public override bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
 {
     if (isProxy == true)
     {
         if (_credential == null)
         {
             throw new NullReferenceException("credential is null");
         }
         callback.Continue(_credential.UserName, _credential.Password);
         return(true);
     }
     return(false);
 }
Beispiel #12
0
        protected override bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            if (isProxy)
            {
                callback.Continue(ApplicationSettings.Default.ProxyUser, ApplicationSettings.Default.ProxyPassword);

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            Task.Run(() =>
            {
                using (callback)
                {
                    if (broserSetting != null && broserSetting.Proxy != null && !string.IsNullOrEmpty(broserSetting.Proxy.UserName) && !string.IsNullOrEmpty(broserSetting.Proxy.Password))
                    {
                        callback.Continue(broserSetting.Proxy.UserName, broserSetting.Proxy.Password);
                        Log.Loging.Info(string.Format("{0}:{1}-{2}-{3} 应用代理密码:", host, port, realm, scheme));
                    }
                }
            });

            return(true);
        }
Beispiel #14
0
        public override bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame,
                                                bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            //NOTE: If you do not wish to implement this method returning false is the default behaviour
            // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.

            //callback.Dispose();
            if (isProxy)
            {
                callback.Continue(auth_user, auth_pass);

                return(true);
            }

            return(false);
        }
        protected override bool GetAuthCredentials(IWebBrowser webBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            if (isProxy)
            {
                foreach (var proxy in settings.Proxy.Proxies)
                {
                    if (proxy.RequiresAuthentication && host?.Equals(proxy.Host, StringComparison.OrdinalIgnoreCase) == true && port == proxy.Port)
                    {
                        callback.Continue(proxy.Username, proxy.Password);

                        return(true);
                    }
                }
            }

            return(base.GetAuthCredentials(webBrowser, browser, originUrl, isProxy, host, port, realm, scheme, callback));
        }
        public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            using (AuthenticationForm auth = new AuthenticationForm())
            {
                auth.TopMost = true; //this isn't always setting to top, need to check

                //use attempts counter to stop basic auth dialog popping up in continually incorrect un and pass entered.
                //test here: https://www.httpwatch.com/httpgallery/authentication/
                DialogResult dr = auth.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    callback.Continue(auth.UserName, auth.Password);
                    return(true);
                }
                else
                {
                    callback.Dispose();
                    return(false);
                }
            }
            //callback.Dispose();
            //return false;
        }
 public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
 {
     callback.Continue("", sessionId);
     return(true);
 }
        //http://cefsharp.github.io/api/51.0.0/html/M_CefSharp_IRequestHandler_GetAuthCredentials.htm
        //Return true to continue the request and call CefAuthCallback::Continue() when the authentication information is available. Return false to cancel the request.
        public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port,
                                       string realm, string scheme, IAuthCallback callback)
        {
            bool success = false;

            foreach (var preparedHttpAuth in PreparedHttpAuths)
            {
                if (preparedHttpAuth.ExpectedSchemaType == GetHttpAuth.SchemaTypes.Nope ||
                    (preparedHttpAuth.ExpectedSchemaType.ToString() == scheme))
                {
                    if (preparedHttpAuth.ExpectedHost.Value.Value == "" ||
                        (preparedHttpAuth.ExpectedHost.IsRegex.Value &&
                         Regex.IsMatch(host, preparedHttpAuth.ExpectedHost.Value.Value) ||
                         !preparedHttpAuth.ExpectedHost.IsRegex.Value &&
                         host == preparedHttpAuth.ExpectedHost.Value.Value))
                    {
                        if (preparedHttpAuth.ExpectedRealm.Value.Value == "" ||
                            (preparedHttpAuth.ExpectedRealm.IsRegex.Value &&
                             Regex.IsMatch(realm, preparedHttpAuth.ExpectedRealm.Value.Value) ||
                             !preparedHttpAuth.ExpectedRealm.IsRegex.Value &&
                             realm == preparedHttpAuth.ExpectedRealm.Value.Value))
                        {
                            if (preparedHttpAuth.ExpectedPort == null ||
                                (preparedHttpAuth.ExpectedPort == port))
                            {
                                if (callback.IsDisposed)
                                {
                                    break;
                                }
                                if (preparedHttpAuth.Cancel)
                                {
                                    callback.Cancel();
                                }
                                else
                                {
                                    callback.Continue(preparedHttpAuth.Username /*.ReadString()*/, preparedHttpAuth.Password /*.ReadString()*/);
                                }

                                HandledHttpAuths.Add(new HttpAuth()
                                {
                                    Host  = host,
                                    Port  = port,
                                    Realm = realm,
                                    SuccessfullyHandled = true,
                                    Scheme = scheme,
                                });
                                return(true);
                            }
                        }
                    }
                }
            }
            HandledHttpAuths.Add(new HttpAuth()
            {
                Host   = host,
                Port   = port,
                Realm  = realm,
                Scheme = scheme,
                SuccessfullyHandled = false,
            });
            return(false);
        }
Beispiel #19
0
        bool IRequestHandler.GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            callback.Continue(userName, password);

            return(true);
        }