static bool IsSecureConversationEnabled(BindingElementCollection bindingElements)
        {
            bool foundRM = false;

            for (int i = 0; i < bindingElements.Count; i++)
            {
                if (!foundRM)
                {
                    ReliableSessionBindingElement bindingElement = bindingElements[i] as ReliableSessionBindingElement;
                    foundRM = (bindingElement != null);
                }
                else
                {
                    SecurityBindingElement securityBindingElement = bindingElements[i] as SecurityBindingElement;

                    if (securityBindingElement != null)
                    {
                        SecurityBindingElement bootstrapSecurity;

                        // The difference in bool (requireCancellation) does not affect whether the binding is valid,
                        // but the method does match on the value so we need to pass both true and false.
                        return(SecurityBindingElement.IsSecureConversationBinding(securityBindingElement, true, out bootstrapSecurity) ||
                               SecurityBindingElement.IsSecureConversationBinding(securityBindingElement, false, out bootstrapSecurity));
                    }

                    break;
                }
            }

            return(false);
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (context.BindingElements != null)
            {
                BindingElementCollection      bindingElements = context.BindingElements;
                ReliableSessionBindingElement settings        = bindingElements.Find <ReliableSessionBindingElement>();

                if (settings != null)
                {
                    // ReliableSession assertion
                    XmlElement assertion = settings.CreateReliabilityAssertion(exporter.PolicyVersion, bindingElements);
                    context.GetBindingAssertions().Add(assertion);
                }
            }
        }
        static void ProcessWsrm11Policy(MetadataImporter importer, XmlNode node, ReliableSessionBindingElement settings)
        {
            XmlElement element = ThrowIfNotPolicyElement(node, ReliableMessagingVersion.WSReliableMessaging11);
            IEnumerable <IEnumerable <XmlElement> > alternatives     = importer.NormalizePolicy(new XmlElement[] { element });
            List <Wsrm11PolicyAlternative>          wsrmAlternatives = new List <Wsrm11PolicyAlternative>();

            foreach (IEnumerable <XmlElement> alternative in alternatives)
            {
                Wsrm11PolicyAlternative wsrm11Policy = Wsrm11PolicyAlternative.ImportAlternative(importer, alternative);
                wsrmAlternatives.Add(wsrm11Policy);
            }

            if (wsrmAlternatives.Count == 0)
            {
                // No specific policy other than turn on WS-RM.
                return;
            }

            foreach (Wsrm11PolicyAlternative wsrmAlternative in wsrmAlternatives)
            {
                // The only policy setting that affects the binding is the InOrder assurance.
                // Even that setting does not affect the binding since InOrder is a server delivery assurance.
                // Transfer any that is valid.
                if (wsrmAlternative.HasValidPolicy)
                {
                    wsrmAlternative.TransferSettings(settings);
                    return;
                }
            }

            // Found only invalid policy.
            // This throws an exception about security since that is the only invalid policy we have.
            Wsrm11PolicyAlternative.ThrowInvalidBindingException();
        }
Esempio n. 4
0
        private static bool IsSecureConversationEnabled(BindingElementCollection bindingElements)
        {
            bool flag = false;

            for (int i = 0; i < bindingElements.Count; i++)
            {
                if (!flag)
                {
                    ReliableSessionBindingElement element = bindingElements[i] as ReliableSessionBindingElement;
                    flag = element != null;
                }
                else
                {
                    SecurityBindingElement element3;
                    SecurityBindingElement sbe = bindingElements[i] as SecurityBindingElement;
                    if (sbe == null)
                    {
                        break;
                    }
                    if (!SecurityBindingElement.IsSecureConversationBinding(sbe, true, out element3))
                    {
                        return(SecurityBindingElement.IsSecureConversationBinding(sbe, false, out element3));
                    }
                    return(true);
                }
            }
            return(false);
        }
 private static void SetAcknowledgementInterval(ReliableSessionBindingElement settings, TimeSpan acknowledgementInterval, string localName)
 {
     try
     {
         settings.AcknowledgementInterval = acknowledgementInterval;
     }
     catch (ArgumentOutOfRangeException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(string.Format(SRServiceModel.MillisecondsNotConvertibleToBindingRange, localName), exception));
     }
 }
        private static void ProcessReliableSession11Assertion(MetadataImporter importer, XmlElement element,
                                                              ReliableSessionBindingElement settings)
        {
            // Version
            settings.ReliableMessagingVersion = ReliableMessagingVersion.WSReliableMessaging11;

            IEnumerator assertionChildren = element.ChildNodes.GetEnumerator();
            XmlNode     currentNode       = SkipToNode(assertionChildren);

            // Policy
            ProcessWsrm11Policy(importer, currentNode, settings);
            currentNode = SkipToNode(assertionChildren);

            // Looking for:
            // InactivityTimeout, AcknowledgementInterval
            // InactivityTimeout
            // AcknowledgementInterval
            // or nothing at all.
            State state = State.InactivityTimeout;

            while (currentNode != null)
            {
                if (state == State.InactivityTimeout)
                {
                    // InactivityTimeout assertion
                    if (Is11Assertion(currentNode, ReliableSessionPolicyStrings.InactivityTimeout))
                    {
                        SetInactivityTimeout(settings, ReadMillisecondsAttribute(currentNode, true), currentNode.LocalName);
                        state       = State.AcknowledgementInterval;
                        currentNode = SkipToNode(assertionChildren);
                        continue;
                    }
                }

                // AcknowledgementInterval assertion
                if (Is11Assertion(currentNode, ReliableSessionPolicyStrings.AcknowledgementInterval))
                {
                    SetAcknowledgementInterval(settings, ReadMillisecondsAttribute(currentNode, true), currentNode.LocalName);

                    // ignore the rest
                    break;
                }

                if (state == State.AcknowledgementInterval)
                {
                    // ignore the rest
                    break;
                }

                currentNode = SkipToNode(assertionChildren);
            }

            // Schema allows arbitrary elements from now on, ignore everything else
        }
 private static void SetInactivityTimeout(ReliableSessionBindingElement settings, TimeSpan inactivityTimeout, string localName)
 {
     try
     {
         settings.InactivityTimeout = inactivityTimeout;
     }
     catch (ArgumentOutOfRangeException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(System.ServiceModel.SR.GetString("MillisecondsNotConvertibleToBindingRange", new object[] { localName }), exception));
     }
 }
        private static ReliableSessionBindingElement GetReliableSessionBindingElement(PolicyConversionContext context)
        {
            ReliableSessionBindingElement item = context.BindingElements.Find <ReliableSessionBindingElement>();

            if (item == null)
            {
                item = new ReliableSessionBindingElement();
                context.BindingElements.Add(item);
            }
            return(item);
        }
        private static ReliableSessionBindingElement GetReliableSessionBindingElement(PolicyConversionContext context)
        {
            ReliableSessionBindingElement settings = context.BindingElements.Find <ReliableSessionBindingElement>();

            if (settings == null)
            {
                settings = new ReliableSessionBindingElement();
                context.BindingElements.Add(settings);
            }

            return(settings);
        }
 internal ReliableSessionBindingElement(ReliableSessionBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     AcknowledgementInterval = elementToBeCloned.AcknowledgementInterval;
     FlowControlEnabled      = elementToBeCloned.FlowControlEnabled;
     InactivityTimeout       = elementToBeCloned.InactivityTimeout;
     MaxPendingChannels      = elementToBeCloned.MaxPendingChannels;
     MaxRetryCount           = elementToBeCloned.MaxRetryCount;
     MaxTransferWindowSize   = elementToBeCloned.MaxTransferWindowSize;
     Ordered = elementToBeCloned.Ordered;
     ReliableMessagingVersion = elementToBeCloned.ReliableMessagingVersion;
 }
 protected ReliableChannelListenerBase(ReliableSessionBindingElement settings, Binding binding) : base(true, binding)
 {
     this.acknowledgementInterval = settings.AcknowledgementInterval;
     this.flowControlEnabled      = settings.FlowControlEnabled;
     this.inactivityTimeout       = settings.InactivityTimeout;
     this.maxPendingChannels      = settings.MaxPendingChannels;
     this.maxRetryCount           = settings.MaxRetryCount;
     this.maxTransferWindowSize   = settings.MaxTransferWindowSize;
     this.messageVersion          = binding.MessageVersion;
     this.ordered = settings.Ordered;
     this.reliableMessagingVersion = settings.ReliableMessagingVersion;
 }
Esempio n. 12
0
 private void Initialize()
 {
     this.httpTransport               = new HttpTransportBindingElement();
     this.httpsTransport              = new HttpsTransportBindingElement();
     this.messageEncoding             = WSMessageEncoding.Text;
     this.txFlow                      = GetDefaultTransactionFlowBindingElement();
     this.session                     = new System.ServiceModel.Channels.ReliableSessionBindingElement(true);
     this.textEncoding                = new TextMessageEncodingBindingElement();
     this.textEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10;
     this.mtomEncoding                = new MtomMessageEncodingBindingElement();
     this.mtomEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10;
     this.reliableSession             = new OptionalReliableSession(this.session);
 }
 private void Initialize()
 {
     this.httpTransport = new HttpTransportBindingElement();
     this.httpsTransport = new HttpsTransportBindingElement();
     this.messageEncoding = WSMessageEncoding.Text;
     this.txFlow = GetDefaultTransactionFlowBindingElement();
     this.session = new System.ServiceModel.Channels.ReliableSessionBindingElement(true);
     this.textEncoding = new TextMessageEncodingBindingElement();
     this.textEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10;
     this.mtomEncoding = new MtomMessageEncodingBindingElement();
     this.mtomEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10;
     this.reliableSession = new OptionalReliableSession(this.session);
 }
Esempio n. 14
0
 public ReliableChannelFactory(ReliableSessionBindingElement settings, IChannelFactory <InnerChannel> innerChannelFactory, Binding binding) : base(binding)
 {
     this.acknowledgementInterval = settings.AcknowledgementInterval;
     this.flowControlEnabled      = settings.FlowControlEnabled;
     this.inactivityTimeout       = settings.InactivityTimeout;
     this.maxPendingChannels      = settings.MaxPendingChannels;
     this.maxRetryCount           = settings.MaxRetryCount;
     this.maxTransferWindowSize   = settings.MaxTransferWindowSize;
     this.messageVersion          = binding.MessageVersion;
     this.ordered = settings.Ordered;
     this.reliableMessagingVersion = settings.ReliableMessagingVersion;
     this.innerChannelFactory      = innerChannelFactory;
     this.faultHelper = new SendFaultHelper(binding.SendTimeout, binding.CloseTimeout);
 }
        internal override bool IsMatch(BindingElement b)
        {
            if (b == null)
            {
                return(false);
            }
            ReliableSessionBindingElement session = b as ReliableSessionBindingElement;

            if (session == null)
            {
                return(false);
            }
            if (this.acknowledgementInterval != session.acknowledgementInterval)
            {
                return(false);
            }
            if (this.flowControlEnabled != session.flowControlEnabled)
            {
                return(false);
            }
            if (this.inactivityTimeout != session.inactivityTimeout)
            {
                return(false);
            }
            if (this.maxPendingChannels != session.maxPendingChannels)
            {
                return(false);
            }
            if (this.maxRetryCount != session.maxRetryCount)
            {
                return(false);
            }
            if (this.maxTransferWindowSize != session.maxTransferWindowSize)
            {
                return(false);
            }
            if (this.ordered != session.ordered)
            {
                return(false);
            }
            if (this.reliableMessagingVersion != session.reliableMessagingVersion)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 16
0
        private void Initialize()
        {
            WSHttpBinding wSHttpBinding = new WSHttpBinding();

            this.httpTransport   = new HttpRelayTransportBindingElement();
            this.httpsTransport  = new HttpsRelayTransportBindingElement();
            this.messageEncoding = wSHttpBinding.MessageEncoding;
            this.session         = new System.ServiceModel.Channels.ReliableSessionBindingElement(true);
            this.textEncoding    = new TextMessageEncodingBindingElement()
            {
                MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap12WSAddressing10
            };
            this.mtomEncoding = new MtomMessageEncodingBindingElement()
            {
                MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap12WSAddressing10
            };
            this.reliableSession = new OptionalReliableSession(this.session);
        }
Esempio n. 17
0
 internal ReliableSessionBindingElement(ReliableSessionBindingElement elementToBeCloned) : base(elementToBeCloned)
 {
     this.acknowledgementInterval = ReliableSessionDefaults.AcknowledgementInterval;
     this.flowControlEnabled      = true;
     this.inactivityTimeout       = ReliableSessionDefaults.InactivityTimeout;
     this.maxPendingChannels      = 4;
     this.maxRetryCount           = 8;
     this.maxTransferWindowSize   = 8;
     this.ordered = true;
     this.reliableMessagingVersion = System.ServiceModel.ReliableMessagingVersion.Default;
     this.AcknowledgementInterval  = elementToBeCloned.AcknowledgementInterval;
     this.FlowControlEnabled       = elementToBeCloned.FlowControlEnabled;
     this.InactivityTimeout        = elementToBeCloned.InactivityTimeout;
     this.MaxPendingChannels       = elementToBeCloned.MaxPendingChannels;
     this.MaxRetryCount            = elementToBeCloned.MaxRetryCount;
     this.MaxTransferWindowSize    = elementToBeCloned.MaxTransferWindowSize;
     this.Ordered = elementToBeCloned.Ordered;
     this.ReliableMessagingVersion     = elementToBeCloned.ReliableMessagingVersion;
     this.internalDuplexBindingElement = elementToBeCloned.internalDuplexBindingElement;
 }
        static void ProcessReliableSessionFeb2005Assertion(XmlElement element, ReliableSessionBindingElement settings)
        {
            // Version
            settings.ReliableMessagingVersion = ReliableMessagingVersion.WSReliableMessagingFebruary2005;

            IEnumerator nodes       = element.ChildNodes.GetEnumerator();
            XmlNode     currentNode = SkipToNode(nodes);

            // InactivityTimeout assertion
            if (IsFeb2005Assertion(currentNode, ReliableSessionPolicyStrings.InactivityTimeout))
            {
                SetInactivityTimeout(settings, ReadMillisecondsAttribute(currentNode, true), currentNode.LocalName);
                currentNode = SkipToNode(nodes);
            }

            // BaseRetransmissionInterval assertion is read but ignored
            if (IsFeb2005Assertion(currentNode, ReliableSessionPolicyStrings.BaseRetransmissionInterval))
            {
                ReadMillisecondsAttribute(currentNode, false);
                currentNode = SkipToNode(nodes);
            }

            // ExponentialBackoff assertion is read but ignored
            if (IsFeb2005Assertion(currentNode, ReliableSessionPolicyStrings.ExponentialBackoff))
            {
                currentNode = SkipToNode(nodes);
            }

            // AcknowledgementInterval assertion
            if (IsFeb2005Assertion(currentNode, ReliableSessionPolicyStrings.AcknowledgementInterval))
            {
                SetAcknowledgementInterval(settings, ReadMillisecondsAttribute(currentNode, true), currentNode.LocalName);
            }

            // Schema allows arbitrary elements from now on, ignore everything else
        }
Esempio n. 19
0
 internal BindingDeliveryCapabilitiesHelper(ReliableSessionBindingElement element, IBindingDeliveryCapabilities inner)
 {
     this.element = element;
     this.inner   = inner;
 }
 public ReliableInputListenerOverReplySession(ReliableSessionBindingElement binding, BindingContext context) : base(binding, context)
 {
 }
Esempio n. 21
0
        internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            binding = null;
            if (elements.Count > 6)
            {
                return(false);
            }
            PrivacyNoticeBindingElement privacy = null;

            System.ServiceModel.Channels.TransactionFlowBindingElement tfbe = null;
            System.ServiceModel.Channels.ReliableSessionBindingElement rsbe = null;
            SecurityBindingElement        sbe       = null;
            MessageEncodingBindingElement encoding  = null;
            HttpTransportBindingElement   transport = null;

            foreach (BindingElement element7 in elements)
            {
                if (element7 is SecurityBindingElement)
                {
                    sbe = element7 as SecurityBindingElement;
                }
                else if (element7 is TransportBindingElement)
                {
                    transport = element7 as HttpTransportBindingElement;
                }
                else if (element7 is MessageEncodingBindingElement)
                {
                    encoding = element7 as MessageEncodingBindingElement;
                }
                else if (element7 is System.ServiceModel.Channels.TransactionFlowBindingElement)
                {
                    tfbe = element7 as System.ServiceModel.Channels.TransactionFlowBindingElement;
                }
                else if (element7 is System.ServiceModel.Channels.ReliableSessionBindingElement)
                {
                    rsbe = element7 as System.ServiceModel.Channels.ReliableSessionBindingElement;
                }
                else if (element7 is PrivacyNoticeBindingElement)
                {
                    privacy = element7 as PrivacyNoticeBindingElement;
                }
                else
                {
                    return(false);
                }
            }
            if (transport == null)
            {
                return(false);
            }
            if (encoding == null)
            {
                return(false);
            }
            if (((privacy != null) || !WSHttpBinding.TryCreate(sbe, transport, rsbe, tfbe, out binding)) && ((!WSFederationHttpBinding.TryCreate(sbe, transport, privacy, rsbe, tfbe, out binding) && !WS2007HttpBinding.TryCreate(sbe, transport, rsbe, tfbe, out binding)) && !WS2007FederationHttpBinding.TryCreate(sbe, transport, privacy, rsbe, tfbe, out binding)))
            {
                return(false);
            }
            if (tfbe == null)
            {
                tfbe = GetDefaultTransactionFlowBindingElement();
                if ((binding is WS2007HttpBinding) || (binding is WS2007FederationHttpBinding))
                {
                    tfbe.TransactionProtocol = TransactionProtocol.WSAtomicTransaction11;
                }
            }
            WSHttpBindingBase base2 = binding as WSHttpBindingBase;

            base2.InitializeFrom(transport, encoding, tfbe, rsbe);
            if (!base2.IsBindingElementsMatch(transport, encoding, tfbe, rsbe))
            {
                return(false);
            }
            return(true);
        }
Esempio n. 22
0
 private bool IsBindingElementsMatch(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, System.ServiceModel.Channels.TransactionFlowBindingElement txFlow, System.ServiceModel.Channels.ReliableSessionBindingElement session)
 {
     if (!this.GetTransport().IsMatch(transport))
     {
         return(false);
     }
     if (this.MessageEncoding == WSMessageEncoding.Text)
     {
         if (!this.textEncoding.IsMatch(encoding))
         {
             return(false);
         }
     }
     else if ((this.MessageEncoding == WSMessageEncoding.Mtom) && !this.mtomEncoding.IsMatch(encoding))
     {
         return(false);
     }
     if (!this.txFlow.IsMatch(txFlow))
     {
         return(false);
     }
     if (this.reliableSession.Enabled)
     {
         if (!this.session.IsMatch(session))
         {
             return(false);
         }
     }
     else if (session != null)
     {
         return(false);
     }
     return(true);
 }
        private static void ProcessReliableSession11Assertion(MetadataImporter importer, XmlElement element, ReliableSessionBindingElement settings)
        {
            settings.ReliableMessagingVersion = ReliableMessagingVersion.WSReliableMessaging11;
            IEnumerator nodes = element.ChildNodes.GetEnumerator();

            System.Xml.XmlNode node = SkipToNode(nodes);
            ProcessWsrm11Policy(importer, node, settings);
            node = SkipToNode(nodes);
            State inactivityTimeout = State.InactivityTimeout;

            while (node != null)
            {
                if ((inactivityTimeout == State.InactivityTimeout) && Is11Assertion(node, "InactivityTimeout"))
                {
                    SetInactivityTimeout(settings, ReadMillisecondsAttribute(node, true), node.LocalName);
                    inactivityTimeout = State.AcknowledgementInterval;
                    node = SkipToNode(nodes);
                }
                else
                {
                    if (Is11Assertion(node, "AcknowledgementInterval"))
                    {
                        SetAcknowledgementInterval(settings, ReadMillisecondsAttribute(node, true), node.LocalName);
                        return;
                    }
                    if (inactivityTimeout == State.AcknowledgementInterval)
                    {
                        return;
                    }
                    node = SkipToNode(nodes);
                }
            }
        }
        private static void ProcessReliableSessionFeb2005Assertion(XmlElement element, ReliableSessionBindingElement settings)
        {
            settings.ReliableMessagingVersion = ReliableMessagingVersion.WSReliableMessagingFebruary2005;
            IEnumerator nodes = element.ChildNodes.GetEnumerator();

            System.Xml.XmlNode node = SkipToNode(nodes);
            if (IsFeb2005Assertion(node, "InactivityTimeout"))
            {
                SetInactivityTimeout(settings, ReadMillisecondsAttribute(node, true), node.LocalName);
                node = SkipToNode(nodes);
            }
            if (IsFeb2005Assertion(node, "BaseRetransmissionInterval"))
            {
                ReadMillisecondsAttribute(node, false);
                node = SkipToNode(nodes);
            }
            if (IsFeb2005Assertion(node, "ExponentialBackoff"))
            {
                node = SkipToNode(nodes);
            }
            if (IsFeb2005Assertion(node, "AcknowledgementInterval"))
            {
                SetAcknowledgementInterval(settings, ReadMillisecondsAttribute(node, true), node.LocalName);
            }
        }
Esempio n. 25
0
 private void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, System.ServiceModel.Channels.TransactionFlowBindingElement txFlow, System.ServiceModel.Channels.ReliableSessionBindingElement session)
 {
     this.BypassProxyOnLocal     = transport.BypassProxyOnLocal;
     this.HostNameComparisonMode = transport.HostNameComparisonMode;
     this.MaxBufferPoolSize      = transport.MaxBufferPoolSize;
     this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize;
     this.ProxyAddress           = transport.ProxyAddress;
     this.UseDefaultWebProxy     = transport.UseDefaultWebProxy;
     if (encoding is TextMessageEncodingBindingElement)
     {
         this.MessageEncoding = WSMessageEncoding.Text;
         TextMessageEncodingBindingElement element = (TextMessageEncodingBindingElement)encoding;
         this.TextEncoding = element.WriteEncoding;
         this.ReaderQuotas = element.ReaderQuotas;
     }
     else if (encoding is MtomMessageEncodingBindingElement)
     {
         this.messageEncoding = WSMessageEncoding.Mtom;
         MtomMessageEncodingBindingElement element2 = (MtomMessageEncodingBindingElement)encoding;
         this.TextEncoding = element2.WriteEncoding;
         this.ReaderQuotas = element2.ReaderQuotas;
     }
     this.TransactionFlow         = txFlow.Transactions;
     this.reliableSession.Enabled = session != null;
     if (session != null)
     {
         this.session.InactivityTimeout = session.InactivityTimeout;
         this.session.Ordered           = session.Ordered;
     }
 }
 public void TransferSettings(ReliableSessionBindingElement settings)
 {
     settings.Ordered = this.isOrdered;
 }
Esempio n. 27
0
        public static WSHttpBinding BuildWSHttpBinding(BindingSecurity bindingSecurity, MessageSecurityType messageSecurity,
                                                       WSMessageEncoding encoding, TimeoutQuotas timeoutQuotas, MessageSizeQuotas quotas)
        {
            if (quotas == null)
            {
                quotas = new MessageSizeQuotas()
                {
                    MaxBufferPoolSize      = 15000000,
                    MaxReceivedMessageSize = 15000000
                };
            }

            if (timeoutQuotas == null)
            {
                timeoutQuotas = new TimeoutQuotas()
                {
                    CloseTimeout   = 600000000,  // 1 minute
                    OpenTimeout    = 600000000,  // 1 minute
                    ReceiveTimeout = 3000000000, // 5 minutes
                    SendTimeout    = 3000000000, // 5 minutes
                };
            }

            WSHttpBinding binding_Text = new WSHttpBinding();

            binding_Text.Name                   = "WSHttpBinding_" + encoding.ToString() + "_" + bindingSecurity.ToString();
            binding_Text.CloseTimeout           = new TimeSpan(timeoutQuotas.CloseTimeout);
            binding_Text.OpenTimeout            = new TimeSpan(timeoutQuotas.OpenTimeout);
            binding_Text.ReceiveTimeout         = new TimeSpan(timeoutQuotas.ReceiveTimeout);
            binding_Text.SendTimeout            = new TimeSpan(timeoutQuotas.SendTimeout);
            binding_Text.BypassProxyOnLocal     = false;
            binding_Text.TransactionFlow        = false;
            binding_Text.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            binding_Text.MaxBufferPoolSize      = quotas.MaxBufferPoolSize;
            binding_Text.MaxReceivedMessageSize = quotas.MaxReceivedMessageSize;
            binding_Text.MessageEncoding        = encoding;
            binding_Text.TextEncoding           = System.Text.Encoding.UTF8;
            binding_Text.UseDefaultWebProxy     = true;
            binding_Text.AllowCookies           = false;
            binding_Text.ReaderQuotas           = new XmlDictionaryReaderQuotas();
            binding_Text.ReaderQuotas.MaxDepth  = 32;
            binding_Text.ReaderQuotas.MaxStringContentLength = 81920;
            binding_Text.ReaderQuotas.MaxArrayLength         = 16384;
            binding_Text.ReaderQuotas.MaxBytesPerRead        = 32768;
            binding_Text.ReaderQuotas.MaxNameTableCharCount  = 16384000;
            System.ServiceModel.Channels.ReliableSessionBindingElement reliableSessionBindingElement = new System.ServiceModel.Channels.ReliableSessionBindingElement(true);
            reliableSessionBindingElement.InactivityTimeout = new TimeSpan(6000000000); //10 minutes
            //binding_Text.ReliableSession = new OptionalReliableSession(reliableSessionBindingElement);
            switch (bindingSecurity)
            {
            case BindingSecurity.None:
                binding_Text.Security.Mode = SecurityMode.None;
                binding_Text.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding_Text.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.None;
                binding_Text.Security.Transport.Realm = String.Empty;
                //binding_Text.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
                //binding_Text.Security.Message.NegotiateServiceCredential = true;
                //binding_Text.Security.Message.EstablishSecurityContext = true;
                break;

            case BindingSecurity.TLSWithCertificate:
                binding_Text.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
                binding_Text.Security.Mode = SecurityMode.Transport;
                binding_Text.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
                binding_Text.Security.Transport.Realm = String.Empty;
                break;

            case BindingSecurity.TLS:
                binding_Text.Security.Mode = SecurityMode.Transport;
                binding_Text.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
                binding_Text.Security.Transport.Realm = String.Empty;
                break;

            case BindingSecurity.Credentials:
                binding_Text.Security.Mode = SecurityMode.TransportWithMessageCredential;
                binding_Text.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
                break;

            default:
                break;
            }
            switch (messageSecurity)
            {
            case MessageSecurityType.None:
                break;

            case MessageSecurityType.CertificateOverTransport:
                binding_Text.Security.Message.ClientCredentialType       = MessageCredentialType.Certificate;
                binding_Text.Security.Message.NegotiateServiceCredential = true;
                binding_Text.Security.Message.EstablishSecurityContext   = true;
                break;

            case MessageSecurityType.MutualCertificate:
                binding_Text.Security.Message.ClientCredentialType       = MessageCredentialType.Certificate;
                binding_Text.Security.Message.NegotiateServiceCredential = true;
                binding_Text.Security.Message.EstablishSecurityContext   = true;
                break;

            default:
                break;
            }
            return(binding_Text);
        }
        private static void ProcessWsrm11Policy(MetadataImporter importer, System.Xml.XmlNode node, ReliableSessionBindingElement settings)
        {
            XmlElement element = ThrowIfNotPolicyElement(node, ReliableMessagingVersion.WSReliableMessaging11);
            IEnumerable <IEnumerable <XmlElement> > enumerable = importer.NormalizePolicy(new XmlElement[] { element });
            List <Wsrm11PolicyAlternative>          list       = new List <Wsrm11PolicyAlternative>();

            foreach (IEnumerable <XmlElement> enumerable2 in enumerable)
            {
                Wsrm11PolicyAlternative item = Wsrm11PolicyAlternative.ImportAlternative(importer, enumerable2);
                list.Add(item);
            }
            if (list.Count != 0)
            {
                foreach (Wsrm11PolicyAlternative alternative2 in list)
                {
                    if (alternative2.HasValidPolicy)
                    {
                        alternative2.TransferSettings(settings);
                        return;
                    }
                }
                Wsrm11PolicyAlternative.ThrowInvalidBindingException();
            }
        }
        internal static bool TryCreate(SecurityBindingElement sbe, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, TransportBindingElement transport, System.ServiceModel.Channels.ReliableSessionBindingElement rsbe, out Binding binding)
        {
            Microsoft.ServiceBus.UnifiedSecurityMode unifiedSecurityMode;
            WSHttpRelaySecurity wSHttpRelaySecurity;
            bool flag;
            bool flag1 = rsbe != null;

            binding = null;
            HttpRelayTransportSecurity defaultHttpTransportSecurity = WSHttpRelaySecurity.GetDefaultHttpTransportSecurity();

            if (!WSHttpRelayBinding.GetSecurityModeFromTransport(transport, defaultHttpTransportSecurity, out unifiedSecurityMode))
            {
                return(false);
            }
            HttpsRelayTransportBindingElement httpsRelayTransportBindingElement = transport as HttpsRelayTransportBindingElement;

            if (httpsRelayTransportBindingElement != null && httpsRelayTransportBindingElement.MessageSecurityVersion != null && httpsRelayTransportBindingElement.MessageSecurityVersion.SecurityPolicyVersion != WS2007HttpRelayBinding.WS2007MessageSecurityVersion.SecurityPolicyVersion)
            {
                return(false);
            }
            if (WS2007HttpRelayBinding.TryCreateSecurity(sbe, unifiedSecurityMode, relayClientAuthenticationType, defaultHttpTransportSecurity, flag1, out wSHttpRelaySecurity))
            {
                WS2007HttpRelayBinding wS2007HttpRelayBinding = new WS2007HttpRelayBinding(wSHttpRelaySecurity, flag1);
                if (!WSHttpRelayBinding.TryGetAllowCookiesFromTransport(transport, out flag))
                {
                    return(false);
                }
                wS2007HttpRelayBinding.AllowCookies = flag;
                binding = wS2007HttpRelayBinding;
            }
            if (rsbe != null && rsbe.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11)
            {
                return(false);
            }
            return(binding != null);
        }
Esempio n. 30
0
 protected ReliableChannelListener(ReliableSessionBindingElement binding, BindingContext context) : base(binding, context.Binding)
 {
     this.typedListener             = context.BuildInnerChannelListener <TInnerChannel>();
     this.inputQueueChannelAcceptor = new InputQueueChannelAcceptor <TChannel>(this);
     base.Acceptor = this.inputQueueChannelAcceptor;
 }
Esempio n. 31
0
 public ReliableDuplexListenerOverDuplex(ReliableSessionBindingElement binding, BindingContext context) : base(binding, context)
 {
 }