/*
         * <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;
        }
Exemple #2
0
        //
        // Handle <file src=""/> elements
        //
        static void ProcessFile(ArrayList fileList, XmlNode node)
        {
            string  filename = null;
            XmlNode attr     = HandlerBase.GetAndRemoveRequiredStringAttribute(node, "src", ref filename);

            HandlerBase.CheckForUnrecognizedAttributes(node);
            HandlerBase.CheckForNonCommentChildNodes(node);

            fileList.Add(new Pair(filename, attr));
        }
        /*
         * <capabilities>
         *   <capability name="mobileDeviceManufacturer" value="OpenWave"</capability>
         *   <capability name="numberOfSoftKeys" value="$(softkeys)"</capability>
         * </capabilities>
         */

        internal void ProcessCapabilitiesNode(XmlNode node)
        {
            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (child.Name != "capability")
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_unrecognized_element), child);
                }
                string capabilityName  = null;
                string capabilityValue = null;
                HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "name", ref capabilityName);
                HandlerBase.GetAndRemoveRequiredStringAttribute(child, "value", ref capabilityValue);
                _capabilities[capabilityName] = capabilityValue;
            }
            return;
        }
Exemple #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);
                        }
                    }
                }
            }
        }
        internal SecurityPolicyConfig(SecurityPolicyConfig parent, XmlNode node, String strFile)
        {
            if (parent != null)
            {
                _PolicyFiles = (Hashtable)parent.PolicyFiles.Clone();
            }
            else
            {
                _PolicyFiles = new Hashtable();
            }


            // CONSIDER: Path.GetDirectoryName()
            String strDir = strFile.Substring(0, strFile.LastIndexOf('\\') + 1);

            foreach (XmlNode child in node.ChildNodes)
            {
                ////////////////////////////////////////////////////////////
                // Step 1: For each child
                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                {
                    continue;
                }

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

                string  name          = null;
                string  file          = null;
                XmlNode nameAttribute = HandlerBase.GetAndRemoveRequiredStringAttribute(child, "name", ref name);
                HandlerBase.GetAndRemoveRequiredStringAttribute(child, "policyFile", ref file);
                HandlerBase.CheckForUnrecognizedAttributes(child);
                HandlerBase.CheckForChildNodes(child);

                bool fAppend = true; // Append dir to filename
                if (file.Length > 1)
                {
                    char c1 = file[1];
                    char c0 = file[0];

                    if (c1 == ':') // Absolute file path
                    {
                        fAppend = false;
                    }
                    else
                    if (c0 == '\\' && c1 == '\\')     // UNC file path
                    {
                        fAppend = false;
                    }
                }

                String strTemp;
                if (fAppend)
                {
                    strTemp = strDir + file;
                }
                else
                {
                    strTemp = file;
                }

                if (_PolicyFiles.Contains(name))
                {
                    throw new ConfigurationException(
                              HttpRuntime.FormatResourceString(SR.Security_policy_level_already_defined, name),
                              nameAttribute);
                }
                _PolicyFiles.Add(name, strTemp);
            }

            HandlerBase.CheckForUnrecognizedAttributes(node);
        }