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);
        }
 private static void EnsureCallbackDisposal(IAuthCallback callbackToDispose)
 {
     if (callbackToDispose != null && !callbackToDispose.IsDisposed)
     {
         callbackToDispose.Dispose();
     }
 }
Beispiel #3
0
        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.Dispose();
            return(false);
        }
Beispiel #4
0
        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.Dispose();
            return false;
        }
        protected override bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, 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();
            return(false);
        }
Beispiel #6
0
 public bool GetAuthCredentials(IWebBrowser browserControl,
                                IBrowser browser,
                                IFrame frame,
                                bool isProxy,
                                string host,
                                int port,
                                string realm,
                                string scheme,
                                IAuthCallback callback)
 {
     callback.Dispose();
     return(false);
 }
        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.Dispose();
     return(false);
 }
 public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
 {
     callback.Dispose();
     return false;
 }
Beispiel #10
0
 bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
 {
     callback.Dispose();
     return false;
 }
Beispiel #11
0
 /// <summary>
 /// Called when the browser needs credentials from the user.
 /// </summary>
 /// <param name="chromiumWebBrowser">The ChromiumWebBrowser control</param>
 /// <param name="browser">the browser object</param>
 /// <param name="frame">The frame object that needs credentials (This will contain the URL that is being requested.)</param>
 /// <param name="isProxy">indicates whether the host is a proxy server</param>
 /// <param name="host">hostname</param>
 /// <param name="port">port number</param>
 /// <param name="realm">realm</param>
 /// <param name="scheme">scheme</param>
 /// <param name="callback">Callback interface used for asynchronous continuation of authentication requests.</param>
 /// <returns>Return true to continue the request and call CefAuthCallback::Continue() when the authentication information is available. Return false to cancel the request. </returns>
 protected virtual bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, bool isProxy, string host,
                                           int port, string realm, string scheme, IAuthCallback callback)
 {
     callback.Dispose();
     return(false);
 }