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);
 }
 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);
 }
        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);
        }
        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);
        }
 internal WSHttpRelaySecurity() : this(EndToEndSecurityMode.Transport, Microsoft.ServiceBus.RelayClientAuthenticationType.RelayAccessToken, WSHttpRelaySecurity.GetDefaultHttpTransportSecurity(), new NonDualMessageSecurityOverRelayHttp())
 {
 }
 internal WS2007HttpRelayBinding(WSHttpRelaySecurity security, bool reliableSessionEnabled) : base(security, reliableSessionEnabled)
 {
     base.ReliableSessionBindingElement.ReliableMessagingVersion = WS2007HttpRelayBinding.WS2007ReliableMessagingVersion;
     base.HttpsTransport.MessageSecurityVersion = WS2007HttpRelayBinding.WS2007MessageSecurityVersion;
 }
 internal WSHttpRelayBinding(WSHttpRelaySecurity security, bool reliableSessionEnabled) : base(reliableSessionEnabled)
 {
     this.security = security ?? new WSHttpRelaySecurity();
 }