Remove experimental .Azure project

This commit is contained in:
Levi B 2015-03-17 10:45:21 -07:00
parent d673df7ef3
commit 94233e76ff
6 changed files with 1 additions and 240 deletions

View File

@ -1,14 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22609.0
VisualStudioVersion = 14.0.22710.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5FCB2DA3-5395-47F5-BCEE-E0EA319448EA}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.DataProtection", "src\Microsoft.AspNet.DataProtection\Microsoft.AspNet.DataProtection.xproj", "{1E570CD4-6F12-44F4-961E-005EE2002BC2}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.DataProtection.Azure", "src\Microsoft.AspNet.DataProtection.Azure\Microsoft.AspNet.DataProtection.Azure.xproj", "{DF3671D7-A9B1-45F1-A195-0AD596001735}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{60336AB3-948D-4D15-A5FB-F32A2B91E814}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.DataProtection.Test", "test\Microsoft.AspNet.DataProtection.Test\Microsoft.AspNet.DataProtection.Test.xproj", "{7A637185-2BA1-437D-9D4C-7CC4F94CF7BF}"
@ -45,12 +43,6 @@ Global
{1E570CD4-6F12-44F4-961E-005EE2002BC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E570CD4-6F12-44F4-961E-005EE2002BC2}.Release|Any CPU.Build.0 = Release|Any CPU
{1E570CD4-6F12-44F4-961E-005EE2002BC2}.Release|x86.ActiveCfg = Release|Any CPU
{DF3671D7-A9B1-45F1-A195-0AD596001735}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF3671D7-A9B1-45F1-A195-0AD596001735}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF3671D7-A9B1-45F1-A195-0AD596001735}.Debug|x86.ActiveCfg = Debug|Any CPU
{DF3671D7-A9B1-45F1-A195-0AD596001735}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF3671D7-A9B1-45F1-A195-0AD596001735}.Release|Any CPU.Build.0 = Release|Any CPU
{DF3671D7-A9B1-45F1-A195-0AD596001735}.Release|x86.ActiveCfg = Release|Any CPU
{7A637185-2BA1-437D-9D4C-7CC4F94CF7BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A637185-2BA1-437D-9D4C-7CC4F94CF7BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A637185-2BA1-437D-9D4C-7CC4F94CF7BF}.Debug|x86.ActiveCfg = Debug|Any CPU
@ -135,7 +127,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1E570CD4-6F12-44F4-961E-005EE2002BC2} = {5FCB2DA3-5395-47F5-BCEE-E0EA319448EA}
{DF3671D7-A9B1-45F1-A195-0AD596001735} = {5FCB2DA3-5395-47F5-BCEE-E0EA319448EA}
{7A637185-2BA1-437D-9D4C-7CC4F94CF7BF} = {60336AB3-948D-4D15-A5FB-F32A2B91E814}
{E2779976-A28C-4365-A4BB-4AD854FAF23E} = {5FCB2DA3-5395-47F5-BCEE-E0EA319448EA}
{421F0383-34B1-402D-807B-A94542513ABA} = {5FCB2DA3-5395-47F5-BCEE-E0EA319448EA}

View File

@ -1,143 +0,0 @@
// 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.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.ExceptionServices;
using System.Xml.Linq;
using Microsoft.AspNet.DataProtection.Repositories;
using Microsoft.Framework.Internal;
using Microsoft.Framework.OptionsModel;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
namespace Microsoft.AspNet.DataProtection.Azure
{
/// <summary>
/// An XML repository backed by Azure blob storage.
/// </summary>
public class BlobStorageXmlRepository : IXmlRepository
{
private const int MAX_NUM_UPDATE_ATTEMPTS = 10;
internal static readonly XNamespace XmlNamespace = XNamespace.Get("http://www.asp.net/dataProtection/2014/azure");
internal static readonly XName KeyRingElementName = XmlNamespace.GetName("keyRing");
public BlobStorageXmlRepository([NotNull] IOptions<BlobStorageXmlRepositoryOptions> optionsAccessor)
{
Directory = optionsAccessor.Options.Directory;
CryptoUtil.Assert(Directory != null, "Directory != null");
}
protected CloudBlobDirectory Directory
{
get;
private set;
}
// IXmlRepository objects are supposed to be thread-safe, but CloudBlockBlob
// instances do not meet this criterion. We'll create them on-demand so that each
// thread can have its own instance that doesn't impact others.
private CloudBlockBlob GetKeyRingBlockBlobReference()
{
return Directory.GetBlockBlobReference("keyring.xml");
}
public virtual IReadOnlyCollection<XElement> GetAllElements()
{
var blobRef = GetKeyRingBlockBlobReference();
XDocument document = ReadDocumentFromStorage(blobRef);
return (IReadOnlyCollection<XElement>)document?.Root.Elements().ToList().AsReadOnly() ?? new XElement[0];
}
private XDocument ReadDocumentFromStorage(CloudBlockBlob blobRef)
{
// Try downloading from Azure storage
using (var memoryStream = new MemoryStream())
{
try
{
blobRef.DownloadToStream(memoryStream);
}
catch (StorageException ex) when (ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
{
// 404s are not a fatal error - empty keyring
return null;
}
// Rewind the memory stream and read it into an XDocument
memoryStream.Position = 0;
XDocument document = XDocument.Load(memoryStream);
// Format checks
CryptoUtil.Assert(document.Root.Name == KeyRingElementName, "TODO: Unknown element.");
CryptoUtil.Assert((int)document.Root.Attribute("version") == 1, "TODO: Unknown version.");
return document;
}
}
public virtual void StoreElement([NotNull] XElement element, string friendlyName)
{
ExceptionDispatchInfo lastException = null;
// To perform a transactional update of keyring.xml, we first need to get
// the original contents of the blob.
var blobRef = GetKeyRingBlockBlobReference();
for (int i = 0; i < MAX_NUM_UPDATE_ATTEMPTS; i++)
{
AccessCondition updateAccessCondition;
XDocument document = ReadDocumentFromStorage(blobRef);
// Inject the new element into the existing <keyRing> root.
if (document != null)
{
document.Root.Add(element);
// only update if the contents haven't changed (prevents overwrite)
updateAccessCondition = AccessCondition.GenerateIfMatchCondition(blobRef.Properties.ETag);
}
else
{
document = new XDocument(
new XElement(KeyRingElementName,
new XAttribute("version", 1),
element));
// only update if the file doesn't exist (prevents overwrite)
updateAccessCondition = AccessCondition.GenerateIfNoneMatchCondition("*");
}
// Write the updated document back out
MemoryStream memoryStream = new MemoryStream();
document.Save(memoryStream);
try
{
blobRef.UploadFromByteArray(memoryStream.GetBuffer(), 0, checked((int)memoryStream.Length), accessCondition: updateAccessCondition);
return; // success!
}
catch (StorageException ex)
{
switch ((HttpStatusCode)ex.RequestInformation.HttpStatusCode)
{
// If we couldn't update the blob due to a conflict on the server, try again.
case HttpStatusCode.Conflict:
case HttpStatusCode.PreconditionFailed:
lastException = ExceptionDispatchInfo.Capture(ex);
continue;
default:
throw;
}
}
}
// If we got this far, too many conflicts occurred while trying to update the blob.
// Just bail.
lastException.Throw();
}
}
}

View File

@ -1,19 +0,0 @@
// 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.
using System;
using Microsoft.WindowsAzure.Storage.Blob;
namespace Microsoft.AspNet.DataProtection.Azure
{
/// <summary>
/// Specifies options for configuring an Azure blob storage-based repository.
/// </summary>
public class BlobStorageXmlRepositoryOptions
{
/// <summary>
/// The blob storage directory where the key ring will be stored.
/// </summary>
public CloudBlobDirectory Directory { get; set; }
}
}

View File

@ -1,35 +0,0 @@
// 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.
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
namespace Microsoft.AspNet.DataProtection
{
internal static class CryptoUtil
{
// This isn't a typical Debug.Assert; the check is always performed, even in retail builds.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Assert(bool condition, string message)
{
if (!condition)
{
Fail(message);
}
}
// This isn't a typical Debug.Fail; an error always occurs, even in retail builds.
// This method doesn't return, but since the CLR doesn't allow specifying a 'never'
// return type, we mimic it by specifying our return type as Exception. That way
// callers can write 'throw Fail(...);' to make the C# compiler happy, as the
// throw keyword is implicitly of type O.
[MethodImpl(MethodImplOptions.NoInlining)]
public static Exception Fail(string message)
{
Debug.Fail(message);
throw new CryptographicException("Assertion failed: " + message);
}
}
}

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>DF3671D7-A9B1-45F1-A195-0AD596001735</ProjectGuid>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@ -1,16 +0,0 @@
{
"version": "1.0.0-*",
"description": "ASP.NET 5 blob storage repository for DataProtection.",
"dependencies": {
"Microsoft.AspNet.DataProtection": "1.0.0-*",
"Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" },
"WindowsAzure.Storage": "4.3.0"
},
"frameworks": {
"net451": {},
"dnx451": {}
},
"compilationOptions": {
"warningsAsErrors": true
}
}