diff --git a/Rhino.ServiceBus.Autofac/AutofacBuilder.cs b/Rhino.ServiceBus.Autofac/AutofacBuilder.cs index 28ffcd8..8ccba71 100644 --- a/Rhino.ServiceBus.Autofac/AutofacBuilder.cs +++ b/Rhino.ServiceBus.Autofac/AutofacBuilder.cs @@ -265,8 +265,8 @@ public void RegisterSecurity(byte[] key) builder.RegisterType() .WithParameter(new NamedParameter("key", key)) .As().SingleInstance(); - builder.RegisterType() - .As>() + builder.RegisterType() + .As>() .SingleInstance(); builder.RegisterType() .As().SingleInstance(); @@ -276,8 +276,8 @@ public void RegisterSecurity(byte[] key) public void RegisterNoSecurity() { var builder = new ContainerBuilder(); - builder.RegisterType() - .As>().SingleInstance(); + builder.RegisterType() + .As>().SingleInstance(); builder.RegisterType() .As().SingleInstance(); builder.Update(container); diff --git a/Rhino.ServiceBus.Castle/CastleBuilder.cs b/Rhino.ServiceBus.Castle/CastleBuilder.cs index a63ed97..7bb66de 100644 --- a/Rhino.ServiceBus.Castle/CastleBuilder.cs +++ b/Rhino.ServiceBus.Castle/CastleBuilder.cs @@ -313,8 +313,8 @@ public void RegisterSecurity(byte[] key) ); container.Register( - Component.For>() - .ImplementedBy() + Component.For>() + .ImplementedBy() .DependsOn(Dependency.OnComponent("encryptionService", "esb.security")) ); @@ -328,8 +328,8 @@ public void RegisterSecurity(byte[] key) public void RegisterNoSecurity() { container.Register( - Component.For>() - .ImplementedBy() + Component.For>() + .ImplementedBy() ); container.Register( Component.For() diff --git a/Rhino.ServiceBus.Spring/SpringBuilder.cs b/Rhino.ServiceBus.Spring/SpringBuilder.cs index 3aeaaaa..3b37fc9 100644 --- a/Rhino.ServiceBus.Spring/SpringBuilder.cs +++ b/Rhino.ServiceBus.Spring/SpringBuilder.cs @@ -239,13 +239,13 @@ public void RegisterRhinoQueuesOneWay() public void RegisterSecurity(byte[] key) { applicationContext.RegisterSingleton(() => new RijndaelEncryptionService(key)); - applicationContext.RegisterSingleton>(() => new WireEcryptedStringConvertor(applicationContext.Get())); + applicationContext.RegisterSingleton>(() => new WireEncryptedStringConvertor(applicationContext.Get())); applicationContext.RegisterSingleton(() => new WireEncryptedMessageConvertor(applicationContext.Get())); } public void RegisterNoSecurity() { - applicationContext.RegisterSingleton>(() => new ThrowingWireEcryptedStringConvertor()); + applicationContext.RegisterSingleton>(() => new ThrowingWireEncryptedStringConvertor()); applicationContext.RegisterSingleton(() => new ThrowingWireEncryptedMessageConvertor()); } } diff --git a/Rhino.ServiceBus.StructureMap/StructureMapBuilder.cs b/Rhino.ServiceBus.StructureMap/StructureMapBuilder.cs index 3eed142..0681fb2 100644 --- a/Rhino.ServiceBus.StructureMap/StructureMapBuilder.cs +++ b/Rhino.ServiceBus.StructureMap/StructureMapBuilder.cs @@ -226,7 +226,7 @@ public void RegisterSecurity(byte[] key) { c.For().Singleton().Use() .Ctor().Is(key); - c.For>().Singleton().Use(); + c.For>().Singleton().Use(); c.For().Singleton().Use(); }); } @@ -235,7 +235,7 @@ public void RegisterNoSecurity() { container.Configure(c => { - c.For>().Singleton().Use(); + c.For>().Singleton().Use(); c.For().Singleton().Use(); }); } diff --git a/Rhino.ServiceBus.Tests/When_Security_Is_Not_Specified_In_Config.cs b/Rhino.ServiceBus.Tests/When_Security_Is_Not_Specified_In_Config.cs index 724af7d..8918cac 100644 --- a/Rhino.ServiceBus.Tests/When_Security_Is_Not_Specified_In_Config.cs +++ b/Rhino.ServiceBus.Tests/When_Security_Is_Not_Specified_In_Config.cs @@ -35,7 +35,7 @@ public void Will_throw_for_wire_encrypted_string() } catch (SerializationException e) { - Assert.Equal("Cannot send message containing WireEcryptedString when was not properly set up", + Assert.Equal("Cannot send message containing WireEncryptedString when was not properly set up", e.InnerException.Message); } } diff --git a/Rhino.ServiceBus.Tests/When_Security_Is_Specified_In_Config.cs b/Rhino.ServiceBus.Tests/When_Security_Is_Specified_In_Config.cs index d9a3744..2b878f6 100644 --- a/Rhino.ServiceBus.Tests/When_Security_Is_Specified_In_Config.cs +++ b/Rhino.ServiceBus.Tests/When_Security_Is_Specified_In_Config.cs @@ -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>(); - Assert.IsType(convertor); + var convertor = container.Resolve>(); + Assert.IsType(convertor); } [Fact] @@ -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; } @@ -56,11 +56,11 @@ public class SecretMessage : IWireEncryptedMessage public const string encryptedMessage = @" - + - + q9a10IFuRxrzFoZewfdOyg== - + "; @@ -74,7 +74,7 @@ public void Will_encrypt_fields_of_messages() { new ClassWithSecretField { - ShouldBeEncrypted = new WireEcryptedString{Value = "abc"} + ShouldBeEncrypted = new WireEncryptedString{Value = "abc"} } },memoryStream); @@ -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; @@ -102,7 +102,7 @@ public void Will_decrypt_fields_of_messages() { new ClassWithSecretField { - ShouldBeEncrypted = new WireEcryptedString{Value = "abc"} + ShouldBeEncrypted = new WireEncryptedString{Value = "abc"} } }, memoryStream); @@ -171,7 +171,7 @@ public void When_key_is_different_deserializing_key_will_fail() { var container = CreateContainer(); var serializer = container.Resolve(); - var convertor = (WireEcryptedStringConvertor)container.Resolve>(); + var convertor = (WireEncryptedStringConvertor)container.Resolve>(); var managed = new RijndaelManaged(); managed.GenerateKey(); diff --git a/Rhino.ServiceBus.Unity/UnityBuilder.cs b/Rhino.ServiceBus.Unity/UnityBuilder.cs index ba220ac..9bd573a 100644 --- a/Rhino.ServiceBus.Unity/UnityBuilder.cs +++ b/Rhino.ServiceBus.Unity/UnityBuilder.cs @@ -279,7 +279,7 @@ public void RegisterSecurity(byte[] key) new InjectionConstructor( new InjectionParameter(key))); - container.RegisterType, WireEcryptedStringConvertor>( + container.RegisterType, WireEncryptedStringConvertor>( new ContainerControlledLifetimeManager(), new InjectionConstructor( new ResolvedParameter("esb.security"))); @@ -291,7 +291,7 @@ public void RegisterSecurity(byte[] key) public void RegisterNoSecurity() { - container.RegisterType, ThrowingWireEcryptedStringConvertor>( + container.RegisterType, ThrowingWireEncryptedStringConvertor>( new ContainerControlledLifetimeManager()); container.RegisterType( new ContainerControlledLifetimeManager()); diff --git a/Rhino.ServiceBus/Convertors/ThrowingWireEcryptedStringConvertor.cs b/Rhino.ServiceBus/Convertors/ThrowingWireEcryptedStringConvertor.cs deleted file mode 100644 index bf7a316..0000000 --- a/Rhino.ServiceBus/Convertors/ThrowingWireEcryptedStringConvertor.cs +++ /dev/null @@ -1,29 +0,0 @@ -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 ThrowingWireEcryptedStringConvertor : IValueConvertor - { - public XElement ToElement(WireEcryptedString val, Func getNamespace) - { - throw new SecurityException( - "Cannot send message containing WireEcryptedString when was not properly set up"); - } - - public WireEcryptedString FromElement(XElement element) - { - var value = element.Element(XName.Get("Value", "System.String")); - if(value==null) - throw new SerializationException(" did not have mandatory element"); - return new WireEcryptedString - { - Value = value.Value - }; - } - } -} diff --git a/Rhino.ServiceBus/Convertors/ThrowingWireEncryptedStringConvertor.cs b/Rhino.ServiceBus/Convertors/ThrowingWireEncryptedStringConvertor.cs new file mode 100644 index 0000000..ad12b9d --- /dev/null +++ b/Rhino.ServiceBus/Convertors/ThrowingWireEncryptedStringConvertor.cs @@ -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 + { + public XElement ToElement(WireEncryptedString val, Func getNamespace) + { + throw new SecurityException( + "Cannot send message containing WireEncryptedString when 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(" did not have mandatory element"); + return new WireEncryptedString + { + Value = value.Value + }; + } + } +} diff --git a/Rhino.ServiceBus/Convertors/WireEcryptedStringConvertor.cs b/Rhino.ServiceBus/Convertors/WireEncryptedStringConvertor.cs similarity index 75% rename from Rhino.ServiceBus/Convertors/WireEcryptedStringConvertor.cs rename to Rhino.ServiceBus/Convertors/WireEncryptedStringConvertor.cs index f120f29..3910ac7 100644 --- a/Rhino.ServiceBus/Convertors/WireEcryptedStringConvertor.cs +++ b/Rhino.ServiceBus/Convertors/WireEncryptedStringConvertor.cs @@ -5,16 +5,16 @@ namespace Rhino.ServiceBus.Convertors { - public class WireEcryptedStringConvertor : IValueConvertor + public class WireEncryptedStringConvertor : IValueConvertor { public IEncryptionService EncryptionService { get; set;} - public WireEcryptedStringConvertor(IEncryptionService encryptionService) + public WireEncryptedStringConvertor(IEncryptionService encryptionService) { EncryptionService = encryptionService; } - public XElement ToElement(WireEcryptedString val, Func getNamespace) + public XElement ToElement(WireEncryptedString val, Func getNamespace) { var encryptedValue = EncryptionService.Encrypt(val); return new XElement(getNamespace(typeof(string)) + "Value", @@ -22,7 +22,7 @@ public XElement ToElement(WireEcryptedString val, Func getName encryptedValue.EncryptedBase64Value); } - public WireEcryptedString FromElement(XElement element) + public WireEncryptedString FromElement(XElement element) { var value = element.Element(XName.Get("Value","System.String")); if(value==null) diff --git a/Rhino.ServiceBus/DataStructures/WireEcryptedString.cs b/Rhino.ServiceBus/DataStructures/WireEcryptedString.cs deleted file mode 100644 index 53e230e..0000000 --- a/Rhino.ServiceBus/DataStructures/WireEcryptedString.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Rhino.ServiceBus.DataStructures -{ - public class WireEcryptedString - { - public string Value { get; set; } - - public static implicit operator string(WireEcryptedString s) - { - return s==null ? null : s.Value; - } - - public static implicit operator WireEcryptedString(string s) - { - return new WireEcryptedString {Value = s}; - } - } -} \ No newline at end of file diff --git a/Rhino.ServiceBus/DataStructures/WireEncryptedString.cs b/Rhino.ServiceBus/DataStructures/WireEncryptedString.cs new file mode 100644 index 0000000..89d393e --- /dev/null +++ b/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}; + } + } +} \ No newline at end of file diff --git a/Rhino.ServiceBus/Rhino.ServiceBus.csproj b/Rhino.ServiceBus/Rhino.ServiceBus.csproj index 4698e55..c723b96 100644 --- a/Rhino.ServiceBus/Rhino.ServiceBus.csproj +++ b/Rhino.ServiceBus/Rhino.ServiceBus.csproj @@ -160,12 +160,12 @@ - - + + - +