Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
smithc committed Sep 8, 2016
2 parents 9bd5d0a + 6619525 commit 5789783
Show file tree
Hide file tree
Showing 42 changed files with 1,303 additions and 114 deletions.
24 changes: 18 additions & 6 deletions Jabberwocky.Core/Cryptography/AesHmacCryptoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public class AesHmacCryptoService : IHmacCryptoService
protected ISerializationProvider SerializationProvider { get; }

/// <summary>
/// Symmetric Key size for 256-bit cipher
/// Symmetric Key size for 256-bit cipher (in bytes)
/// </summary>
private const int KeySize = 32;
/// <summary>
/// AES cipher block-size
/// AES cipher block-size (in bytes)
/// </summary>
private const int BlockSize = 128;
private const int BlockSize = 16;
/// <summary>
/// Initialization Vector size
/// Initialization Vector size (in bytes)
/// </summary>
private const int SaltSize = 16;

Expand All @@ -45,6 +45,7 @@ public static AesHmacCryptoService Create(string secretKey, string digestKey, st
public AesHmacCryptoService(CryptoConfiguration config, ISerializationProvider serializationProvider)
{
if (serializationProvider == null) throw new ArgumentNullException(nameof(serializationProvider));
if (!IsCryptoConfigurationValid(config)) throw new ArgumentException("All configuration properties must be valid.", nameof(config));
SerializationProvider = serializationProvider;

_lazyDerivedBytes = new Lazy<KeySaltPair>(() => GenerateDerivedBytes(config));
Expand Down Expand Up @@ -122,9 +123,11 @@ protected virtual byte[] GenerateNonce()

protected virtual byte[] CryptContent(byte[] contentBytes, Func<SymmetricAlgorithm, ICryptoTransform> cryptorFunc)
{
const int blockSizeInBits = BlockSize * 8;

using (var aes = new RijndaelManaged())
{
aes.BlockSize = BlockSize;
aes.BlockSize = blockSizeInBits;
aes.Mode = CipherMode.CBC;
aes.Key = SymmetricKey;
aes.IV = Salt;
Expand All @@ -147,7 +150,9 @@ protected virtual byte[] ComputeHash(byte[] content)
private static KeySaltPair GenerateDerivedBytes(CryptoConfiguration config)
{
var saltBytes = new byte[SaltSize];
Encoding.UTF8.GetBytes(config.InitializationVector, 0, config.InitializationVector.Length, saltBytes, 0);
var charSizeInBytes = sizeof(char);
var characterCount = Math.Min(SaltSize / charSizeInBytes, config.InitializationVector.Length);
Encoding.UTF8.GetBytes(config.InitializationVector, 0, characterCount, saltBytes, 0);

using (var derivePassword = new Rfc2898DeriveBytes(config.SecretKey, saltBytes))
{
Expand All @@ -163,6 +168,13 @@ private static KeySaltPair GenerateDerivedBytes(CryptoConfiguration config)
}
}

private static bool IsCryptoConfigurationValid(CryptoConfiguration config)
{
return !string.IsNullOrEmpty(config.DigestKey)
&& !string.IsNullOrEmpty(config.InitializationVector)
&& !string.IsNullOrEmpty(config.SecretKey);
}

#endregion

protected struct KeySaltPair
Expand Down
8 changes: 4 additions & 4 deletions Jabberwocky.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("Jabberwocky.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCompany("Velir")]
[assembly: AssemblyProduct("Jabberwocky.Core")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
[assembly: AssemblyCopyright("Copyright © Velir 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyVersion("1.0.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: InternalsVisibleTo("Jabberwocky.Core.Tests")]
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Glass.Mapper.Sc.4.0.3.51\lib\72\Glass.Mapper.Sc.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack">
<HintPath>..\lib\Sitecore\Testing\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="ITHit.WebDAV.Server">
<HintPath>..\lib\Sitecore\Testing\ITHit.WebDAV.Server.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net">
<HintPath>..\lib\Sitecore\Testing\Lucene.Net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Mvp.Xml">
<HintPath>..\lib\Sitecore\Testing\Mvp.Xml.dll</HintPath>
</Reference>
Expand All @@ -79,13 +67,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Sitecore\Sitecore.Kernel.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Kernel.7.0.0.0.Fakes">
<HintPath>FakesAssemblies\Sitecore.Kernel.7.0.0.0.Fakes.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Logging, Version=1.2.0.30715, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Sitecore\Testing\Sitecore.Logging.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Mvc, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Sitecore\Sitecore.Mvc.dll</HintPath>
Expand All @@ -103,11 +84,9 @@
<ItemGroup>
<Compile Include="Models\Factory\AutofacViewModelFactoryTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\RenderingContextServiceTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<Fakes Include="Fakes\Sitecore.Kernel.fakes" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand All @@ -119,11 +98,16 @@
<Project>{5EAD110F-F074-47E4-8B93-C0EECB9FC27A}</Project>
<Name>Jabberwocky.Glass.Autofac.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\Jabberwocky.Glass.Mvc\Jabberwocky.Glass.Mvc.csproj">
<Project>{dd17db22-247c-44a6-b0dd-091786863626}</Project>
<Name>Jabberwocky.Glass.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\Jabberwocky.Glass\Jabberwocky.Glass.csproj">
<Project>{13E08D30-B2A4-45EF-A28E-C916EB80B70D}</Project>
<Name>Jabberwocky.Glass</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using Jabberwocky.Glass.Autofac.Mvc.Models;
using Jabberwocky.Glass.Autofac.Mvc.Models.Attributes;
using Jabberwocky.Glass.Autofac.Mvc.Models.Factory;
using Jabberwocky.Glass.Autofac.Mvc.Services;
using Jabberwocky.Glass.Models;
using Jabberwocky.Glass.Mvc.Services;
using NSubstitute;
using NUnit.Framework;
using Sitecore.Mvc.Presentation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
using Glass.Mapper.Sc.ModelCache;
using Jabberwocky.Glass.Autofac.Mvc.Models;
using Jabberwocky.Glass.Autofac.Mvc.Models.Factory;
using Jabberwocky.Glass.Autofac.Mvc.Services;
using Jabberwocky.Glass.Mvc.Services;
using IViewModelFactory = Jabberwocky.Glass.Mvc.Models.Factory.IViewModelFactory;

namespace Jabberwocky.Glass.Autofac.Mvc.Extensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,17 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Attributes\HttpGetOrInvalidHttpPostAttribute.cs" />
<Compile Include="Attributes\ValidateFormHandlerAttribute.cs" />
<Compile Include="Attributes\ValidHttpPostAttribute.cs" />
<Compile Include="Extensions\MvcRegistrationExtensions.cs" />
<Compile Include="Models\Attributes\AllowNestedDatasourceAttribute.cs" />
<Compile Include="Models\Attributes\ConfigureDatasourceAttribute.cs" />
<Compile Include="Models\Attributes\DisableNestedDatasourceAttribute.cs" />
<Compile Include="Models\Factory\IViewModelFactory.cs" />
<Compile Include="Models\Factory\AutofacViewModelFactory.cs" />
<Compile Include="Models\GlassViewModel.cs" />
<Compile Include="Models\InjectableGlassViewModelBase.cs" />
<Compile Include="Pipelines\Factories\Providers\MvcLifetimeScopeProvider.cs" />
<Compile Include="Pipelines\Processors\GetModelFromViewProcessor.cs" />
<Compile Include="Pipelines\Processors\GetModelProcessor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\IRenderingContextService.cs" />
<Compile Include="Services\RenderingContextService.cs" />
<Compile Include="Util\CustomSitecoreHelper.cs" />
<Compile Include="Views\CustomGlassView.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App_Config\Include\Jabberwocky.Glass.Autofac.Mvc.config">
Expand All @@ -130,6 +122,10 @@
<Project>{EA620F62-8D08-4031-BAC4-1C60D5C5CBC9}</Project>
<Name>Jabberwocky.Glass.Autofac</Name>
</ProjectReference>
<ProjectReference Include="..\Jabberwocky.Glass.Mvc\Jabberwocky.Glass.Mvc.csproj">
<Project>{dd17db22-247c-44a6-b0dd-091786863626}</Project>
<Name>Jabberwocky.Glass.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\Jabberwocky.Glass\Jabberwocky.Glass.csproj">
<Project>{13E08D30-B2A4-45EF-A28E-C916EB80B70D}</Project>
<Name>Jabberwocky.Glass</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
using Autofac;
using Autofac.Core;
using Jabberwocky.Glass.Autofac.Mvc.Models.Attributes;
using Jabberwocky.Glass.Autofac.Mvc.Services;
using Jabberwocky.Glass.Models;
using Jabberwocky.Glass.Mvc.Services;

namespace Jabberwocky.Glass.Autofac.Mvc.Models.Factory
{
public class AutofacViewModelFactory : IViewModelFactory
public class AutofacViewModelFactory : Jabberwocky.Glass.Mvc.Models.Factory.IViewModelFactory
{
private static readonly ConcurrentDictionary<Type, TypeTuple?> ViewModelTypeCache = new ConcurrentDictionary<Type, TypeTuple?>();

Expand Down
11 changes: 6 additions & 5 deletions Jabberwocky.Glass.Autofac.Mvc/Models/GlassViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Jabberwocky.Glass.Models;
using Jabberwocky.Glass.Mvc.Models;

namespace Jabberwocky.Glass.Autofac.Mvc.Models
{
Expand All @@ -7,9 +8,9 @@ public abstract class GlassViewModel<TGlassModel> : InjectableGlassViewModelBase
public virtual TGlassModel GlassModel => InternalDatasourceModel as TGlassModel;
}

public abstract class GlassViewModel<TDatasource, TRenderingParameter> : GlassViewModel<TDatasource>
where TDatasource : class, IGlassBase where TRenderingParameter : class
{
public virtual TRenderingParameter RenderingParameters => InternalRenderingParameterModel as TRenderingParameter;
}
public abstract class GlassViewModel<TDatasource, TRenderingParameter> : GlassViewModel<TDatasource>
where TDatasource : class, IGlassBase where TRenderingParameter : class
{
public virtual TRenderingParameter RenderingParameters => InternalRenderingParameterModel as TRenderingParameter;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Jabberwocky.Glass.Autofac.Mvc.Models
namespace Jabberwocky.Glass.Autofac.Mvc.Models
{
public abstract class InjectableGlassViewModelBase
{
internal object InternalDatasourceModel;

internal object InternalRenderingParameterModel;
internal object InternalRenderingParameterModel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Sitecore.Diagnostics;
using Sitecore.Mvc.Pipelines.Response.GetModel;
using Glass.Mapper;
using Jabberwocky.Glass.Autofac.Mvc.Models.Factory;
using Jabberwocky.Glass.Mvc.Models.Factory;
using Sitecore.Data.Items;

namespace Jabberwocky.Glass.Autofac.Mvc.Pipelines.Processors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Glass.Mapper.Sc.Configuration.Attributes;
using Jabberwocky.Glass.Autofac.Mvc.Models.Factory;
using Jabberwocky.Glass.Autofac.Pipelines.Processors;
using Jabberwocky.Glass.Mvc.Models.Factory;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Mvc.Configuration;
Expand Down
26 changes: 21 additions & 5 deletions Jabberwocky.Glass.Autofac.Mvc/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("Jabberwocky.Glass.Autofac.Mvc")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCompany("Velir")]
[assembly: AssemblyProduct("Jabberwocky.Glass.Autofac.Mvc")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
[assembly: AssemblyCopyright("Copyright © Velir 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,7 +32,23 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]

[assembly: InternalsVisibleTo("Jabberwocky.Glass.Autofac.Mvc.Tests")]
[assembly: InternalsVisibleTo("Jabberwocky.Glass.Autofac.Mvc.Tests")]

#pragma warning disable 612
[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Attributes.HttpGetOrInvalidHttpPostAttribute))]
[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Attributes.ValidateFormHandlerAttribute))]
[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Attributes.ValidHttpPostAttribute))]

[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Models.Factory.IViewModelFactory))]

[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Services.IRenderingContextService))]
[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Services.RenderingContextService))]
[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Services.DatasourceNestingOptions))]

[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Util.CustomSitecoreHelper))]

[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Views.CustomGlassView<>))]
#pragma warning restore 612
24 changes: 0 additions & 24 deletions Jabberwocky.Glass.Autofac.Mvc/Services/IRenderingContextService.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Jabberwocky.Glass.Autofac/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("Jabberwocky.Glass.Autofac")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCompany("Velir")]
[assembly: AssemblyProduct("Jabberwocky.Glass.Autofac")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
[assembly: AssemblyCopyright("Copyright © Velir 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 5789783

Please sign in to comment.