static XmlNode GetAndRemoveIntegerOrInfiniteAttribute(XmlNode node, string attrib, ref int val) { string sValue = null; XmlNode a = HandlerBase.GetAndRemoveStringAttribute(node, attrib, ref sValue); if (a != null) { if (sValue == "Infinite") { val = int.MaxValue; } else { try { val = int.Parse(sValue, NumberStyles.None, CultureInfo.InvariantCulture); } catch (Exception e) { throw new ConfigurationException( HttpRuntime.FormatResourceString(SR.Invalid_integer_attribute, a.Name), e, a); } } } return(a); }
internal void CheckAndUpdate(XmlNode section, string [] lockableAttrList) { // verify the attributes at this level have not been locked CheckForLocked(section); string stringlockList = null; XmlNode attr = HandlerBase.GetAndRemoveStringAttribute(section, "lockAttributes", ref stringlockList); if (stringlockList == null) { return; } // comma-delimited list of attributes string [] attributesToLock = stringlockList.Split(new char [] { ',', ';' }); foreach (string s in attributesToLock) { string attributeToLock = s.Trim(' '); if (HandlerBase.IndexOfCultureInvariant(lockableAttrList, attributeToLock) == -1) { throw new ConfigurationException( HttpRuntime.FormatResourceString(SR.Invalid_lockAttributes, attributeToLock, HandlerBase.CombineStrings(lockableAttrList)), attr); } _lockedAttributes[attributeToLock] = ""; } }
/* * <controlAdapters> * <adapter controlType="System.Web.UI.WebControls.Image" * adapterType="System.Web.UI.WebControls.Adapters.Html32ImageAdapter" /> * </controlAdapters> */ internal void ProcessControlAdaptersNode(XmlNode node) { HandlerBase.GetAndRemoveStringAttribute(node, "markupTextWriterType", ref _htmlTextWriterString); foreach (XmlNode child in node.ChildNodes) { if (child.NodeType != XmlNodeType.Element) { continue; } if (child.Name != "adapter") { throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_unrecognized_element), child); } XmlAttributeCollection nodeAttributes = child.Attributes; string controlString = null; string adapterString = null; HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "controlType", ref controlString); HandlerBase.GetAndRemoveRequiredStringAttribute(child, "adapterType", ref adapterString); Type type = CheckType(controlString, typeof(Control), child); // Normalize control type name controlString = type.AssemblyQualifiedName; if (!String.IsNullOrEmpty(adapterString)) { CheckType(adapterString, typeof(System.Web.UI.Adapters.ControlAdapter), child); } _adapters[controlString] = adapterString; } return; }
private void DisallowNonMatchAttribute(XmlNode node) { string check = null; HandlerBase.GetAndRemoveStringAttribute(node, "nonMatch", ref check); if (check != null) { throw new ConfigurationErrorsException(SR.GetString(SR.Browser_mutually_exclusive_attributes, "match", "nonMatch"), node); } }
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)); }
static XmlNode GetAndRemoveUnsignedIntegerAttribute(XmlNode node, string attrib, ref uint val) { string sValue = null; XmlNode a = HandlerBase.GetAndRemoveStringAttribute(node, attrib, ref sValue); if (a != null) { try { val = ParseHexOrDecUInt(sValue); } catch (Exception e) { throw new ConfigurationException( HttpRuntime.FormatResourceString(SR.Invalid_integer_attribute, a.Name), e, a); } } return(a); }
static XmlNode GetAndRemoveProcessModelTimeout(XmlNode section, string attrName, ref int val) { string sValue = null; XmlNode a = HandlerBase.GetAndRemoveStringAttribute(section, attrName, ref sValue); if (sValue != null) { try { if (sValue == "Infinite") { val = int.MaxValue; } else if (sValue.IndexOf(':') == -1) { val = 60 * int.Parse(sValue, CultureInfo.InvariantCulture); } else { string [] times = sValue.Split(new char [] { ':' }); if (times.Length > 3) { throw new ConfigurationException(SR.GetString(SR.Config_Process_model_time_invalid), a); } int timeInSeconds = 0; foreach (string time in times) { timeInSeconds = timeInSeconds * 60 + int.Parse(time, NumberStyles.None, CultureInfo.InvariantCulture); } val = timeInSeconds; } } catch (Exception e) { throw new ConfigurationException(SR.GetString(SR.Config_Process_model_time_invalid), e, a); } } return(a); }
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); }