Ejemplo n.º 1
0
 public RedirectBindingElement(RedirectBindingElement other)
 {
     this.EnableRedirect          = other.EnableRedirect;
     this.IncludeExceptionDetails = other.IncludeExceptionDetails;
     this.UseSslStreamSecurity    = other.UseSslStreamSecurity;
     this.EndpointIdentity        = other.EndpointIdentity;
 }
Ejemplo n.º 2
0
 public RedirectContainerSessionChannel(RedirectBindingElement.RedirectContainerChannelFactory <IRequestSessionChannel> factory, EndpointAddress address, Uri via) : base(factory)
 {
     this.innerFactory   = factory.innerFactory;
     this.bindingElement = factory.BindingElement;
     this.RemoteAddress  = address;
     this.Via            = via;
     this.entityMap      = new ConcurrentDictionary <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkKey, RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue>();
     this.primaryChannel = this.innerFactory.CreateChannel(address, via);
     RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.OutputSession outputSession = new RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.OutputSession()
     {
         Id = this.primaryChannel.Session.Id
     };
     this.Session = outputSession;
     this.onCorrelatorNotifyCleanup        = new EventHandler(this.OnCorrelatorNotifyCleanup);
     this.correlatorManager                = new ContainerChannelManager(true, this.bindingElement.UseSslStreamSecurity, this.bindingElement.IncludeExceptionDetails, this.bindingElement.EndpointIdentity);
     this.correlatorManager.NotifyCleanup += new EventHandler(this.OnCorrelatorNotifyCleanup);
 }
Ejemplo n.º 3
0
 public RedirectContainerChannelFactory(BindingContext context, RedirectBindingElement bindingElement) : base(context.Binding)
 {
     this.BindingElement = bindingElement;
     this.innerFactory   = context.BuildInnerChannelFactory <TChannel>();
 }
        private void Initialize(bool useWebStream, bool useHttpsWebStream, IEnumerable <Uri> baseAddresses)
        {
            List <Uri> uris = new List <Uri>();

            foreach (Uri baseAddress in baseAddresses)
            {
                if (base.Address == null)
                {
                    base.Address = baseAddress;
                }
                UriBuilder uriBuilder = new UriBuilder(baseAddress);
                if (!this.Settings.GatewayMode && string.Compare(uriBuilder.Scheme, "sb", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    ExceptionTrace exception        = Microsoft.ServiceBus.Messaging.FxTrace.Exception;
                    string         invalidUriScheme = Resources.InvalidUriScheme;
                    object[]       scheme           = new object[] { uriBuilder.Scheme, "sb" };
                    throw exception.AsError(new ArgumentException(Microsoft.ServiceBus.SR.GetString(invalidUriScheme, scheme)), null);
                }
                if (!useWebStream)
                {
                    uriBuilder.Scheme = SbmpProtocolDefaults.TransportUriScheme;
                }
                else
                {
                    uriBuilder.Scheme = "sb";
                    uriBuilder.Port   = (useHttpsWebStream ? RelayEnvironment.RelayHttpsPort : RelayEnvironment.RelayHttpPort);
                }
                if (!this.Settings.GatewayMode && uriBuilder.Port == -1)
                {
                    if (!useWebStream)
                    {
                        uriBuilder.Port = RelayEnvironment.RelayNmfPort;
                    }
                    else
                    {
                        uriBuilder.Port = (useHttpsWebStream ? RelayEnvironment.RelayHttpsPort : RelayEnvironment.RelayHttpPort);
                    }
                }
                MessagingUtilities.EnsureTrailingSlash(uriBuilder);
                uris.Add(uriBuilder.Uri);
            }
            this.baseAddresses = null;
            this.BaseAddress   = uris.First <Uri>();
            bool          useSslStreamSecurity = this.Settings.UseSslStreamSecurity;
            CustomBinding customBinding        = SbmpProtocolDefaults.CreateBinding(false, useWebStream, useHttpsWebStream, 2147483647, useSslStreamSecurity, this.Settings.EndpointIdentity);
            DuplexRequestBindingElement duplexRequestBindingElement = new DuplexRequestBindingElement()
            {
                ClientMode = !this.Settings.GatewayMode,
                IncludeExceptionDetails = true
            };
            DuplexRequestBindingElement duplexRequestBindingElement1 = duplexRequestBindingElement;
            int num = 0;

            if (!this.Settings.GatewayMode)
            {
                RedirectBindingElement redirectBindingElement = new RedirectBindingElement()
                {
                    EnableRedirect          = this.Settings.EnableRedirect,
                    UseSslStreamSecurity    = useSslStreamSecurity,
                    IncludeExceptionDetails = true,
                    EndpointIdentity        = this.Settings.EndpointIdentity
                };
                RedirectBindingElement redirectBindingElement1 = redirectBindingElement;
                int num1 = num;
                num = num1 + 1;
                customBinding.Elements.Insert(num1, new ReconnectBindingElement(uris));
                int num2 = num;
                num = num2 + 1;
                customBinding.Elements.Insert(num2, redirectBindingElement1);
            }
            int num3 = num;

            num = num3 + 1;
            customBinding.Elements.Insert(num3, new ReconnectBindingElement(uris));
            int num4 = num;

            num = num4 + 1;
            customBinding.Elements.Insert(num4, duplexRequestBindingElement1);
            BindingParameterCollection bindingParameterCollection = new BindingParameterCollection();

            if (useSslStreamSecurity)
            {
                ClientCredentials clientCredential = new ClientCredentials();
                clientCredential.ServiceCertificate.Authentication.CertificateValidationMode  = X509CertificateValidationMode.Custom;
                clientCredential.ServiceCertificate.Authentication.CustomCertificateValidator = RetriableCertificateValidator.Instance;
                bindingParameterCollection.Add(clientCredential);
            }
            this.ChannelFactory  = customBinding.BuildChannelFactory <IRequestSessionChannel>(bindingParameterCollection);
            this.MessageVersion  = customBinding.MessageVersion;
            this.ResourceManager = SbmpResourceManager.Instance;
            this.acceptMessageSessionForNamespaceLinkSettings = new CreateControlLinkSettings(this, string.Empty, "||", MessagingEntityType.Namespace, null);
            EventHandler eventHandler = new EventHandler(this.OnInnerFactoryFaulted);

            this.ChannelFactory.SafeAddFaulted(eventHandler);
        }