--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

@@ -136,7 +136,7 @@
<Target Name="Package-Stage"> <Target Name="Package-Stage">
<Exec <Exec
Command="&quot;$(ServiceHostingSDKBinDir)cspack&quot; &quot;$(ServiceFolder)\ServiceDefinition.build.csdef&quot; /role:Orchard.Azure.Web;&quot;$(CloudRootFolder)&quot;;Orchard.Azure.Web.dll /rolePropertiesFile:Orchard.Azure.Web;&quot;$(ServiceFolder)\Properties.txt&quot; /out:&quot;$(StageFolder)\Orchard.Azure.Web.cspkg&quot;" Command="&quot;$(ServiceHostingSDKBinDir)cspack&quot; &quot;$(ServiceFolder)\ServiceDefinition.csdef&quot; /role:Orchard.Azure.Web;&quot;$(CloudRootFolder)&quot;;Orchard.Azure.Web.dll /rolePropertiesFile:Orchard.Azure.Web;&quot;$(ServiceFolder)\Properties.txt&quot; /out:&quot;$(StageFolder)\Orchard.Azure.Web.cspkg&quot;"
WorkingDirectory="$(CloudRootFolder)" WorkingDirectory="$(CloudRootFolder)"
/> />

View File

@@ -1,5 +1,5 @@
SET CDIR = %CD% SET CDIR = %CD%
call "%ProgramFiles%\Windows Azure SDK\v1.3\bin\setenv.cmd" call "%ProgramFiles%\Windows Azure SDK\v1.2\bin\setenv.cmd"
csrun /devstore csrun /devstore
csrun /run:"%CDIR %\build\Compile\Orchard.Azure.CloudService.csx";"%CDIR %\src\Orchard.Azure\Orchard.Azure.CloudService\ServiceConfiguration.cscfg" /launchbrowser csrun /run:"%CDIR %\build\Compile\Orchard.Azure.CloudService.csx";"%CDIR %\src\Orchard.Azure\Orchard.Azure.CloudService\ServiceConfiguration.cscfg" /launchbrowser
pause pause

View File

@@ -1,6 +1,9 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<configuration> <configuration>
<appSettings> <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> </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.Diagnostics;
using System.IO; using System.IO;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient; using Microsoft.WindowsAzure.StorageClient;
using NUnit.Framework; using NUnit.Framework;
@@ -35,7 +37,11 @@ namespace Orchard.Azure.Tests {
_dsService.Close(); _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() ) { foreach ( var blob in container.ListBlobs() ) {
if ( blob is CloudBlob ) { if ( blob is CloudBlob ) {
( (CloudBlob)blob ).DeleteIfExists(); ( (CloudBlob)blob ).DeleteIfExists();

View File

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

View File

@@ -10,19 +10,19 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
[TestFixture] [TestFixture]
public class AzureBlobStorageProviderTests : AzureVirtualEnvironmentTest { public class AzureBlobStorageProviderTests : AzureVirtualEnvironmentTest {
CloudStorageAccount DevAccount;
private AzureBlobStorageProvider _azureBlobStorageProvider; private AzureBlobStorageProvider _azureBlobStorageProvider;
protected override void OnInit() { 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] [SetUp]
public void Setup() { public void Setup() {
// ensure default container is empty before running any test // ensure default container is empty before running any test
DeleteAllBlobs(_azureBlobStorageProvider.Container); DeleteAllBlobs(_azureBlobStorageProvider.Container.Name, DevAccount);
} }
[Test] [Test]

View File

@@ -55,7 +55,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <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.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"> <Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\moq\Moq.dll</HintPath> <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 // Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount; _storageAccount = storageAccount;
ContainerName = containerName; ContainerName = containerName;
_root = String.IsNullOrEmpty(root) || root == "/" ? String.Empty : root + "/"; _root = String.IsNullOrEmpty(root) ? "": root + "/";
_absoluteRoot = _storageAccount.BlobEndpoint.AbsoluteUri + containerName + "/" + root + "/"; _absoluteRoot = _storageAccount.BlobEndpoint.AbsoluteUri + "/" + containerName + "/" + root;
using ( new HttpContextWeaver() ) { using ( new HttpContextWeaver() ) {
@@ -40,12 +40,11 @@ namespace Orchard.Azure {
Container.CreateIfNotExist(); Container.CreateIfNotExist();
if (isPrivate) { Container.SetPermissions(isPrivate
Container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Off }); ? new BlobContainerPermissions
} {PublicAccess = BlobContainerPublicAccessType.Off}
else { : new BlobContainerPermissions
Container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container }); {PublicAccess = BlobContainerPublicAccessType.Container});
}
} }
} }
@@ -107,7 +106,7 @@ namespace Orchard.Azure {
EnsurePathIsRelative(path); EnsurePathIsRelative(path);
string prefix = String.Concat(Combine(Container.Name, _root), path); string prefix = Combine(Combine(Container.Name, _root), path);
if ( !prefix.EndsWith("/") ) if ( !prefix.EndsWith("/") )
prefix += "/"; prefix += "/";
@@ -128,7 +127,16 @@ namespace Orchard.Azure {
EnsurePathIsRelative(path); EnsurePathIsRelative(path);
using ( new HttpContextWeaver() ) { 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 { try {
CreateFolder(String.Concat(_root, path)); CreateFolder(String.Concat(_root, path));
} }
@@ -146,14 +154,12 @@ namespace Orchard.Azure {
} }
} }
public void TryCreateFolder(string path) public void TryCreateFolder(string path) {
{
EnsurePathIsRelative(path); EnsurePathIsRelative(path);
CreateFile(Combine(path, FolderEntry)); CreateFile(Combine(path, FolderEntry));
} }
public void CreateFolder(string path) public void CreateFolder(string path) {
{
EnsurePathIsRelative(path); EnsurePathIsRelative(path);
using (new HttpContextWeaver()) { using (new HttpContextWeaver()) {
Container.EnsureDirectoryDoesNotExist(String.Concat(_root, path)); Container.EnsureDirectoryDoesNotExist(String.Concat(_root, path));

View File

@@ -2,10 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using Microsoft.WindowsAzure; using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.ServiceRuntime; using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.StorageClient;
using Orchard.Environment.Configuration; using Orchard.Environment.Configuration;
using Orchard.Localization; using Orchard.Localization;
@@ -13,97 +11,68 @@ namespace Orchard.Azure.Environment.Configuration {
public class AzureShellSettingsManager : IShellSettingsManager { public class AzureShellSettingsManager : IShellSettingsManager {
public const string ContainerName = "sites"; // container names must be lower cased public const string ContainerName = "sites"; // container names must be lower cased
public const string SettingsFilename = "Settings.txt";
private readonly IShellSettingsManagerEventHandler _events; private readonly IShellSettingsManagerEventHandler _events;
private readonly AzureFileSystem _fileSystem;
private readonly CloudStorageAccount _storageAccount; Localizer T { get; set; }
public CloudBlobClient BlobClient { get; private set; }
public CloudBlobContainer Container { get; private set; }
Localizer T { get; [UsedImplicitly]
set; }
public AzureShellSettingsManager(IShellSettingsManagerEventHandler events) public AzureShellSettingsManager(IShellSettingsManagerEventHandler events)
: this(CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString")), events) : this(CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString")), events) {}
{
}
public AzureShellSettingsManager(CloudStorageAccount storageAccount, IShellSettingsManagerEventHandler events) public AzureShellSettingsManager(CloudStorageAccount storageAccount, IShellSettingsManagerEventHandler events) {
{
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
_events = events; _events = events;
_fileSystem = new AzureFileSystem(ContainerName, String.Empty, true, storageAccount);
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 });
}
} }
IEnumerable<ShellSettings> IShellSettingsManager.LoadSettings() { IEnumerable<ShellSettings> IShellSettingsManager.LoadSettings() {
return LoadSettings().ToArray(); var settings = LoadSettings().ToArray();
return settings;
} }
void IShellSettingsManager.SaveSettings(ShellSettings settings) { void IShellSettingsManager.SaveSettings(ShellSettings settings) {
if ( settings == null ) var content = ComposeSettings(settings);
throw new ArgumentException(T("There are no settings to save.").ToString()); var filePath = String.Concat(settings.Name, "/", SettingsFilename);
var file = _fileSystem.CreateFile(filePath);
if ( string.IsNullOrEmpty(settings.Name) )
throw new ArgumentException(T("Settings \"Name\" is not set.").ToString());
using ( new HttpContextWeaver() ) { using (var stream = file.OpenWrite()) {
var filePath = String.Concat(settings.Name, "/", "Settings.txt"); using (var writer = new StreamWriter(stream)) {
var blob = Container.GetBlockBlobReference(filePath); writer.Write(content);
blob.UploadText(ComposeSettings(settings)); }
} }
_events.Saved(settings); _events.Saved(settings);
} }
IEnumerable<ShellSettings> LoadSettings() { 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() ) { using (var stream = file.OpenRead())
var settingsBlobs = using (var reader = new StreamReader(stream))
BlobClient.ListBlobsWithPrefix(Container.Name + "/").OfType<CloudBlobDirectory>() yield return ParseSettings(reader.ReadToEnd());
.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();
}
} }
static ShellSettings ParseSettings(string text) static ShellSettings ParseSettings(string text) {
{
var shellSettings = new ShellSettings(); var shellSettings = new ShellSettings();
if (String.IsNullOrEmpty(text)) if (String.IsNullOrEmpty(text))
return shellSettings; return shellSettings;
string[] settings = text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string[] settings = text.Split(new[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries);
foreach (var setting in settings) foreach (var setting in settings) {
{ string[] settingFields = setting.Split(new[] {":"}, StringSplitOptions.RemoveEmptyEntries);
string[] settingFields = setting.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
int fieldsLength = settingFields.Length; int fieldsLength = settingFields.Length;
if (fieldsLength != 2) if (fieldsLength != 2)
continue; continue;
for (int i = 0; i < fieldsLength; i++) for (int i = 0; i < fieldsLength; i++) {
{
settingFields[i] = settingFields[i].Trim(); settingFields[i] = settingFields[i].Trim();
} }
if (settingFields[1] != "null") if (settingFields[1] != "null") {
{ switch (settingFields[0]) {
switch (settingFields[0])
{
case "Name": case "Name":
shellSettings.Name = settingFields[1]; shellSettings.Name = settingFields[1];
break; break;
@@ -140,23 +109,22 @@ namespace Orchard.Azure.Environment.Configuration {
return shellSettings; return shellSettings;
} }
static string ComposeSettings(ShellSettings settings) static string ComposeSettings(ShellSettings settings) {
{
if (settings == null) if (settings == null)
return ""; 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", 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.Name,
settings.DataProvider, settings.DataProvider,
settings.DataConnectionString ?? "null", settings.DataConnectionString ?? "null",
settings.DataTablePrefix ?? "null", settings.DataTablePrefix ?? "null",
settings.RequestUrlHost ?? "null", settings.RequestUrlHost ?? "null",
settings.RequestUrlPrefix ?? "null", settings.RequestUrlPrefix ?? "null",
settings.State != null ? settings.State.ToString() : String.Empty, settings.State != null ? settings.State.ToString() : String.Empty,
settings.EncryptionAlgorithm ?? "null", settings.EncryptionAlgorithm ?? "null",
settings.EncryptionKey ?? "null", settings.EncryptionKey ?? "null",
settings.EncryptionIV ?? "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"?> <?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"> <Role name="Orchard.Azure.Web">
<Instances count="1" /> <Instances count="1" />
<ConfigurationSettings> <ConfigurationSettings>
<Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="DataConnectionString" value="UseDevelopmentStorage=true" /> <Setting name="DataConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings> </ConfigurationSettings>
</Role> </Role>

View File

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

View File

@@ -58,7 +58,7 @@
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, 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">
<Private>False</Private> <Private>False</Private>
</Reference> </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"> <Reference Include="NHibernate.ByteCode.Castle">
<HintPath>..\..\..\lib\fluentnhibernate\NHibernate.ByteCode.Castle.dll</HintPath> <HintPath>..\..\..\lib\fluentnhibernate\NHibernate.ByteCode.Castle.dll</HintPath>
</Reference> </Reference>

View File

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

View File

@@ -54,7 +54,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, 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="System" /> <Reference Include="System" />
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>

View File

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