diff --git a/src/mono/WampSharp/WampSharp.csproj b/src/mono/WampSharp/WampSharp.csproj index 7040d2990..bab04067c 100644 --- a/src/mono/WampSharp/WampSharp.csproj +++ b/src/mono/WampSharp/WampSharp.csproj @@ -891,6 +891,9 @@ WAMP2\V2\Client\Rpc\WampRpcOperationCatalogProxy.cs + + WAMP2\V2\Client\Session\IWampClientAutenticator.cs + WAMP2\V2\Client\Session\IWampSessionClientExtended.cs @@ -1217,4 +1220,4 @@ --> - \ No newline at end of file + diff --git a/src/net40/WampSharp/WampSharp.csproj b/src/net40/WampSharp/WampSharp.csproj index 9be50abae..df411b039 100644 --- a/src/net40/WampSharp/WampSharp.csproj +++ b/src/net40/WampSharp/WampSharp.csproj @@ -601,6 +601,9 @@ WAMP2\V2\Client\IWampPendingRequest.cs + + WAMP2\V2\Client\Session\IWampClientAutenticator.cs + WAMP2\V2\Client\Session\IWampClientConnectionMonitor.cs @@ -1221,4 +1224,4 @@ --> - \ No newline at end of file + diff --git a/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/App.config b/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/App.config new file mode 100644 index 000000000..fad249e40 --- /dev/null +++ b/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/Program.cs b/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/Program.cs new file mode 100644 index 000000000..b8a5c9b80 --- /dev/null +++ b/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/Program.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WampSharp.Binding; +using WampSharp.V2; +using WampSharp.V2.Client; +using WampSharp.V2.Rpc; + +namespace WampSharp.Samples.Authentication +{ + public interface IArgumentsService + { + [WampProcedure("com.timeservice.now")] + string timeservice(); + } + + public class CustomAuthenticator : IWampClientAutenticator + { + private string[] authenticationMethods; + private IDictionary tickets = new Dictionary() + { + { "peter", "md5f39d45e1da71cf755a7ee5d5840c7b0d" }, + { "joe", "magic_secret_2" } + }; + private string user = "peter"; + + public CustomAuthenticator() + { + this.authenticationMethods = new string[] { "ticket" }; + } + + public ChallengeResult Authenticate(string challenge, ChallengeDetails extra) + { + var challengeExtra = extra.OriginalValue.Deserialize>(); + + var method = (string)challengeExtra["authmethod"]; + Console.WriteLine(method); + foreach (var ce in challengeExtra) + { + Console.WriteLine(ce); + } + + if (method == "ticket") + { + Console.WriteLine("authenticating via '" + method + "'"); + var result = new ChallengeResult(); + result.Signature = tickets[user]; + result.Extra = new Dictionary() { }; + return result; + } + else + { + throw new WampAuthenticationException("don't know how to authenticate using '" + method + "'"); + } + } + + public string[] AuthenticationMethods + { + get { return authenticationMethods; } + } + + public string AuthenticationId + { + get { return user; } + } + } + + class Program + { + private static IWampRealmProxy proxy; + + private static void Test(IWampRealmServiceProvider serviceProvider) + { + IArgumentsService proxy = serviceProvider.GetCalleeProxy(); + string now; + try + { + now = proxy.timeservice(); + Console.WriteLine("call result {0}", now); + } + catch (Exception e) + { + Console.WriteLine("call error {0}", e); + } + } + + static void Main(string[] args) + { + string url = "ws://127.0.0.1:8080/"; + string realm = "integra-s"; + + DefaultWampChannelFactory channelFactory = new DefaultWampChannelFactory(); + + IWampClientAutenticator authenticator = new CustomAuthenticator(); + IWampChannel channel = channelFactory.CreateJsonChannel(url, realm, authenticator); + channel.RealmProxy.Monitor.ConnectionEstablished += Monitor_ConnectionEstablished; + channel.RealmProxy.Monitor.ConnectionBroken += Monitor_ConnectionBroken; + Program.proxy = channel.RealmProxy; + channel.Open().Wait(); + Test(channel.RealmProxy.Services); + Console.ReadLine(); + } + + static void Monitor_ConnectionEstablished(object sender, V2.Realm.WampSessionEventArgs e) + { + var details = e.Details.Deserialize>(); + + Console.WriteLine("connected session with ID " + e.SessionId); + Console.WriteLine("authenticated using method '" + details["authmethod"] + "' and provider '" + details["authprovider"] + "'"); + Console.WriteLine("authenticated with authid '" + details["authid"] + "' and authrole '" + details["authrole"] + "'"); + + //Test(Program.proxy.Services); + } + + static void Monitor_ConnectionBroken(object sender, V2.Realm.WampSessionCloseEventArgs e) + { + Console.WriteLine("disconnected {0}", e.Reason); + } + } +} \ No newline at end of file diff --git a/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/Properties/AssemblyInfo.cs b/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..6667a12af --- /dev/null +++ b/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WampSharp.Samples.Authentication")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WampSharp.Samples.Authentication")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3e3df86c-9d5d-45f5-858d-5e653c196d58")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/WampSharp.Samples.Authentication.csproj b/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/WampSharp.Samples.Authentication.csproj new file mode 100644 index 000000000..2407eec57 --- /dev/null +++ b/src/net45/Samples/WAMP2/WampSharp.Samples.Authentication/WampSharp.Samples.Authentication.csproj @@ -0,0 +1,68 @@ + + + + + Debug + AnyCPU + {305C0F3D-1A51-4D8C-8729-481F73A7C7D6} + Exe + Properties + WampSharp.Samples.Authentication + WampSharp.Samples.Authentication + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + {6ab75291-d296-457e-88a3-b41b16a1a247} + WampSharp.Default + + + {653a76dc-00d7-4eff-a25e-2fa10c5c927d} + WampSharp + + + + + \ No newline at end of file diff --git a/src/net45/WampSharp.Default/WAMP2/V2/DefaultWampChannelFactory.cs b/src/net45/WampSharp.Default/WAMP2/V2/DefaultWampChannelFactory.cs index bb3100afa..e43d3e158 100644 --- a/src/net45/WampSharp.Default/WAMP2/V2/DefaultWampChannelFactory.cs +++ b/src/net45/WampSharp.Default/WAMP2/V2/DefaultWampChannelFactory.cs @@ -11,7 +11,7 @@ namespace WampSharp.V2 public class DefaultWampChannelFactory : WampChannelFactory { private readonly JTokenMsgpackBinding mMsgpackBinding = new JTokenMsgpackBinding(); - private readonly JTokenJsonBinding mJsonBinding = new JTokenJsonBinding(); + private readonly JTokenJsonBinding mJsonBinding = new JTokenJsonBinding(); /// /// Creates a that connects to a given realm, @@ -26,9 +26,29 @@ public IWampChannel CreateChannel(string address, IWampTextBinding binding) { var connection = - new WebSocket4NetTextConnection(address, binding); - + new WebSocket4NetTextConnection(address, binding); + return this.CreateChannel(realm, connection, binding); + } + + /// + /// Creates a that connects to a given realm, + /// using the given address and the given text binding + /// + /// The given address. + /// The given realm to connect to. + /// The given text binding. + /// The authenticator object to handle CHALLENGE request. + /// + public IWampChannel CreateChannel(string address, + string realm, + IWampTextBinding binding, + IWampClientAutenticator autenticator) + { + var connection = + new WebSocket4NetTextConnection(address, binding); + + return this.CreateChannel(realm, connection, binding, autenticator); } /// @@ -44,11 +64,31 @@ public IWampChannel CreateChannel(string address, IWampBinaryBinding binding) { var connection = - new WebSocket4NetBinaryConnection(address, binding); - + new WebSocket4NetBinaryConnection(address, binding); + return this.CreateChannel(realm, connection, binding); } + /// + /// Creates a that connects to a given realm, + /// using the given address and the given binary binding + /// + /// The given address. + /// The given realm to connect to. + /// The given binary binding. + /// The authenticator object to handle CHALLENGE request. + /// + public IWampChannel CreateChannel(string address, + string realm, + IWampBinaryBinding binding, + IWampClientAutenticator autenticator) + { + var connection = + new WebSocket4NetBinaryConnection(address, binding); + + return this.CreateChannel(realm, connection, binding, autenticator); + } + /// /// Creates a that connects to a given realm, /// using the given address and json binding @@ -62,6 +102,21 @@ public IWampChannel CreateJsonChannel(string address, return this.CreateChannel(address, realm, mJsonBinding); } + /// + /// Creates a that connects to a given realm, + /// using the given address and json binding + /// + /// The given address. + /// The given realm to connect to. + /// The authenticator object to handle CHALLENGE request. + /// + public IWampChannel CreateJsonChannel(string address, + string realm, + IWampClientAutenticator autenticator) + { + return this.CreateChannel(address, realm, mJsonBinding, autenticator); + } + /// /// Creates a that connects to a given realm, /// using the given address and msgpack binding @@ -73,6 +128,21 @@ public IWampChannel CreateMsgpackChannel(string address, string realm) { return this.CreateChannel(address, realm, mMsgpackBinding); + } + + /// + /// Creates a that connects to a given realm, + /// using the given address and msgpack binding + /// + /// The given address. + /// The given realm to connect to. + /// The authenticator object to handle CHALLENGE request. + /// + public IWampChannel CreateMsgpackChannel(string address, + string realm, + IWampClientAutenticator autenticator) + { + return this.CreateChannel(address, realm, mMsgpackBinding, autenticator); } } } \ No newline at end of file diff --git a/src/net45/WampSharp.sln b/src/net45/WampSharp.sln index aafaed530..756853066 100644 --- a/src/net45/WampSharp.sln +++ b/src/net45/WampSharp.sln @@ -1,140 +1,145 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp", "WampSharp\WampSharp.csproj", "{653A76DC-00D7-4EFF-A25E-2FA10C5C927D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Default", "WampSharp.Default\WampSharp.Default.csproj", "{6AB75291-D296-457E-88A3-B41B16A1A247}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{33E2A6E5-246F-420B-A13C-AA4B617EBFB2}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WAMP1", "WAMP1", "{10B51C05-30BC-412A-BFFB-8C2C02753528}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WAMP2", "WAMP2", "{AF224856-8194-4CA0-92D9-03926B743987}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.PubSubServerSample", "Samples\WAMP1\WampSharp.PubSubServerSample\WampSharp.PubSubServerSample.csproj", "{AD5C9AA6-6810-488E-9EDD-FCC945AAD627}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.RpcClientSample", "Samples\WAMP1\WampSharp.RpcClientSample\WampSharp.RpcClientSample.csproj", "{2128E477-97B6-4224-A8A9-789F79514B41}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.RpcServerSample", "Samples\WAMP1\WampSharp.RpcServerSample\WampSharp.RpcServerSample.csproj", "{0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Callee", "Samples\WAMP2\WampSharp.Samples.Callee\WampSharp.Samples.Callee.csproj", "{7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{FA4B348E-3BBD-4F98-B429-891376EBA17E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.RawTcp", "Extensions\WampSharp.RawTcp\WampSharp.RawTcp.csproj", "{678473BD-87FC-4788-A444-4ABF45FDCFEC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Tests", "Tests\WampSharp.Tests\WampSharp.Tests.csproj", "{D3FB3310-A761-45B5-AC4B-78FE90C2829C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Tests.Wampv2", "Tests\WampSharp.Tests.Wampv2\WampSharp.Tests.Wampv2.csproj", "{710B61C1-E7E0-4D8F-BF39-F82086D610ED}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.SignalR", "Extensions\WampSharp.SignalR\WampSharp.SignalR.csproj", "{F5B01D7B-14C3-419C-9887-C0A24FF2DE59}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.CraClientSample", "Samples\WAMP1\WampSharp.CraClientSample\WampSharp.CraClientSample.csproj", "{6AD8C6F1-05AE-4826-BE27-BF54C73D6159}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.CraServerSample", "Samples\WAMP1\WampSharp.CraServerSample\WampSharp.CraServerSample.csproj", "{32A38656-5BAF-4D80-9780-95C3B594DA3F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Subscriber", "Samples\WAMP2\WampSharp.Samples.Subscriber\WampSharp.Samples.Subscriber.csproj", "{0EB744B6-235C-4460-B25C-EBC966201C26}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Caller", "Samples\WAMP2\WampSharp.Samples.Caller\WampSharp.Samples.Caller.csproj", "{7434FFFF-F5E5-48DF-9544-19131885FA4E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Publisher", "Samples\WAMP2\WampSharp.Samples.Publisher\WampSharp.Samples.Publisher.csproj", "{E924BD74-041F-4F3A-8041-FC7F8827728A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Vtortola", "Extensions\WampSharp.Vtortola\WampSharp.Vtortola.csproj", "{DE13BC69-B822-45EA-846F-DDEF66D34BD9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {653A76DC-00D7-4EFF-A25E-2FA10C5C927D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {653A76DC-00D7-4EFF-A25E-2FA10C5C927D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {653A76DC-00D7-4EFF-A25E-2FA10C5C927D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {653A76DC-00D7-4EFF-A25E-2FA10C5C927D}.Release|Any CPU.Build.0 = Release|Any CPU - {6AB75291-D296-457E-88A3-B41B16A1A247}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6AB75291-D296-457E-88A3-B41B16A1A247}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6AB75291-D296-457E-88A3-B41B16A1A247}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6AB75291-D296-457E-88A3-B41B16A1A247}.Release|Any CPU.Build.0 = Release|Any CPU - {AD5C9AA6-6810-488E-9EDD-FCC945AAD627}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AD5C9AA6-6810-488E-9EDD-FCC945AAD627}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AD5C9AA6-6810-488E-9EDD-FCC945AAD627}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AD5C9AA6-6810-488E-9EDD-FCC945AAD627}.Release|Any CPU.Build.0 = Release|Any CPU - {2128E477-97B6-4224-A8A9-789F79514B41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2128E477-97B6-4224-A8A9-789F79514B41}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2128E477-97B6-4224-A8A9-789F79514B41}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2128E477-97B6-4224-A8A9-789F79514B41}.Release|Any CPU.Build.0 = Release|Any CPU - {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}.Release|Any CPU.Build.0 = Release|Any CPU - {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}.Release|Any CPU.Build.0 = Release|Any CPU - {678473BD-87FC-4788-A444-4ABF45FDCFEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {678473BD-87FC-4788-A444-4ABF45FDCFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {678473BD-87FC-4788-A444-4ABF45FDCFEC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {678473BD-87FC-4788-A444-4ABF45FDCFEC}.Release|Any CPU.Build.0 = Release|Any CPU - {D3FB3310-A761-45B5-AC4B-78FE90C2829C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D3FB3310-A761-45B5-AC4B-78FE90C2829C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D3FB3310-A761-45B5-AC4B-78FE90C2829C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D3FB3310-A761-45B5-AC4B-78FE90C2829C}.Release|Any CPU.Build.0 = Release|Any CPU - {710B61C1-E7E0-4D8F-BF39-F82086D610ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {710B61C1-E7E0-4D8F-BF39-F82086D610ED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {710B61C1-E7E0-4D8F-BF39-F82086D610ED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {710B61C1-E7E0-4D8F-BF39-F82086D610ED}.Release|Any CPU.Build.0 = Release|Any CPU - {F5B01D7B-14C3-419C-9887-C0A24FF2DE59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F5B01D7B-14C3-419C-9887-C0A24FF2DE59}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F5B01D7B-14C3-419C-9887-C0A24FF2DE59}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F5B01D7B-14C3-419C-9887-C0A24FF2DE59}.Release|Any CPU.Build.0 = Release|Any CPU - {6AD8C6F1-05AE-4826-BE27-BF54C73D6159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6AD8C6F1-05AE-4826-BE27-BF54C73D6159}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6AD8C6F1-05AE-4826-BE27-BF54C73D6159}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6AD8C6F1-05AE-4826-BE27-BF54C73D6159}.Release|Any CPU.Build.0 = Release|Any CPU - {32A38656-5BAF-4D80-9780-95C3B594DA3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {32A38656-5BAF-4D80-9780-95C3B594DA3F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {32A38656-5BAF-4D80-9780-95C3B594DA3F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {32A38656-5BAF-4D80-9780-95C3B594DA3F}.Release|Any CPU.Build.0 = Release|Any CPU - {0EB744B6-235C-4460-B25C-EBC966201C26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0EB744B6-235C-4460-B25C-EBC966201C26}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0EB744B6-235C-4460-B25C-EBC966201C26}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0EB744B6-235C-4460-B25C-EBC966201C26}.Release|Any CPU.Build.0 = Release|Any CPU - {7434FFFF-F5E5-48DF-9544-19131885FA4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7434FFFF-F5E5-48DF-9544-19131885FA4E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7434FFFF-F5E5-48DF-9544-19131885FA4E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7434FFFF-F5E5-48DF-9544-19131885FA4E}.Release|Any CPU.Build.0 = Release|Any CPU - {E924BD74-041F-4F3A-8041-FC7F8827728A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E924BD74-041F-4F3A-8041-FC7F8827728A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E924BD74-041F-4F3A-8041-FC7F8827728A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E924BD74-041F-4F3A-8041-FC7F8827728A}.Release|Any CPU.Build.0 = Release|Any CPU - {DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {10B51C05-30BC-412A-BFFB-8C2C02753528} = {33E2A6E5-246F-420B-A13C-AA4B617EBFB2} - {AF224856-8194-4CA0-92D9-03926B743987} = {33E2A6E5-246F-420B-A13C-AA4B617EBFB2} - {AD5C9AA6-6810-488E-9EDD-FCC945AAD627} = {10B51C05-30BC-412A-BFFB-8C2C02753528} - {2128E477-97B6-4224-A8A9-789F79514B41} = {10B51C05-30BC-412A-BFFB-8C2C02753528} - {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77} = {10B51C05-30BC-412A-BFFB-8C2C02753528} - {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F} = {AF224856-8194-4CA0-92D9-03926B743987} - {678473BD-87FC-4788-A444-4ABF45FDCFEC} = {FA4B348E-3BBD-4F98-B429-891376EBA17E} - {D3FB3310-A761-45B5-AC4B-78FE90C2829C} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E} - {710B61C1-E7E0-4D8F-BF39-F82086D610ED} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E} - {F5B01D7B-14C3-419C-9887-C0A24FF2DE59} = {FA4B348E-3BBD-4F98-B429-891376EBA17E} - {6AD8C6F1-05AE-4826-BE27-BF54C73D6159} = {10B51C05-30BC-412A-BFFB-8C2C02753528} - {32A38656-5BAF-4D80-9780-95C3B594DA3F} = {10B51C05-30BC-412A-BFFB-8C2C02753528} - {0EB744B6-235C-4460-B25C-EBC966201C26} = {AF224856-8194-4CA0-92D9-03926B743987} - {7434FFFF-F5E5-48DF-9544-19131885FA4E} = {AF224856-8194-4CA0-92D9-03926B743987} - {E924BD74-041F-4F3A-8041-FC7F8827728A} = {AF224856-8194-4CA0-92D9-03926B743987} - {DE13BC69-B822-45EA-846F-DDEF66D34BD9} = {FA4B348E-3BBD-4F98-B429-891376EBA17E} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp", "WampSharp\WampSharp.csproj", "{653A76DC-00D7-4EFF-A25E-2FA10C5C927D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Default", "WampSharp.Default\WampSharp.Default.csproj", "{6AB75291-D296-457E-88A3-B41B16A1A247}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{33E2A6E5-246F-420B-A13C-AA4B617EBFB2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WAMP1", "WAMP1", "{10B51C05-30BC-412A-BFFB-8C2C02753528}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WAMP2", "WAMP2", "{AF224856-8194-4CA0-92D9-03926B743987}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.PubSubServerSample", "Samples\WAMP1\WampSharp.PubSubServerSample\WampSharp.PubSubServerSample.csproj", "{AD5C9AA6-6810-488E-9EDD-FCC945AAD627}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.RpcClientSample", "Samples\WAMP1\WampSharp.RpcClientSample\WampSharp.RpcClientSample.csproj", "{2128E477-97B6-4224-A8A9-789F79514B41}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.RpcServerSample", "Samples\WAMP1\WampSharp.RpcServerSample\WampSharp.RpcServerSample.csproj", "{0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Callee", "Samples\WAMP2\WampSharp.Samples.Callee\WampSharp.Samples.Callee.csproj", "{7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{FA4B348E-3BBD-4F98-B429-891376EBA17E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.RawTcp", "Extensions\WampSharp.RawTcp\WampSharp.RawTcp.csproj", "{678473BD-87FC-4788-A444-4ABF45FDCFEC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Tests", "Tests\WampSharp.Tests\WampSharp.Tests.csproj", "{D3FB3310-A761-45B5-AC4B-78FE90C2829C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Tests.Wampv2", "Tests\WampSharp.Tests.Wampv2\WampSharp.Tests.Wampv2.csproj", "{710B61C1-E7E0-4D8F-BF39-F82086D610ED}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.SignalR", "Extensions\WampSharp.SignalR\WampSharp.SignalR.csproj", "{F5B01D7B-14C3-419C-9887-C0A24FF2DE59}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.CraClientSample", "Samples\WAMP1\WampSharp.CraClientSample\WampSharp.CraClientSample.csproj", "{6AD8C6F1-05AE-4826-BE27-BF54C73D6159}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.CraServerSample", "Samples\WAMP1\WampSharp.CraServerSample\WampSharp.CraServerSample.csproj", "{32A38656-5BAF-4D80-9780-95C3B594DA3F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Subscriber", "Samples\WAMP2\WampSharp.Samples.Subscriber\WampSharp.Samples.Subscriber.csproj", "{0EB744B6-235C-4460-B25C-EBC966201C26}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Caller", "Samples\WAMP2\WampSharp.Samples.Caller\WampSharp.Samples.Caller.csproj", "{7434FFFF-F5E5-48DF-9544-19131885FA4E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Publisher", "Samples\WAMP2\WampSharp.Samples.Publisher\WampSharp.Samples.Publisher.csproj", "{E924BD74-041F-4F3A-8041-FC7F8827728A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Vtortola", "Extensions\WampSharp.Vtortola\WampSharp.Vtortola.csproj", "{DE13BC69-B822-45EA-846F-DDEF66D34BD9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Authentication", "Samples\WAMP2\WampSharp.Samples.Authentication\WampSharp.Samples.Authentication.csproj", "{305C0F3D-1A51-4D8C-8729-481F73A7C7D6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {653A76DC-00D7-4EFF-A25E-2FA10C5C927D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {653A76DC-00D7-4EFF-A25E-2FA10C5C927D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {653A76DC-00D7-4EFF-A25E-2FA10C5C927D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {653A76DC-00D7-4EFF-A25E-2FA10C5C927D}.Release|Any CPU.Build.0 = Release|Any CPU + {6AB75291-D296-457E-88A3-B41B16A1A247}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6AB75291-D296-457E-88A3-B41B16A1A247}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6AB75291-D296-457E-88A3-B41B16A1A247}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6AB75291-D296-457E-88A3-B41B16A1A247}.Release|Any CPU.Build.0 = Release|Any CPU + {AD5C9AA6-6810-488E-9EDD-FCC945AAD627}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD5C9AA6-6810-488E-9EDD-FCC945AAD627}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD5C9AA6-6810-488E-9EDD-FCC945AAD627}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD5C9AA6-6810-488E-9EDD-FCC945AAD627}.Release|Any CPU.Build.0 = Release|Any CPU + {2128E477-97B6-4224-A8A9-789F79514B41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2128E477-97B6-4224-A8A9-789F79514B41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2128E477-97B6-4224-A8A9-789F79514B41}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2128E477-97B6-4224-A8A9-789F79514B41}.Release|Any CPU.Build.0 = Release|Any CPU + {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77}.Release|Any CPU.Build.0 = Release|Any CPU + {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F}.Release|Any CPU.Build.0 = Release|Any CPU + {678473BD-87FC-4788-A444-4ABF45FDCFEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {678473BD-87FC-4788-A444-4ABF45FDCFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {678473BD-87FC-4788-A444-4ABF45FDCFEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {678473BD-87FC-4788-A444-4ABF45FDCFEC}.Release|Any CPU.Build.0 = Release|Any CPU + {D3FB3310-A761-45B5-AC4B-78FE90C2829C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3FB3310-A761-45B5-AC4B-78FE90C2829C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3FB3310-A761-45B5-AC4B-78FE90C2829C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3FB3310-A761-45B5-AC4B-78FE90C2829C}.Release|Any CPU.Build.0 = Release|Any CPU + {710B61C1-E7E0-4D8F-BF39-F82086D610ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {710B61C1-E7E0-4D8F-BF39-F82086D610ED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {710B61C1-E7E0-4D8F-BF39-F82086D610ED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {710B61C1-E7E0-4D8F-BF39-F82086D610ED}.Release|Any CPU.Build.0 = Release|Any CPU + {F5B01D7B-14C3-419C-9887-C0A24FF2DE59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5B01D7B-14C3-419C-9887-C0A24FF2DE59}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5B01D7B-14C3-419C-9887-C0A24FF2DE59}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5B01D7B-14C3-419C-9887-C0A24FF2DE59}.Release|Any CPU.Build.0 = Release|Any CPU + {6AD8C6F1-05AE-4826-BE27-BF54C73D6159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6AD8C6F1-05AE-4826-BE27-BF54C73D6159}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6AD8C6F1-05AE-4826-BE27-BF54C73D6159}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6AD8C6F1-05AE-4826-BE27-BF54C73D6159}.Release|Any CPU.Build.0 = Release|Any CPU + {32A38656-5BAF-4D80-9780-95C3B594DA3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32A38656-5BAF-4D80-9780-95C3B594DA3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32A38656-5BAF-4D80-9780-95C3B594DA3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32A38656-5BAF-4D80-9780-95C3B594DA3F}.Release|Any CPU.Build.0 = Release|Any CPU + {0EB744B6-235C-4460-B25C-EBC966201C26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0EB744B6-235C-4460-B25C-EBC966201C26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0EB744B6-235C-4460-B25C-EBC966201C26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0EB744B6-235C-4460-B25C-EBC966201C26}.Release|Any CPU.Build.0 = Release|Any CPU + {7434FFFF-F5E5-48DF-9544-19131885FA4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7434FFFF-F5E5-48DF-9544-19131885FA4E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7434FFFF-F5E5-48DF-9544-19131885FA4E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7434FFFF-F5E5-48DF-9544-19131885FA4E}.Release|Any CPU.Build.0 = Release|Any CPU + {E924BD74-041F-4F3A-8041-FC7F8827728A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E924BD74-041F-4F3A-8041-FC7F8827728A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E924BD74-041F-4F3A-8041-FC7F8827728A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E924BD74-041F-4F3A-8041-FC7F8827728A}.Release|Any CPU.Build.0 = Release|Any CPU + {DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Release|Any CPU.Build.0 = Release|Any CPU + {305C0F3D-1A51-4D8C-8729-481F73A7C7D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {305C0F3D-1A51-4D8C-8729-481F73A7C7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {305C0F3D-1A51-4D8C-8729-481F73A7C7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {305C0F3D-1A51-4D8C-8729-481F73A7C7D6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {10B51C05-30BC-412A-BFFB-8C2C02753528} = {33E2A6E5-246F-420B-A13C-AA4B617EBFB2} + {AF224856-8194-4CA0-92D9-03926B743987} = {33E2A6E5-246F-420B-A13C-AA4B617EBFB2} + {AD5C9AA6-6810-488E-9EDD-FCC945AAD627} = {10B51C05-30BC-412A-BFFB-8C2C02753528} + {2128E477-97B6-4224-A8A9-789F79514B41} = {10B51C05-30BC-412A-BFFB-8C2C02753528} + {0A431511-B51D-42A2-AE0F-DEFCDB9FCE77} = {10B51C05-30BC-412A-BFFB-8C2C02753528} + {6AD8C6F1-05AE-4826-BE27-BF54C73D6159} = {10B51C05-30BC-412A-BFFB-8C2C02753528} + {32A38656-5BAF-4D80-9780-95C3B594DA3F} = {10B51C05-30BC-412A-BFFB-8C2C02753528} + {7D74C7E0-3F4E-4C60-BC75-C5086706CF7F} = {AF224856-8194-4CA0-92D9-03926B743987} + {0EB744B6-235C-4460-B25C-EBC966201C26} = {AF224856-8194-4CA0-92D9-03926B743987} + {7434FFFF-F5E5-48DF-9544-19131885FA4E} = {AF224856-8194-4CA0-92D9-03926B743987} + {E924BD74-041F-4F3A-8041-FC7F8827728A} = {AF224856-8194-4CA0-92D9-03926B743987} + {305C0F3D-1A51-4D8C-8729-481F73A7C7D6} = {AF224856-8194-4CA0-92D9-03926B743987} + {D3FB3310-A761-45B5-AC4B-78FE90C2829C} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E} + {710B61C1-E7E0-4D8F-BF39-F82086D610ED} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E} + {678473BD-87FC-4788-A444-4ABF45FDCFEC} = {FA4B348E-3BBD-4F98-B429-891376EBA17E} + {F5B01D7B-14C3-419C-9887-C0A24FF2DE59} = {FA4B348E-3BBD-4F98-B429-891376EBA17E} + {DE13BC69-B822-45EA-846F-DDEF66D34BD9} = {FA4B348E-3BBD-4F98-B429-891376EBA17E} + EndGlobalSection +EndGlobal diff --git a/src/net45/WampSharp/WAMP2/V2/Api/Client/IWampChannelFactory.cs b/src/net45/WampSharp/WAMP2/V2/Api/Client/IWampChannelFactory.cs index c158b971d..398ae6759 100644 --- a/src/net45/WampSharp/WAMP2/V2/Api/Client/IWampChannelFactory.cs +++ b/src/net45/WampSharp/WAMP2/V2/Api/Client/IWampChannelFactory.cs @@ -20,6 +20,22 @@ public interface IWampChannelFactory IWampChannel CreateChannel (string realm, IControlledWampConnection connection, - IWampBinding binding); + IWampBinding binding); + + /// + /// Creates a that connects to a given realm, + /// using the given connection and the given binding. + /// + /// + /// The given realm to connect to. + /// The connection to use to connect to the router. + /// The binding to use to communicate with the router. + /// The authenticator object to handle CHALLENGE request. + /// + IWampChannel CreateChannel + (string realm, + IControlledWampConnection connection, + IWampBinding binding, + IWampClientAutenticator authenticator); } } \ No newline at end of file diff --git a/src/net45/WampSharp/WAMP2/V2/Client/Realm/WampRealmProxy.cs b/src/net45/WampSharp/WAMP2/V2/Client/Realm/WampRealmProxy.cs index d61fdc6fb..9e171f13c 100644 --- a/src/net45/WampSharp/WAMP2/V2/Client/Realm/WampRealmProxy.cs +++ b/src/net45/WampSharp/WAMP2/V2/Client/Realm/WampRealmProxy.cs @@ -15,17 +15,19 @@ internal class WampRealmProxy : IWampRealmProxy private readonly string mName; private readonly IWampServerProxy mProxy; private readonly IWampRealmServiceProvider mServices; - private readonly WampSessionClient mMonitor; - - public WampRealmProxy(string name, IWampServerProxy proxy, IWampBinding binding) + private readonly WampSessionClient mMonitor; + private readonly IWampClientAutenticator mAuthenticator; + + public WampRealmProxy(string name, IWampServerProxy proxy, IWampBinding binding, IWampClientAutenticator authenticator) { mName = name; mProxy = proxy; - IWampFormatter formatter = binding.Formatter; - mMonitor = new WampSessionClient(this, formatter); + IWampFormatter formatter = binding.Formatter; + mMonitor = new WampSessionClient(this, formatter, authenticator); mRpcCatalog = new WampRpcOperationCatalogProxy(proxy, formatter, mMonitor); mTopicContainer = new WampTopicContainerProxy(proxy, formatter, mMonitor); - mServices = new WampRealmProxyServiceProvider(this); + mServices = new WampRealmProxyServiceProvider(this); + mAuthenticator = authenticator; } public string Name @@ -68,6 +70,14 @@ public IWampClientConnectionMonitor Monitor { return mMonitor; } + } + + public IWampClientAutenticator Autenticator + { + get + { + return mAuthenticator; + } } } } \ No newline at end of file diff --git a/src/net45/WampSharp/WAMP2/V2/Client/Session/IWampClientAutenticator.cs b/src/net45/WampSharp/WAMP2/V2/Client/Session/IWampClientAutenticator.cs new file mode 100644 index 000000000..b6c3fed8f --- /dev/null +++ b/src/net45/WampSharp/WAMP2/V2/Client/Session/IWampClientAutenticator.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using WampSharp.V2.Core.Contracts; + +namespace WampSharp +{ + public interface IWampClientAutenticator + { + ChallengeResult Authenticate(string challenge, ChallengeDetails extra); + + string[] AuthenticationMethods + { + get; + } + + string AuthenticationId + { + get; + } + } + + public class ChallengeDetails : WampDetailsOptions + { + } + + public class ChallengeResult + { + public string Signature + { + get; + set; + } + + public IDictionary Extra + { + get; + set; + } + } + + [Serializable] + public class WampAuthenticationException : Exception + { + public WampAuthenticationException() { } + + public WampAuthenticationException(string message) : base(message) { } + + public WampAuthenticationException(string message, Exception inner) : base(message, inner) { } + + protected WampAuthenticationException( + System.Runtime.Serialization.SerializationInfo info, + System.Runtime.Serialization.StreamingContext context) + : base(info, context) { } + } + + /// + /// A default implementation of . + /// + public class DefaultWampClientAutenticator : IWampClientAutenticator + { + /// + /// Just throws exception on CHALLENGE + /// + /// + /// + /// + public ChallengeResult Authenticate(string challenge, ChallengeDetails extra) + { + throw new WampAuthenticationException("Authorization was requested but no authenticator was provided"); + } + + public string[] AuthenticationMethods + { + get { return null; } + } + + public string AuthenticationId + { + get { return null; } + } + } +} \ No newline at end of file diff --git a/src/net45/WampSharp/WAMP2/V2/Client/Session/WampSessionClient.cs b/src/net45/WampSharp/WAMP2/V2/Client/Session/WampSessionClient.cs index 5a0753b69..ae9a14309 100644 --- a/src/net45/WampSharp/WAMP2/V2/Client/Session/WampSessionClient.cs +++ b/src/net45/WampSharp/WAMP2/V2/Client/Session/WampSessionClient.cs @@ -22,7 +22,8 @@ public class WampSessionClient : IWampSessionClientExtended, private readonly IWampFormatter mFormatter; private readonly object mLock = new object(); private bool mGoodbyeSent; - private readonly IDictionary mDetails = GetDetails(); + private readonly IDictionary mDetails = GetDetails(); + private readonly IWampClientAutenticator mAuthenticator; private static Dictionary GetDetails() { @@ -76,18 +77,25 @@ private static Dictionary GetDetails() } } }; - } - - public WampSessionClient(IWampRealmProxy realm, IWampFormatter formatter) + } + + public WampSessionClient(IWampRealmProxy realm, IWampFormatter formatter, IWampClientAutenticator authenticator) { mRealm = realm; mFormatter = formatter; - mServerProxy = realm.Proxy; + mServerProxy = realm.Proxy; + mAuthenticator = authenticator ?? new DefaultWampClientAutenticator(); } - public void Challenge(string challenge, TMessage extra) - { - throw new System.NotImplementedException(); + public void Challenge(string challenge, ChallengeDetails extra) + { + ChallengeResult result = mAuthenticator.Authenticate(challenge, extra); + + IDictionary authenticationExtraData = result.Extra ?? EmptyDetails; + + string authenticationSignature = result.Signature; + + mServerProxy.Authenticate(authenticationSignature, authenticationExtraData); } public void Welcome(long session, TMessage details) @@ -170,10 +178,22 @@ public void Close(string reason, object details) } public void OnConnectionOpen() - { + { + var details = new Dictionary(mDetails); + + if (mAuthenticator.AuthenticationId != null) + { + details.Add("authid", mAuthenticator.AuthenticationId); + } + + if (mAuthenticator.AuthenticationMethods != null) + { + details.Add("authmethods", mAuthenticator.AuthenticationMethods); + } + mServerProxy.Hello - (Realm.Name, - mDetails); + (Realm.Name, + details); } public void OnConnectionClosed() diff --git a/src/net45/WampSharp/WAMP2/V2/Client/WampChannelBuilder.cs b/src/net45/WampSharp/WAMP2/V2/Client/WampChannelBuilder.cs index 6ee78af48..599e42c28 100644 --- a/src/net45/WampSharp/WAMP2/V2/Client/WampChannelBuilder.cs +++ b/src/net45/WampSharp/WAMP2/V2/Client/WampChannelBuilder.cs @@ -25,13 +25,25 @@ public WampChannelBuilder(IWampBinding binding) new WampOutgoingRequestSerializer(formatter), new WampServerProxyOutgoingMessageHandlerBuilder> (new WampServerProxyIncomingMessageHandlerBuilder>(formatter))); + } + + + public WampChannel CreateChannel(string realm, IControlledWampConnection connection) + { + var wampRealmProxyFactory = + new WampRealmProxyFactory(this, realm, connection); + + WampClient client = + new WampClient(wampRealmProxyFactory); + + return new WampChannel(connection, client); } - - public WampChannel CreateChannel(string realm, IControlledWampConnection connection) + public WampChannel CreateChannel(string realm, IControlledWampConnection connection, + IWampClientAutenticator authenticator) { - var wampRealmProxyFactory = - new WampRealmProxyFactory(this, realm, connection); + var wampRealmProxyFactory = + new WampRealmProxyFactory(this, realm, connection, authenticator); WampClient client = new WampClient(wampRealmProxyFactory); @@ -43,23 +55,33 @@ private class WampRealmProxyFactory : IWampRealmProxyFactory { private readonly WampChannelBuilder mParent; private readonly string mRealmName; - private readonly IWampConnection mConnection; + private readonly IWampConnection mConnection; + private readonly IWampClientAutenticator mAuthenticator; + + public WampRealmProxyFactory(WampChannelBuilder parent, + string realmName, + IWampConnection connection) + { + mParent = parent; + mRealmName = realmName; + mConnection = connection; + } public WampRealmProxyFactory(WampChannelBuilder parent, - string realmName, - IWampConnection connection) + string realmName, + IWampConnection connection, + IWampClientAutenticator authenticator) + : this(parent, realmName, connection) { - mParent = parent; - mRealmName = realmName; - mConnection = connection; + mAuthenticator = authenticator; } public IWampRealmProxy Build(WampClient client) { IWampServerProxy proxy = mParent.mFactory.Create(client, mConnection); - WampRealmProxy realm = - new WampRealmProxy(mRealmName, proxy, mParent.mBinding); + WampRealmProxy realm = + new WampRealmProxy(mRealmName, proxy, mParent.mBinding, mAuthenticator); return realm; } diff --git a/src/net45/WampSharp/WAMP2/V2/Client/WampChannelFactory.cs b/src/net45/WampSharp/WAMP2/V2/Client/WampChannelFactory.cs index dac5868bd..1ae5e3344 100644 --- a/src/net45/WampSharp/WAMP2/V2/Client/WampChannelFactory.cs +++ b/src/net45/WampSharp/WAMP2/V2/Client/WampChannelFactory.cs @@ -18,6 +18,14 @@ public IWampChannel CreateChannel(string realm, IControlledWampConnect WampChannelBuilder builder = GetChannelBuilder(binding); WampChannel channel = builder.CreateChannel(realm, connection); return channel; + } + + public IWampChannel CreateChannel(string realm, IControlledWampConnection connection, + IWampBinding binding, IWampClientAutenticator authenticator) + { + WampChannelBuilder builder = GetChannelBuilder(binding); + WampChannel channel = builder.CreateChannel(realm, connection, authenticator); + return channel; } private WampChannelBuilder GetChannelBuilder(IWampBinding binding) diff --git a/src/net45/WampSharp/WAMP2/V2/Client/WampClient.cs b/src/net45/WampSharp/WAMP2/V2/Client/WampClient.cs index 75e0c7359..a5cc51192 100644 --- a/src/net45/WampSharp/WAMP2/V2/Client/WampClient.cs +++ b/src/net45/WampSharp/WAMP2/V2/Client/WampClient.cs @@ -102,7 +102,7 @@ public Task OpenTask get { return SessionClient.OpenTask; } } - public void Challenge(string challenge, TMessage extra) + public void Challenge(string challenge, ChallengeDetails extra) { SessionClient.Challenge(challenge, extra); } diff --git a/src/net45/WampSharp/WAMP2/V2/Core/Contracts/Proxy/IWampSessionProxy.cs b/src/net45/WampSharp/WAMP2/V2/Core/Contracts/Proxy/IWampSessionProxy.cs index f8ca881d4..620e3c633 100644 --- a/src/net45/WampSharp/WAMP2/V2/Core/Contracts/Proxy/IWampSessionProxy.cs +++ b/src/net45/WampSharp/WAMP2/V2/Core/Contracts/Proxy/IWampSessionProxy.cs @@ -1,4 +1,5 @@ -using WampSharp.Core.Contracts; +using System.Collections.Generic; +using WampSharp.Core.Contracts; using WampSharp.Core.Message; namespace WampSharp.V2.Core.Contracts @@ -32,7 +33,7 @@ public interface IWampSessionProxy /// A signature. /// Extra data. [WampHandler(WampMessageType.v2Authenticate)] - void Authenticate(string signature, TMessage extra); + void Authenticate(string signature, IDictionary extra); /// /// Sends a GOODBYE message. diff --git a/src/net45/WampSharp/WAMP2/V2/Core/Contracts/Session/IWampSessionClient.cs b/src/net45/WampSharp/WAMP2/V2/Core/Contracts/Session/IWampSessionClient.cs index 12f0d023e..c618da0a7 100644 --- a/src/net45/WampSharp/WAMP2/V2/Core/Contracts/Session/IWampSessionClient.cs +++ b/src/net45/WampSharp/WAMP2/V2/Core/Contracts/Session/IWampSessionClient.cs @@ -10,7 +10,7 @@ public interface IWampSessionClient : IWampSessionClient public interface IWampSessionClient { [WampHandler(WampMessageType.v2Challenge)] - void Challenge(string challenge, TMessage extra); + void Challenge(string challenge, ChallengeDetails extra); [WampHandler(WampMessageType.v2Welcome)] void Welcome(long session, TMessage details); diff --git a/src/net45/WampSharp/WampSharp.csproj b/src/net45/WampSharp/WampSharp.csproj index cc6307315..1f429c4d1 100644 --- a/src/net45/WampSharp/WampSharp.csproj +++ b/src/net45/WampSharp/WampSharp.csproj @@ -341,6 +341,7 @@ + @@ -459,4 +460,4 @@ --> - \ No newline at end of file +