Skip to content

Commit

Permalink
renamed WireEcryptedString -> WireEncryptedString
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyherrera authored and CoreyKaylor committed Aug 3, 2012
1 parent b539ebb commit b2bd5b0
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 78 deletions.
8 changes: 4 additions & 4 deletions Rhino.ServiceBus.Autofac/AutofacBuilder.cs
Expand Up @@ -265,8 +265,8 @@ public void RegisterSecurity(byte[] key)
builder.RegisterType<RijndaelEncryptionService>()
.WithParameter(new NamedParameter("key", key))
.As<IEncryptionService>().SingleInstance();
builder.RegisterType<WireEcryptedStringConvertor>()
.As<IValueConvertor<WireEcryptedString>>()
builder.RegisterType<WireEncryptedStringConvertor>()
.As<IValueConvertor<WireEncryptedString>>()
.SingleInstance();
builder.RegisterType<WireEncryptedMessageConvertor>()
.As<IElementSerializationBehavior>().SingleInstance();
Expand All @@ -276,8 +276,8 @@ public void RegisterSecurity(byte[] key)
public void RegisterNoSecurity()
{
var builder = new ContainerBuilder();
builder.RegisterType<ThrowingWireEcryptedStringConvertor>()
.As<IValueConvertor<WireEcryptedString>>().SingleInstance();
builder.RegisterType<ThrowingWireEncryptedStringConvertor>()
.As<IValueConvertor<WireEncryptedString>>().SingleInstance();
builder.RegisterType<ThrowingWireEncryptedMessageConvertor>()
.As<IElementSerializationBehavior>().SingleInstance();
builder.Update(container);
Expand Down
8 changes: 4 additions & 4 deletions Rhino.ServiceBus.Castle/CastleBuilder.cs
Expand Up @@ -313,8 +313,8 @@ public void RegisterSecurity(byte[] key)
);

container.Register(
Component.For<IValueConvertor<WireEcryptedString>>()
.ImplementedBy<WireEcryptedStringConvertor>()
Component.For<IValueConvertor<WireEncryptedString>>()
.ImplementedBy<WireEncryptedStringConvertor>()
.DependsOn(Dependency.OnComponent("encryptionService", "esb.security"))
);

Expand All @@ -328,8 +328,8 @@ public void RegisterSecurity(byte[] key)
public void RegisterNoSecurity()
{
container.Register(
Component.For<IValueConvertor<WireEcryptedString>>()
.ImplementedBy<ThrowingWireEcryptedStringConvertor>()
Component.For<IValueConvertor<WireEncryptedString>>()
.ImplementedBy<ThrowingWireEncryptedStringConvertor>()
);
container.Register(
Component.For<IElementSerializationBehavior>()
Expand Down
4 changes: 2 additions & 2 deletions Rhino.ServiceBus.Spring/SpringBuilder.cs
Expand Up @@ -239,13 +239,13 @@ public void RegisterRhinoQueuesOneWay()
public void RegisterSecurity(byte[] key)
{
applicationContext.RegisterSingleton<IEncryptionService>(() => new RijndaelEncryptionService(key));
applicationContext.RegisterSingleton<IValueConvertor<WireEcryptedString>>(() => new WireEcryptedStringConvertor(applicationContext.Get<IEncryptionService>()));
applicationContext.RegisterSingleton<IValueConvertor<WireEncryptedString>>(() => new WireEncryptedStringConvertor(applicationContext.Get<IEncryptionService>()));
applicationContext.RegisterSingleton<IElementSerializationBehavior>(() => new WireEncryptedMessageConvertor(applicationContext.Get<IEncryptionService>()));
}

public void RegisterNoSecurity()
{
applicationContext.RegisterSingleton<IValueConvertor<WireEcryptedString>>(() => new ThrowingWireEcryptedStringConvertor());
applicationContext.RegisterSingleton<IValueConvertor<WireEncryptedString>>(() => new ThrowingWireEncryptedStringConvertor());
applicationContext.RegisterSingleton<IElementSerializationBehavior>(() => new ThrowingWireEncryptedMessageConvertor());
}
}
Expand Down
4 changes: 2 additions & 2 deletions Rhino.ServiceBus.StructureMap/StructureMapBuilder.cs
Expand Up @@ -226,7 +226,7 @@ public void RegisterSecurity(byte[] key)
{
c.For<IEncryptionService>().Singleton().Use<RijndaelEncryptionService>()
.Ctor<byte[]>().Is(key);
c.For<IValueConvertor<WireEcryptedString>>().Singleton().Use<WireEcryptedStringConvertor>();
c.For<IValueConvertor<WireEncryptedString>>().Singleton().Use<WireEncryptedStringConvertor>();
c.For<IElementSerializationBehavior>().Singleton().Use<WireEncryptedMessageConvertor>();
});
}
Expand All @@ -235,7 +235,7 @@ public void RegisterNoSecurity()
{
container.Configure(c =>
{
c.For<IValueConvertor<WireEcryptedString>>().Singleton().Use<ThrowingWireEcryptedStringConvertor>();
c.For<IValueConvertor<WireEncryptedString>>().Singleton().Use<ThrowingWireEncryptedStringConvertor>();
c.For<IElementSerializationBehavior>().Singleton().Use<ThrowingWireEncryptedMessageConvertor>();
});
}
Expand Down
Expand Up @@ -35,7 +35,7 @@ public void Will_throw_for_wire_encrypted_string()
}
catch (SerializationException e)
{
Assert.Equal("Cannot send message containing WireEcryptedString when <security> was not properly set up",
Assert.Equal("Cannot send message containing WireEncryptedString when <security> was not properly set up",
e.InnerException.Message);
}
}
Expand Down
20 changes: 10 additions & 10 deletions Rhino.ServiceBus.Tests/When_Security_Is_Specified_In_Config.cs
Expand Up @@ -27,8 +27,8 @@ private static IWindsorContainer CreateContainer()
public void Will_register_wire_encrypted_string_convertor_on_container()
{
var container = CreateContainer();
var convertor = container.Resolve<IValueConvertor<WireEcryptedString>>();
Assert.IsType<WireEcryptedStringConvertor>(convertor);
var convertor = container.Resolve<IValueConvertor<WireEncryptedString>>();
Assert.IsType<WireEncryptedStringConvertor>(convertor);
}

[Fact]
Expand All @@ -42,7 +42,7 @@ public void Will_register_wire_encrypted_message_convertor_on_container()

public class ClassWithSecretField
{
public WireEcryptedString ShouldBeEncrypted
public WireEncryptedString ShouldBeEncrypted
{
get; set;
}
Expand All @@ -56,11 +56,11 @@ public class SecretMessage : IWireEncryptedMessage

public const string encryptedMessage =
@"<?xml version=""1.0"" encoding=""utf-8""?>
<esb:messages xmlns:esb=""http://servicebus.hibernatingrhinos.com/2008/12/20/esb"" xmlns:tests.classwithsecretfield=""Rhino.ServiceBus.Tests.When_Security_Is_Specified_In_Config+ClassWithSecretField, Rhino.ServiceBus.Tests"" xmlns:datastructures.wireecryptedstring=""Rhino.ServiceBus.DataStructures.WireEcryptedString, Rhino.ServiceBus"" xmlns:string=""System.String"">
<esb:messages xmlns:esb=""http://servicebus.hibernatingrhinos.com/2008/12/20/esb"" xmlns:tests.classwithsecretfield=""Rhino.ServiceBus.Tests.When_Security_Is_Specified_In_Config+ClassWithSecretField, Rhino.ServiceBus.Tests"" xmlns:datastructures.wireencryptedstring=""Rhino.ServiceBus.DataStructures.WireEncryptedString, Rhino.ServiceBus"" xmlns:string=""System.String"">
<tests.classwithsecretfield:ClassWithSecretField>
<datastructures.wireecryptedstring:ShouldBeEncrypted>
<datastructures.wireencryptedstring:ShouldBeEncrypted>
<string:Value iv=""0yL9+t0uyDy9NeP7CU1Wow=="">q9a10IFuRxrzFoZewfdOyg==</string:Value>
</datastructures.wireecryptedstring:ShouldBeEncrypted>
</datastructures.wireencryptedstring:ShouldBeEncrypted>
</tests.classwithsecretfield:ClassWithSecretField>
</esb:messages>";

Expand All @@ -74,7 +74,7 @@ public void Will_encrypt_fields_of_messages()
{
new ClassWithSecretField
{
ShouldBeEncrypted = new WireEcryptedString{Value = "abc"}
ShouldBeEncrypted = new WireEncryptedString{Value = "abc"}
}
},memoryStream);

Expand All @@ -85,7 +85,7 @@ public void Will_encrypt_fields_of_messages()
var actual = document
.Element(XName.Get("messages", "http://servicebus.hibernatingrhinos.com/2008/12/20/esb"))
.Element(XName.Get("ClassWithSecretField","Rhino.ServiceBus.Tests.When_Security_Is_Specified_In_Config+ClassWithSecretField, Rhino.ServiceBus.Tests"))
.Element(XName.Get("ShouldBeEncrypted","Rhino.ServiceBus.DataStructures.WireEcryptedString, Rhino.ServiceBus"))
.Element(XName.Get("ShouldBeEncrypted","Rhino.ServiceBus.DataStructures.WireEncryptedString, Rhino.ServiceBus"))
.Element(XName.Get("Value","System.String"))
.Value;

Expand All @@ -102,7 +102,7 @@ public void Will_decrypt_fields_of_messages()
{
new ClassWithSecretField
{
ShouldBeEncrypted = new WireEcryptedString{Value = "abc"}
ShouldBeEncrypted = new WireEncryptedString{Value = "abc"}
}
}, memoryStream);

Expand Down Expand Up @@ -171,7 +171,7 @@ public void When_key_is_different_deserializing_key_will_fail()
{
var container = CreateContainer();
var serializer = container.Resolve<IMessageSerializer>();
var convertor = (WireEcryptedStringConvertor)container.Resolve<IValueConvertor<WireEcryptedString>>();
var convertor = (WireEncryptedStringConvertor)container.Resolve<IValueConvertor<WireEncryptedString>>();

var managed = new RijndaelManaged();
managed.GenerateKey();
Expand Down
4 changes: 2 additions & 2 deletions Rhino.ServiceBus.Unity/UnityBuilder.cs
Expand Up @@ -279,7 +279,7 @@ public void RegisterSecurity(byte[] key)
new InjectionConstructor(
new InjectionParameter<byte[]>(key)));

container.RegisterType<IValueConvertor<WireEcryptedString>, WireEcryptedStringConvertor>(
container.RegisterType<IValueConvertor<WireEncryptedString>, WireEncryptedStringConvertor>(
new ContainerControlledLifetimeManager(),
new InjectionConstructor(
new ResolvedParameter<IEncryptionService>("esb.security")));
Expand All @@ -291,7 +291,7 @@ public void RegisterSecurity(byte[] key)

public void RegisterNoSecurity()
{
container.RegisterType<IValueConvertor<WireEcryptedString>, ThrowingWireEcryptedStringConvertor>(
container.RegisterType<IValueConvertor<WireEncryptedString>, ThrowingWireEncryptedStringConvertor>(
new ContainerControlledLifetimeManager());
container.RegisterType<IElementSerializationBehavior, ThrowingWireEncryptedMessageConvertor>(
new ContainerControlledLifetimeManager());
Expand Down
29 changes: 0 additions & 29 deletions Rhino.ServiceBus/Convertors/ThrowingWireEcryptedStringConvertor.cs

This file was deleted.

@@ -0,0 +1,29 @@
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
using Rhino.ServiceBus.DataStructures;
using Rhino.ServiceBus.Internal;

namespace Rhino.ServiceBus.Convertors
{
public class ThrowingWireEncryptedStringConvertor : IValueConvertor<WireEncryptedString>
{
public XElement ToElement(WireEncryptedString val, Func<Type, XNamespace> getNamespace)
{
throw new SecurityException(
"Cannot send message containing WireEncryptedString when <security> was not properly set up");
}

public WireEncryptedString FromElement(XElement element)
{
var value = element.Element(XName.Get("Value", "System.String"));
if(value==null)
throw new SerializationException("<WireEncryptedString> did not have mandatory <Value> element");
return new WireEncryptedString
{
Value = value.Value
};
}
}
}
Expand Up @@ -5,24 +5,24 @@

namespace Rhino.ServiceBus.Convertors
{
public class WireEcryptedStringConvertor : IValueConvertor<WireEcryptedString>
public class WireEncryptedStringConvertor : IValueConvertor<WireEncryptedString>
{
public IEncryptionService EncryptionService { get; set;}

public WireEcryptedStringConvertor(IEncryptionService encryptionService)
public WireEncryptedStringConvertor(IEncryptionService encryptionService)
{
EncryptionService = encryptionService;
}

public XElement ToElement(WireEcryptedString val, Func<Type, XNamespace> getNamespace)
public XElement ToElement(WireEncryptedString val, Func<Type, XNamespace> getNamespace)
{
var encryptedValue = EncryptionService.Encrypt(val);
return new XElement(getNamespace(typeof(string)) + "Value",
new XAttribute("iv", encryptedValue.Base64Iv),
encryptedValue.EncryptedBase64Value);
}

public WireEcryptedString FromElement(XElement element)
public WireEncryptedString FromElement(XElement element)
{
var value = element.Element(XName.Get("Value","System.String"));
if(value==null)
Expand Down
17 changes: 0 additions & 17 deletions Rhino.ServiceBus/DataStructures/WireEcryptedString.cs

This file was deleted.

17 changes: 17 additions & 0 deletions Rhino.ServiceBus/DataStructures/WireEncryptedString.cs
@@ -0,0 +1,17 @@
namespace Rhino.ServiceBus.DataStructures
{
public class WireEncryptedString
{
public string Value { get; set; }

public static implicit operator string(WireEncryptedString s)
{
return s==null ? null : s.Value;
}

public static implicit operator WireEncryptedString(string s)
{
return new WireEncryptedString {Value = s};
}
}
}
6 changes: 3 additions & 3 deletions Rhino.ServiceBus/Rhino.ServiceBus.csproj
Expand Up @@ -160,12 +160,12 @@
<Compile Include="Config\SecurityConfiguration.cs" />
<Compile Include="Config\SecurityElement.cs" />
<Compile Include="ConsumerOf.cs" />
<Compile Include="Convertors\ThrowingWireEcryptedStringConvertor.cs" />
<Compile Include="Convertors\WireEcryptedStringConvertor.cs" />
<Compile Include="Convertors\ThrowingWireEncryptedStringConvertor.cs" />
<Compile Include="Convertors\WireEncryptedStringConvertor.cs" />
<Compile Include="DataStructures\OrderedList.cs" />
<Compile Include="DataStructures\Queue.cs" />
<Compile Include="DataStructures\Set.cs" />
<Compile Include="DataStructures\WireEcryptedString.cs" />
<Compile Include="DataStructures\WireEncryptedString.cs" />
<Compile Include="DataStructures\MultiValueIndexHashtable.cs" />
<Compile Include="DataStructures\LeastRecentlyUsedSet.cs" />
<Compile Include="DataStructures\Hashtable.cs" />
Expand Down

0 comments on commit b2bd5b0

Please sign in to comment.