예제 #1
0
 private void InitializeFrom(HttpRelayTransportBindingElement transport, MessageEncodingBindingElement encoding, System.ServiceModel.Channels.ReliableSessionBindingElement session)
 {
     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 textMessageEncodingBindingElement = (TextMessageEncodingBindingElement)encoding;
         this.TextEncoding = textMessageEncodingBindingElement.WriteEncoding;
         this.ReaderQuotas = textMessageEncodingBindingElement.ReaderQuotas;
     }
     else if (encoding is MtomMessageEncodingBindingElement)
     {
         this.messageEncoding = WSMessageEncoding.Mtom;
         MtomMessageEncodingBindingElement mtomMessageEncodingBindingElement = (MtomMessageEncodingBindingElement)encoding;
         this.TextEncoding = mtomMessageEncodingBindingElement.WriteEncoding;
         this.ReaderQuotas = mtomMessageEncodingBindingElement.ReaderQuotas;
     }
     this.reliableSession.Enabled = session != null;
     if (session != null)
     {
         this.session.InactivityTimeout = session.InactivityTimeout;
         this.session.Ordered           = session.Ordered;
     }
 }
예제 #2
0
 private bool IsBindingElementsMatch(HttpRelayTransportBindingElement transport, MessageEncodingBindingElement encoding, System.ServiceModel.Channels.ReliableSessionBindingElement session)
 {
     if (!WSHttpRelayBindingBase.IsBindingElementMatch(this.GetTransport(), transport))
     {
         return(false);
     }
     if (this.MessageEncoding == WSMessageEncoding.Text)
     {
         if (!WSHttpRelayBindingBase.IsBindingElementMatch(this.textEncoding, encoding))
         {
             return(false);
         }
     }
     else if (this.MessageEncoding == WSMessageEncoding.Mtom && !WSHttpRelayBindingBase.IsBindingElementMatch(this.mtomEncoding, encoding))
     {
         return(false);
     }
     if (this.reliableSession.Enabled)
     {
         if (!WSHttpRelayBindingBase.IsBindingElementMatch(this.session, session))
         {
             return(false);
         }
     }
     else if (session != null)
     {
         return(false);
     }
     return(true);
 }
예제 #3
0
        private bool IsBindingElementsMatch(HttpRelayTransportBindingElement transport, MessageEncodingBindingElement encoding)
        {
            if (this.MessageEncoding == WSMessageEncoding.Text)
            {
                Type type = typeof(BindingElement);
                TextMessageEncodingBindingElement textMessageEncodingBindingElement = this.textEncoding;
                object[] objArray = new object[] { encoding };
                if (!(bool)InvokeHelper.InvokeInstanceMethod(type, textMessageEncodingBindingElement, "IsMatch", objArray))
                {
                    return(false);
                }
            }
            else if (this.MessageEncoding == WSMessageEncoding.Mtom)
            {
                Type type1 = typeof(BindingElement);
                MtomMessageEncodingBindingElement mtomMessageEncodingBindingElement = this.mtomEncoding;
                object[] objArray1 = new object[] { encoding };
                if (!(bool)InvokeHelper.InvokeInstanceMethod(type1, mtomMessageEncodingBindingElement, "IsMatch", objArray1))
                {
                    return(false);
                }
            }
            Type type2 = typeof(BindingElement);
            TransportBindingElement transportBindingElement = this.GetTransport();

            object[] objArray2 = new object[] { transport };
            if (!(bool)InvokeHelper.InvokeInstanceMethod(type2, transportBindingElement, "IsMatch", objArray2))
            {
                return(false);
            }
            return(true);
        }
 private void Initialize()
 {
     this.httpRelayTransportBindingElement  = new HttpRelayTransportBindingElement();
     this.httpsRelayTransportBindingElement = new HttpsRelayTransportBindingElement();
     this.httpRelayTransportBindingElement.ManualAddressing  = true;
     this.httpsRelayTransportBindingElement.ManualAddressing = true;
     this.webMessageEncodingBindingElement = new WebMessageEncodingBindingElement()
     {
         MessageVersion = System.ServiceModel.Channels.MessageVersion.None
     };
 }
        internal static bool TryGetAllowCookiesFromTransport(TransportBindingElement transport, out bool allowCookies)
        {
            HttpRelayTransportBindingElement httpRelayTransportBindingElement = transport as HttpRelayTransportBindingElement;

            if (httpRelayTransportBindingElement == null)
            {
                allowCookies = false;
                return(false);
            }
            allowCookies = httpRelayTransportBindingElement.AllowCookies;
            return(true);
        }
예제 #6
0
 protected HttpRelayTransportBindingElement(HttpRelayTransportBindingElement elementToBeCloned) : base(elementToBeCloned)
 {
     this.allowCookies                  = elementToBeCloned.allowCookies;
     this.HostNameComparisonMode        = elementToBeCloned.HostNameComparisonMode;
     this.keepAliveEnabled              = elementToBeCloned.keepAliveEnabled;
     this.maxBufferSize                 = elementToBeCloned.maxBufferSize;
     this.maxBufferSizeInitialized      = elementToBeCloned.maxBufferSizeInitialized;
     this.proxyAddress                  = elementToBeCloned.proxyAddress;
     this.proxyAuthenticationScheme     = elementToBeCloned.proxyAuthenticationScheme;
     this.transferMode                  = elementToBeCloned.transferMode;
     this.useDefaultWebProxy            = elementToBeCloned.useDefaultWebProxy;
     this.relayClientAuthenticationType = elementToBeCloned.relayClientAuthenticationType;
     this.IsDynamic = elementToBeCloned.IsDynamic;
 }
예제 #7
0
 private void Initialize()
 {
     this.httpTransport   = new HttpRelayTransportBindingElement();
     this.httpsTransport  = new HttpsRelayTransportBindingElement();
     this.messageEncoding = WSMessageEncoding.Text;
     this.textEncoding    = new TextMessageEncodingBindingElement()
     {
         MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap11
     };
     this.mtomEncoding = new MtomMessageEncodingBindingElement()
     {
         MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap11
     };
 }
예제 #8
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);
        }
예제 #9
0
 private static bool GetSecurityModeFromTransport(HttpRelayTransportBindingElement http, HttpRelayTransportSecurity transportSecurity, out Microsoft.ServiceBus.UnifiedSecurityMode mode)
 {
     mode = Microsoft.ServiceBus.UnifiedSecurityMode.None;
     if (http == null)
     {
         return(false);
     }
     if (!(http is HttpsRelayTransportBindingElement))
     {
         if (!HttpRelayTransportSecurity.IsDisabledTransportAuthentication(http))
         {
             return(false);
         }
         mode = Microsoft.ServiceBus.UnifiedSecurityMode.None | Microsoft.ServiceBus.UnifiedSecurityMode.Message;
     }
     else
     {
         mode = Microsoft.ServiceBus.UnifiedSecurityMode.Transport | Microsoft.ServiceBus.UnifiedSecurityMode.TransportWithMessageCredential;
         BasicHttpRelaySecurity.EnableTransportSecurity((HttpsRelayTransportBindingElement)http, transportSecurity);
     }
     return(true);
 }
예제 #10
0
 private void InitializeFrom(HttpRelayTransportBindingElement transport, MessageEncodingBindingElement encoding)
 {
     this.MaxBufferPoolSize      = transport.MaxBufferPoolSize;
     this.MaxBufferSize          = transport.MaxBufferSize;
     this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize;
     this.ProxyAddress           = transport.ProxyAddress;
     this.TransferMode           = transport.TransferMode;
     this.UseDefaultWebProxy     = transport.UseDefaultWebProxy;
     if (encoding is TextMessageEncodingBindingElement)
     {
         this.MessageEncoding = WSMessageEncoding.Text;
         TextMessageEncodingBindingElement textMessageEncodingBindingElement = (TextMessageEncodingBindingElement)encoding;
         this.TextEncoding = textMessageEncodingBindingElement.WriteEncoding;
         this.ReaderQuotas = textMessageEncodingBindingElement.ReaderQuotas;
         return;
     }
     if (encoding is MtomMessageEncodingBindingElement)
     {
         this.messageEncoding = WSMessageEncoding.Mtom;
         MtomMessageEncodingBindingElement mtomMessageEncodingBindingElement = (MtomMessageEncodingBindingElement)encoding;
         this.TextEncoding = mtomMessageEncodingBindingElement.WriteEncoding;
         this.ReaderQuotas = mtomMessageEncodingBindingElement.ReaderQuotas;
     }
 }
예제 #11
0
 internal static bool IsDisabledTransportAuthentication(HttpRelayTransportBindingElement http)
 {
     return(HttpRelayTransportSecurity.IsDisabledAuthentication(http));
 }
예제 #12
0
 private static bool IsDisabledAuthentication(HttpRelayTransportBindingElement http)
 {
     return(http.ProxyAuthenticationScheme == AuthenticationSchemes.Anonymous);
 }
예제 #13
0
 internal static bool IsConfiguredTransportAuthentication(HttpRelayTransportBindingElement http, HttpRelayTransportSecurity transportSecurity)
 {
     HttpRelayTransportSecurity.ConfigureAuthentication(http, transportSecurity);
     return(true);
 }
예제 #14
0
 internal void DisableTransportAuthentication(HttpRelayTransportBindingElement http)
 {
     HttpRelayTransportSecurity.DisableAuthentication(http);
 }
예제 #15
0
 private static void DisableAuthentication(HttpRelayTransportBindingElement http)
 {
     http.ProxyAuthenticationScheme = AuthenticationSchemes.Anonymous;
 }
예제 #16
0
 internal void ConfigureTransportAuthentication(HttpRelayTransportBindingElement http)
 {
     this.ConfigureAuthentication(http);
 }
예제 #17
0
 private static void ConfigureAuthentication(HttpRelayTransportBindingElement http, HttpRelayTransportSecurity transportSecurity)
 {
     transportSecurity.proxyCredentialType = Microsoft.ServiceBus.HttpProxyCredentialTypeHelper.MapToProxyCredentialType(http.ProxyAuthenticationScheme);
 }
예제 #18
0
 private void ConfigureAuthentication(HttpRelayTransportBindingElement http)
 {
     http.ProxyAuthenticationScheme = Microsoft.ServiceBus.HttpProxyCredentialTypeHelper.MapToAuthenticationScheme(this.proxyCredentialType);
 }
예제 #19
0
        internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            bool flag;

            binding = null;
            if (elements.Count > 5)
            {
                return(false);
            }
            PrivacyNoticeBindingElement privacyNoticeBindingElement = null;

            System.ServiceModel.Channels.ReliableSessionBindingElement reliableSessionBindingElement = null;
            SecurityBindingElement           securityBindingElement           = null;
            MessageEncodingBindingElement    messageEncodingBindingElement    = null;
            HttpRelayTransportBindingElement httpRelayTransportBindingElement = 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 HttpsRelayTransportBindingElement)
                    {
                        httpRelayTransportBindingElement = current as HttpsRelayTransportBindingElement;
                    }
                    else if (current is HttpRelayTransportBindingElement)
                    {
                        httpRelayTransportBindingElement = current as HttpRelayTransportBindingElement;
                    }
                    else if (current is MessageEncodingBindingElement)
                    {
                        messageEncodingBindingElement = current as MessageEncodingBindingElement;
                    }
                    else if (current is System.ServiceModel.Channels.ReliableSessionBindingElement)
                    {
                        reliableSessionBindingElement = current as System.ServiceModel.Channels.ReliableSessionBindingElement;
                    }
                    else if (!(current is PrivacyNoticeBindingElement))
                    {
                        flag = false;
                        return(flag);
                    }
                    else
                    {
                        privacyNoticeBindingElement = current as PrivacyNoticeBindingElement;
                    }
                }
                if (httpRelayTransportBindingElement == null)
                {
                    return(false);
                }
                if (messageEncodingBindingElement == null)
                {
                    return(false);
                }
                if (privacyNoticeBindingElement != null || !WS2007HttpRelayBinding.TryCreate(securityBindingElement, httpRelayTransportBindingElement.RelayClientAuthenticationType, httpRelayTransportBindingElement, reliableSessionBindingElement, out binding))
                {
                    return(false);
                }
                WSHttpRelayBindingBase wSHttpRelayBindingBase = binding as WSHttpRelayBindingBase;
                wSHttpRelayBindingBase.InitializeFrom(httpRelayTransportBindingElement, messageEncodingBindingElement, reliableSessionBindingElement);
                if (!wSHttpRelayBindingBase.IsBindingElementsMatch(httpRelayTransportBindingElement, messageEncodingBindingElement, reliableSessionBindingElement))
                {
                    return(false);
                }
                return(true);
            }
            return(flag);
        }
예제 #20
0
 internal static bool IsEnabledTransportAuthentication(HttpRelayTransportBindingElement http, HttpRelayTransportSecurity transportSecurity)
 {
     return(HttpRelayTransportSecurity.IsConfiguredTransportAuthentication(http, transportSecurity));
 }
 internal void EnableTransportAuthentication(HttpRelayTransportBindingElement http)
 {
     this.transportSecurity.ConfigureTransportAuthentication(http);
 }
예제 #22
0
        internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            Microsoft.ServiceBus.UnifiedSecurityMode unifiedSecurityMode;
            BasicHttpRelaySecurity basicHttpRelaySecurity;
            bool flag;

            binding = null;
            if (elements.Count > 3)
            {
                return(false);
            }
            SecurityBindingElement           securityBindingElement           = null;
            MessageEncodingBindingElement    messageEncodingBindingElement    = null;
            HttpRelayTransportBindingElement httpRelayTransportBindingElement = 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 HttpsRelayTransportBindingElement)
                    {
                        httpRelayTransportBindingElement = current as HttpsRelayTransportBindingElement;
                    }
                    else if (current is HttpRelayTransportBindingElement)
                    {
                        httpRelayTransportBindingElement = current as HttpRelayTransportBindingElement;
                    }
                    else if (!(current is MessageEncodingBindingElement))
                    {
                        flag = false;
                        return(flag);
                    }
                    else
                    {
                        messageEncodingBindingElement = current as MessageEncodingBindingElement;
                    }
                }
                HttpRelayTransportSecurity httpRelayTransportSecurity = new HttpRelayTransportSecurity();
                if (!BasicHttpRelayBinding.GetSecurityModeFromTransport(httpRelayTransportBindingElement, httpRelayTransportSecurity, out unifiedSecurityMode))
                {
                    return(false);
                }
                if (messageEncodingBindingElement == null)
                {
                    return(false);
                }
                if (messageEncodingBindingElement.MessageVersion.Envelope != System.ServiceModel.EnvelopeVersion.Soap11)
                {
                    return(false);
                }
                if (!BasicHttpRelayBinding.TryCreateSecurity(securityBindingElement, httpRelayTransportBindingElement.RelayClientAuthenticationType, unifiedSecurityMode, httpRelayTransportSecurity, out basicHttpRelaySecurity))
                {
                    return(false);
                }
                BasicHttpRelayBinding basicHttpRelayBinding = new BasicHttpRelayBinding(basicHttpRelaySecurity);
                basicHttpRelayBinding.InitializeFrom(httpRelayTransportBindingElement, messageEncodingBindingElement);
                if (!basicHttpRelayBinding.IsBindingElementsMatch(httpRelayTransportBindingElement, messageEncodingBindingElement))
                {
                    return(false);
                }
                binding = basicHttpRelayBinding;
                return(true);
            }
            return(flag);
        }