Exemplo n.º 1
0
 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));
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 4
0
 private void View_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
 {
     sender.AddWebAllowedObject("TelegramWebviewProxy", new TelegramPaymentProxy((title, credentials) =>
     {
         Credentials = new SavedCredentials(credentials, title);
         Hide(ContentDialogResult.Primary);
     }));
 }
Exemplo n.º 5
0
        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());
    }
Exemplo n.º 7
0
    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);
        }
Exemplo n.º 9
0
    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);
        }
    }
Exemplo n.º 10
0
        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();
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
 public static void SaveCredentials(NetworkCredential credentials)
 {
     SavedCredentials.SaveCredentials(credentials.UserName, credentials.SecurePassword);
 }
Exemplo n.º 13
0
 public static void PropSetter(SavedCredentials sc) => SavedCredentials = sc;