--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-12-10 17:37:16 -08:00
16 changed files with 227 additions and 140 deletions

View File

@@ -1,6 +1,9 @@
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="AzureSDK" value="C:\Program Files\Windows Azure SDK\v1.3\"/>
<add key="AzureSDK" value="C:\Program Files\Windows Azure SDK\v1.2\"/>
</appSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

View File

@@ -1,6 +1,8 @@
using System.Configuration;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using NUnit.Framework;
@@ -35,7 +37,11 @@ namespace Orchard.Azure.Tests {
_dsService.Close();
}
protected void DeleteAllBlobs(CloudBlobContainer container) {
protected void DeleteAllBlobs(string containerName, CloudStorageAccount account)
{
var blobClient = account.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);
foreach ( var blob in container.ListBlobs() ) {
if ( blob is CloudBlob ) {
( (CloudBlob)blob ).DeleteIfExists();

View File

@@ -8,36 +8,35 @@ namespace Orchard.Azure.Tests.Environment.Configuration {
[TestFixture]
public class AzureShellSettingsManagerTests : AzureVirtualEnvironmentTest {
protected IShellSettingsManager Loader;
protected CloudStorageAccount DevAccount;
protected IShellSettingsManager ShellSettingsManager;
protected override void OnInit() {
CloudStorageAccount devAccount;
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out devAccount);
Loader = new AzureShellSettingsManager(devAccount, new Moq.Mock<IShellSettingsManagerEventHandler>().Object);
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out DevAccount);
ShellSettingsManager = new AzureShellSettingsManager(DevAccount, new Moq.Mock<IShellSettingsManagerEventHandler>().Object);
}
[SetUp]
public void Setup() {
// ensure default container is empty before running any test
DeleteAllBlobs( ((AzureShellSettingsManager)Loader).Container);
DeleteAllBlobs(AzureShellSettingsManager.ContainerName, DevAccount);
}
[TearDown]
public void TearDown() {
// ensure default container is empty after running tests
DeleteAllBlobs(( (AzureShellSettingsManager)Loader ).Container);
DeleteAllBlobs(AzureShellSettingsManager.ContainerName, DevAccount);
}
[Test]
public void SingleSettingsFileShouldComeBackAsExpected() {
Loader.SaveSettings(new ShellSettings { Name = "Default", DataProvider = "SQLite", DataConnectionString = "something else" });
ShellSettingsManager.SaveSettings(new ShellSettings { Name = "Default", DataProvider = "SQLCe", DataConnectionString = "something else" });
var settings = Loader.LoadSettings().Single();
var settings = ShellSettingsManager.LoadSettings().Single();
Assert.That(settings, Is.Not.Null);
Assert.That(settings.Name, Is.EqualTo("Default"));
Assert.That(settings.DataProvider, Is.EqualTo("SQLite"));
Assert.That(settings.DataProvider, Is.EqualTo("SQLCe"));
Assert.That(settings.DataConnectionString, Is.EqualTo("something else"));
}
@@ -45,37 +44,37 @@ namespace Orchard.Azure.Tests.Environment.Configuration {
[Test]
public void MultipleFilesCanBeDetected() {
Loader.SaveSettings(new ShellSettings { Name = "Default", DataProvider = "SQLite", DataConnectionString = "something else" });
Loader.SaveSettings(new ShellSettings { Name = "Another", DataProvider = "SQLite2", DataConnectionString = "something else2" });
ShellSettingsManager.SaveSettings(new ShellSettings { Name = "Default", DataProvider = "SQLCe", DataConnectionString = "something else" });
ShellSettingsManager.SaveSettings(new ShellSettings { Name = "Another", DataProvider = "SQLCe2", DataConnectionString = "something else2" });
var settings = Loader.LoadSettings();
var settings = ShellSettingsManager.LoadSettings();
Assert.That(settings.Count(), Is.EqualTo(2));
var def = settings.Single(x => x.Name == "Default");
Assert.That(def.Name, Is.EqualTo("Default"));
Assert.That(def.DataProvider, Is.EqualTo("SQLite"));
Assert.That(def.DataProvider, Is.EqualTo("SQLCe"));
Assert.That(def.DataConnectionString, Is.EqualTo("something else"));
var alt = settings.Single(x => x.Name == "Another");
Assert.That(alt.Name, Is.EqualTo("Another"));
Assert.That(alt.DataProvider, Is.EqualTo("SQLite2"));
Assert.That(alt.DataProvider, Is.EqualTo("SQLCe2"));
Assert.That(alt.DataConnectionString, Is.EqualTo("something else2"));
}
[Test]
public void NewSettingsCanBeStored() {
Loader.SaveSettings(new ShellSettings { Name = "Default", DataProvider = "SQLite", DataConnectionString = "something else" });
ShellSettingsManager.SaveSettings(new ShellSettings { Name = "Default", DataProvider = "SQLite", DataConnectionString = "something else" });
var foo = new ShellSettings { Name = "Foo", DataProvider = "Bar", DataConnectionString = "Quux" };
Assert.That(Loader.LoadSettings().Count(), Is.EqualTo(1));
Loader.SaveSettings(foo);
Assert.That(Loader.LoadSettings().Count(), Is.EqualTo(2));
Assert.That(ShellSettingsManager.LoadSettings().Count(), Is.EqualTo(1));
ShellSettingsManager.SaveSettings(foo);
Assert.That(ShellSettingsManager.LoadSettings().Count(), Is.EqualTo(2));
var text = ( (AzureShellSettingsManager)Loader ).Container.GetBlockBlobReference("Foo/Settings.txt").DownloadText();
Assert.That(text, Is.StringContaining("Foo"));
Assert.That(text, Is.StringContaining("Bar"));
Assert.That(text, Is.StringContaining("Quux"));
foo = ShellSettingsManager.LoadSettings().Where(s => s.Name == "Foo").Single();
Assert.That(foo.Name, Is.StringContaining("Foo"));
Assert.That(foo.DataProvider, Is.StringContaining("Bar"));
Assert.That(foo.DataConnectionString, Is.StringContaining("Quux"));
}
}
}

View File

@@ -10,19 +10,19 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
[TestFixture]
public class AzureBlobStorageProviderTests : AzureVirtualEnvironmentTest {
CloudStorageAccount DevAccount;
private AzureBlobStorageProvider _azureBlobStorageProvider;
protected override void OnInit() {
CloudStorageAccount devAccount;
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out devAccount);
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out DevAccount);
_azureBlobStorageProvider = new AzureBlobStorageProvider(new ShellSettings { Name = "default" }, devAccount);
_azureBlobStorageProvider = new AzureBlobStorageProvider(new ShellSettings { Name = "default" }, DevAccount);
}
[SetUp]
public void Setup() {
// ensure default container is empty before running any test
DeleteAllBlobs(_azureBlobStorageProvider.Container);
DeleteAllBlobs(_azureBlobStorageProvider.Container.Name, DevAccount);
}
[Test]

View File

@@ -55,7 +55,7 @@
<ItemGroup>
<Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\moq\Moq.dll</HintPath>

View File

@@ -28,8 +28,8 @@ namespace Orchard.Azure {
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
ContainerName = containerName;
_root = String.IsNullOrEmpty(root) || root == "/" ? String.Empty : root + "/";
_absoluteRoot = _storageAccount.BlobEndpoint.AbsoluteUri + containerName + "/" + root + "/";
_root = String.IsNullOrEmpty(root) ? "": root + "/";
_absoluteRoot = _storageAccount.BlobEndpoint.AbsoluteUri + "/" + containerName + "/" + root;
using ( new HttpContextWeaver() ) {
@@ -40,12 +40,11 @@ namespace Orchard.Azure {
Container.CreateIfNotExist();
if (isPrivate) {
Container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Off });
}
else {
Container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container });
}
Container.SetPermissions(isPrivate
? new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Off}
: new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Container});
}
}
@@ -107,7 +106,7 @@ namespace Orchard.Azure {
EnsurePathIsRelative(path);
string prefix = String.Concat(Combine(Container.Name, _root), path);
string prefix = Combine(Combine(Container.Name, _root), path);
if ( !prefix.EndsWith("/") )
prefix += "/";
@@ -128,7 +127,16 @@ namespace Orchard.Azure {
EnsurePathIsRelative(path);
using ( new HttpContextWeaver() ) {
if ( !Container.DirectoryExists(String.Concat(_root, path)) ) {
// return root folders
if (String.Concat(_root, path) == String.Empty) {
return Container.ListBlobs()
.OfType<CloudBlobDirectory>()
.Select<CloudBlobDirectory, IStorageFolder>(d => new AzureBlobFolderStorage(d, _absoluteRoot))
.ToList();
}
if (!Container.DirectoryExists(String.Concat(_root, path)) ) {
try {
CreateFolder(String.Concat(_root, path));
}
@@ -146,14 +154,12 @@ namespace Orchard.Azure {
}
}
public void TryCreateFolder(string path)
{
public void TryCreateFolder(string path) {
EnsurePathIsRelative(path);
CreateFile(Combine(path, FolderEntry));
}
public void CreateFolder(string path)
{
public void CreateFolder(string path) {
EnsurePathIsRelative(path);
using (new HttpContextWeaver()) {
Container.EnsureDirectoryDoesNotExist(String.Concat(_root, path));

View File

@@ -2,10 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.StorageClient;
using Orchard.Environment.Configuration;
using Orchard.Localization;
@@ -13,97 +11,68 @@ namespace Orchard.Azure.Environment.Configuration {
public class AzureShellSettingsManager : IShellSettingsManager {
public const string ContainerName = "sites"; // container names must be lower cased
public const string SettingsFilename = "Settings.txt";
private readonly IShellSettingsManagerEventHandler _events;
private readonly AzureFileSystem _fileSystem;
private readonly CloudStorageAccount _storageAccount;
public CloudBlobClient BlobClient { get; private set; }
public CloudBlobContainer Container { get; private set; }
Localizer T { get; [UsedImplicitly]
set; }
Localizer T { get; set; }
public AzureShellSettingsManager(IShellSettingsManagerEventHandler events)
: this(CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString")), events)
{
}
: this(CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString")), events) {}
public AzureShellSettingsManager(CloudStorageAccount storageAccount, IShellSettingsManagerEventHandler events)
{
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
public AzureShellSettingsManager(CloudStorageAccount storageAccount, IShellSettingsManagerEventHandler events) {
_events = events;
using ( new HttpContextWeaver() ) {
BlobClient = _storageAccount.CreateCloudBlobClient();
// Get and create the container if it does not exist
// The container is named with DNS naming restrictions (i.e. all lower case)
Container = new CloudBlobContainer(ContainerName, BlobClient);
Container.CreateIfNotExist();
// Tenant settings are protected by default
Container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Off });
}
_fileSystem = new AzureFileSystem(ContainerName, String.Empty, true, storageAccount);
}
IEnumerable<ShellSettings> IShellSettingsManager.LoadSettings() {
return LoadSettings().ToArray();
var settings = LoadSettings().ToArray();
return settings;
}
void IShellSettingsManager.SaveSettings(ShellSettings settings) {
if ( settings == null )
throw new ArgumentException(T("There are no settings to save.").ToString());
if ( string.IsNullOrEmpty(settings.Name) )
throw new ArgumentException(T("Settings \"Name\" is not set.").ToString());
var content = ComposeSettings(settings);
var filePath = String.Concat(settings.Name, "/", SettingsFilename);
var file = _fileSystem.CreateFile(filePath);
using ( new HttpContextWeaver() ) {
var filePath = String.Concat(settings.Name, "/", "Settings.txt");
var blob = Container.GetBlockBlobReference(filePath);
blob.UploadText(ComposeSettings(settings));
using (var stream = file.OpenWrite()) {
using (var writer = new StreamWriter(stream)) {
writer.Write(content);
}
}
_events.Saved(settings);
}
IEnumerable<ShellSettings> LoadSettings() {
foreach (var folder in _fileSystem.ListFolders(null))
foreach (var file in _fileSystem.ListFiles(folder.GetPath())) {
if (!String.Equals(file.GetName(), SettingsFilename))
continue;
using ( new HttpContextWeaver() ) {
var settingsBlobs =
BlobClient.ListBlobsWithPrefix(Container.Name + "/").OfType<CloudBlobDirectory>()
.SelectMany(directory => directory.ListBlobs()).OfType<CloudBlockBlob>()
.Where(
blob =>
string.Equals(Path.GetFileName(blob.Uri.ToString()),
"Settings.txt",
StringComparison.OrdinalIgnoreCase));
return settingsBlobs.Select(settingsBlob => ParseSettings(settingsBlob.DownloadText())).ToList();
}
using (var stream = file.OpenRead())
using (var reader = new StreamReader(stream))
yield return ParseSettings(reader.ReadToEnd());
}
}
static ShellSettings ParseSettings(string text)
{
static ShellSettings ParseSettings(string text) {
var shellSettings = new ShellSettings();
if (String.IsNullOrEmpty(text))
return shellSettings;
string[] settings = text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var setting in settings)
{
string[] settingFields = setting.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
string[] settings = text.Split(new[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries);
foreach (var setting in settings) {
string[] settingFields = setting.Split(new[] {":"}, StringSplitOptions.RemoveEmptyEntries);
int fieldsLength = settingFields.Length;
if (fieldsLength != 2)
continue;
for (int i = 0; i < fieldsLength; i++)
{
for (int i = 0; i < fieldsLength; i++) {
settingFields[i] = settingFields[i].Trim();
}
if (settingFields[1] != "null")
{
switch (settingFields[0])
{
if (settingFields[1] != "null") {
switch (settingFields[0]) {
case "Name":
shellSettings.Name = settingFields[1];
break;
@@ -140,23 +109,22 @@ namespace Orchard.Azure.Environment.Configuration {
return shellSettings;
}
static string ComposeSettings(ShellSettings settings)
{
static string ComposeSettings(ShellSettings settings) {
if (settings == null)
return "";
return string.Format("Name: {0}\r\nDataProvider: {1}\r\nDataConnectionString: {2}\r\nDataPrefix: {3}\r\nRequestUrlHost: {4}\r\nRequestUrlPrefix: {5}\r\nState: {6}\r\nEncryptionAlgorithm: {7}\r\nEncryptionKey: {8}\r\nEncryptionIV: {9}\r\n",
settings.Name,
settings.DataProvider,
settings.DataConnectionString ?? "null",
settings.DataTablePrefix ?? "null",
settings.RequestUrlHost ?? "null",
settings.RequestUrlPrefix ?? "null",
settings.State != null ? settings.State.ToString() : String.Empty,
settings.EncryptionAlgorithm ?? "null",
settings.EncryptionKey ?? "null",
settings.EncryptionIV ?? "null"
);
settings.Name,
settings.DataProvider,
settings.DataConnectionString ?? "null",
settings.DataTablePrefix ?? "null",
settings.RequestUrlHost ?? "null",
settings.RequestUrlPrefix ?? "null",
settings.State != null ? settings.State.ToString() : String.Empty,
settings.EncryptionAlgorithm ?? "null",
settings.EncryptionKey ?? "null",
settings.EncryptionIV ?? "null"
);
}
}
}

View File

@@ -0,0 +1,108 @@
<Configuration>
<CodeStyleSettings>
<ExternalPath IsNull="False">
</ExternalPath>
<Sharing>SOLUTION</Sharing>
<CSharp>
<FormatSettings>
<ALIGN_MULTILINE_ARRAY_AND_OBJECT_INITIALIZER>False</ALIGN_MULTILINE_ARRAY_AND_OBJECT_INITIALIZER>
<ALIGN_MULTILINE_FOR_STMT>False</ALIGN_MULTILINE_FOR_STMT>
<ALIGN_MULTIPLE_DECLARATION>False</ALIGN_MULTIPLE_DECLARATION>
<ANONYMOUS_METHOD_DECLARATION_BRACES>END_OF_LINE</ANONYMOUS_METHOD_DECLARATION_BRACES>
<CASE_BLOCK_BRACES>END_OF_LINE</CASE_BLOCK_BRACES>
<EMPTY_BLOCK_STYLE>TOGETHER</EMPTY_BLOCK_STYLE>
<FORCE_FIXED_BRACES_STYLE>ALWAYS_ADD</FORCE_FIXED_BRACES_STYLE>
<FORCE_FOR_BRACES_STYLE>ALWAYS_ADD</FORCE_FOR_BRACES_STYLE>
<FORCE_FOREACH_BRACES_STYLE>ALWAYS_ADD</FORCE_FOREACH_BRACES_STYLE>
<FORCE_IFELSE_BRACES_STYLE>ALWAYS_ADD</FORCE_IFELSE_BRACES_STYLE>
<FORCE_USING_BRACES_STYLE>ALWAYS_ADD</FORCE_USING_BRACES_STYLE>
<FORCE_WHILE_BRACES_STYLE>ALWAYS_ADD</FORCE_WHILE_BRACES_STYLE>
<INITIALIZER_BRACES>END_OF_LINE</INITIALIZER_BRACES>
<INVOCABLE_DECLARATION_BRACES>END_OF_LINE</INVOCABLE_DECLARATION_BRACES>
<MODIFIERS_ORDER IsNull="False">
<Item>public</Item>
<Item>protected</Item>
<Item>internal</Item>
<Item>private</Item>
<Item>new</Item>
<Item>abstract</Item>
<Item>virtual</Item>
<Item>override</Item>
<Item>sealed</Item>
<Item>static</Item>
<Item>readonly</Item>
<Item>extern</Item>
<Item>unsafe</Item>
<Item>volatile</Item>
</MODIFIERS_ORDER>
<OTHER_BRACES>END_OF_LINE</OTHER_BRACES>
<TYPE_DECLARATION_BRACES>END_OF_LINE</TYPE_DECLARATION_BRACES>
<WRAP_LINES>False</WRAP_LINES>
</FormatSettings>
<UsingsSettings />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
<ExceptionName IsNull="False">
</ExceptionName>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
</Naming2>
</CSharp>
<VB>
<FormatSettings />
<ImportsSettings />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
</Naming2>
</VB>
<Web>
<Naming2 />
</Web>
<Xaml>
<Naming2 />
</Xaml>
<XML>
<FormatSettings />
</XML>
<GenerateMemberBody />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
<ExceptionName IsNull="False">
</ExceptionName>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PublicFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
<PredefinedRule Inspect="False" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
<Abbreviation Text="SQ" />
</Naming2>
</CodeStyleSettings>
</Configuration>

View File

@@ -1,9 +1,8 @@
<?xml version="1.0"?>
<ServiceConfiguration serviceName="OrchardCloudService" osFamily="1" osVersion="*" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<ServiceConfiguration serviceName="OrchardCloudService" osVersion="*" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="Orchard.Azure.Web">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="DataConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>

View File

@@ -2,11 +2,10 @@
<ServiceDefinition name="OrchardCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="Orchard.Azure.Web">
<ConfigurationSettings>
<Setting name="DiagnosticsConnectionString" />
<Setting name="DataConnectionString" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoints>
<InputEndpoint name="HttpIn" protocol="http" port="80" />
</Endpoints>
</InputEndpoints>
</WebRole>
</ServiceDefinition>

View File

@@ -58,7 +58,7 @@
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="NHibernate.ByteCode.Castle">
<HintPath>..\..\..\lib\fluentnhibernate\NHibernate.ByteCode.Castle.dll</HintPath>
</Reference>

View File

@@ -1,13 +1,10 @@
using System.Linq;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
namespace Orchard.Azure.Web {
public class WebRole : RoleEntryPoint {
public override bool OnStart() {
DiagnosticMonitor.Start("DiagnosticsConnectionString");
CloudStorageAccount.SetConfigurationSettingPublisher(
(configName, configSetter) =>
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName))
@@ -20,7 +17,7 @@ namespace Orchard.Azure.Web {
return base.OnStart();
}
private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e) {
private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e) {
// If a configuration setting is changing
if ( e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange) ) {
// Set e.Cancel to true to restart this role instance

View File

@@ -54,7 +54,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>

View File

@@ -20,11 +20,13 @@ namespace Orchard.Users.Services {
private readonly IOrchardServices _orchardServices;
private readonly IMessageManager _messageManager;
private readonly IEnumerable<IUserEventHandler> _userEventHandlers;
private readonly IEncryptionService _encryptionService;
public MembershipService(IOrchardServices orchardServices, IMessageManager messageManager, IEnumerable<IUserEventHandler> userEventHandlers, IClock clock) {
public MembershipService(IOrchardServices orchardServices, IMessageManager messageManager, IEnumerable<IUserEventHandler> userEventHandlers, IClock clock, IEncryptionService encryptionService) {
_orchardServices = orchardServices;
_messageManager = messageManager;
_userEventHandlers = userEventHandlers;
_encryptionService = encryptionService;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
@@ -208,13 +210,13 @@ namespace Orchard.Users.Services {
return partRecord.Password == Convert.ToBase64String(hashBytes);
}
private static void SetPasswordEncrypted(UserPartRecord partRecord, string password) {
throw new NotImplementedException();
private void SetPasswordEncrypted(UserPartRecord partRecord, string password) {
partRecord.Password = Convert.ToBase64String(_encryptionService.Encode(Encoding.UTF8.GetBytes(password)));
partRecord.PasswordSalt = null;
}
private static bool ValidatePasswordEncrypted(UserPartRecord partRecord, string password) {
throw new NotImplementedException();
private bool ValidatePasswordEncrypted(UserPartRecord partRecord, string password) {
return String.Equals(password, Encoding.UTF8.GetString(_encryptionService.Decode(Convert.FromBase64String(partRecord.Password))), StringComparison.Ordinal);
}
}
}