public virtual object Create(Object parent, object configContextObj, XmlNode section)
        {
            // if called through client config don't even load HttpRuntime
            if (!HandlerBase.IsServerConfiguration(configContextObj))
            {
                return(null);
            }

            bool   bTemp                    = false;
            int    iTemp                    = 0;
            uint   uiTemp                   = 0;
            string sTemp                    = null;
            int    maxWorkerThreads         = 0;
            int    maxIoThreads             = 0;
            int    minWorkerThreads         = 0;
            int    minIoThreads             = 0;
            int    responseDeadlockInterval = 0;

            HandlerBase.GetAndRemoveBooleanAttribute(section, "enable", ref bTemp);
            GetAndRemoveProcessModelTimeout(section, "timeout", ref iTemp);
            GetAndRemoveProcessModelTimeout(section, "idleTimeout", ref iTemp);
            GetAndRemoveProcessModelTimeout(section, "shutdownTimeout", ref iTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "requestLimit", ref iTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "requestQueueLimit", ref iTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "restartQueueLimit", ref iTemp);
            HandlerBase.GetAndRemoveIntegerAttribute(section, "memoryLimit", ref iTemp);
            GetAndRemoveUnsignedIntegerAttribute(section, "cpuMask", ref uiTemp);
            HandlerBase.GetAndRemoveEnumAttribute(section, "logLevel", typeof(LogLevelEnum), ref iTemp);
            HandlerBase.GetAndRemoveStringAttribute(section, "userName", ref sTemp);
            HandlerBase.GetAndRemoveStringAttribute(section, "password", ref sTemp);
            HandlerBase.GetAndRemoveBooleanAttribute(section, "webGarden", ref bTemp);
            GetAndRemoveProcessModelTimeout(section, "clientConnectedCheck", ref iTemp);
            HandlerBase.GetAndRemoveStringAttribute(section, "comImpersonationLevel", ref sTemp);
            HandlerBase.GetAndRemoveStringAttribute(section, "comAuthenticationLevel", ref sTemp);
            GetAndRemoveProcessModelTimeout(section, "responseDeadlockInterval", ref responseDeadlockInterval);
            GetAndRemoveProcessModelTimeout(section, "responseRestartDeadlockInterval", ref iTemp);
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "maxWorkerThreads", ref maxWorkerThreads);
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "maxIoThreads", ref maxIoThreads);
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "minWorkerThreads", ref minWorkerThreads);
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "minIoThreads", ref minIoThreads);
            HandlerBase.GetAndRemoveStringAttribute(section, "serverErrorMessageFile", ref sTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "requestAcks", ref iTemp);
            GetAndRemoveProcessModelTimeout(section, "pingFrequency", ref iTemp);
            GetAndRemoveProcessModelTimeout(section, "pingTimeout", ref iTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "asyncOption", ref iTemp);


            HandlerBase.CheckForUnrecognizedAttributes(section);
            HandlerBase.CheckForChildNodes(section);

            return(new ProcessModelConfig(maxWorkerThreads, maxIoThreads, minWorkerThreads, minIoThreads, responseDeadlockInterval));
        }
Ejemplo n.º 2
0
        //
        // Handle the <result> tag
        //
        static void ProcessResult(HttpCapabilitiesDefaultProvider capabilitiesEvaluator, XmlNode node)
        {
            bool inherit = true;

            HandlerBase.GetAndRemoveBooleanAttribute(node, "inherit", ref inherit);
            if (inherit == false)
            {
                capabilitiesEvaluator.ClearParent();
            }

            Type    resultType = null;
            XmlNode attribute  = HandlerBase.GetAndRemoveTypeAttribute(node, "type", ref resultType);

            if (attribute != null)
            {
                if (resultType.Equals(capabilitiesEvaluator._resultType) == false)
                {
                    // be sure the new type is assignable to the parent type
                    HandlerBase.CheckAssignableType(attribute, capabilitiesEvaluator._resultType, resultType);
                    capabilitiesEvaluator._resultType = resultType;
                }
            }

            int cacheTime = 0;

            attribute = HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "cacheTime", ref cacheTime);
            //NOTE: we continue to parse the cacheTime for backwards compat
            // it has never been used.  Customer scenarios don't require this support.
            if (attribute != null)
            {
                capabilitiesEvaluator.CacheTime = TimeSpan.FromSeconds(cacheTime);
            }

            HandlerBase.CheckForUnrecognizedAttributes(node);
            HandlerBase.CheckForNonCommentChildNodes(node);
        }
        //
        // Handle the <result> tag
        //
        static void ProcessResult(HttpCapabilitiesEvaluator capabilitiesEvaluator, XmlNode node)
        {
            bool inherit = true;

            HandlerBase.GetAndRemoveBooleanAttribute(node, "inherit", ref inherit);
            if (inherit == false)
            {
                capabilitiesEvaluator.ClearParent();
            }

            Type    resultType = null;
            XmlNode attribute  = HandlerBase.GetAndRemoveTypeAttribute(node, "type", ref resultType);

            if (attribute != null)
            {
                if (resultType.Equals(capabilitiesEvaluator._resultType) == false)
                {
                    // be sure the new type is assignable to the parent type
                    HandlerBase.CheckAssignableType(attribute, capabilitiesEvaluator._resultType, resultType);
                    capabilitiesEvaluator._resultType = resultType;
                }
            }

            int cacheTime = 0;

            attribute = HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "cacheTime", ref cacheTime);
            if (attribute != null)
            {
                capabilitiesEvaluator.SetCacheTime(cacheTime);
            }

            HandlerBase.GetAndRemoveBooleanAttribute(node, "cache", ref capabilitiesEvaluator._useCache);

            HandlerBase.CheckForUnrecognizedAttributes(node);
            HandlerBase.CheckForChildNodes(node);
        }
Ejemplo n.º 4
0
        private void ReadFormsSettings(XmlNode node)
        {
            XmlNode tempAttr = HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "name", ref _CookieName);

            //Trace("FormsAuthConfigSettings::ReadSettings cookie name " + _CookieName);

            tempAttr = HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "loginUrl", ref _LoginUrl);
            if (tempAttr != null)
            {
                if (_LoginUrl.StartsWith("\\\\") || (_LoginUrl.Length > 1 && _LoginUrl[1] == ':'))
                {
                    throw new ConfigurationException(
                              HttpRuntime.FormatResourceString(SR.Auth_bad_url),
                              tempAttr);
                }
            }
            //Trace("FormsAuthConfigSettings::ReadSettings login url " + _LoginUrl);

            int iTemp = 0;

            tempAttr = HandlerBase.GetAndRemoveEnumAttribute(node, "protection", typeof(FormsProtectionEnum), ref iTemp);
            if (tempAttr != null)
            {
                _Protection = (FormsProtectionEnum)iTemp;
            }

            tempAttr = HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "timeout", ref _Timeout);
            tempAttr = HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "path", ref _FormsCookiePath);
            HandlerBase.GetAndRemoveBooleanAttribute(node, "requireSSL", ref _RequireSSL);
            HandlerBase.GetAndRemoveBooleanAttribute(node, "slidingExpiration", ref _SlidingExpiration);
            HandlerBase.CheckForUnrecognizedAttributes(node);

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                if (child.Name != "credentials")
                {
                    HandlerBase.ThrowUnrecognizedElement(child);
                }

                tempAttr = HandlerBase.GetAndRemoveEnumAttribute(child, "passwordFormat", typeof(FormsAuthPasswordFormat), ref iTemp);
                if (tempAttr != null)
                {
                    _PasswordFormat = (FormsAuthPasswordFormat)iTemp;
                    //Trace("FormsAuthConfigSettings::ReadSettings password format " + strTemp);
                }

                HandlerBase.CheckForUnrecognizedAttributes(child);

                foreach (XmlNode child2 in child.ChildNodes)
                {
                    if (child2.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    if (child2.Name != "user")
                    {
                        HandlerBase.ThrowUnrecognizedElement(child2);
                    }

                    string strUser = null;
                    string strPass = null;
                    tempAttr = HandlerBase.GetAndRemoveRequiredStringAttribute(child2, "name", ref strUser);
                    HandlerBase.GetAndRemoveRequiredStringAttribute(child2, "password", ref strPass);
                    HandlerBase.CheckForUnrecognizedAttributes(child2);
                    HandlerBase.CheckForChildNodes(child2);

                    //Trace("FormsAuthConfigSettings::ReadSettings adding user " + strUser + " " + strPass);
                    strUser = strUser.ToLower(CultureInfo.InvariantCulture);
                    String strPassInTable = (String)_Credentials[strUser];
                    if (strPassInTable == null)
                    {
                        _Credentials.Add(strUser, strPass);
                    }
                    else
                    {
                        if (String.Compare(strPassInTable, strPass, false, CultureInfo.InvariantCulture) != 0)
                        {
                            throw new ConfigurationException(
                                      HttpRuntime.FormatResourceString(SR.User_Already_Specified, strUser), tempAttr);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        //
        // As required by IConfigurationSectionHandler
        //
        public object Create(object parent, object configurationContext, XmlNode section)
        {
            // if called through client config don't even load HttpRuntime
            if (!HandlerBase.IsServerConfiguration(configurationContext))
            {
                return(null);
            }

            ParseState parseState = new ParseState();

            parseState.SectionName = section.Name;

            // the rule is going to be the previous rule followed by a list containing the new rules
            parseState.Evaluator = new HttpCapabilitiesDefaultProvider((HttpCapabilitiesDefaultProvider)parent);

            int userAgentCacheKeyLength = 0;

            // Get the useragent string cachekey length
            if (parent != null)
            {
                userAgentCacheKeyLength = ((HttpCapabilitiesDefaultProvider)parent).UserAgentCacheKeyLength;
            }
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "userAgentCacheKeyLength", ref userAgentCacheKeyLength);

            if (userAgentCacheKeyLength == 0)
            {
                userAgentCacheKeyLength = _defaultUserAgentCacheKeyLength;
            }
            parseState.Evaluator.UserAgentCacheKeyLength = userAgentCacheKeyLength;

            string browserCapabilitiesProviderType = null;

            if (parent != null)
            {
                browserCapabilitiesProviderType = ((HttpCapabilitiesDefaultProvider)parent).BrowserCapabilitiesProviderType;
            }
            HandlerBase.GetAndRemoveNonEmptyStringAttribute(section, "provider", ref browserCapabilitiesProviderType);
            parseState.Evaluator.BrowserCapabilitiesProviderType = browserCapabilitiesProviderType;

            // check for random attributes
            HandlerBase.CheckForUnrecognizedAttributes(section);


            // iterate through XML section in order and apply the directives

            ArrayList sublist;

            sublist = RuleListFromElement(parseState, section, true);

            if (sublist.Count > 0)
            {
                parseState.RuleList.Add(new CapabilitiesSection(CapabilitiesRule.Filter, null, null, sublist));
            }

            if (parseState.FileList.Count > 0)
            {
                parseState.IsExternalFile = true;
                ResolveFiles(parseState, configurationContext);
            }

            // Add the new rules

            parseState.Evaluator.AddRuleList(parseState.RuleList);

            return(parseState.Evaluator);
        }
        internal void LoadValuesFromConfigurationInput(XmlNode node)
        {
            XmlNode n;

            // executionTimeout
            HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "executionTimeout", ref _executionTimeout);

            // maxRequestLength
            int limit = 0;

            if (HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(node, "maxRequestLength", ref limit) != null)
            {
                _maxRequestLength = limit * 1024;
            }

            // useFullyQualifiedRedirectUrl
            HandlerBase.GetAndRemoveBooleanAttribute(node, "useFullyQualifiedRedirectUrl", ref _useFullyQualifiedRedirectUrl);

            // minFreeThreads
            n = HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(node, "minFreeThreads", ref _minFreeThreads);

            int workerMax, ioMax;

            System.Threading.ThreadPool.GetMaxThreads(out workerMax, out ioMax);
            int maxThreads = (workerMax < ioMax) ? workerMax : ioMax;

            if (_minFreeThreads >= maxThreads)
            {
                throw new ConfigurationException(HttpRuntime.FormatResourceString(SR.Min_free_threads_must_be_under_thread_pool_limits, maxThreads.ToString()), (n != null) ? n : node);
            }

            // minLocalRequestFreeThreads
            n = HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(node, "minLocalRequestFreeThreads", ref _minLocalRequestFreeThreads);
            if (_minLocalRequestFreeThreads > _minFreeThreads)
            {
                throw new ConfigurationException(HttpRuntime.FormatResourceString(SR.Local_free_threads_cannot_exceed_free_threads), (n != null) ? n : node);
            }

            // appRequestQueueLimit
            HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "appRequestQueueLimit", ref _appRequestQueueLimit);

            // shutdownTimeout
            HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(node, "shutdownTimeout", ref _shutdownTimeout);

            // delayNotificationTimeout
            HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(node, "delayNotificationTimeout", ref _delayNotificationTimeout);

            // waitChangeNotification
            HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(node, "waitChangeNotification", ref _waitChangeNotification);

            // maxWaitChangeNotification
            HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(node, "maxWaitChangeNotification", ref _maxWaitChangeNotification);

            // enableKernelOutputCache
            HandlerBase.GetAndRemoveBooleanAttribute(node, "enableKernelOutputCache", ref _enableKernelOutputCache);

            // enableVersionHeader
            HandlerBase.GetAndRemoveBooleanAttribute(node, "enableVersionHeader", ref _enableVersionHeader);

#if USE_REGEX_CSS_VALIDATION // ASURT 122278
            // If we find a requestValidationRegex string, create a new regex
            string  requestValidationRegexString = null;
            XmlNode attrib = HandlerBase.GetAndRemoveStringAttribute(node, "requestValidationRegex", ref requestValidationRegexString);
            if (attrib != null)
            {
                // REVIEW: consider using a compiled regex, though that is slow on first hit (and a memory hog).
                // Obviously, we can't precompile it since it's not know ahead of time.
                try {
                    _requestValidationRegex = new Regex(requestValidationRegexString, RegexOptions.IgnoreCase /*| RegexOptions.Compiled*/);
                }
                catch (Exception e) {
                    throw new ConfigurationException(e.Message, e, attrib);
                }
            }
#endif

            // error on unrecognized attributes and nodes
            HandlerBase.CheckForUnrecognizedAttributes(node);
            HandlerBase.CheckForChildNodes(node);
        }