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);
 }
Example #2
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));
        }
 public TcpRelayTransportBindingElement(Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType)
 {
     this.relayClientAuthenticationType = relayClientAuthenticationType;
     this.relayedConnectionMode         = TcpRelayConnectionMode.Relayed;
     this.listenBacklog          = 10;
     this.connectionPoolSettings = new SocketConnectionPoolSettings();
     this.IsDynamic = true;
 }
 protected TcpRelayTransportBindingElement(TcpRelayTransportBindingElement elementToBeCloned) : base(elementToBeCloned)
 {
     this.relayClientAuthenticationType = elementToBeCloned.relayClientAuthenticationType;
     this.relayedConnectionMode         = elementToBeCloned.relayedConnectionMode;
     this.listenBacklog = elementToBeCloned.listenBacklog;
     this.transportProtectionEnabled = elementToBeCloned.transportProtectionEnabled;
     this.connectionPoolSettings     = elementToBeCloned.connectionPoolSettings.Clone();
     this.IsDynamic = elementToBeCloned.IsDynamic;
 }
Example #5
0
        private NetOnewayRelaySecurity(EndToEndSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, RelayedOnewayTransportSecurity transportSecurity, MessageSecurityOverRelayOneway messageSecurity)
        {
            bool        flag             = EndToEndSecurityModeHelper.IsDefined(mode);
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            object[] str = new object[] { mode.ToString() };
            DiagnosticUtility.DebugAssert(flag, string.Format(invariantCulture, "Invalid RelaySecurityMode value: {0}.", str));
            this.mode = mode;
            this.relayClientAuthenticationType = relayClientAuthenticationType;
            this.transportSecurity             = (transportSecurity == null ? new RelayedOnewayTransportSecurity() : transportSecurity);
            this.messageSecurity = (messageSecurity == null ? new MessageSecurityOverRelayOneway() : messageSecurity);
        }
Example #6
0
 public RelayedOnewayTransportBindingElement(Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, RelayedOnewayConnectionMode connectionMode)
 {
     this.relayClientAuthenticationType = relayClientAuthenticationType;
     this.connectionMode               = connectionMode;
     this.listenBacklog                = 10;
     this.connectionPoolSettings       = new SocketConnectionPoolSettings();
     this.connectionBufferSize         = 65536;
     this.channelInitializationTimeout = Microsoft.ServiceBus.Channels.ConnectionOrientedTransportDefaults.ChannelInitializationTimeout;
     this.maxBufferSize                = 65536;
     this.maxPendingConnections        = 10;
     this.maxOutputDelay               = Microsoft.ServiceBus.Channels.ConnectionOrientedTransportDefaults.MaxOutputDelay;
     this.maxPendingAccepts            = 1;
 }
Example #7
0
        public HttpRelayTransportBindingElement(Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType)
        {
            HttpTransportBindingElement httpTransportBindingElement = new HttpTransportBindingElement();

            this.allowCookies                  = httpTransportBindingElement.AllowCookies;
            this.keepAliveEnabled              = httpTransportBindingElement.KeepAliveEnabled;
            this.maxBufferSize                 = httpTransportBindingElement.MaxBufferSize;
            this.proxyAuthenticationScheme     = httpTransportBindingElement.ProxyAuthenticationScheme;
            this.proxyAddress                  = httpTransportBindingElement.ProxyAddress;
            this.transferMode                  = httpTransportBindingElement.TransferMode;
            this.useDefaultWebProxy            = httpTransportBindingElement.UseDefaultWebProxy;
            this.relayClientAuthenticationType = relayClientAuthenticationType;
            this.IsDynamic = true;
        }
Example #8
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;
 }
Example #9
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;
 }
        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 WSHttpRelayBinding(EndToEndSecurityMode securityMode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, bool reliableSessionEnabled) : base(reliableSessionEnabled)
 {
     this.security.Mode = securityMode;
     this.security.RelayClientAuthenticationType = relayClientAuthenticationType;
 }
Example #12
0
 internal NetOnewayRelaySecurity(EndToEndSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType) : this(mode, relayClientAuthenticationType, null, null)
 {
 }
Example #13
0
        internal static bool TryCreate(SecurityBindingElement sbe, EndToEndSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, out NetOnewayRelaySecurity security)
        {
            MessageSecurityOverRelayOneway messageSecurityOverRelayOneway;

            security = null;
            if (!MessageSecurityOverRelayOneway.TryCreate(sbe, out messageSecurityOverRelayOneway))
            {
                messageSecurityOverRelayOneway = null;
            }
            security = new NetOnewayRelaySecurity(mode, relayClientAuthenticationType, null, messageSecurityOverRelayOneway);
            if (sbe == null)
            {
                return(true);
            }
            Type type = typeof(SecurityElementBase);

            object[] objArray = new object[] { security.CreateMessageSecurity(), sbe, false };
            return((bool)InvokeHelper.InvokeStaticMethod(type, "AreBindingsMatching", objArray));
        }
 public HttpsRelayTransportBindingElement(Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType) : base(relayClientAuthenticationType)
 {
 }
        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);
        }
 private WebHttpRelaySecurity(EndToEndWebHttpSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, HttpRelayTransportSecurity transportSecurity)
 {
     this.Mode = mode;
     this.RelayClientAuthenticationType = relayClientAuthenticationType;
     this.transportSecurity             = (transportSecurity == null ? new HttpRelayTransportSecurity() : transportSecurity);
 }
 public WS2007HttpRelayBinding(EndToEndSecurityMode securityMode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, bool reliableSessionEnabled) : base(securityMode, relayClientAuthenticationType, reliableSessionEnabled)
 {
     base.ReliableSessionBindingElement.ReliableMessagingVersion = WS2007HttpRelayBinding.WS2007ReliableMessagingVersion;
     base.HttpsTransport.MessageSecurityVersion = WS2007HttpRelayBinding.WS2007MessageSecurityVersion;
 }
 public WS2007HttpRelayBinding(EndToEndSecurityMode securityMode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType) : this(securityMode, relayClientAuthenticationType, false)
 {
 }
 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));
 }
        private BindingElement BuildInnerBindingElement(BindingContext context)
        {
            SocketConnectionBindingElement socketConnectionBindingElement = null;
            NameSettings nameSetting = context.BindingParameters.Find <NameSettings>();
            NameSettings relayClientAuthenticationType = nameSetting;

            if (nameSetting == null)
            {
                relayClientAuthenticationType = new NameSettings();
                context.BindingParameters.Add(relayClientAuthenticationType);
            }
            relayClientAuthenticationType.ServiceSettings.TransportProtection           = (this.transportProtectionEnabled ? RelayTransportProtectionMode.EndToEnd : RelayTransportProtectionMode.None);
            relayClientAuthenticationType.ServiceSettings.RelayClientAuthenticationType = this.RelayClientAuthenticationType;
            relayClientAuthenticationType.ServiceSettings.IsDynamic = this.IsDynamic;
            TokenProvider tokenProvider = TokenProviderUtility.CreateTokenProvider(context);

            switch (this.relayedConnectionMode)
            {
            case TcpRelayConnectionMode.Relayed:
            {
                if (relayClientAuthenticationType.ServiceSettings.ListenerType != ListenerType.RelayedHttp)
                {
                    relayClientAuthenticationType.ServiceSettings.ListenerType = ListenerType.RelayedConnection;
                }
                ConnectivitySettings     connectivitySetting     = context.BindingParameters.Find <ConnectivitySettings>();
                HttpConnectivitySettings httpConnectivitySetting = context.BindingParameters.Find <HttpConnectivitySettings>();
                socketConnectionBindingElement = new SocketConnectionBindingElement(new ConnectivityModeConnectionElement(tokenProvider, (this.transportProtectionEnabled ? SocketSecurityRole.SslClient : SocketSecurityRole.None), context, relayClientAuthenticationType, connectivitySetting, httpConnectivitySetting));
                break;
            }

            case TcpRelayConnectionMode.Hybrid:
            {
                if (base.ChannelInitializationTimeout < TimeSpan.FromSeconds(60))
                {
                    base.ChannelInitializationTimeout = TimeSpan.FromSeconds(60);
                }
                relayClientAuthenticationType.ServiceSettings.ListenerType = ListenerType.DirectConnection;
                socketConnectionBindingElement = new SocketConnectionBindingElement(new HybridConnectionElement(context, this, relayClientAuthenticationType, tokenProvider));
                break;
            }

            default:
            {
                goto case TcpRelayConnectionMode.Relayed;
            }
            }
            socketConnectionBindingElement.ChannelInitializationTimeout        = base.ChannelInitializationTimeout;
            socketConnectionBindingElement.ConnectionBufferSize                = base.ConnectionBufferSize;
            socketConnectionBindingElement.ConnectionPoolSettings.GroupName    = this.ConnectionPoolSettings.GroupName;
            socketConnectionBindingElement.ConnectionPoolSettings.IdleTimeout  = this.ConnectionPoolSettings.IdleTimeout;
            socketConnectionBindingElement.ConnectionPoolSettings.LeaseTimeout = this.ConnectionPoolSettings.LeaseTimeout;
            socketConnectionBindingElement.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = this.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint;
            socketConnectionBindingElement.ExposeConnectionProperty   = base.ExposeConnectionProperty;
            socketConnectionBindingElement.HostNameComparisonMode     = base.HostNameComparisonMode;
            socketConnectionBindingElement.InheritBaseAddressSettings = base.InheritBaseAddressSettings;
            socketConnectionBindingElement.ListenBacklog          = this.ListenBacklog;
            socketConnectionBindingElement.ManualAddressing       = base.ManualAddressing;
            socketConnectionBindingElement.MaxBufferPoolSize      = this.MaxBufferPoolSize;
            socketConnectionBindingElement.MaxBufferSize          = base.MaxBufferSize;
            socketConnectionBindingElement.MaxOutputDelay         = base.MaxOutputDelay;
            socketConnectionBindingElement.MaxPendingAccepts      = base.MaxPendingAccepts;
            socketConnectionBindingElement.MaxPendingConnections  = base.MaxPendingConnections;
            socketConnectionBindingElement.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
            socketConnectionBindingElement.TransferMode           = base.TransferMode;
            socketConnectionBindingElement.TeredoEnabled          = false;
            return(socketConnectionBindingElement);
        }
Example #21
0
 public RelayedOnewayTransportBindingElement(Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType) : this(relayClientAuthenticationType, RelayedOnewayConnectionMode.Unicast)
 {
 }
Example #22
0
        internal static bool TryCreate(SecurityBindingElement wsSecurity, EndToEndSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, bool isReliableSessionEnabled, TcpRelayTransportSecurity tcpTransportSecurity, out NetTcpRelaySecurity security)
        {
            security = null;
            MessageSecurityOverRelayConnection messageSecurityOverRelayConnection = null;

            if ((mode == EndToEndSecurityMode.Message || mode == EndToEndSecurityMode.TransportWithMessageCredential) && !MessageSecurityOverRelayConnection.TryCreate(wsSecurity, isReliableSessionEnabled, out messageSecurityOverRelayConnection))
            {
                return(false);
            }
            security = new NetTcpRelaySecurity(mode, relayClientAuthenticationType, tcpTransportSecurity, messageSecurityOverRelayConnection);
            if (wsSecurity == null)
            {
                return(true);
            }
            Type type = typeof(SecurityElementBase);

            object[] objArray = new object[] { security.CreateMessageSecurity(isReliableSessionEnabled, wsSecurity.MessageSecurityVersion), wsSecurity, false };
            return((bool)InvokeHelper.InvokeStaticMethod(type, "AreBindingsMatching", objArray));
        }