/
NullXmlDecryptor.cs
35 lines (30 loc) · 1.1 KB
/
NullXmlDecryptor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Linq;
using System.Xml.Linq;
namespace Microsoft.AspNetCore.DataProtection.XmlEncryption;
/// <summary>
/// An <see cref="IXmlDecryptor"/> that decrypts XML elements with a null decryptor.
/// </summary>
public sealed class NullXmlDecryptor : IXmlDecryptor
{
/// <summary>
/// Decrypts the specified XML element.
/// </summary>
/// <param name="encryptedElement">An encrypted XML element.</param>
/// <returns>The decrypted form of <paramref name="encryptedElement"/>.</returns>
public XElement Decrypt(XElement encryptedElement)
{
if (encryptedElement == null)
{
throw new ArgumentNullException(nameof(encryptedElement));
}
// <unencryptedKey>
// <!-- This key is not encrypted. -->
// <plaintextElement />
// </unencryptedKey>
// Return a clone of the single child node.
return new XElement(encryptedElement.Elements().Single());
}
}