private Creds LoadCredentials(SavedCredentials toLoad) { if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ArbBetSystem"))) { Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ArbBetSystem")); } if (File.Exists(credsFileName)) { string[] contents = Encoding.UTF8.GetString(CryptoUtils.Unprotect(FileUtils.FileToByteArray(credsFileName), additionalEntropy)).Split(Environment.NewLine.ToCharArray()); try { if (string.IsNullOrWhiteSpace(contents[(int)toLoad * 4]) || string.IsNullOrWhiteSpace(contents[((int)toLoad * 4) + 2])) { logger.Info("Credentials for " + toLoad + " contained an empty string"); return(SetCredentials(toLoad, false)); } return(new Creds(contents[(int)toLoad * 4], contents[((int)toLoad * 4) + 2])); } catch (IndexOutOfRangeException) { logger.Warn("Credentials file smaller than expected"); return(SetCredentials(toLoad, false)); } } else { logger.Info("No credentials file"); return(SetCredentials(toLoad, false)); } }
private async Task InitializeReceipt(Message message, long receiptMessageId) { IsReceipt = true; var paymentReceipt = await ProtoService.SendAsync(new GetPaymentReceipt(message.ChatId, receiptMessageId)) as PaymentReceipt; if (paymentReceipt == null) { return; } Message = message; Photo = paymentReceipt.Photo; Title = paymentReceipt.Title; Description = paymentReceipt.Description; Invoice = paymentReceipt.Invoice; Bot = CacheService.GetUser(paymentReceipt.SellerBotUserId); Credentials = new SavedCredentials(string.Empty, paymentReceipt.CredentialsTitle); Info = paymentReceipt.OrderInfo; Shipping = paymentReceipt.ShippingOption; TipAmount = paymentReceipt.TipAmount; }
private void SaveCredential(string credentialId) { SavedCredentials savedCredentials = new SavedCredentials { UserName = ConnectionItem.UserName, Password = ConnectionItem.Password }; CredentialManager.WriteCredentials(credentialId, savedCredentials, true); }
private void View_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args) { sender.AddWebAllowedObject("TelegramWebviewProxy", new TelegramPaymentProxy((title, credentials) => { Credentials = new SavedCredentials(credentials, title); Hide(ContentDialogResult.Primary); })); }
private async void OnPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var deferral = args.GetDeferral(); var validated = await ViewModel.ValidateAsync(); Credentials = validated; args.Cancel = validated == null; deferral.Complete(); }
public void ReadWrite() { string username; SecureString password; DeleteCredentials(); Assert.IsFalse(SavedCredentials.TryRetrieveSavedCredentials(out username, out password)); Assert.IsNull(username); Assert.IsNull(password); SavedCredentials.SaveCredentials("username", "password".ToSecureString()); Assert.IsTrue(SavedCredentials.TryRetrieveSavedCredentials(out username, out password)); Assert.AreEqual("username", username); Assert.AreEqual("password", password.ToOriginalString()); }
public void RetrieveSavedCredentials() { SecureString password; string username; if (SavedCredentials.TryRetrieveSavedCredentials(out username, out password)) { Credentials = new NetworkCredential(username, password); LogTo.Information("Using stored proxy credentials"); return; } LogTo.Information("No stored proxy credentials"); }
public string BuildConnectionString(CrmConnectionInfo crmConnectionInfo) { string credentialId = GetCredentialId(crmConnectionInfo); SavedCredentials credential = CredentialManager.ReadCredentials(credentialId); string connectionString = BuildConnectionString(crmConnectionInfo.OrganizationURL, crmConnectionInfo.AuthType, crmConnectionInfo.Domain, credential.UserName, credential.Password); return(connectionString); }
void OkClick(object sender, RoutedEventArgs e) { var credentials = new NetworkCredential(username.Text, password.Password); if (proxyTester.TestCredentials(credentials)) { credentialStore.Credentials = credentials; if (saveCredentials.IsChecked.GetValueOrDefault(false)) { SavedCredentials.SaveCredentials(username.Text, password.SecurePassword); } Close(); } else { MessageBox.Show(this, "The supplied username and password were not accepted by the proxy server", "Credentials failed", MessageBoxButton.OK, MessageBoxImage.Error); } }
public async Task SaveCredentials(string username, string password, string userId) { if (Application.Current.Properties.ContainsKey(CredentialsKey)) { return; } var credentials = new SavedCredentials { Username = username, Password = password, UserId = userId }; var asString = JsonConvert.SerializeObject(credentials); Application.Current.Properties.Add(CredentialsKey, asString); await Application.Current.SavePropertiesAsync(); }
private Creds SetCredentials(SavedCredentials toUpdate, bool canCancel = true) { Creds newCreds = InputCredentials(toUpdate.ToString(), canCancel); if (newCreds == null || newCreds.Username == null || newCreds.Password == null) { logger.Warn("Credentials contains a null value. Not set"); return(null); } switch (toUpdate) { case SavedCredentials.BetFair: bfApi.LoginDetails = newCreds; break; case SavedCredentials.DynamicOdds: dynOdds.LoginDetails = newCreds; break; } SaveCredentials(); return(newCreds); }
public static void SaveCredentials(NetworkCredential credentials) { SavedCredentials.SaveCredentials(credentials.UserName, credentials.SecurePassword); }
public static void PropSetter(SavedCredentials sc) => SavedCredentials = sc;