// 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;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNet.DataProtection.XmlEncryption
{
///
/// Wraps an that contains a blob of encrypted XML
/// and information about the class which can be used to decrypt it.
///
public sealed class EncryptedXmlInfo
{
///
/// Creates an instance of an .
///
/// A piece of encrypted XML.
/// The class whose
/// method can be used to decrypt .
public EncryptedXmlInfo([NotNull] XElement encryptedElement, [NotNull] Type decryptorType)
{
if (!typeof(IXmlDecryptor).IsAssignableFrom(decryptorType))
{
throw new ArgumentException(
Resources.FormatTypeExtensions_BadCast(decryptorType.FullName, typeof(IXmlDecryptor).FullName),
nameof(decryptorType));
}
EncryptedElement = encryptedElement;
DecryptorType = decryptorType;
}
///
/// The class whose method can be used to
/// decrypt the value stored in .
///
public Type DecryptorType { get; }
///
/// A piece of encrypted XML.
///
public XElement EncryptedElement { get; }
}
}