예제 #1
0
        /// <include file='doc\FileIOPermission.uex' path='docs/doc[@for="FileIOPermission.ToXml"]/*' />
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this);

            if (!IsUnrestricted())
            {
                if (this.m_read != null && !this.m_read.IsEmpty())
                {
                    esd.AddAttribute("Read", SecurityElement.Escape(m_read.ToString()));
                }
                if (this.m_write != null && !this.m_write.IsEmpty())
                {
                    esd.AddAttribute("Write", SecurityElement.Escape(m_write.ToString()));
                }
                if (this.m_append != null && !this.m_append.IsEmpty())
                {
                    esd.AddAttribute("Append", SecurityElement.Escape(m_append.ToString()));
                }
                if (this.m_pathDiscovery != null && !this.m_pathDiscovery.IsEmpty())
                {
                    esd.AddAttribute("PathDiscovery", SecurityElement.Escape(m_pathDiscovery.ToString()));
                }
            }
            else
            {
                esd.AddAttribute("Unrestricted", "true");
            }
            return(esd);
        }
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement root = new SecurityElement("IMembershipCondition");

            System.Security.Util.XMLUtil.AddClassAttribute(root, this.GetType(), "System.Security.Policy.StrongNameMembershipCondition");
            // 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.StrongNameMembershipCondition"), "Class name changed!");

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

            if (PublicKey != null)
            {
                root.AddAttribute(s_tagPublicKeyBlob, System.Security.Util.Hex.EncodeHexString(PublicKey.PublicKey));
            }

            if (Name != null)
            {
                root.AddAttribute(s_tagName, Name);
            }

            if ((Object)Version != null)
            {
                root.AddAttribute(s_tagVersion, Version.ToString());
            }

            return(root);
        }
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this, "System.Security.Permissions.SiteIdentityPermission");

            if (m_unrestricted)
            {
                esd.AddAttribute("Unrestricted", "true");
            }
            else if (m_sites != null)
            {
                if (m_sites.Length == 1)
                {
                    esd.AddAttribute("Site", m_sites[0].ToString());
                }
                else
                {
                    int n;
                    for (n = 0; n < m_sites.Length; n++)
                    {
                        SecurityElement child = new SecurityElement("Site");
                        child.AddAttribute("Site", m_sites[n].ToString());
                        esd.AddChild(child);
                    }
                }
            }
            return(esd);
        }
        /// <include file='doc\HashMembershipCondition.uex' path='docs/doc[@for="HashMembershipCondition.ToXml1"]/*' />
        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");

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

            if (m_value != null)
            {
                root.AddAttribute(s_tagHashValue, System.Security.Util.Hex.EncodeHexString(HashValue));
            }

            if (m_hashAlg != null)
            {
                root.AddAttribute(s_tagHashAlgorithm, HashAlgorithm.GetType().FullName);
            }

            return(root);
        }
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this, "System.Security.Permissions.PublisherIdentityPermission");

            if (m_unrestricted)
            {
                esd.AddAttribute("Unrestricted", "true");
            }
            else if (m_certs != null)
            {
                if (m_certs.Length == 1)
                {
                    esd.AddAttribute("X509v3Certificate", m_certs[0].GetRawCertDataString());
                }
                else
                {
                    int n;
                    for (n = 0; n < m_certs.Length; n++)
                    {
                        SecurityElement child = new SecurityElement("Cert");
                        child.AddAttribute("X509v3Certificate", m_certs[n].GetRawCertDataString());
                        esd.AddChild(child);
                    }
                }
            }
            return(esd);
        }
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this, "System.Security.Permissions.StrongNameIdentityPermission");

            if (m_unrestricted)
            {
                esd.AddAttribute("Unrestricted", "true");
            }
            else if (m_strongNames != null)
            {
                if (m_strongNames.Length == 1)
                {
                    if (m_strongNames[0].m_publicKeyBlob != null)
                    {
                        esd.AddAttribute("PublicKeyBlob", Hex.EncodeHexString(m_strongNames[0].m_publicKeyBlob.PublicKey));
                    }
                    if (m_strongNames[0].m_name != null)
                    {
                        esd.AddAttribute("Name", m_strongNames[0].m_name);
                    }
                    if ((Object)m_strongNames[0].m_version != null)
                    {
                        esd.AddAttribute("AssemblyVersion", m_strongNames[0].m_version.ToString());
                    }
                }
                else
                {
                    int n;
                    for (n = 0; n < m_strongNames.Length; n++)
                    {
                        SecurityElement child = new SecurityElement("StrongName");
                        if (m_strongNames[n].m_publicKeyBlob != null)
                        {
                            child.AddAttribute("PublicKeyBlob", Hex.EncodeHexString(m_strongNames[n].m_publicKeyBlob.PublicKey));
                        }
                        if (m_strongNames[n].m_name != null)
                        {
                            child.AddAttribute("Name", m_strongNames[n].m_name);
                        }
                        if ((Object)m_strongNames[n].m_version != null)
                        {
                            child.AddAttribute("AssemblyVersion", m_strongNames[n].m_version.ToString());
                        }
                        esd.AddChild(child);
                    }
                }
            }
            return(esd);
        }
예제 #7
0
        /// <summary>
        /// Recupera os dados do xml.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private static System.Security.SecurityElement FromXml(System.Xml.XmlReader reader)
        {
            var element = new System.Security.SecurityElement(reader.Name);

            for (var i = 0; i < reader.AttributeCount; i++)
            {
                reader.MoveToAttribute(i);
                element.AddAttribute(reader.Name, reader.Value);
            }
            reader.MoveToContent();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    var child = FromXml(reader);
                    element.AddChild(child);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            return(element);
        }
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this, "System.Security.Permissions.ZoneIdentityPermission");

            if (SecurityZone != SecurityZone.NoZone)
            {
                esd.AddAttribute("Zone", Enum.GetName(typeof(SecurityZone), this.SecurityZone));
            }
            else
            {
                int  nEnum = 0;
                uint nFlag;
                for (nFlag = 1; nFlag < AllZones; nFlag <<= 1)
                {
                    if ((m_zones & nFlag) != 0)
                    {
                        SecurityElement child = new SecurityElement("Zone");
                        child.AddAttribute("Zone", Enum.GetName(typeof(SecurityZone), (SecurityZone)nEnum));
                        esd.AddChild(child);
                    }
                    nEnum++;
                }
            }
            return(esd);
        }
예제 #9
0
 /// <summary>
 /// Adiciona um atributo de classe.
 /// </summary>
 /// <param name="element"></param>
 /// <param name="type"></param>
 /// <param name="typename"></param>
 public static void AddClassAttribute(System.Security.SecurityElement element, Type type, string typename)
 {
     if (typename == null)
     {
         typename = type.FullName;
     }
     element.AddAttribute("class", typename + ", " + type.Module.Assembly.FullName.Replace('"', '\''));
 }
        /// <include file='doc\ApplicationDirectoryMembershipCondition.uex' path='docs/doc[@for="ApplicationDirectoryMembershipCondition.ToXml1"]/*' />
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement root = new SecurityElement("IMembershipCondition");

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

            return(root);
        }
        /// <include file='doc\ZoneMembershipCondition.uex' path='docs/doc[@for="ZoneMembershipCondition.ToXml1"]/*' />
        public SecurityElement ToXml(PolicyLevel level)
        {
            if (m_zone == SecurityZone.NoZone && m_element != null)
            {
                ParseZone();
            }

            SecurityElement root = new SecurityElement("IMembershipCondition");

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

            if (m_zone != SecurityZone.NoZone)
            {
                root.AddAttribute("Zone", Enum.GetName(typeof(SecurityZone), m_zone));
            }

            return(root);
        }
예제 #12
0
        /// <include file='doc\SiteMembershipCondition.uex' path='docs/doc[@for="SiteMembershipCondition.ToXml1"]/*' />
        public SecurityElement ToXml(PolicyLevel level)
        {
            if (m_site == null && m_element != null)
            {
                ParseSite();
            }

            SecurityElement root = new SecurityElement("IMembershipCondition");

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

            if (m_site != null)
            {
                root.AddAttribute("Site", m_site.ToString());
            }

            return(root);
        }
예제 #13
0
        /// <include file='doc\URLIdentityPermission.uex' path='docs/doc[@for="UrlIdentityPermission.ToXml"]/*' />
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this);

            if (m_url != null)
            {
                esd.AddAttribute("Url", m_url.ToString());
            }
            return(esd);
        }
예제 #14
0
        /// <include file='doc\ZoneIdentityPermission.uex' path='docs/doc[@for="ZoneIdentityPermission.ToXml"]/*' />
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this);

            if (m_zone != SecurityZone.NoZone)
            {
                esd.AddAttribute("Zone", Enum.GetName(typeof(SecurityZone), this.m_zone));
            }
            return(esd);
        }
 internal SecurityElement ToXml()
 {
     SecurityElement root = new SecurityElement( "Identity" );
     
     if (m_authenticated)
         root.AddAttribute( "Authenticated", "true" );
         
     if (m_id != null)
     {
         root.AddAttribute( "ID", SecurityElement.Escape( m_id ) );
     }
        
     if (m_role != null)
     {
         root.AddAttribute( "Role", SecurityElement.Escape( m_role ) );
     }
                     
     return root;
 }
        /// <include file='doc\PublisherIdentityPermission.uex' path='docs/doc[@for="PublisherIdentityPermission.ToXml"]/*' />
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this);

            if (m_certificate != null)
            {
                esd.AddAttribute("X509v3Certificate", m_certificate.GetRawCertDataString());
            }
            return(esd);
        }
예제 #17
0
        /// <include file='doc\StrongNameIdentityPermission.uex' path='docs/doc[@for="StrongNameIdentityPermission.ToXml"]/*' />
        public override SecurityElement ToXml()
        {
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this);

            if (m_publicKeyBlob != null)
            {
                esd.AddAttribute("PublicKeyBlob", Hex.EncodeHexString(m_publicKeyBlob.PublicKey));
            }

            if (m_name != null)
            {
                esd.AddAttribute("Name", m_name);
            }

            if ((Object)m_version != null)
            {
                esd.AddAttribute("AssemblyVersion", m_version.ToString());
            }
            return(esd);
        }
예제 #18
0
        internal SecurityElement ToXml()
        {
            SecurityElement root = new SecurityElement("Identity");

            if (m_authenticated)
            {
                root.AddAttribute("Authenticated", "true");
            }

            if (m_id != null)
            {
                root.AddAttribute("ID", SecurityElement.Escape(m_id));
            }

            if (m_role != null)
            {
                root.AddAttribute("Role", SecurityElement.Escape(m_role));
            }

            return(root);
        }
예제 #19
0
        public override SecurityElement ToXml()
        {
            // SafeCritical: our string expression sets don't contain paths, so there's no information that
            // needs to be guarded in them.
            SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this, "System.Security.Permissions.RegistryPermission");

            if (!IsUnrestricted())
            {
                if (this.m_read != null && !this.m_read.IsEmpty())
                {
                    esd.AddAttribute("Read", SecurityElement.Escape(m_read.UnsafeToString()));
                }
                if (this.m_write != null && !this.m_write.IsEmpty())
                {
                    esd.AddAttribute("Write", SecurityElement.Escape(m_write.UnsafeToString()));
                }
                if (this.m_create != null && !this.m_create.IsEmpty())
                {
                    esd.AddAttribute("Create", SecurityElement.Escape(m_create.UnsafeToString()));
                }
                if (this.m_viewAcl != null && !this.m_viewAcl.IsEmpty())
                {
                    esd.AddAttribute("ViewAccessControl", SecurityElement.Escape(m_viewAcl.UnsafeToString()));
                }
                if (this.m_changeAcl != null && !this.m_changeAcl.IsEmpty())
                {
                    esd.AddAttribute("ChangeAccessControl", SecurityElement.Escape(m_changeAcl.UnsafeToString()));
                }
            }
            else
            {
                esd.AddAttribute("Unrestricted", "true");
            }
            return(esd);
        }
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement root = new SecurityElement("IMembershipCondition");

            System.Security.Util.XMLUtil.AddClassAttribute(root, this.GetType(), "System.Security.Policy.ApplicationDirectoryMembershipCondition");
            // 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(this.GetType().FullName.Equals("System.Security.Policy.ApplicationDirectoryMembershipCondition"), "Class name changed!");

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

            return(root);
        }
예제 #21
0
        public SecurityElement ToXml(PolicyLevel level)
        {
            if (m_zone == SecurityZone.NoZone && m_element != null)
            {
                ParseZone();
            }

            SecurityElement root = new SecurityElement("IMembershipCondition");

            System.Security.Util.XMLUtil.AddClassAttribute(root, this.GetType(), "System.Security.Policy.ZoneMembershipCondition");
            // 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(this.GetType().FullName.Equals("System.Security.Policy.ZoneMembershipCondition"), "Class name changed!");

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

            if (m_zone != SecurityZone.NoZone)
            {
                root.AddAttribute("Zone", Enum.GetName(typeof(SecurityZone), m_zone));
            }

            return(root);
        }
예제 #22
0
        /// <include file='doc\StrongNameMembershipCondition.uex' path='docs/doc[@for="StrongNameMembershipCondition.ToXml1"]/*' />
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement root = new SecurityElement("IMembershipCondition");

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

            if (PublicKey != null)
            {
                root.AddAttribute(s_tagPublicKeyBlob, System.Security.Util.Hex.EncodeHexString(PublicKey.PublicKey));
            }

            if (Name != null)
            {
                root.AddAttribute(s_tagName, Name);
            }

            if ((Object)Version != null)
            {
                root.AddAttribute(s_tagVersion, Version.ToString());
            }

            return(root);
        }
예제 #23
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);
        }
예제 #24
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);
        }
 public override SecurityElement ToXml()
 {
     SecurityElement esd = CodeAccessPermission.CreatePermissionElement( this, "System.Security.Permissions.StrongNameIdentityPermission" );
     if (m_unrestricted)
         esd.AddAttribute( "Unrestricted", "true" );
     else if (m_strongNames != null)
     {
         if (m_strongNames.Length == 1)
         {
             if (m_strongNames[0].m_publicKeyBlob != null)
                 esd.AddAttribute("PublicKeyBlob", Hex.EncodeHexString(m_strongNames[0].m_publicKeyBlob.PublicKey));
             if (m_strongNames[0].m_name != null)
                 esd.AddAttribute("Name", m_strongNames[0].m_name);
             if ((Object)m_strongNames[0].m_version != null)
                 esd.AddAttribute("AssemblyVersion", m_strongNames[0].m_version.ToString());
         }
         else
         {
             int n;
             for(n = 0; n < m_strongNames.Length; n++)
             {
                 SecurityElement child = new SecurityElement("StrongName");
                 if (m_strongNames[n].m_publicKeyBlob != null)
                     child.AddAttribute("PublicKeyBlob", Hex.EncodeHexString(m_strongNames[n].m_publicKeyBlob.PublicKey));
                 if (m_strongNames[n].m_name != null)
                     child.AddAttribute("Name", m_strongNames[n].m_name);
                 if ((Object)m_strongNames[n].m_version != null)
                     child.AddAttribute("AssemblyVersion", m_strongNames[n].m_version.ToString());
                 esd.AddChild(child);
             }
         }
     }
     return esd;
 }
예제 #26
0
 /// <include file='doc\ZoneMembershipCondition.uex' path='docs/doc[@for="ZoneMembershipCondition.ToXml1"]/*' />
 public SecurityElement ToXml( PolicyLevel level )
 {
     if (m_zone == SecurityZone.NoZone && m_element != null)
         ParseZone();
         
     SecurityElement root = new SecurityElement( "IMembershipCondition" );
     System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType() );
     root.AddAttribute( "version", "1" );
     
     if (m_zone != SecurityZone.NoZone)
         root.AddAttribute( "Zone", Enum.GetName( typeof( SecurityZone ), m_zone ) );
     
     return root;
 }
 public override SecurityElement ToXml()
 {
     SecurityElement esd = CodeAccessPermission.CreatePermissionElement( this, "System.Security.Permissions.PublisherIdentityPermission" );
     if (m_unrestricted)
         esd.AddAttribute( "Unrestricted", "true" );
     else if (m_certs != null)
     {
         if (m_certs.Length == 1)
             esd.AddAttribute( "X509v3Certificate", m_certs[0].GetRawCertDataString() );
         else
         {
             int n;
             for(n = 0; n < m_certs.Length; n++)
             {
                 SecurityElement child = new SecurityElement("Cert");
                 child.AddAttribute( "X509v3Certificate", m_certs[n].GetRawCertDataString() );
                 esd.AddChild(child);
             }
         }
     }
     return esd;
 }
예제 #28
0
 public override SecurityElement ToXml()
 { 
     SecurityElement esd = CodeAccessPermission.CreatePermissionElement( this, "System.Security.Permissions.ZoneIdentityPermission" );
     if (SecurityZone != SecurityZone.NoZone)
     {
         esd.AddAttribute( "Zone", Enum.GetName( typeof( SecurityZone ), this.SecurityZone ) ); 
     }
     else 
     { 
         int nEnum = 0;
         uint nFlag; 
         for(nFlag = 1; nFlag < AllZones; nFlag <<= 1)
         {
             if((m_zones & nFlag) != 0)
             { 
                 SecurityElement child = new SecurityElement("Zone");
                 child.AddAttribute( "Zone", Enum.GetName( typeof( SecurityZone ), (SecurityZone)nEnum ) ); 
                 esd.AddChild(child); 
             }
             nEnum++; 
         }
     }
     return esd;
 } 
 /// <include file='doc\ApplicationDirectoryMembershipCondition.uex' path='docs/doc[@for="ApplicationDirectoryMembershipCondition.ToXml1"]/*' />
 public SecurityElement ToXml( PolicyLevel level )
 {
     SecurityElement root = new SecurityElement( "IMembershipCondition" );
     System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType() );
     root.AddAttribute( "version", "1" );
     
     return root;
 }
        /// <include file='doc\StrongNameMembershipCondition.uex' path='docs/doc[@for="StrongNameMembershipCondition.ToXml1"]/*' />
        public SecurityElement ToXml( PolicyLevel level )
        {
            SecurityElement root = new SecurityElement( "IMembershipCondition" );
            System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType() );
            root.AddAttribute( "version", "1" );
            
            if (PublicKey != null)
                root.AddAttribute( s_tagPublicKeyBlob, System.Security.Util.Hex.EncodeHexString( PublicKey.PublicKey ) );

            if (Name != null)
                root.AddAttribute( s_tagName, Name );

            if ((Object) Version != null)
                root.AddAttribute( s_tagVersion, Version.ToString() );

            return root;

        }
        public SecurityElement ToXml( PolicyLevel level )
        {
            if (m_site == null && m_element != null)
                ParseSite();
                        
            SecurityElement root = new SecurityElement( "IMembershipCondition" );
            System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), "System.Security.Policy.SiteMembershipCondition" );
            // 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( this.GetType().FullName.Equals( "System.Security.Policy.SiteMembershipCondition" ), "Class name changed!" );

            root.AddAttribute( "version", "1" );
            
            if (m_site != null)
                root.AddAttribute( "Site", m_site.ToString() );
            
            return root;
        }
        public SecurityElement ToXml( PolicyLevel level )
        {
            SecurityElement root = new SecurityElement( "IMembershipCondition" );
            System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), "System.Security.Policy.StrongNameMembershipCondition" );
            // 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.StrongNameMembershipCondition" ), "Class name changed!" );

            root.AddAttribute( "version", "1" );
            
            if (PublicKey != null)
                root.AddAttribute( s_tagPublicKeyBlob, System.Security.Util.Hex.EncodeHexString( PublicKey.PublicKey ) );

            if (Name != null)
                root.AddAttribute( s_tagName, Name );

            if ((Object) Version != null)
                root.AddAttribute( s_tagVersion, Version.ToString() );

            return root;

        }
        public SecurityElement ToXml( PolicyLevel level )
        {
            SecurityElement root = new SecurityElement( "IMembershipCondition" );
            System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), "System.Security.Policy.ApplicationDirectoryMembershipCondition" );
            // 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( this.GetType().FullName.Equals( "System.Security.Policy.ApplicationDirectoryMembershipCondition" ), "Class name changed!" );

            root.AddAttribute( "version", "1" );
            
            return root;
        }
예제 #34
0
 /// <include file='doc\SiteMembershipCondition.uex' path='docs/doc[@for="SiteMembershipCondition.ToXml1"]/*' />
 public SecurityElement ToXml( PolicyLevel level )
 {
     if (m_site == null && m_element != null)
         ParseSite();
                 
     SecurityElement root = new SecurityElement( "IMembershipCondition" );
     System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType() );
     root.AddAttribute( "version", "1" );
     
     if (m_site != null)
         root.AddAttribute( "Site", m_site.ToString() );
     
     return root;
 }
예제 #35
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;
 }
 public override SecurityElement ToXml()
 {
     SecurityElement esd = CodeAccessPermission.CreatePermissionElement( this, "System.Security.Permissions.UrlIdentityPermission" );
     if (m_unrestricted)
         esd.AddAttribute( "Unrestricted", "true" );
     else if (m_urls != null)
     {
         if (m_urls.Length == 1)
             esd.AddAttribute( "Url", m_urls[0].ToString() );
         else
         {
             int n;
             for(n = 0; n < m_urls.Length; n++)
             {
                 SecurityElement child = new SecurityElement("Url");
                 child.AddAttribute( "Url", m_urls[n].ToString() );
                 esd.AddChild(child);
             }
         }
     }
     return esd;
 }
        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;
        }