This repository has been archived by the owner on Oct 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
/
EncryptedXmlInfo.cs
56 lines (49 loc) · 2.04 KB
/
EncryptedXmlInfo.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Reflection;
using System.Xml.Linq;
namespace Microsoft.AspNetCore.DataProtection.XmlEncryption
{
/// <summary>
/// Wraps an <see cref="XElement"/> that contains a blob of encrypted XML
/// and information about the class which can be used to decrypt it.
/// </summary>
public sealed class EncryptedXmlInfo
{
/// <summary>
/// Creates an instance of an <see cref="EncryptedXmlInfo"/>.
/// </summary>
/// <param name="encryptedElement">A piece of encrypted XML.</param>
/// <param name="decryptorType">The class whose <see cref="IXmlDecryptor.Decrypt(XElement)"/>
/// method can be used to decrypt <paramref name="encryptedElement"/>.</param>
public EncryptedXmlInfo(XElement encryptedElement, Type decryptorType)
{
if (encryptedElement == null)
{
throw new ArgumentNullException(nameof(encryptedElement));
}
if (decryptorType == null)
{
throw new ArgumentNullException(nameof(decryptorType));
}
if (!typeof(IXmlDecryptor).IsAssignableFrom(decryptorType))
{
throw new ArgumentException(
Resources.FormatTypeExtensions_BadCast(decryptorType.FullName, typeof(IXmlDecryptor).FullName),
nameof(decryptorType));
}
EncryptedElement = encryptedElement;
DecryptorType = decryptorType;
}
/// <summary>
/// The class whose <see cref="IXmlDecryptor.Decrypt(XElement)"/> method can be used to
/// decrypt the value stored in <see cref="EncryptedElement"/>.
/// </summary>
public Type DecryptorType { get; }
/// <summary>
/// A piece of encrypted XML.
/// </summary>
public XElement EncryptedElement { get; }
}
}