internal ProtocolsConfiguration(XmlNode section) { // process XML section in order and apply the directives HandlerBase.CheckForUnrecognizedAttributes(section); foreach (XmlNode child in section.ChildNodes) { // skip whitespace and comments if (IsIgnorableAlsoCheckForNonElement(child)) { continue; } // process <add> elements if (child.Name == "add") { String id = HandlerBase.RemoveRequiredAttribute(child, "id"); String phType = HandlerBase.RemoveRequiredAttribute(child, "processHandlerType"); String ahType = HandlerBase.RemoveRequiredAttribute(child, "appDomainHandlerType"); bool validate = true; HandlerBase.GetAndRemoveBooleanAttribute(child, "validate", ref validate); HandlerBase.CheckForUnrecognizedAttributes(child); HandlerBase.CheckForNonCommentChildNodes(child); // check duplicate Id /* TEMPORARY allow duplicates for easy Indigo machine.config update * if (_protocolEntries[id] != null) { * throw new ConfigurationErrorsException( * SR.GetString(SR.Dup_protocol_id, id), * child); * } */ // add entry /* TEMPORARY hide errors and ignore bad <add> tags * to let breaking changes through */ try { _protocolEntries[id] = new ProtocolsConfigurationEntry( id, phType, ahType, validate, ConfigurationErrorsException.GetFilename(child), ConfigurationErrorsException.GetLineNumber(child)); } catch { } } else { HandlerBase.ThrowUnrecognizedElement(child); } } }
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 impersonation = false; String username = null; String password = null; HandlerBase.CheckForChildNodes(section); HandlerBase.GetAndRemoveBooleanAttribute(section, "impersonate", ref impersonation); HandlerBase.GetAndRemoveStringAttribute(section, "userName", ref username); HandlerBase.GetAndRemoveStringAttribute(section, "password", ref password); HandlerBase.CheckForUnrecognizedAttributes(section); HandlerBase.CheckForChildNodes(section); if (username != null && username.Length < 1) { username = null; } if (password != null && (password.StartsWith("registry:") || password.StartsWith("Registry:"))) { StringBuilder str = new StringBuilder(100); int iRet = UnsafeNativeMethods.GetCredentialFromRegistry(password, str, 100); if (iRet == 0) { password = str.ToString(); } else { throw new ConfigurationException( HttpRuntime.FormatResourceString(SR.Invalid_credentials_pass), section); } } if (username != null && (username.StartsWith("registry:") || username.StartsWith("Registry:"))) { StringBuilder str = new StringBuilder(100); int iRet = UnsafeNativeMethods.GetCredentialFromRegistry(username, str, 100); if (iRet == 0) { username = str.ToString(); } else { throw new ConfigurationException( HttpRuntime.FormatResourceString(SR.Invalid_credentials_name), section); } } return(new IdentityConfig((IdentityConfig)parent, impersonation, username, password, section)); }
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)); }
internal void LoadValuesFromConfigurationXml(XmlNode section) { HandlerBase.GetAndRemoveBooleanAttribute(section, "enabled", ref _isEnabled); HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(section, "requestLimit", ref _requestLimit); HandlerBase.GetAndRemoveBooleanAttribute(section, "pageOutput", ref _pageOutput); HandlerBase.GetAndRemoveBooleanAttribute(section, "localOnly", ref _localOnly); string [] values = { "SortByTime", "SortByCategory" }; // TraceMode is in another file in a different namespace ... so lets have some protection if they change Debug.Assert(TraceMode.SortByTime == (TraceMode)0); Debug.Assert(TraceMode.SortByCategory == (TraceMode)1); int iMode = 0; XmlNode attribute = HandlerBase.GetAndRemoveEnumAttribute(section, "traceMode", values, ref iMode); if (attribute != null) { _outputMode = (TraceMode)iMode; } HandlerBase.CheckForUnrecognizedAttributes(section); // section can have no content HandlerBase.CheckForChildNodes(section); }
// // 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); }
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); } } } } }
/* * Create * * Given a partially composed config object (possibly null) * and some input from the config system, return a * further partially composed config object */ internal Object InternalCreate(Object parent, XmlNode node) { HandlerMap map; // start list as shallow clone of parent if (parent == null) { map = new HandlerMap(); } else { map = new HandlerMap((HandlerMap)parent); } map.BeginGroup(); // process XML section HandlerBase.CheckForUnrecognizedAttributes(node); foreach (XmlNode child in node.ChildNodes) { // skip whitespace and comments if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child)) { continue; } // process <add> and <clear> elements if (child.Name.Equals("add")) { String verb = HandlerBase.RemoveRequiredAttribute(child, "verb"); String path = HandlerBase.RemoveRequiredAttribute(child, "path"); String classname = HandlerBase.RemoveRequiredAttribute(child, "type"); int phase = 1; XmlNode phaseNode = HandlerBase.GetAndRemoveIntegerAttribute(child, "phase", ref phase); if (phaseNode != null) { ValidatePhase(phase, phaseNode); } bool validate = true; HandlerBase.GetAndRemoveBooleanAttribute(child, "validate", ref validate); HandlerBase.CheckForUnrecognizedAttributes(child); HandlerBase.CheckForChildNodes(child); try { map.Add(new HandlerMapping(verb, path, classname, !validate), phase); } catch (Exception e) { throw new ConfigurationException(e.Message, e, child); } } else if (child.Name.Equals("remove")) { String verb = HandlerBase.RemoveRequiredAttribute(child, "verb"); String path = HandlerBase.RemoveRequiredAttribute(child, "path"); bool validate = true; HandlerBase.GetAndRemoveBooleanAttribute(child, "validate", ref validate); HandlerBase.CheckForUnrecognizedAttributes(child); HandlerBase.CheckForChildNodes(child); if (!map.RemoveMapping(verb, path) && validate) { throw new ConfigurationException( HttpRuntime.FormatResourceString(SR.No_mapping_to_remove, verb, path), child); } } else if (child.Name.Equals("clear")) { int phase = 1; XmlNode phaseNode = HandlerBase.GetAndRemoveIntegerAttribute(child, "phase", ref phase); HandlerBase.CheckForUnrecognizedAttributes(child); HandlerBase.CheckForChildNodes(child); if (phaseNode == null) { map.ClearAll(); } else { ValidatePhase(phase, phaseNode); map.ClearPhase(phase); } } else { HandlerBase.ThrowUnrecognizedElement(child); } } map.EndGroup(); return(map); }
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); }