aspnetcore/src/Microsoft.AspNet.DataProtec.../XmlEncryption/EncryptedXmlDecryptor.core5...

44 lines
1.4 KiB
C#

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNXCORE50
// [[ISSUE60]] Remove this entire file when Core CLR gets support for EncryptedXml.
// This is just a dummy implementation of the class that always throws.
// The only reason it's here (albeit internal) is to provide a nice error message if key
// material that was generated by Desktop CLR needs to be read by Core CLR.
using System;
using System.Xml.Linq;
using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging;
namespace Microsoft.AspNet.DataProtection.XmlEncryption
{
internal sealed class EncryptedXmlDecryptor : IXmlDecryptor
{
private readonly ILogger _logger;
public EncryptedXmlDecryptor()
: this(services: null)
{
}
public EncryptedXmlDecryptor(IServiceProvider services)
{
_logger = services.GetLogger<EncryptedXmlDecryptor>();
}
public XElement Decrypt([NotNull] XElement encryptedElement)
{
if (_logger.IsErrorLevelEnabled())
{
_logger.LogError(Resources.EncryptedXmlDecryptor_DoesNotWorkOnCoreClr);
}
throw new PlatformNotSupportedException(Resources.EncryptedXmlDecryptor_DoesNotWorkOnCoreClr);
}
}
}
#endif