private void PromptForAuthToken(OfxDownloadData ofxData, OfxSignOnInfo info, OfxErrorCode code) { ofxData.OnlineAccount.AuthToken = null; ofxData.OnlineAccount.AccessKey = null; AuthTokenDialog dialog = new AuthTokenDialog(info, code); dialog.Owner = Application.Current.MainWindow; if (dialog.ShowDialog() == true) { ofxData.OnlineAccount.AuthToken = dialog.AuthorizationToken; } }
public AuthTokenDialog(OfxSignOnInfo info, OfxErrorCode code) { this.PasswordPrompt = null; this.Title = "Authentication Token Required"; string label = info.AuthTokenLabel; if (string.IsNullOrEmpty(info.AuthTokenLabel)) { label = "Authentication token"; } this.AddUserDefinedField(customFieldId, info.AuthTokenLabel); string url = info.AuthTokenInfoUrl; // add instructions pointing to AuthTokenInfoUrl RichTextBox box = this.IntroMessagePrompt; box.Document.Blocks.Clear(); if (code == OfxErrorCode.AUTHTOKENInvalid) { this.ShowError("Your authentication token is invalid"); } Paragraph p = new Paragraph(); p.Inlines.Add(new Run("An authentication token is intended to be used in conjunction with your user name and password " + "to help your financial institution ensure that your account information is not being accessed by an unauthorized user.")); box.Document.Blocks.Add(p); p = new Paragraph(); p.Inlines.Add(new Run("Please ")); if (!string.IsNullOrEmpty(url)) { p.Inlines.Add(InternetExplorer.GetOpenFileHyperlink("click on this link", info.AuthTokenInfoUrl)); p.Inlines.Add(new Run(" for instructions on how get a new authentication token.")); } else { p.Inlines.Add(new Run("Please call your bank for instructions on how to get a new authentication token.")); } box.Document.Blocks.Add(p); box.Visibility = System.Windows.Visibility.Visible; }
public OfxLoginDialog(OfxSignOnInfo info, OnlineAccount account, List <Block> prompt, OfxErrorCode code, string error) { this.account = account; this.UserNamePrompt = "User Name"; this.UserName = this.account.UserId; // provide what we know already... this.UserName = this.account.UserId; this.PasswordConfirmation = this.account.Password; RichTextBox intro = this.IntroMessagePrompt; intro.Visibility = System.Windows.Visibility.Visible; intro.Document.Blocks.Clear(); if (error != null) { this.ShowError(error); } else if (code == OfxErrorCode.SignonInvalid) { this.ShowError("Your sign on is invalid"); } if (prompt == null) { prompt = new List <Block>(); } if (prompt.Count == 0) { Paragraph instructions = new Paragraph(); prompt.Add(instructions); instructions.Inlines.Add(new Run("Please enter your online banking credentials for ")); instructions.Inlines.Add(new Run(this.account.Name) { FontWeight = FontWeights.Bold }); instructions.Inlines.Add(new Run(".")); } // try and gain the user's trust... Uri url = new Uri(this.account.Ofx); Paragraph trust = new Paragraph(); prompt.Add(trust); trust.Inlines.Add(new Run("These credentials will be sent securely using HTTPS to the OFX server at ")); trust.Inlines.Add(new Run(url.Host) { FontWeight = FontWeights.Bold }); trust.Inlines.Add(new Run(". Click cancel if you are not sure that this is the right address.")); foreach (Block b in prompt) { intro.Document.Blocks.Add(b); } if (info != null && !string.IsNullOrWhiteSpace(info.UserCredentialLabel1)) { this.AddUserDefinedField("UserCred1", info.UserCredentialLabel1); this.SetUserDefinedField("UserCred1", this.account.UserCred1); } if (info != null && !string.IsNullOrWhiteSpace(info.UserCredentialLabel2)) { this.AddUserDefinedField("UserCred2", info.UserCredentialLabel2); this.SetUserDefinedField("UserCred2", this.account.UserCred2); } this.OkClicked += new EventHandler <OkEventArgs>((s, e) => { this.account.UserId = this.UserName; this.account.Password = this.PasswordConfirmation; if (info != null && !string.IsNullOrWhiteSpace(info.UserCredentialLabel1)) { this.account.UserCred1 = this.GetUserDefinedField("UserCred1"); } if (info != null && !string.IsNullOrWhiteSpace(info.UserCredentialLabel2)) { this.account.UserCred2 = this.GetUserDefinedField("UserCred2"); } }); }
public ChangePasswordDialog(OfxSignOnInfo info, OnlineAccount account, MyMoney money) { this.account = account; this.money = money; this.UserNamePrompt = "User Name"; this.UserName = account.UserId; this.Title = "Change Password"; RichTextBox intro = this.IntroMessagePrompt; intro.Visibility = System.Windows.Visibility.Visible; intro.Document.Blocks.Clear(); Paragraph p = new Paragraph(); intro.Document.Blocks.Add(p); this.AddUserDefinedField(newPasswordFieldId, "New Password"); this.AddUserDefinedField(confirmPasswordFieldId, "Confirm New Password"); p.Inlines.Add(new Run(account.Name + " is requesting that you enter a new password.")); OkClicked += new EventHandler <OkEventArgs>((s, e) => { string newpswd = this.GetUserDefinedField("NewPassword"); string newpswdconfirm = this.GetUserDefinedField("ConfirmNewPassword"); if (newpswd != newpswdconfirm) { e.Cancel = true; e.Error = "New passwords do not match"; return; } if (info != null && newpswd.Length < info.MinimumLength) { e.Cancel = true; e.Error = "New password must be at least " + info.MinimumLength + " characters"; return; } if (info != null && info.MaximumLength != 0 && newpswd.Length > info.MaximumLength) { e.Cancel = true; e.Error = "New password cannot be more than " + info.MaximumLength + " characters"; return; } // capture value so thread can use it. newPassword = this.NewPassword; account.UserId = this.UserName; account.Password = this.PasswordConfirmation; ThreadPool.QueueUserWorkItem(new WaitCallback(ChangePassword)); e.Error = "Sending new password information to " + account.Name + ".\nPlease do NOT close this dialog until we get a response."; e.Cancel = true; // stop user from hitting OK again and stop user from trying to cancel, // cancel is problematic because we won't know if the server // received the password change or not! DisableButtons(); }); }