Пример #1
0
        public SecurityElement ToXml(PolicyLevel level)
        {
            if (m_value == null && m_element != null)
            {
                ParseHashValue();
            }

            if (m_hashAlg == null && m_element != null)
            {
                ParseHashAlgorithm();
            }

            SecurityElement root = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(root, this.GetType(), "System.Security.Policy.HashMembershipCondition");
            // If you hit this assert then most likely you are trying to change the name of this class.
            // This is ok as long as you change the hard coded string above and change the assert below.
            Contract.Assert(this.GetType().FullName.Equals("System.Security.Policy.HashMembershipCondition"), "Class name changed!");

            root.AddAttribute("version", "1");
            if (m_value != null)
            {
                root.AddAttribute(s_tagHashValue, Hex.EncodeHexString(HashValue));
            }
            if (m_hashAlg != null)
            {
                root.AddAttribute(s_tagHashAlgorithm, HashAlgorithm.GetType().FullName);
            }
            return(root);
        }
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement element = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(element, base.GetType(), "System.Security.Policy.ApplicationDirectoryMembershipCondition");
            element.AddAttribute("version", "1");
            return(element);
        }
Пример #3
0
        static internal SecurityElement CreatePermissionElement(IPermission perm)
        {
            SecurityElement root = new SecurityElement("IPermission");

            XMLUtil.AddClassAttribute(root, perm.GetType());
            root.AddAttribute("version", "1");
            return(root);
        }
Пример #4
0
        internal static SecurityElement CreatePermissionElement(IPermission perm, string permname)
        {
            SecurityElement element = new SecurityElement("IPermission");

            XMLUtil.AddClassAttribute(element, perm.GetType(), permname);
            element.AddAttribute("version", "1");
            return(element);
        }
Пример #5
0
        /// <summary>Creates an XML encoding of the security object and its current state, using the specified policy level context.</summary>
        /// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for resolving <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
        /// <returns>A <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding of the security object, including any state information.</returns>
        // Token: 0x06002AA9 RID: 10921 RVA: 0x0009E51C File Offset: 0x0009C71C
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement securityElement = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(securityElement, base.GetType(), base.GetType().FullName);
            securityElement.AddAttribute("version", "1");
            return(securityElement);
        }
Пример #6
0
        internal SecurityElement ToXml(PolicyLevel level, string policyClassName)
        {
            if ((this.m_membershipCondition == null) && (this.m_element != null))
            {
                this.ParseMembershipCondition();
            }
            if (this.m_children == null)
            {
                this.ParseChildren();
            }
            if ((this.m_policy == null) && (this.m_element != null))
            {
                this.ParsePolicy();
            }
            SecurityElement element = new SecurityElement("CodeGroup");

            XMLUtil.AddClassAttribute(element, base.GetType(), policyClassName);
            element.AddAttribute("version", "1");
            element.AddChild(this.m_membershipCondition.ToXml(level));
            if (this.m_policy != null)
            {
                PermissionSet      permissionSetNoCopy = this.m_policy.GetPermissionSetNoCopy();
                NamedPermissionSet set2 = permissionSetNoCopy as NamedPermissionSet;
                if (((set2 != null) && (level != null)) && (level.GetNamedPermissionSetInternal(set2.Name) != null))
                {
                    element.AddAttribute("PermissionSetName", set2.Name);
                }
                else if (!permissionSetNoCopy.IsEmpty())
                {
                    element.AddChild(permissionSetNoCopy.ToXml());
                }
                if (this.m_policy.Attributes != PolicyStatementAttribute.Nothing)
                {
                    element.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), this.m_policy.Attributes));
                }
            }
            if (this.m_children.Count > 0)
            {
                lock (this)
                {
                    IEnumerator enumerator = this.m_children.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        element.AddChild(((CodeGroup)enumerator.Current).ToXml(level));
                    }
                }
            }
            if (this.m_name != null)
            {
                element.AddAttribute("Name", SecurityElement.Escape(this.m_name));
            }
            if (this.m_description != null)
            {
                element.AddAttribute("Description", SecurityElement.Escape(this.m_description));
            }
            this.CreateXml(element, level);
            return(element);
        }
Пример #7
0
        internal SecurityElement ToXml(PolicyLevel level, string policyClassName)
        {
            if (this.m_membershipCondition == null && this.m_element != null)
            {
                this.ParseMembershipCondition();
            }
            if (this.m_children == null)
            {
                this.ParseChildren();
            }
            if (this.m_policy == null && this.m_element != null)
            {
                this.ParsePolicy();
            }
            SecurityElement element = new SecurityElement("CodeGroup");

            XMLUtil.AddClassAttribute(element, this.GetType(), policyClassName);
            element.AddAttribute("version", "1");
            element.AddChild(this.m_membershipCondition.ToXml(level));
            if (this.m_policy != null)
            {
                PermissionSet      permissionSetNoCopy = this.m_policy.GetPermissionSetNoCopy();
                NamedPermissionSet namedPermissionSet  = permissionSetNoCopy as NamedPermissionSet;
                if (namedPermissionSet != null && level != null && level.GetNamedPermissionSetInternal(namedPermissionSet.Name) != null)
                {
                    element.AddAttribute("PermissionSetName", namedPermissionSet.Name);
                }
                else if (!permissionSetNoCopy.IsEmpty())
                {
                    element.AddChild(permissionSetNoCopy.ToXml());
                }
                if (this.m_policy.Attributes != PolicyStatementAttribute.Nothing)
                {
                    element.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), (object)this.m_policy.Attributes));
                }
            }
            if (this.m_children.Count > 0)
            {
                lock (this)
                {
                    foreach (CodeGroup item_0 in (IEnumerable)this.m_children)
                    {
                        element.AddChild(item_0.ToXml(level));
                    }
                }
            }
            if (this.m_name != null)
            {
                element.AddAttribute("Name", SecurityElement.Escape(this.m_name));
            }
            if (this.m_description != null)
            {
                element.AddAttribute("Description", SecurityElement.Escape(this.m_description));
            }
            this.CreateXml(element, level);
            return(element);
        }
        static internal SecurityElement CreatePermissionElement(IPermission perm, String permname)
        {
            SecurityElement root = new SecurityElement("IPermission");

            XMLUtil.AddClassAttribute(root, perm.GetType(), permname);
            // If you hit this assert then most likely you are trying to change the name of this class.
            // This is ok as long as you change the hard coded string above and change the assert below.
            BCLDebug.Assert(perm.GetType().FullName.Equals(permname), "Incorrect class name passed in! Was: " + permname + " Should be " + perm.GetType().FullName);

            root.AddAttribute("version", "1");
            return(root);
        }
Пример #9
0
        internal static SecurityElement CreatePermissionElement(IPermission perm, string permname)
        {
            SecurityElement element  = new SecurityElement("IPermission");
            Type            type     = perm.GetType();
            string          typename = permname;

            XMLUtil.AddClassAttribute(element, type, typename);
            string name = "version";
            string str  = "1";

            element.AddAttribute(name, str);
            return(element);
        }
Пример #10
0
        /// <summary>使用指定的 <see cref="T:System.Security.Policy.PolicyLevel" /> 创建安全对象及其当前状态的 XML 编码。</summary>
        /// <returns>安全对象的 XML 编码,包括任何状态信息。</returns>
        /// <param name="level">用于解析命名的权限集引用的策略级别上下文。</param>
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement element  = new SecurityElement("IMembershipCondition");
            Type            type     = this.GetType();
            string          typename = "System.Security.Policy.AllMembershipCondition";

            XMLUtil.AddClassAttribute(element, type, typename);
            string name = "version";
            string str  = "1";

            element.AddAttribute(name, str);
            return(element);
        }
Пример #11
0
        /// <summary>Creates an XML encoding of the permission and its current state.</summary>
        /// <returns>An XML encoding of the permission, including any state information.</returns>
        // Token: 0x0600260F RID: 9743 RVA: 0x0008954C File Offset: 0x0008774C
        public SecurityElement ToXml()
        {
            SecurityElement securityElement = new SecurityElement("IPermission");

            XMLUtil.AddClassAttribute(securityElement, base.GetType(), "System.Security.Permissions.PrincipalPermission");
            securityElement.AddAttribute("version", "1");
            int num = this.m_array.Length;

            for (int i = 0; i < num; i++)
            {
                securityElement.AddChild(this.m_array[i].ToXml());
            }
            return(securityElement);
        }
Пример #12
0
        /// <summary>创建权限及其当前状态的 XML 编码。</summary>
        /// <returns>权限的 XML 编码,包括任何状态信息。</returns>
        public SecurityElement ToXml()
        {
            SecurityElement element = new SecurityElement("IPermission");

            XMLUtil.AddClassAttribute(element, this.GetType(), "System.Security.Permissions.PrincipalPermission");
            element.AddAttribute("version", "1");
            int length = this.m_array.Length;

            for (int index = 0; index < length; ++index)
            {
                element.AddChild(this.m_array[index].ToXml());
            }
            return(element);
        }
        public SecurityElement ToXml(PolicyLevel level)
        {
            if ((this.m_site == null) && (this.m_element != null))
            {
                this.ParseSite();
            }
            SecurityElement element = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(element, base.GetType(), "System.Security.Policy.SiteMembershipCondition");
            element.AddAttribute("version", "1");
            if (this.m_site != null)
            {
                element.AddAttribute("Site", this.m_site.ToString());
            }
            return(element);
        }
Пример #14
0
        /// <include file='doc\PrincipalPermission.uex' path='docs/doc[@for="PrincipalPermission.ToXml"]/*' />
        public SecurityElement ToXml()
        {
            SecurityElement root = new SecurityElement("Permission");

            XMLUtil.AddClassAttribute(root, this.GetType());
            root.AddAttribute("version", "1");

            int count = m_array.Length;

            for (int i = 0; i < count; ++i)
            {
                root.AddChild(m_array[i].ToXml());
            }

            return(root);
        }
Пример #15
0
        /// <summary>使用指定的 <see cref="T:System.Security.Policy.PolicyLevel" /> 创建安全对象及其当前状态的 XML 编码。</summary>
        /// <returns>安全对象的 XML 编码,包括任何状态信息。</returns>
        /// <param name="level">用于解析命名的权限集引用的策略级别上下文。</param>
        /// <exception cref="T:System.ArgumentNullException">
        /// <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> 属性为 null。</exception>
        public SecurityElement ToXml(PolicyLevel level)
        {
            if (this.m_url == null && this.m_element != null)
            {
                this.ParseURL();
            }
            SecurityElement element = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(element, this.GetType(), "System.Security.Policy.UrlMembershipCondition");
            element.AddAttribute("version", "1");
            if (this.m_url != null)
            {
                element.AddAttribute("Url", this.m_url.ToString());
            }
            return(element);
        }
Пример #16
0
        /// <summary>使用指定的 <see cref="T:System.Security.Policy.PolicyLevel" /> 创建安全对象及其当前状态的 XML 编码。</summary>
        /// <returns>安全对象的 XML 编码,包括任何状态信息。</returns>
        /// <param name="level">用于解析命名的权限集引用的策略级别上下文。</param>
        /// <exception cref="T:System.ArgumentNullException">
        /// <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> 属性为 null。</exception>
        /// <exception cref="T:System.ArgumentException">
        /// <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> 属性不是有效的 <see cref="T:System.Security.SecurityZone" />。</exception>
        public SecurityElement ToXml(PolicyLevel level)
        {
            if (this.m_zone == SecurityZone.NoZone && this.m_element != null)
            {
                this.ParseZone();
            }
            SecurityElement element = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(element, this.GetType(), "System.Security.Policy.ZoneMembershipCondition");
            element.AddAttribute("version", "1");
            if (this.m_zone != SecurityZone.NoZone)
            {
                element.AddAttribute("Zone", Enum.GetName(typeof(SecurityZone), (object)this.m_zone));
            }
            return(element);
        }
        public SecurityElement ToXml(PolicyLevel level)
        {
            if ((this.m_certificate == null) && (this.m_element != null))
            {
                this.ParseCertificate();
            }
            SecurityElement element = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(element, base.GetType(), "System.Security.Policy.PublisherMembershipCondition");
            element.AddAttribute("version", "1");
            if (this.m_certificate != null)
            {
                element.AddAttribute("X509Certificate", this.m_certificate.GetRawCertDataString());
            }
            return(element);
        }
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement element = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(element, base.GetType(), "System.Security.Policy.StrongNameMembershipCondition");
            element.AddAttribute("version", "1");
            if (this.PublicKey != null)
            {
                element.AddAttribute("PublicKeyBlob", Hex.EncodeHexString(this.PublicKey.PublicKey));
            }
            if (this.Name != null)
            {
                element.AddAttribute("Name", this.Name);
            }
            if (this.Version != null)
            {
                element.AddAttribute("AssemblyVersion", this.Version.ToString());
            }
            return(element);
        }
Пример #19
0
        public SecurityElement ToXml()
        {
            SecurityElement root = new SecurityElement("IPermission");

            XMLUtil.AddClassAttribute(root, this.GetType(), "System.Security.Permissions.PrincipalPermission");
            // If you hit this assert then most likely you are trying to change the name of this class.
            // This is ok as long as you change the hard coded string above and change the assert below.
            Contract.Assert(this.GetType().FullName.Equals("System.Security.Permissions.PrincipalPermission"), "Class name changed!");

            root.AddAttribute("version", "1");

            int count = m_array.Length;

            for (int i = 0; i < count; ++i)
            {
                root.AddChild(m_array[i].ToXml());
            }

            return(root);
        }
Пример #20
0
        /// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
        /// <param name="level">The policy level context for resolving named permission set references. </param>
        /// <returns>An XML encoding of the security object, including any state information.</returns>
        // Token: 0x06002AD5 RID: 10965 RVA: 0x0009EFD8 File Offset: 0x0009D1D8
        public SecurityElement ToXml(PolicyLevel level)
        {
            if (this.m_value == null && this.m_element != null)
            {
                this.ParseHashValue();
            }
            if (this.m_hashAlg == null && this.m_element != null)
            {
                this.ParseHashAlgorithm();
            }
            SecurityElement securityElement = new SecurityElement("IMembershipCondition");

            XMLUtil.AddClassAttribute(securityElement, base.GetType(), "System.Security.Policy.HashMembershipCondition");
            securityElement.AddAttribute("version", "1");
            if (this.m_value != null)
            {
                securityElement.AddAttribute("HashValue", Hex.EncodeHexString(this.HashValue));
            }
            if (this.m_hashAlg != null)
            {
                securityElement.AddAttribute("HashAlgorithm", this.HashAlgorithm.GetType().FullName);
            }
            return(securityElement);
        }