internal WSHttpRelaySecurity(EndToEndSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, HttpRelayTransportSecurity transportSecurity, NonDualMessageSecurityOverRelayHttp messageSecurity)
 {
     this.mode = mode;
     this.relayClientAuthenticationType = relayClientAuthenticationType;
     this.transportSecurity             = (transportSecurity == null ? WSHttpRelaySecurity.GetDefaultHttpTransportSecurity() : transportSecurity);
     this.messageSecurity = (messageSecurity == null ? new NonDualMessageSecurityOverRelayHttp() : messageSecurity);
 }
Beispiel #2
0
        private BasicHttpRelaySecurity(EndToEndBasicHttpSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, HttpRelayTransportSecurity transportSecurity, BasicHttpRelayMessageSecurity messageSecurity)
        {
            bool        flag             = EndToEndBasicHttpSecurityModeHelper.IsDefined(mode);
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            object[] str = new object[] { mode.ToString() };
            DiagnosticUtility.DebugAssert(flag, string.Format(invariantCulture, "Invalid BasicHttpSecurityMode value: {0}.", str));
            this.Mode = mode;
            this.RelayClientAuthenticationType = relayClientAuthenticationType;
            this.transportSecurity             = (transportSecurity == null ? new HttpRelayTransportSecurity() : transportSecurity);
            this.messageSecurity = (messageSecurity == null ? new BasicHttpRelayMessageSecurity() : messageSecurity);
        }
Beispiel #3
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);
 }
        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);
        }
 private static bool TryCreateSecurity(SecurityBindingElement sbe, Microsoft.ServiceBus.UnifiedSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, HttpRelayTransportSecurity transportSecurity, bool isReliableSession, out WSHttpRelaySecurity security)
 {
     if (!WSHttpRelaySecurity.TryCreate(sbe, mode, transportSecurity, relayClientAuthenticationType, isReliableSession, out security))
     {
         return(false);
     }
     if (sbe == null)
     {
         return(true);
     }
     return(WS2007HttpRelayBinding.AreBindingsMatching(security.CreateMessageSecurity(isReliableSession, WS2007HttpRelayBinding.WS2007MessageSecurityVersion), sbe));
 }
 internal static bool GetSecurityModeFromTransport(TransportBindingElement transport, HttpRelayTransportSecurity transportSecurity, out Microsoft.ServiceBus.UnifiedSecurityMode mode)
 {
     mode = Microsoft.ServiceBus.UnifiedSecurityMode.None;
     if (!(transport is HttpsRelayTransportBindingElement))
     {
         if (!(transport is HttpRelayTransportBindingElement))
         {
             return(false);
         }
         mode = Microsoft.ServiceBus.UnifiedSecurityMode.None | Microsoft.ServiceBus.UnifiedSecurityMode.Message;
     }
     else
     {
         mode = Microsoft.ServiceBus.UnifiedSecurityMode.Transport | Microsoft.ServiceBus.UnifiedSecurityMode.TransportWithMessageCredential;
         WSHttpRelaySecurity.ApplyTransportSecurity((HttpsRelayTransportBindingElement)transport, transportSecurity);
     }
     return(true);
 }
Beispiel #7
0
 internal static bool IsDisabledTransportAuthentication(HttpRelayTransportBindingElement http)
 {
     return(HttpRelayTransportSecurity.IsDisabledAuthentication(http));
 }
Beispiel #8
0
 internal static bool IsConfiguredTransportAuthentication(HttpRelayTransportBindingElement http, HttpRelayTransportSecurity transportSecurity)
 {
     HttpRelayTransportSecurity.ConfigureAuthentication(http, transportSecurity);
     return(true);
 }
Beispiel #9
0
        internal static bool TryCreate(SecurityBindingElement sbe, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, UnifiedSecurityMode mode, HttpRelayTransportSecurity transportSecurity, out BasicHttpRelaySecurity security)
        {
            bool flag;

            security = null;
            BasicHttpRelayMessageSecurity basicHttpRelayMessageSecurity = null;

            if (sbe == null)
            {
                mode = mode & (UnifiedSecurityMode.None | UnifiedSecurityMode.Transport | UnifiedSecurityMode.Both);
            }
            else
            {
                mode = mode & (UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential);
                if (!BasicHttpRelayMessageSecurity.TryCreate(sbe, out basicHttpRelayMessageSecurity, out flag))
                {
                    return(false);
                }
            }
            EndToEndBasicHttpSecurityMode endToEndBasicHttpSecurityMode = EndToEndBasicHttpSecurityModeHelper.ToEndToEndBasicHttpSecurityMode(mode);
            bool        flag1            = EndToEndBasicHttpSecurityModeHelper.IsDefined(endToEndBasicHttpSecurityMode);
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            object[] str = new object[] { endToEndBasicHttpSecurityMode.ToString() };
            DiagnosticUtility.DebugAssert(flag1, string.Format(invariantCulture, "Invalid BasicHttpSecurityMode value: {0}.", str));
            security = new BasicHttpRelaySecurity(endToEndBasicHttpSecurityMode, relayClientAuthenticationType, transportSecurity, basicHttpRelayMessageSecurity);
            if (sbe == null)
            {
                return(true);
            }
            Type type = typeof(SecurityElementBase);

            object[] objArray = new object[] { security.CreateMessageSecurity(), sbe };
            return((bool)InvokeHelper.InvokeStaticMethod(type, "AreBindingsMatching", objArray));
        }
Beispiel #10
0
 internal static void ConfigureTransportProtectionAndAuthentication(HttpsRelayTransportBindingElement https, HttpRelayTransportSecurity transportSecurity)
 {
     HttpRelayTransportSecurity.ConfigureAuthentication(https, transportSecurity);
 }
Beispiel #11
0
 private static void ConfigureAuthentication(HttpRelayTransportBindingElement http, HttpRelayTransportSecurity transportSecurity)
 {
     transportSecurity.proxyCredentialType = Microsoft.ServiceBus.HttpProxyCredentialTypeHelper.MapToProxyCredentialType(http.ProxyAuthenticationScheme);
 }
Beispiel #12
0
 private static bool TryCreateSecurity(SecurityBindingElement securityElement, RelayClientAuthenticationType relayClientAuthenticationType, Microsoft.ServiceBus.UnifiedSecurityMode mode, HttpRelayTransportSecurity transportSecurity, out BasicHttpRelaySecurity security)
 {
     return(BasicHttpRelaySecurity.TryCreate(securityElement, relayClientAuthenticationType, mode, transportSecurity, out security));
 }
Beispiel #13
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);
        }
 private WebHttpRelaySecurity(EndToEndWebHttpSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, HttpRelayTransportSecurity transportSecurity)
 {
     this.Mode = mode;
     this.RelayClientAuthenticationType = relayClientAuthenticationType;
     this.transportSecurity             = (transportSecurity == null ? new HttpRelayTransportSecurity() : transportSecurity);
 }
Beispiel #15
0
 internal void ConfigureTransportProtectionOnly(HttpsRelayTransportBindingElement https)
 {
     HttpRelayTransportSecurity.DisableAuthentication(https);
 }
        internal static bool TryCreate(SecurityBindingElement sbe, Microsoft.ServiceBus.UnifiedSecurityMode mode, HttpRelayTransportSecurity transportSecurity, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, bool isReliableSessionEnabled, out WSHttpRelaySecurity security)
        {
            security = null;
            NonDualMessageSecurityOverRelayHttp nonDualMessageSecurityOverRelayHttp = null;
            EndToEndSecurityMode relaySecurityMode = EndToEndSecurityMode.None;

            if (sbe == null)
            {
                mode = mode & (Microsoft.ServiceBus.UnifiedSecurityMode.None | Microsoft.ServiceBus.UnifiedSecurityMode.Transport | Microsoft.ServiceBus.UnifiedSecurityMode.Both);
                relaySecurityMode = EndToEndSecurityModeHelper.ToRelaySecurityMode(mode);
            }
            else
            {
                mode = mode & (Microsoft.ServiceBus.UnifiedSecurityMode.Message | Microsoft.ServiceBus.UnifiedSecurityMode.TransportWithMessageCredential);
                relaySecurityMode = EndToEndSecurityModeHelper.ToRelaySecurityMode(mode);
                if (!MessageSecurityOverRelayHttp.TryCreate <NonDualMessageSecurityOverRelayHttp>(sbe, relaySecurityMode == EndToEndSecurityMode.TransportWithMessageCredential, isReliableSessionEnabled, out nonDualMessageSecurityOverRelayHttp))
                {
                    return(false);
                }
            }
            security = new WSHttpRelaySecurity(relaySecurityMode, relayClientAuthenticationType, transportSecurity, nonDualMessageSecurityOverRelayHttp);
            return(true);
        }
Beispiel #17
0
 internal void DisableTransportAuthentication(HttpRelayTransportBindingElement http)
 {
     HttpRelayTransportSecurity.DisableAuthentication(http);
 }
 internal static void ApplyTransportSecurity(HttpsRelayTransportBindingElement transport, HttpRelayTransportSecurity transportSecurity)
 {
     HttpRelayTransportSecurity.ConfigureTransportProtectionAndAuthentication(transport, transportSecurity);
 }
Beispiel #19
0
 internal static bool IsEnabledTransportAuthentication(HttpRelayTransportBindingElement http, HttpRelayTransportSecurity transportSecurity)
 {
     return(HttpRelayTransportSecurity.IsConfiguredTransportAuthentication(http, transportSecurity));
 }