public static void Validate(HostNameComparisonMode value, string parameterName)
 {
     if (!IsDefined(value))
     {
         throw Error.InvalidEnumArgument(parameterName, (int)value, typeof(HostNameComparisonMode));
     }
 }
 public static bool IsDefined(HostNameComparisonMode value)
 {
     return
         value == HostNameComparisonMode.StrongWildcard
         || value == HostNameComparisonMode.Exact
         || value == HostNameComparisonMode.WeakWildcard;
 }
 public static void Validate(HostNameComparisonMode value)
 {
     if (!IsDefined(value))
     {
         throw Fx.Exception.AsError(new InvalidEnumArgumentException("value", (int)value, typeof(HostNameComparisonMode)));
     }
 }
 public static bool IsDefined(HostNameComparisonMode value)
 {
     return
         (value == HostNameComparisonMode.StrongWildcard ||
          value == HostNameComparisonMode.Exact ||
          value == HostNameComparisonMode.WeakWildcard);
 }
        protected HttpTransportBindingElement(
            HttpTransportBindingElement other)
            : base(other)
        {
            allow_cookies         = other.allow_cookies;
            bypass_proxy_on_local = other.bypass_proxy_on_local;
            unsafe_ntlm_auth      = other.unsafe_ntlm_auth;
            use_default_proxy     = other.use_default_proxy;
            keep_alive_enabled    = other.keep_alive_enabled;
            max_buffer_size       = other.max_buffer_size;
            host_cmp_mode         = other.host_cmp_mode;
            proxy_address         = other.proxy_address;
            realm         = other.realm;
            transfer_mode = other.transfer_mode;
            // FIXME: it does not look safe
            timeouts          = other.timeouts;
            auth_scheme       = other.auth_scheme;
            proxy_auth_scheme = other.proxy_auth_scheme;

#if NET_4_0
            DecompressionEnabled           = other.DecompressionEnabled;
            LegacyExtendedProtectionPolicy = other.LegacyExtendedProtectionPolicy;
            ExtendedProtectionPolicy       = other.ExtendedProtectionPolicy;
            cookie_manager = other.cookie_manager;
#endif
        }
 public static void Validate(HostNameComparisonMode value)
 {
     if (!IsDefined(value))
     {
         throw Fx.Exception.AsError(new InvalidEnumArgumentException("value", (int)value, typeof(HostNameComparisonMode)));
     }
 }
示例#7
0
 public static void Validate(HostNameComparisonMode value)
 {
     if (!IsDefined(value))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int)value, typeof(HostNameComparisonMode)));
     }
 }
示例#8
0
        internal bool IsScopeIdCompatible(HostNameComparisonMode hostNameComparisonMode, Uri uri)
        {
            if (this.hostNameComparisonMode != hostNameComparisonMode)
            {
                return(false);
            }

            if (hostNameComparisonMode == HostNameComparisonMode.Exact && uri.HostNameType == UriHostNameType.IPv6)
            {
                // the hostname type of the channel listener MUST be IPv6 if we got here.
                // as this should have been enforced by UriPrefixTable.
                if (Uri.HostNameType != UriHostNameType.IPv6)
                {
                    return(false);
                }

                IPAddress channelListenerIP = IPAddress.Parse(Uri.DnsSafeHost);
                IPAddress otherIP           = IPAddress.Parse(uri.DnsSafeHost);

                if (channelListenerIP.ScopeId != otherIP.ScopeId)
                {
                    return(false);
                }
            }

            return(true);
        }
 protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     AllowCookies                = elementToBeCloned.AllowCookies;
     AuthenticationScheme        = elementToBeCloned.AuthenticationScheme;
     BypassProxyOnLocal          = elementToBeCloned.BypassProxyOnLocal;
     _decompressionEnabled       = elementToBeCloned._decompressionEnabled;
     _hostNameComparisonMode     = elementToBeCloned._hostNameComparisonMode;
     _inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings;
     KeepAliveEnabled            = elementToBeCloned.KeepAliveEnabled;
     _maxBufferSize              = elementToBeCloned._maxBufferSize;
     _maxBufferSizeInitialized   = elementToBeCloned._maxBufferSizeInitialized;
     _maxPendingAccepts          = elementToBeCloned._maxPendingAccepts;
     _method      = elementToBeCloned._method;
     Proxy        = elementToBeCloned.Proxy;
     ProxyAddress = elementToBeCloned.ProxyAddress;
     _proxyAuthenticationScheme = elementToBeCloned._proxyAuthenticationScheme;
     _realm = elementToBeCloned._realm;
     _requestInitializationTimeout = elementToBeCloned._requestInitializationTimeout;
     _transferMode = elementToBeCloned._transferMode;
     UnsafeConnectionNtlmAuthentication = elementToBeCloned.UnsafeConnectionNtlmAuthentication;
     _useDefaultWebProxy       = elementToBeCloned._useDefaultWebProxy;
     _webSocketSettings        = elementToBeCloned._webSocketSettings.Clone();
     _extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
     MessageHandlerFactory     = elementToBeCloned.MessageHandlerFactory;
 }
 public static void Validate(HostNameComparisonMode value)
 {
     if (!IsDefined(value))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int) value, typeof(HostNameComparisonMode)));
     }
 }
示例#11
0
        public void Endpoint_Ctor_Initializes_All_Properties()
        {
            HttpEndpointElement el = new HttpEndpointElement();

            Assert.AreEqual(HttpBehavior.DefaultHelpEnabled, el.HelpEnabled, "HelpEnabled wrong");
            Assert.AreEqual(HttpBehavior.DefaultTrailingSlashMode, el.TrailingSlashMode, "TrailingSlashMode wrong");
            Assert.AreEqual(string.Empty, el.OperationHandlerFactory, "HttpOperationHandlerFactory should default to empty");

            HostNameComparisonMode mode = el.HostNameComparisonMode;

            Assert.AreEqual(HostNameComparisonMode.StrongWildcard, mode, "HostNameComparisonMode failed");

            long maxBufferPoolSize         = el.MaxBufferPoolSize;
            long expectedMaxBufferPoolSize = 0x80000L;

            Assert.AreEqual(expectedMaxBufferPoolSize, maxBufferPoolSize, "MaxBufferPoolSize failed");

            Assert.AreEqual(0x10000, el.MaxBufferSize, "MaxBufferSize failed");
            Assert.AreEqual(0x10000L, el.MaxReceivedMessageSize, "MaxReceivedMessageSize failed");

            HttpBindingSecurityElement secElement = el.Security;

            Assert.IsNotNull(secElement, "Security failed");

            TransferMode xferMode = el.TransferMode;

            Assert.AreEqual(TransferMode.Buffered, xferMode, "TransferMode failed");
        }
示例#12
0
 protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     this.allowCookies               = elementToBeCloned.allowCookies;
     this.authenticationScheme       = elementToBeCloned.authenticationScheme;
     this.bypassProxyOnLocal         = elementToBeCloned.bypassProxyOnLocal;
     this.decompressionEnabled       = elementToBeCloned.decompressionEnabled;
     this.hostNameComparisonMode     = elementToBeCloned.hostNameComparisonMode;
     this.inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings;
     this.keepAliveEnabled           = elementToBeCloned.keepAliveEnabled;
     this.maxBufferSize              = elementToBeCloned.maxBufferSize;
     this.maxBufferSizeInitialized   = elementToBeCloned.maxBufferSizeInitialized;
     this.maxPendingAccepts          = elementToBeCloned.maxPendingAccepts;
     this.method       = elementToBeCloned.method;
     this.proxyAddress = elementToBeCloned.proxyAddress;
     this.proxyAuthenticationScheme = elementToBeCloned.proxyAuthenticationScheme;
     this.realm = elementToBeCloned.realm;
     this.requestInitializationTimeout = elementToBeCloned.requestInitializationTimeout;
     this.transferMode = elementToBeCloned.transferMode;
     this.unsafeConnectionNtlmAuthentication = elementToBeCloned.unsafeConnectionNtlmAuthentication;
     this.useDefaultWebProxy       = elementToBeCloned.useDefaultWebProxy;
     this.webSocketSettings        = elementToBeCloned.webSocketSettings.Clone();
     this.webProxy                 = elementToBeCloned.webProxy;
     this.extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
     if (elementToBeCloned.anonymousUriPrefixMatcher != null)
     {
         this.anonymousUriPrefixMatcher = new HttpAnonymousUriPrefixMatcher(elementToBeCloned.anonymousUriPrefixMatcher);
     }
     this.MessageHandlerFactory = elementToBeCloned.MessageHandlerFactory;
 }
 public static void Validate(HostNameComparisonMode value, string parameterName)
 {
     if (!IsDefined(value))
     {
         throw Error.InvalidEnumArgument(parameterName, (int)value, typeof(HostNameComparisonMode));
     }
 }
示例#14
0
 public static void Validate(HostNameComparisonMode value)
 {
     if (!Microsoft.ServiceBus.Channels.HostNameComparisonModeHelper.IsDefined(value))
     {
         throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int)value, typeof(HostNameComparisonMode)));
     }
 }
示例#15
0
        public bool TryLookupUri(Uri uri, HostNameComparisonMode hostNameComparisonMode, out TItem item)
        {
            BaseUriWithWildcard key = new BaseUriWithWildcard(uri, hostNameComparisonMode);

            if (TryCacheLookup(key, out item))
            {
                return(item != null);
            }

            using (AsyncLock.TakeLock())
            {
                // exact match failed, perform the full lookup (which will also
                // catch case-insensitive variations that aren't yet in our cache)
                bool dummy;
                SegmentHierarchyNode <TItem> node = FindDataNode(
                    UriSegmenter.ToPath(key.BaseAddress, hostNameComparisonMode, includePortInComparison), out dummy);
                if (node != null)
                {
                    item = node.Data;
                }
                // We want to cache both positive AND negative results
                AddToCache(key, item);
                return(item != null);
            }
        }
示例#16
0
 internal static bool IsDefined(HostNameComparisonMode value)
 {
     if ((value != HostNameComparisonMode.StrongWildcard) && (value != HostNameComparisonMode.Exact))
     {
         return(value == HostNameComparisonMode.WeakWildcard);
     }
     return(true);
 }
示例#17
0
 public BaseUriWithWildcard(Uri baseAddress, HostNameComparisonMode hostNameComparisonMode)
 {
     _baseAddress = baseAddress;
     _hostNameComparisonMode = hostNameComparisonMode;
     this.SetComparisonAddressAndHashCode();
     // Note the Uri may contain query string for WSDL purpose.
     // So do not check IsValid().
 }
 internal static bool IsDefined(HostNameComparisonMode value)
 {
     if ((value != HostNameComparisonMode.StrongWildcard) && (value != HostNameComparisonMode.Exact))
     {
         return (value == HostNameComparisonMode.WeakWildcard);
     }
     return true;
 }
 internal static string[] ToPath(Uri uriPath, HostNameComparisonMode hostNameComparisonMode, bool includePortInComparison)
 {
     if (null == uriPath)
     {
         return(new string[0]);
     }
     return((new UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum(uriPath)).GetSegments(hostNameComparisonMode, includePortInComparison));
 }
示例#20
0
 public BaseUriWithWildcard(Uri baseAddress, HostNameComparisonMode hostNameComparisonMode)
 {
     _baseAddress            = baseAddress;
     _hostNameComparisonMode = hostNameComparisonMode;
     this.SetComparisonAddressAndHashCode();
     // Note the Uri may contain query string for WSDL purpose.
     // So do not check IsValid().
 }
示例#21
0
        //private int _maxItemsInObjectGraph;

        #endregion

        /// <summary>
        /// wcf服务端常量设置文件
        /// </summary>
        /// <param name="doc"></param>
        public WcfConstantSettingConfig(XmlDocument doc)
        {
            try
            {
                foreach (XmlNode elem in XmlHelper.Children(doc.DocumentElement, "NetTcpBinding"))
                {
                    XmlElement xe = XmlHelper.Child(elem, "readerQuotas");
                    int.TryParse(xe.GetAttribute("maxDepth"), out _maxDepth);
                    int.TryParse(xe.GetAttribute("maxStringContentLength"), out _maxStringContentLength);
                    int.TryParse(xe.GetAttribute("maxArrayLength"), out _maxArrayLength);
                    int.TryParse(xe.GetAttribute("maxBytesPerRead"), out _maxBytesPerRead);
                    int.TryParse(xe.GetAttribute("maxNameTableCharCount"), out _maxNameTableCharCount);

                    XmlElement xea = XmlHelper.Child(elem, "reliableSession");
                    Boolean.TryParse(xea.GetAttribute("enabled"), out _reliableSessionEnabled);
                    Boolean.TryParse(xea.GetAttribute("ordered"), out _reliableSessionOrdered);
                    TimeSpan.TryParse(xea.GetAttribute("inactivityTimeout"), out _reliableSessionInactivityTimeout);

                    XmlElement xe1 = XmlHelper.Child(elem, "host");
                    _addres  = new Uri(xe1.GetAttribute("baseAddress"));
                    _binding = new NetTcpBinding();

                    XmlElement xe2 = XmlHelper.Child(elem, "behaviors");
                    TimeSpan.TryParse(xe2.GetAttribute("closeTimeout"), out _closeTimeout);
                    TimeSpan.TryParse(xe2.GetAttribute("openTimeout"), out _openTimeout);
                    TimeSpan.TryParse(xe2.GetAttribute("receiveTimeout"), out _receiveTimeout);
                    TimeSpan.TryParse(xe2.GetAttribute("sendTimeout"), out _sendTimeout);
                    Boolean.TryParse(xe2.GetAttribute("transactionFlow"), out _transactionFlow);
                    _transferMode           = (TransferMode)Enum.Parse(typeof(TransferMode), xe2.GetAttribute("transferMode"));
                    _transactionProtocol    = xe2.GetAttribute("transactionProtocol");
                    _hostNameComparisonMode = (HostNameComparisonMode)Enum.Parse(typeof(HostNameComparisonMode), xe2.GetAttribute("hostNameComparisonMode"));
                    int.TryParse(xe2.GetAttribute("listenBacklog"), out _listenBacklog);
                    int.TryParse(xe2.GetAttribute("maxBufferPoolSize"), out _maxBufferPoolSize);
                    int.TryParse(xe2.GetAttribute("maxBufferSize"), out _maxBufferSize);
                    int.TryParse(xe2.GetAttribute("maxConnections"), out _maxConnections);
                    int.TryParse(xe2.GetAttribute("maxReceivedMessageSize"), out _maxReceivedMessageSize);
                    bool.TryParse(xe2.GetAttribute("portSharingEnabled"), out _portSharingEnabled);
                    _securitymode         = (SecurityMode)Enum.Parse(typeof(SecurityMode), xe2.GetAttribute("securitymode"));
                    _clientCredentialType = (MessageCredentialType)Enum.Parse(typeof(MessageCredentialType), xe2.GetAttribute("clientCredentialType"));
                    //_enableBinaryFormatterBehavior = bool.Parse(xe2.GetAttribute("enableBinaryFormatterBehavior"));

                    XmlElement xe3 = XmlHelper.Child(elem, "serviceDebug");
                    Boolean.TryParse(xe3.GetAttribute("includeExceptionDetailInFaults"), out _includeExceptionDetailInFaults);

                    XmlElement xe4 = XmlHelper.Child(elem, "serviceThrottling");
                    int.TryParse(xe4.GetAttribute("maxConcurrentCalls"), out _maxConcurrentCalls);
                    int.TryParse(xe4.GetAttribute("maxConcurrentInstances"), out _maxConcurrentInstances);
                    int.TryParse(xe4.GetAttribute("maxConcurrentSessions"), out _maxConcurrentSessions);

                    //XmlElement xe5 = XmlHelper.Child(elem, "dataContractSerializer");
                    //int.TryParse(xe5.GetAttribute("maxItemsInObjectGraph"), out _maxItemsInObjectGraph);
                }
            }
            catch (Exception oe)
            {
                throw new ArgumentException(oe.Message);
            }
        }
        /// <summary>
        /// wcf服务端常量设置文件
        /// </summary>
        /// <param name="doc"></param>
        public WcfConstantSettingConfig(XmlDocument doc)
        {
            try
            {
                foreach (XmlNode elem in XmlHelper.Children(doc.DocumentElement, "NetTcpBinding"))
                {
                    XmlElement xe = XmlHelper.Child(elem, "readerQuotas");
                    int.TryParse(xe.GetAttribute("maxDepth"), out _maxDepth);
                    int.TryParse(xe.GetAttribute("maxStringContentLength"), out _maxStringContentLength);
                    int.TryParse(xe.GetAttribute("maxArrayLength"), out _maxArrayLength);
                    int.TryParse(xe.GetAttribute("maxBytesPerRead"), out _maxBytesPerRead);
                    int.TryParse(xe.GetAttribute("maxNameTableCharCount"), out _maxNameTableCharCount);

                    XmlElement xea = XmlHelper.Child(elem, "reliableSession");
                    Boolean.TryParse(xea.GetAttribute("enabled"), out _reliableSessionEnabled);
                    Boolean.TryParse(xea.GetAttribute("ordered"), out _reliableSessionOrdered);
                    TimeSpan.TryParse(xea.GetAttribute("inactivityTimeout"), out _reliableSessionInactivityTimeout);

                    XmlElement xe1 = XmlHelper.Child(elem, "host");
                    _addres = new Uri(xe1.GetAttribute("baseAddress"));
                    _binding = new NetTcpBinding();

                    XmlElement xe2 = XmlHelper.Child(elem, "behaviors");
                    TimeSpan.TryParse(xe2.GetAttribute("closeTimeout"), out _closeTimeout);
                    TimeSpan.TryParse(xe2.GetAttribute("openTimeout"), out _openTimeout);
                    TimeSpan.TryParse(xe2.GetAttribute("receiveTimeout"), out _receiveTimeout);
                    TimeSpan.TryParse(xe2.GetAttribute("sendTimeout"), out _sendTimeout);
                    Boolean.TryParse(xe2.GetAttribute("transactionFlow"), out _transactionFlow);
                    _transferMode = (TransferMode)Enum.Parse(typeof(TransferMode), xe2.GetAttribute("transferMode"));
                    _transactionProtocol = xe2.GetAttribute("transactionProtocol");
                    _hostNameComparisonMode = (HostNameComparisonMode)Enum.Parse(typeof(HostNameComparisonMode), xe2.GetAttribute("hostNameComparisonMode"));
                    int.TryParse(xe2.GetAttribute("listenBacklog"), out _listenBacklog);
                    int.TryParse(xe2.GetAttribute("maxBufferPoolSize"), out _maxBufferPoolSize);
                    int.TryParse(xe2.GetAttribute("maxBufferSize"), out _maxBufferSize);
                    int.TryParse(xe2.GetAttribute("maxConnections"), out _maxConnections);
                    int.TryParse(xe2.GetAttribute("maxReceivedMessageSize"), out _maxReceivedMessageSize);
                    bool.TryParse(xe2.GetAttribute("portSharingEnabled"), out _portSharingEnabled);
                    _securitymode = (SecurityMode)Enum.Parse(typeof(SecurityMode), xe2.GetAttribute("securitymode"));
                    _clientCredentialType = (MessageCredentialType)Enum.Parse(typeof(MessageCredentialType), xe2.GetAttribute("clientCredentialType"));
                    //_enableBinaryFormatterBehavior = bool.Parse(xe2.GetAttribute("enableBinaryFormatterBehavior"));

                    XmlElement xe3 = XmlHelper.Child(elem, "serviceDebug");
                    Boolean.TryParse(xe3.GetAttribute("includeExceptionDetailInFaults"), out _includeExceptionDetailInFaults);

                    XmlElement xe4 = XmlHelper.Child(elem, "serviceThrottling");
                    int.TryParse(xe4.GetAttribute("maxConcurrentCalls"), out _maxConcurrentCalls);
                    int.TryParse(xe4.GetAttribute("maxConcurrentInstances"), out _maxConcurrentInstances);
                    int.TryParse(xe4.GetAttribute("maxConcurrentSessions"), out _maxConcurrentSessions);

                    //XmlElement xe5 = XmlHelper.Child(elem, "dataContractSerializer");
                    //int.TryParse(xe5.GetAttribute("maxItemsInObjectGraph"), out _maxItemsInObjectGraph);
                }
            }
            catch (Exception oe)
            {
                throw new ArgumentException(oe.Message);
            }
        }
 internal ConnectionOrientedTransportBindingElement()
     : base()
 {
     _connectionBufferSize   = ConnectionOrientedTransportDefaults.ConnectionBufferSize;
     _hostNameComparisonMode = ConnectionOrientedTransportDefaults.HostNameComparisonMode;
     _maxOutputDelay         = ConnectionOrientedTransportDefaults.MaxOutputDelay;
     _maxBufferSize          = TransportDefaults.MaxBufferSize;
     _transferMode           = ConnectionOrientedTransportDefaults.TransferMode;
 }
 internal ConnectionOrientedTransportBindingElement(ConnectionOrientedTransportBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     _connectionBufferSize     = elementToBeCloned._connectionBufferSize;
     _exposeConnectionProperty = elementToBeCloned._exposeConnectionProperty;
     _hostNameComparisonMode   = elementToBeCloned._hostNameComparisonMode;
     _maxBufferSize            = elementToBeCloned._maxBufferSize;
     _maxBufferSizeInitialized = elementToBeCloned._maxBufferSizeInitialized;
     _transferMode             = elementToBeCloned._transferMode;
 }
            internal static string[] ToPath(Uri uriPath, HostNameComparisonMode hostNameComparisonMode, bool includePortInComparison)
            {
                if (null == uriPath)
                {
                    return(new string[0]);
                }
                UriSegmentEnum <TItem> enum2 = new UriSegmentEnum <TItem>(uriPath);

                return(enum2.GetSegments(hostNameComparisonMode, includePortInComparison));
            }
示例#26
0
            internal static string[] ToPath(Uri uriPath, HostNameComparisonMode hostNameComparisonMode,
                                            bool includePortInComparison)
            {
                if (null == uriPath)
                {
                    return(new string[0]);
                }
                UriSegmentEnum segmentEnum = new UriSegmentEnum(uriPath); // struct

                return(segmentEnum.GetSegments(hostNameComparisonMode, includePortInComparison));
            }
 public PipeConnectionListener(Uri pipeUri, HostNameComparisonMode hostNameComparisonMode, int bufferSize, List<SecurityIdentifier> allowedSids, bool useCompletionPort, int maxConnections)
 {
     PipeUri.Validate(pipeUri);
     this.pipeUri = pipeUri;
     this.hostNameComparisonMode = hostNameComparisonMode;
     this.allowedSids = allowedSids;
     this.bufferSize = bufferSize;
     this.pendingAccepts = new List<PendingAccept>();
     this.useCompletionPort = useCompletionPort;
     this.maxInstances = Math.Min(maxConnections, 0xff);
 }
 public PipeConnectionListener(Uri pipeUri, HostNameComparisonMode hostNameComparisonMode, int bufferSize, List <SecurityIdentifier> allowedSids, bool useCompletionPort, int maxConnections)
 {
     PipeUri.Validate(pipeUri);
     this.pipeUri = pipeUri;
     this.hostNameComparisonMode = hostNameComparisonMode;
     this.allowedSids            = allowedSids;
     this.bufferSize             = bufferSize;
     this.pendingAccepts         = new List <PendingAccept>();
     this.useCompletionPort      = useCompletionPort;
     this.maxInstances           = Math.Min(maxConnections, 0xff);
 }
示例#29
0
 internal ConnectionOrientedTransportBindingElement(
     ConnectionOrientedTransportBindingElement other)
     : base(other)
 {
     connection_buf_size = other.connection_buf_size;
     max_buf_size        = other.max_buf_size;
     max_pending_conn    = other.max_pending_conn;
     max_pending_accepts = other.max_pending_accepts;
     host_cmp_mode       = other.host_cmp_mode;
     max_output_delay    = other.max_output_delay;
     transfer_mode       = other.transfer_mode;
 }
示例#30
0
 internal ConnectionOrientedTransportBindingElement()
     : base()
 {
     connectionBufferSize         = ConnectionOrientedTransportDefaults.ConnectionBufferSize;
     hostNameComparisonMode       = ConnectionOrientedTransportDefaults.HostNameComparisonMode;
     channelInitializationTimeout = ConnectionOrientedTransportDefaults.ChannelInitializationTimeout;
     maxBufferSize         = TransportDefaults.MaxBufferSize;
     maxPendingConnections = ConnectionOrientedTransportDefaults.GetMaxPendingConnections();
     maxOutputDelay        = ConnectionOrientedTransportDefaults.MaxOutputDelay;
     maxPendingAccepts     = ConnectionOrientedTransportDefaults.GetMaxPendingAccepts();
     transferMode          = ConnectionOrientedTransportDefaults.TransferMode;
 }
        public PrefixEndpointAddressMessageFilter(EndpointAddress address, bool includeHostNameInComparison)
        {
            Address = address ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(address));
            _helper = new EndpointAddressMessageFilterHelper(Address);

            _hostNameComparisonMode = includeHostNameInComparison
                ? HostNameComparisonMode.Exact
                : HostNameComparisonMode.StrongWildcard;

            _addressTable = new UriPrefixTable <object>();
            _addressTable.RegisterUri(Address.Uri, _hostNameComparisonMode, new object());
        }
 public PrefixEndpointAddressMessageFilter(EndpointAddress address, bool includeHostNameInComparison)
 {
     if (address == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("address");
     }
     this.address = address;
     this.helper  = new EndpointAddressMessageFilterHelper(this.address);
     this.hostNameComparisonMode = includeHostNameInComparison ? HostNameComparisonMode.Exact : HostNameComparisonMode.StrongWildcard;
     this.addressTable           = new UriPrefixTable <object>();
     this.addressTable.RegisterUri(this.address.Uri, this.hostNameComparisonMode, new object());
 }
示例#33
0
 protected override void OnOpening()
 {
     base.OnOpening();
     if (this.HostedVirtualPath != null)
     {
         BaseUriWithWildcard baseUri = AspNetEnvironment.Current.GetBaseUri(this.Scheme, this.Uri);
         if (baseUri != null)
         {
             this.hostNameComparisonMode = baseUri.HostNameComparisonMode;
         }
     }
     this.bufferManager = System.ServiceModel.Channels.BufferManager.CreateBufferManager(this.MaxBufferPoolSize, this.GetMaxBufferSize());
 }
                public string[] GetSegments(HostNameComparisonMode hostNameComparisonMode, bool includePortInComparison)
                {
                    List <string> list = new List <string>();

                    while (this.Next())
                    {
                        switch (this.type)
                        {
                        case UriSegmentType <TItem> .Host:
                        {
                            if (hostNameComparisonMode != HostNameComparisonMode.StrongWildcard)
                            {
                                break;
                            }
                            list.Add("+");
                            continue;
                        }

                        case UriSegmentType <TItem> .Port:
                        {
                            if (includePortInComparison || (hostNameComparisonMode == HostNameComparisonMode.Exact))
                            {
                                list.Add(this.segment);
                            }
                            continue;
                        }

                        case UriSegmentType <TItem> .Path:
                        {
                            list.Add(this.segment.Substring(this.segmentStartAt, this.segmentLength));
                            continue;
                        }

                        default:
                            goto Label_008B;
                        }
                        if (hostNameComparisonMode == HostNameComparisonMode.Exact)
                        {
                            list.Add(this.segment);
                        }
                        else
                        {
                            list.Add("*");
                        }
                        continue;
Label_008B:
                        list.Add(this.segment);
                    }
                    return(list.ToArray());
                }
示例#35
0
        protected bool TryLookupUri(Uri requestUri, string requestMethod,
                                    HostNameComparisonMode hostNameComparisonMode, bool isWebSocketRequest, out HttpChannelListener listener)
        {
            listener = null;

            if (isWebSocketRequest)
            {
                Fx.Assert(StringComparer.OrdinalIgnoreCase.Compare(requestMethod, "GET") == 0, "The requestMethod must be GET in WebSocket case.");
                requestMethod = WebSocketTransportSettings.WebSocketMethod;
            }

            if (requestMethod == null)
            {
                requestMethod = string.Empty;
            }

            UriPrefixTable <HttpChannelListener> addressTable;
            Dictionary <string, UriPrefixTable <HttpChannelListener> > localAddressTables = addressTables;

            // check for a method match if necessary
            HttpChannelListener methodListener = null;

            if (requestMethod.Length > 0)
            {
                if (localAddressTables.TryGetValue(requestMethod, out addressTable))
                {
                    if (addressTable.TryLookupUri(requestUri, hostNameComparisonMode, out methodListener) &&
                        string.Compare(requestUri.AbsolutePath, methodListener.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        methodListener = null;
                    }
                }
            }
            // and also check the wildcard bucket
            if (localAddressTables.TryGetValue(string.Empty, out addressTable) &&
                addressTable.TryLookupUri(requestUri, hostNameComparisonMode, out listener))
            {
                if (methodListener != null && methodListener.Uri.AbsoluteUri.Length >= listener.Uri.AbsoluteUri.Length)
                {
                    listener = methodListener;
                }
            }
            else
            {
                listener = methodListener;
            }

            return(listener != null);
        }
 public void RegisterUri(Uri uri, HostNameComparisonMode hostNameComparisonMode, TItem item)
 {
     lock (this.ThisLock)
     {
         this.ClearCache();
         BaseUriWithWildcard          baseUri = new BaseUriWithWildcard(uri, hostNameComparisonMode);
         SegmentHierarchyNode <TItem> node    = this.FindOrCreateNode(baseUri);
         if (node.Data != null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("DuplicateRegistration", new object[] { uri })));
         }
         node.SetData(item, baseUri);
         this.count++;
     }
 }
示例#37
0
        internal override void Unregister(TransportChannelListener channelListener)
        {
            UriPrefixTable <HttpChannelListener> addressTable;

            if (!addressTables.TryGetValue(((HttpChannelListener)channelListener).Method, out addressTable))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(
                                                                                                            SR.ListenerFactoryNotRegistered, channelListener.Uri)));
            }

            HostNameComparisonMode registeredMode = channelListener.InheritBaseAddressSettings ? hostNameComparisonMode : channelListener.HostNameComparisonModeInternal;

            EnsureRegistered(addressTable, (HttpChannelListener)channelListener, registeredMode);
            addressTable.UnregisterUri(channelListener.Uri, registeredMode);
        }
                public string[] GetSegments(HostNameComparisonMode hostNameComparisonMode, bool includePortInComparison)
                {
                    List <string> strs = new List <string>();

                    while (this.Next())
                    {
                        switch (this.type)
                        {
                        case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Host:
                        {
                            if (hostNameComparisonMode == HostNameComparisonMode.StrongWildcard)
                            {
                                strs.Add("+");
                                continue;
                            }
                            else if (hostNameComparisonMode != HostNameComparisonMode.Exact)
                            {
                                strs.Add("*");
                                continue;
                            }
                            else
                            {
                                strs.Add(this.segment);
                                continue;
                            }
                        }

                        case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Port:
                        {
                            if (!includePortInComparison && hostNameComparisonMode != HostNameComparisonMode.Exact)
                            {
                                continue;
                            }
                            strs.Add(this.segment);
                            continue;
                        }

                        case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Path:
                        {
                            strs.Add(this.segment.Substring(this.segmentStartAt, this.segmentLength));
                            continue;
                        }
                        }
                        strs.Add(this.segment);
                    }
                    return(strs.ToArray());
                }
        public static string BuildSharedMemoryName(Uri uri, HostNameComparisonMode hostNameComparisonMode, bool global)
        {
            string path = GetPath(uri);
            string hostName = null;
            switch (hostNameComparisonMode)
            {
                case HostNameComparisonMode.StrongWildcard:
                    hostName = "+";
                    break;

                case HostNameComparisonMode.Exact:
                    hostName = uri.Host;
                    break;

                case HostNameComparisonMode.WeakWildcard:
                    hostName = "*";
                    break;
            }
            return BuildSharedMemoryName(hostName, path, global);
        }
 public UniqueTransportManagerRegistration(TransportManager uniqueManager, Uri listenUri, HostNameComparisonMode hostNameComparisonMode)
     : base(listenUri, hostNameComparisonMode)
 {
     this.list = new List<TransportManager>();
     this.list.Add(uniqueManager);
 }
        protected bool TryLookupUri(Uri requestUri, string requestMethod,
                    HostNameComparisonMode hostNameComparisonMode, bool isWebSocketRequest, out HttpChannelListener listener)
        {
            listener = null;

            if (isWebSocketRequest)
            {
                Fx.Assert(StringComparer.OrdinalIgnoreCase.Compare(requestMethod, "GET") == 0, "The requestMethod must be GET in WebSocket case.");
                requestMethod = WebSocketTransportSettings.WebSocketMethod;
            }
            
            if (requestMethod == null)
            {
                requestMethod = string.Empty;
            }

            UriPrefixTable<HttpChannelListener> addressTable;
            Dictionary<string, UriPrefixTable<HttpChannelListener>> localAddressTables = addressTables;

            // check for a method match if necessary
            HttpChannelListener methodListener = null;
            if (requestMethod.Length > 0)
            {
                if (localAddressTables.TryGetValue(requestMethod, out addressTable))
                {
                    if (addressTable.TryLookupUri(requestUri, hostNameComparisonMode, out methodListener)
                        && string.Compare(requestUri.AbsolutePath, methodListener.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        methodListener = null;
                    }
                }
            }
            // and also check the wildcard bucket 
            if (localAddressTables.TryGetValue(string.Empty, out addressTable)
                && addressTable.TryLookupUri(requestUri, hostNameComparisonMode, out listener))
            {
                if (methodListener != null && methodListener.Uri.AbsoluteUri.Length >= listener.Uri.AbsoluteUri.Length)
                {
                    listener = methodListener;
                }
            }
            else
            {
                listener = methodListener;
            }

            return (listener != null);
        }
 internal HttpTransportManager(Uri listenUri, HostNameComparisonMode hostNameComparisonMode)
     : this()
 {
     this.hostNameComparisonMode = hostNameComparisonMode;
     this.listenUri = listenUri;
 }
 internal HttpTransportManager(Uri listenUri, HostNameComparisonMode hostNameComparisonMode, string realm)
     : this(listenUri, hostNameComparisonMode)
 {
     this.realm = realm;
 }
示例#44
0
 private string ParseHostAndHostNameComparisonMode(string host)
 {
     if (string.IsNullOrEmpty(host) || host.Equals(star))
     {
         _hostNameComparisonMode = HostNameComparisonMode.WeakWildcard;
         host = DnsCache.MachineName;
     }
     else if (host.Equals(plus))
     {
         _hostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
         host = DnsCache.MachineName;
     }
     else
     {
         _hostNameComparisonMode = HostNameComparisonMode.Exact;
     }
     return host;
 }