private static void EnsureCallbackDisposal(IAuthCallback callbackToDispose) { if (callbackToDispose != null && !callbackToDispose.IsDisposed) { callbackToDispose.Dispose(); } }
public void Handle(IAuthCallback[] callbacks) { for (int i = 0; i < callbacks.Length; i++) { IAuthCallback c = callbacks[i]; if (c is FieldCallback) { FieldCallback fc = c as FieldCallback; if (_username == null) { fc.Value = _form[fc.Name]; } else { if (fc.Name == "username") { fc.Value = _username; } else if (fc.Name == "password") { fc.Value = _password; } } } } }
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; }
public GetAuthCredentialsEventArgs(IWebBrowser browserControl, IBrowser browser, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) : base(browserControl, browser) { IsProxy = isProxy; Host = host; Port = port; Realm = realm; Scheme = scheme; Callback = callback; ContinueAsync = false; // default }
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); }
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); }
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 void Handle(IAuthCallback[] callbacks) { for (int i = 0; i < callbacks.Length; i++) { IAuthCallback c = callbacks[i]; if (c is FieldCallback) { FieldCallback fc = c as FieldCallback; if (_username == null) fc.Value = _form[fc.Name]; else { if (fc.Name == "username") fc.Value = _username; else if (fc.Name == "password") fc.Value = _password; } } } }
/// <inheritdoc/> public void Handle(IAuthCallback[] callbacks) { foreach (var callback in callbacks) { var field = callback as FieldCallback; if (field == null) { throw new NotSupportedException(); } switch (field.Name) { case kLoginFieldName: field.Value = login_; break; case kPasswordFieldName: field.Value = password_; break; default: throw new NotSupportedException(); } } }
public void Handle(IAuthCallback[] callback) { }
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); }
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); }
public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return(false); }
/// <inheritdoc/> /// <remarks> /// Throws an <see cref="NotSupportedException"/>. /// </remarks> public void Handle(IAuthCallback[] callback) { throw new NotSupportedException(); }
public void Handle(IAuthCallback[] callback) { handler_(callback); }
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); }
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)); }
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); }
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; }
public new bool GetAuthCredentials(IWebBrowser webBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return(base.GetAuthCredentials(webBrowser, browser, originUrl, isProxy, host, port, realm, scheme, callback)); }
public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, CefSharp.IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return(true); // TODO: We got 2 old ones.. true AND false.. O.o }
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 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); }
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); }
public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return(GetAuthCredentials(browserControl, browser, frame, 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) { //throw new NotImplementedException(); return(false); }
/// <inheritdoc/> bool IRequestHandler.GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return(GetAuthCredentials(chromiumWebBrowser, browser, originUrl, isProxy, host, port, realm, scheme, callback)); }
protected override bool GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return(logic.GetAuthCredentials(callback)); }
bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { 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; }
bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { var args = new GetAuthCredentialsEventArgs(browserControl, browser, frame, isProxy, host, port, realm, scheme, callback); GetAuthCredentialsEvent?.Invoke(this, args); EnsureCallbackDisposal(callback); return(args.ContinueAsync); }
bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return(false); }
bool IUrlRequestClient.GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return(true); }
protected override bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { var args = new GetAuthCredentialsEventArgs(chromiumWebBrowser, browser, originUrl, isProxy, host, port, realm, scheme, callback); GetAuthCredentialsEvent?.Invoke(this, args); EnsureCallbackDisposal(callback); return(args.ContinueAsync); }
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) { using (callback) { if (OwnerWebView.ProxyAuthentication != null) { callback.Continue(OwnerWebView.ProxyAuthentication.UserName, OwnerWebView.ProxyAuthentication.Password); } } return(true); }
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 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); }