Пример #1
0
        public void DecryptJsonAsyncThrowsWhenCryptoIsNull()
        {
            var json          = "{\"foo\":\"ImFiYyI=\",\"bar\":\"MTIz\",\"baz\":\"dHJ1ZQ==\",\"qux\":\"WzEsMiwzXQ==\",\"garply\":\"eyJncmF1bHQiOiJ4eXoifQ==\",\"fred\":\"bnVsbA==\"}";
            var keyIdentifier = new object();

            ICrypto crypto = null;

            Assert.That(async() => await crypto.DecryptJsonAsync(json, new[] { "$.foo", "$.bar", "$.baz", "$.qux", "$.garply", "$.fred" }, keyIdentifier), Throws.ArgumentNullException);
        }
Пример #2
0
 /// <summary>
 /// Asynchronously decrypts the fields, specified by JSONPath, that are contained in the given json document string.
 /// </summary>
 /// <param name="crypto">
 /// The instance of <see cref="ICrypto"/> that ultimately responsible for performing decryption operations
 /// on field values.
 /// </param>
 /// <param name="jsonString">A string containing an json document.</param>
 /// <param name="jsonPathToDecrypt">The JSONPath of the field to decrypt.</param>
 /// <param name="credentialName">
 /// The name of the credential to use for this encryption operation,
 /// or null to use the default credential.
 /// </param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task that will contain the same json document, except with the specified fields decrypted.</returns>
 public static Task <string> DecryptJsonAsync(this ICrypto crypto, string jsonString, string jsonPathToDecrypt, string credentialName = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 crypto.DecryptJsonAsync(jsonString, new[] { jsonPathToDecrypt }, credentialName, cancellationToken);