public Credentials prompt(Host bookmark, String username, String title, String reason, LoginOptions options) { View = ObjectFactory.GetInstance <ILoginView>(); var credentials = new Credentials().withSaved(options.keychain()).withUsername(username); InitEventHandlers(bookmark, credentials, options); View.Title = LocaleFactory.localizedString(title, "Credentials"); View.Message = LocaleFactory.localizedString(reason, "Credentials"); View.Username = username; View.SavePasswordState = options.keychain(); View.DiskIcon = Images.Get(options.icon()).Size(64); InitPrivateKeys(); Update(credentials, options); AsyncDelegate d = delegate { if (DialogResult.Cancel == View.ShowDialog(_browser.View)) { throw new LoginCanceledException(); } }; _browser.Invoke(d); return(credentials); }
public Credentials prompt(Host bookmark, string title, string reason, LoginOptions options) { Credentials credentials = new Credentials().withSaved(options.keychain()); AsyncDelegate d = delegate { View = ObjectFactory.GetInstance <IPasswordPromptView>(); View.Title = title; View.Reason = new StringAppender().append(reason).toString(); View.OkButtonText = LocaleFactory.localizedString("Continue", "Credentials"); View.IconView = Images.Get(options.icon()).Size(64); View.SavePasswordEnabled = options.keychain(); View.SavePasswordState = credentials.isSaved(); View.ValidateInput += ValidateInputEventHandler; if (DialogResult.Cancel == View.ShowDialog(_browser.View)) { throw new LoginCanceledException(); } credentials.setPassword(View.InputText); credentials.setSaved(View.SavePasswordState); }; _browser.Invoke(d); return(credentials); }
private void Update(Credentials credentials, LoginOptions options) { View.UsernameEnabled = options.user() && !credentials.isAnonymousLogin(); View.PasswordEnabled = options.password() && !credentials.isAnonymousLogin(); View.UsernameLabel = options.getUsernamePlaceholder() + ":"; View.PasswordLabel = options.getPasswordPlaceholder() + ":"; { View.SavePasswordEnabled = options.keychain() && !credentials.isAnonymousLogin(); View.SavePasswordState = credentials.isSaved(); } View.AnonymousEnabled = options.anonymous(); if (options.anonymous() && credentials.isAnonymousLogin()) { View.AnonymousState = true; } else { View.AnonymousState = false; } View.PrivateKeyFieldEnabled = options.publickey(); if (options.publickey() && credentials.isPublicKeyAuthentication()) { View.SelectedPrivateKey = credentials.getIdentity().getAbsolute(); } }