public void StoredCredential_ReceiptIn_OTB() { RecurringPaymentMethod storedCard = new RecurringPaymentMethod("03e28f0e-492e-80bd-20ec318e9334", "3c4af936-483e-a393-f558bec2fb2a"); StoredCredential storedCredential = new StoredCredential { Type = StoredCredentialType.Recurring, Initiator = StoredCredentialInitiator.Merchant, Sequence = StoredCredentialSequence.Subsequent }; Transaction response = storedCard.Verify() .WithAllowDuplicates(true) .WithStoredCredential(storedCredential) .Execute(); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); Assert.IsNotNull(response.SchemeId); }
public async Task <JsonResult> MakeAssertion([FromBody] AuthenticatorAssertionRawResponse clientResponse) { try { // 1. Get the assertion options we sent the client var jsonOptions = HttpContext.Session.GetString("fido2.assertionOptions"); var options = AssertionOptions.FromJson(jsonOptions); // 2. Get registered credential from database StoredCredential creds = DemoStorage.GetCredentialById(clientResponse.Id); // 3. Get credential counter from database var storedCounter = creds.SignatureCounter; // 4. Create callback to check if userhandle owns the credentialId IsUserHandleOwnerOfCredentialIdAsync callback = async(args) => { List <StoredCredential> storedCreds = await DemoStorage.GetCredentialsByUserHandleAsync(args.UserHandle); return(storedCreds.Exists(c => c.Descriptor.Id.SequenceEqual(args.CredentialId))); }; // 5. Make the assertion var res = await _lib.MakeAssertionAsync(clientResponse, options, creds.PublicKey, storedCounter, callback); // 6. Store the updated counter DemoStorage.UpdateCounter(res.CredentialId, res.Counter); // 7. return OK to client return(Json(res)); } catch (Exception e) { return(Json(new AssertionVerificationResult { Status = "error", ErrorMessage = FormatException(e) })); } }
public async Task TestStoreCredential() { string testSecret = "This is a secret"; var test = new StoredCredential { ProviderType = "DNS01.API.Route53", Title = "A test credential", StorageKey = Guid.NewGuid().ToString(), Secret = testSecret }; var credentialsManager = new CredentialsManager(); var result = await credentialsManager.UpdateCredential(test); Assert.IsTrue(result, "Credential stored OK"); List <StoredCredential> list = await credentialsManager.GetStoredCredentials(); Assert.IsTrue(list.Any(l => l.StorageKey == test.StorageKey), "Credential retreived"); var secret = await credentialsManager.GetUnlockedCredential(test.StorageKey); Assert.IsTrue(secret == testSecret, "Credential decrypted"); }
public AuthorizationBuilder WithStoredCredential(StoredCredential value) { StoredCredential = value; return(this); }
public Secure3dBuilder WithStoredCredential(StoredCredential storedCredential) { StoredCredential = storedCredential; return(this); }
public async Task <StoredCredential> UpdateCredentials(StoredCredential credential) { var result = await PostAsync("credentials", credential); return(JsonConvert.DeserializeObject <StoredCredential>(await result.Content.ReadAsStringAsync())); }
public async Task <StoredCredential> UpdateCredentials(StoredCredential credential) { DebugLog(); return(await credentialsManager.UpdateCredential(credential)); }
private async Task UpdateCounter(IUser user, StoredCredential credential, uint resultCounter) { credential.SignatureCounter = resultCounter; user.Profile["PasswordlessPublicKey"] = JsonConvert.SerializeObject(credential); await oktaClient.Users.UpdateUserAsync(user, user.Id, false); }
private async void Save_Click(object sender, System.Windows.RoutedEventArgs e) { StoredCredential credential; Dictionary <String, string> credentialsToStore = new Dictionary <string, string>(); if (String.IsNullOrEmpty(EditViewModel.Item.Title)) { MessageBox.Show("Stored credentials require a name."); return; } if (!EditViewModel.CredentialSet.Any()) { MessageBox.Show("No credentials selected."); return; } foreach (var c in this.EditViewModel.CredentialSet) { //store entered value if (c.IsRequired && String.IsNullOrEmpty(c.Value)) { MessageBox.Show($"{c.Name} is a required value"); return; } if (!String.IsNullOrEmpty(c.Value)) { credentialsToStore.Add(c.Key, c.Value); } } var item = EditViewModel.Item; if (item.StorageKey != null) { // edit existing credential = new StoredCredential { StorageKey = item.StorageKey, ProviderType = item.ProviderType, Secret = Newtonsoft.Json.JsonConvert.SerializeObject(credentialsToStore), Title = item.Title }; } else { //create new credential = new Models.Config.StoredCredential { Title = item.Title, ProviderType = item.ProviderType, StorageKey = Guid.NewGuid().ToString(), DateCreated = DateTime.Now, Secret = Newtonsoft.Json.JsonConvert.SerializeObject(credentialsToStore) }; } this.EditViewModel.Item = await MainViewModel.UpdateCredential(credential); this.Close(); }
public async Task AddCredential(UserProfileModel user, StoredCredential credential) { credential.UserId = BitConverter.GetBytes(user.Id); _db.FIDOCredentials.Add(new FIDOCredential(credential)); await _db.SaveChangesAsync(); }
public FIDOCredential(StoredCredential credential) { this.Copy(credential); }