public RelayedOnewayTcpSender(BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement, Uri uri, bool transportProtectionEnabled, EventTraceActivity activity)
 {
     this.client             = new RelayedOnewayTcpSender.RelayedOnewayTcpSenderClient(context, transportBindingElement, uri, transportProtectionEnabled, activity);
     this.client.Connecting += new EventHandler(this.OnConnecting);
     this.client.Online     += new EventHandler(this.OnOnline);
     this.client.Offline    += new EventHandler(this.OnOffline);
 }
        public RelayedOnewayChannelListener(BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement) : base(context.Binding)
        {
            this.nameSettings = context.BindingParameters.Find <Microsoft.ServiceBus.NameSettings>();
            if (this.nameSettings == null)
            {
                this.nameSettings = new Microsoft.ServiceBus.NameSettings();
                this.nameSettings.ServiceSettings.ListenerType = ListenerType.Unicast;
            }
            this.scheme         = context.Binding.Scheme;
            this.messageVersion = context.Binding.MessageVersion;
            switch (context.ListenUriMode)
            {
            case ListenUriMode.Explicit:
            {
                this.SetUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress);
                break;
            }

            case ListenUriMode.Unique:
            {
                this.SetUniqueUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress);
                break;
            }
            }
            this.channel  = new RelayedOnewayChannelListener.RelayedOnewayInputChannel(this, new EndpointAddress(this.Uri, new AddressHeader[0]));
            base.Acceptor = new Microsoft.ServiceBus.Channels.InputChannelAcceptor(this, () => this.GetPendingException());
            this.ChannelAcceptor.EnqueueAndDispatch(this.channel, new Action(this.OnChannelDequeued));
            this.connection = RelayedOnewayManager.RegisterListener(context, transportBindingElement, this);
        }
        internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            Microsoft.ServiceBus.UnifiedSecurityMode unifiedSecurityMode;
            NetOnewayRelaySecurity netOnewayRelaySecurity;
            bool flag;

            binding = null;
            if (elements.Count > 3)
            {
                return(false);
            }
            SecurityBindingElement securityBindingElement = null;
            BinaryMessageEncodingBindingElement  binaryMessageEncodingBindingElement  = null;
            RelayedOnewayTransportBindingElement relayedOnewayTransportBindingElement = null;

            using (IEnumerator <BindingElement> enumerator = elements.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BindingElement current = enumerator.Current;
                    if (current is SecurityBindingElement)
                    {
                        securityBindingElement = current as SecurityBindingElement;
                    }
                    else if (current is TransportBindingElement)
                    {
                        relayedOnewayTransportBindingElement = current as RelayedOnewayTransportBindingElement;
                    }
                    else if (!(current is MessageEncodingBindingElement))
                    {
                        flag = false;
                        return(flag);
                    }
                    else
                    {
                        binaryMessageEncodingBindingElement = current as BinaryMessageEncodingBindingElement;
                    }
                }
                unifiedSecurityMode = (!relayedOnewayTransportBindingElement.TransportProtectionEnabled ? Microsoft.ServiceBus.UnifiedSecurityMode.None | Microsoft.ServiceBus.UnifiedSecurityMode.Message : Microsoft.ServiceBus.UnifiedSecurityMode.Transport | Microsoft.ServiceBus.UnifiedSecurityMode.TransportWithMessageCredential);
                if (binaryMessageEncodingBindingElement == null)
                {
                    return(false);
                }
                if (!NetOnewayRelayBinding.TryCreateSecurity(securityBindingElement, relayedOnewayTransportBindingElement.RelayClientAuthenticationType, unifiedSecurityMode, out netOnewayRelaySecurity))
                {
                    return(false);
                }
                NetOnewayRelayBinding netOnewayRelayBinding = new NetOnewayRelayBinding(netOnewayRelaySecurity);
                NetOnewayRelayBinding.InitializeFrom(relayedOnewayTransportBindingElement, binaryMessageEncodingBindingElement);
                if (!netOnewayRelayBinding.IsBindingElementsMatch(relayedOnewayTransportBindingElement, binaryMessageEncodingBindingElement))
                {
                    return(false);
                }
                binding = netOnewayRelayBinding;
                return(true);
            }
            return(flag);
        }
Example #4
0
 internal void ConfigureTransportSecurity(RelayedOnewayTransportBindingElement oneway)
 {
     if (this.mode != EndToEndSecurityMode.Transport && this.mode != EndToEndSecurityMode.TransportWithMessageCredential)
     {
         oneway.TransportProtectionEnabled = false;
         return;
     }
     oneway.TransportProtectionEnabled = true;
 }
Example #5
0
        internal static new ChannelProtectionRequirements GetProtectionRequirements(BindingContext context)
        {
            AddressingVersion             wSAddressing10 = AddressingVersion.WSAddressing10;
            MessageEncodingBindingElement messageEncodingBindingElement = ClientMessageUtility.CreateInnerEncodingBindingElement(context);

            if (messageEncodingBindingElement != null)
            {
                wSAddressing10 = messageEncodingBindingElement.MessageVersion.Addressing;
            }
            return(RelayedOnewayTransportBindingElement.GetProtectionRequirements(wSAddressing10));
        }
            public RelayedOnewayAmqpListenerClient(BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement, System.Uri uri, RelayedOnewayListener listener, EventTraceActivity activity) : base(context, transportBindingElement, uri, true, activity)
            {
                this.listener = listener;
                BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = ClientMessageUtility.CreateInnerEncodingBindingElement(context);

                this.encoder                  = binaryMessageEncodingBindingElement.CreateMessageEncoderFactory().Encoder;
                this.messageWrapper           = new MessageWrapper(this.encoder);
                this.bufferManager            = BufferManager.CreateBufferManager(transportBindingElement.MaxBufferPoolSize, transportBindingElement.MaxBufferSize);
                base.IsListener               = true;
                this.connectivitySettings     = context.BindingParameters.Find <ConnectivitySettings>();
                this.httpConnectivitySettings = context.BindingParameters.Find <HttpConnectivitySettings>();
            }
 public RelayedOnewayListener(BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement, System.Uri uri, EventTraceActivity activity)
 {
     this.nameSettings = context.BindingParameters.Find <Microsoft.ServiceBus.NameSettings>();
     if (this.nameSettings == null)
     {
         this.nameSettings = new Microsoft.ServiceBus.NameSettings();
         this.nameSettings.ServiceSettings.ListenerType = ListenerType.Unicast;
     }
     this.listenerTable      = new Microsoft.ServiceBus.Channels.UriPrefixTable <RelayedOnewayListener.RelayedOnewayChannelListenerCollection>();
     this.client             = new RelayedOnewayListener.RelayedOnewayAmqpListenerClient(context, transportBindingElement, uri, this, activity);
     this.client.Connecting += new EventHandler(this.OnConnecting);
     this.client.Online     += new EventHandler(this.OnOnline);
     this.client.Offline    += new EventHandler(this.OnOffline);
 }
        public static IRelayedOnewaySender CreateConnection(BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement, Uri uri)
        {
            ConnectivitySettings connectivitySetting = context.BindingParameters.Find <ConnectivitySettings>();
            NameSettings         nameSetting         = context.BindingParameters.Find <NameSettings>();
            ConnectivityMode     connectivityMode    = (connectivitySetting != null ? connectivitySetting.Mode : ConnectivityModeHelper.SystemConnectivityMode);

            if (connectivityMode == ConnectivityMode.AutoDetect)
            {
                connectivityMode = NetworkDetector.DetectConnectivityModeForAutoDetect(uri);
            }
            if (connectivityMode != ConnectivityMode.Tcp)
            {
                return(new RelayedOnewayHttpSender(context, uri, nameSetting.ServiceSettings.TransportProtection == RelayTransportProtectionMode.EndToEnd));
            }
            return(new RelayedOnewayTcpSender(context, transportBindingElement, uri, nameSetting.ServiceSettings.TransportProtection == RelayTransportProtectionMode.EndToEnd, new EventTraceActivity()));
        }
Example #9
0
        public override T GetProperty <T>(BindingContext context)
            where T : class
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (typeof(T) != typeof(ChannelProtectionRequirements))
            {
                return(base.GetProperty <T>(context));
            }
            ChannelProtectionRequirements protectionRequirements = RelayedOnewayTransportBindingElement.GetProtectionRequirements(context);

            protectionRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
            return((T)protectionRequirements);
        }
Example #10
0
 public RelayedOnewayTransportBindingElement(RelayedOnewayTransportBindingElement elementToClone)
 {
     this.channelInitializationTimeout = elementToClone.channelInitializationTimeout;
     this.connectionBufferSize         = elementToClone.connectionBufferSize;
     this.connectionMode                = elementToClone.connectionMode;
     this.connectionPoolSettings        = elementToClone.connectionPoolSettings.Clone();
     this.listenBacklog                 = elementToClone.listenBacklog;
     base.ManualAddressing              = elementToClone.ManualAddressing;
     this.MaxBufferPoolSize             = elementToClone.MaxBufferPoolSize;
     this.maxBufferSize                 = elementToClone.maxBufferSize;
     this.maxBufferSizeInitialized      = elementToClone.maxBufferSizeInitialized;
     this.maxOutputDelay                = elementToClone.maxOutputDelay;
     this.maxPendingAccepts             = elementToClone.maxPendingAccepts;
     this.maxPendingConnections         = elementToClone.maxPendingConnections;
     this.MaxReceivedMessageSize        = elementToClone.MaxReceivedMessageSize;
     this.relayClientAuthenticationType = elementToClone.relayClientAuthenticationType;
     this.transportProtectionEnabled    = elementToClone.transportProtectionEnabled;
 }
        private bool IsBindingElementsMatch(RelayedOnewayTransportBindingElement transport, MessageEncodingBindingElement encoding)
        {
            Type type = typeof(BindingElement);
            RelayedOnewayTransportBindingElement relayedOnewayTransportBindingElement = this.GetTransport();

            object[] objArray = new object[] { transport };
            if ((bool)InvokeHelper.InvokeInstanceMethod(type, relayedOnewayTransportBindingElement, "IsMatch", objArray))
            {
                return(false);
            }
            Type type1 = typeof(BindingElement);
            BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = this.encoding;

            object[] objArray1 = new object[] { encoding };
            if ((bool)InvokeHelper.InvokeInstanceMethod(type1, binaryMessageEncodingBindingElement, "IsMatch", objArray1))
            {
                return(false);
            }
            return(true);
        }
Example #12
0
 protected bool IsBindingElementsMatch(RelayedOnewayTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, ReliableSessionBindingElement session)
 {
     return(true);
 }
Example #13
0
 protected NetEventRelayBinding(RelayedOnewayTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, NetOnewayRelaySecurity security) : base(transport, encoding, security)
 {
     this.transport.ConnectionMode = RelayedOnewayConnectionMode.Multicast;
 }
 public RelayedOnewayChannelFactory(BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement) : base(context.Binding)
 {
     this.context = context;
     this.transportBindingElement = transportBindingElement;
 }
 private static void InitializeFrom(RelayedOnewayTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding)
 {
     throw new NotImplementedException();
 }
 private void Initialize()
 {
     this.transport = new RelayedOnewayTransportBindingElement(this.security.RelayClientAuthenticationType, RelayedOnewayConnectionMode.Unicast);
     this.encoding  = new BinaryMessageEncodingBindingElement();
 }
 protected NetOnewayRelayBinding(RelayedOnewayTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, NetOnewayRelaySecurity security)
 {
     this.transport = transport;
     this.encoding  = encoding;
     this.security  = security;
 }
        public static IRelayedOnewayListener RegisterListener(BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement, RelayedOnewayChannelListener channelListener)
        {
            IRelayedOnewayListener relayedOnewayListener;

            lock (RelayedOnewayManager.listenerTable)
            {
                if (!RelayedOnewayManager.listenerTable.TryLookupUri(channelListener.BaseAddress, HostNameComparisonMode.Exact, out relayedOnewayListener) || !(RelayedOnewayManager.AppendSlash(relayedOnewayListener.Uri).ToString() == RelayedOnewayManager.AppendSlash(channelListener.BaseAddress).ToString()))
                {
                    relayedOnewayListener          = new RelayedOnewayListener(context, transportBindingElement, channelListener.BaseAddress, new EventTraceActivity());
                    relayedOnewayListener.Closing += new EventHandler(RelayedOnewayManager.OnListenerClosing);
                    RelayedOnewayManager.listenerTable.RegisterUri(channelListener.BaseAddress, HostNameComparisonMode.Exact, relayedOnewayListener);
                }
                else if (!relayedOnewayListener.NameSettings.IsCompatible(channelListener.NameSettings))
                {
                    throw Fx.Exception.AsError(new AddressAlreadyInUseException(SRClient.IncompatibleChannelListener), null);
                }
                relayedOnewayListener.Register(channelListener);
            }
            return(relayedOnewayListener);
        }
 public RelayedOnewayOutputChannel(RelayedOnewayChannelFactory channelFactory, BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement, EndpointAddress to, Uri via) : base(channelFactory)
 {
     this.to         = to;
     this.via        = via;
     this.connection = RelayedOnewayManager.CreateConnection(context, transportBindingElement, via);
 }
 public RelayedOnewayTcpSenderClient(BindingContext context, RelayedOnewayTransportBindingElement transportBindingElement, Uri uri, bool transportProtectionEnabled, EventTraceActivity activity) : base(context, transportBindingElement, uri, transportProtectionEnabled, activity)
 {
     base.IsListener = false;
 }