コード例 #1
0
        private TransportClientEndpointBehavior GetACSSecurity(string issuerName, string issuerKey)
        {
            TransportClientEndpointBehavior behavior = new TransportClientEndpointBehavior();

            behavior.TokenProvider = SharedSecretTokenProvider.CreateSharedSecretTokenProvider(issuerName, Encoding.ASCII.GetBytes(issuerKey));

            return(behavior);
        }
コード例 #2
0
        public static TransportClientEndpointBehavior GetUsernamePasswordBehavior(string issuerName, string issuerKey)
        {
            TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();

            sharedSecretServiceBusCredential.TokenProvider = SharedSecretTokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerKey);

            return(sharedSecretServiceBusCredential);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            try
            {
                string serviceNamespaceDomain = ServiceBusHelper.GetServiceBusSolutionName();
                string issuerName             = "owner";
                string issuerSecret           = "wJBJaobUmarWn6kqv7QpaaRh3ttNVr3w1OjiotVEOL4=";
                ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;

                TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();
                relayCredentials.TokenProvider = SharedSecretTokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret);
                Uri serviceAddress = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespaceDomain,
                                                                            "Gateway/MulticastService/");
                ServiceHost host = new ServiceHost(typeof(MulticastGatewayOperations), serviceAddress);
                host.Description.Endpoints[0].Behaviors.Add(relayCredentials);
                host.Open();


                Console.WriteLine("ServiceUri:" + serviceAddress.ToString());

                Console.WriteLine("Service registered for public discovery.");
                NetEventRelayBinding binding = host.Description.Endpoints[0].Binding as NetEventRelayBinding;
                if (binding != null)
                {
                    Console.WriteLine("Scheme:" + binding.Scheme);
                    Console.WriteLine("Security Mode:" + binding.Security.Mode);
                    Console.WriteLine("Security RelayAuthType:" + binding.Security.RelayClientAuthenticationType.ToString());
                    Console.WriteLine("Security Transport.ProtectionLevel:" + binding.Security.Transport.ProtectionLevel.ToString());
                }
                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();

                host.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #4
0
        private void InitNetTcpRelayServer()
        {
            try
            {
                string issuerName             = tsSolutionName.Text;
                string issuerKey              = tsSolutionPassword.Text;
                string serviceNamespaceDomain = tsSolutionToConnect.Text;



                TransportClientEndpointBehavior behavior = new TransportClientEndpointBehavior();
                behavior.TokenProvider = SharedSecretTokenProvider.CreateSharedSecretTokenProvider(issuerName, Encoding.ASCII.GetBytes(issuerKey));

                Uri address = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespaceDomain, ServiceBusHelper.GetGatewayServicePath(tsGatewayId.Text));
                //For WS2207HttpRelayBinding
                // Uri address = ServiceBusEnvironment.CreateServiceUri("http", serviceNamespaceDomain, ServiceBusHelper.GetGatewayServicePath(tsGatewayId.Text));
                serviceUri = address.ToString();
                server     = new ServiceHost(this, address);

                server.Description.Endpoints[0].Behaviors.Add(behavior);

                ServiceRegistrySettings settings = new ServiceRegistrySettings();
                settings.DiscoveryMode = DiscoveryType.Public;
                settings.DisplayName   = address.ToString();
                foreach (ServiceEndpoint se in server.Description.Endpoints)
                {
                    se.Behaviors.Add(settings);
                }

                server.Open();
                AddLog("Gateway Server Running with ServiceUri:" + address.ToString());

                AddLog("Service registered for public discovery.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }