コード例 #1
0
        public void DecryptXmlAsyncThrowsWhenCryptoIsNull()
        {
            var xml           = "<foo bar=\"MTIz\"><baz>NDU2</baz><baz>Nzg5</baz><qux>PGdhcnBseSBncmF1bHQ9ImFiYyIgLz4=</qux></foo>";
            var keyIdentifier = new object();

            ICrypto crypto = null;

            Assert.That(async() => await crypto.DecryptXmlAsync(xml, new[] { "/foo/@bar", "/foo/baz", "/foo/qux" }, keyIdentifier), Throws.ArgumentNullException);
        }
コード例 #2
0
 /// <summary>
 /// Asynchronously decrypts the fields, specified by XPath, that are contained in the given xml 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="xmlString">A string containing an xml document.</param>
 /// <param name="xpathToDecrypt">The XPath 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 xml document, except with the specified fields decrypted.</returns>
 public static Task <string> DecryptXmlAsync(this ICrypto crypto, string xmlString, string xpathToDecrypt, string credentialName = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 crypto.DecryptXmlAsync(xmlString, new[] { xpathToDecrypt }, credentialName, cancellationToken);