/// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
        /// <returns>An XML encoding of the security object, including any state information.</returns>
        /// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, which is used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
        /// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.PublisherMembershipCondition.Certificate" /> property is null. </exception>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
        /// </PermissionSet>
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement securityElement = MembershipConditionHelper.Element(typeof(PublisherMembershipCondition), this.version);

            securityElement.AddAttribute("X509Certificate", this.x509.GetRawCertDataString());
            return(securityElement);
        }
        /// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
        /// <returns>An XML encoding of the security object, including any state information.</returns>
        /// <param name="level">The policy level context for resolving named permission set references. </param>
        /// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.UrlMembershipCondition.Url" /> property is null. </exception>
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement securityElement = MembershipConditionHelper.Element(typeof(UrlMembershipCondition), this.version);

            securityElement.AddAttribute("Url", this.userUrl);
            return(securityElement);
        }
Exemplo n.º 3
0
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement se = MembershipConditionHelper.Element(typeof(ApplicationDirectoryMembershipCondition), version);

            // nothing to add
            return(se);
        }
        /// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
        /// <returns>An XML encoding of the security object, including any state information.</returns>
        /// <param name="level">The policy level context for resolving named permission set references. </param>
        /// <exception cref="T:System.ArgumentNullException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is null. </exception>
        /// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.ZoneMembershipCondition.SecurityZone" /> property is not a valid <see cref="T:System.Security.SecurityZone" />. </exception>
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement securityElement = MembershipConditionHelper.Element(typeof(ZoneMembershipCondition), this.version);

            securityElement.AddAttribute("Zone", this.zone.ToString());
            return(securityElement);
        }
Exemplo n.º 5
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>
        /// <returns>An XML encoding of the security object, including any state information.</returns>
        /// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
        /// <exception cref="T:System.ArgumentException">The <see cref="P:System.Security.Policy.SiteMembershipCondition.Site" /> property is null. </exception>
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement securityElement = MembershipConditionHelper.Element(typeof(SiteMembershipCondition), this.version);

            securityElement.AddAttribute("Site", this._site);
            return(securityElement);
        }
Exemplo n.º 6
0
        public SecurityElement ToXml(PolicyLevel level)
        {
            // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
            SecurityElement se = MembershipConditionHelper.Element(typeof(GacMembershipCondition), version);

            // nothing to add
            return(se);
        }
        public SecurityElement ToXml(PolicyLevel level)
        {
            // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
            SecurityElement se = MembershipConditionHelper.Element(typeof(PublisherMembershipCondition), version);

            se.AddAttribute("X509Certificate", x509.GetRawCertDataString());
            return(se);
        }
Exemplo n.º 8
0
        public SecurityElement ToXml(PolicyLevel level)
        {
            // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
            SecurityElement se = MembershipConditionHelper.Element(typeof(ZoneMembershipCondition), version);

            se.AddAttribute("Zone", zone.ToString());
            return(se);
        }
Exemplo n.º 9
0
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement se = MembershipConditionHelper.Element(typeof(HashMembershipCondition), version);

            se.AddAttribute("HashValue", CryptoConvert.ToHex(HashValue));
            se.AddAttribute("HashAlgorithm", hash_algorithm.GetType().FullName);
            return(se);
        }
Exemplo n.º 10
0
        /// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
        /// <param name="e">The XML encoding to use to reconstruct the security object. </param>
        /// <param name="level">The policy level context, used to resolve named permission set references. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
            this.hash_value = CryptoConvert.FromHex(e.Attribute("HashValue"));
            string text = e.Attribute("HashAlgorithm");

            this.hash_algorithm = ((text != null) ? HashAlgorithm.Create(text) : null);
        }
Exemplo n.º 11
0
 public void FromXml(SecurityElement e, PolicyLevel level)
 {
     MembershipConditionHelper.CheckSecurityElement(e, "e", version, version);
     if (!Boolean.TryParse(e.Attribute("LookAtDir"), out _lookAtDir))
     {
         _lookAtDir = false;
     }
     // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
 }
Exemplo n.º 12
0
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", version, version);

            hash_value = CryptoConvert.FromHex(e.Attribute("HashValue"));

            string algorithm = e.Attribute("HashAlgorithm");

            hash_algorithm = (algorithm == null) ? null : HashAlgorithm.Create(algorithm);
        }
        /// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
        /// <param name="e">The XML encoding to use to reconstruct the security object. </param>
        /// <param name="level">The policy level context used to resolve named permission set references. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
            string text = e.Attribute("Zone");

            if (text != null)
            {
                this.zone = (SecurityZone)((int)Enum.Parse(typeof(SecurityZone), text));
            }
        }
Exemplo n.º 14
0
        public SecurityElement ToXml(PolicyLevel level)
        {
            // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
            SecurityElement se = MembershipConditionHelper.Element(typeof(ApplicationMembershipCondition), version);

            if (_lookAtDir)
            {
                se.AddAttribute("LookAtDir", "true");
            }
            return(se);
        }
Exemplo n.º 15
0
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", version, version);

            string z = e.Attribute("Zone");

            if (z != null)
            {
                zone = (SecurityZone)Enum.Parse(typeof(SecurityZone), z);
            }
        }
        /// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
        /// <param name="e">The XML encoding to use to reconstruct the security object. </param>
        /// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
            string text = e.Attribute("X509Certificate");

            if (text != null)
            {
                byte[] data = CryptoConvert.FromHex(text);
                this.x509 = new X509Certificate(data);
            }
        }
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", version, version);
            string cert = e.Attribute("X509Certificate");

            if (cert != null)
            {
                byte[] rawcert = CryptoConvert.FromHex(cert);
                x509 = new X509Certificate(rawcert);
            }
            // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
        }
        /// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
        /// <param name="e">The XML encoding to use to reconstruct the security object. </param>
        /// <param name="level">The policy level context, used to resolve named permission set references. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
            string text = e.Attribute("Url");

            if (text != null)
            {
                this.CheckUrl(text);
                this.url = new Url(text);
            }
            else
            {
                this.url = null;
            }
            this.userUrl = text;
        }
        /// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
        /// <param name="e">The XML encoding to use to reconstruct the security object. </param>
        /// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
            this.blob = StrongNamePublicKeyBlob.FromString(e.Attribute("PublicKeyBlob"));
            this.name = e.Attribute("Name");
            string text = e.Attribute("AssemblyVersion");

            if (text == null)
            {
                this.assemblyVersion = null;
            }
            else
            {
                this.assemblyVersion = new Version(text);
            }
        }
Exemplo n.º 20
0
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", version, version);

            string u = e.Attribute("Url");

            if (u != null)
            {
                CheckUrl(u);
                url = new Url(u);
            }
            else
            {
                url = null;
            }
            userUrl = u;
        }
Exemplo n.º 21
0
        public void FromXml(SecurityElement e, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(e, "e", version, version);

            blob = StrongNamePublicKeyBlob.FromString(e.Attribute("PublicKeyBlob"));
            name = e.Attribute("Name");
            string v = (string)e.Attribute("AssemblyVersion");

            if (v == null)
            {
                assemblyVersion = null;
            }
            else
            {
                assemblyVersion = new Version(v);
            }
        }
Exemplo n.º 22
0
        public void FromXml(SecurityElement element, PolicyLevel level)
        {
            MembershipConditionHelper.CheckSecurityElement(element, "element", version, version);

            string u = element.Attribute("Url");

#if NET_2_0
            if (u != null)
            {
                CheckUrl(u);
                url = new Url(u);
            }
            else
            {
                url = null;
            }
#else
            url = (u == null) ? null : new Url(u);
#endif
            userUrl = u;
        }
        /// <summary>Creates an XML encoding of the security object and its current state with the specified <see cref="T:System.Security.Policy.PolicyLevel" />.</summary>
        /// <returns>An XML encoding of the security object, including any state information.</returns>
        /// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, which is used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
        public SecurityElement ToXml(PolicyLevel level)
        {
            SecurityElement securityElement = MembershipConditionHelper.Element(typeof(StrongNameMembershipCondition), this.version);

            if (this.blob != null)
            {
                securityElement.AddAttribute("PublicKeyBlob", this.blob.ToString());
            }
            if (this.name != null)
            {
                securityElement.AddAttribute("Name", this.name);
            }
            if (this.assemblyVersion != null)
            {
                string text = this.assemblyVersion.ToString();
                if (text != "0.0")
                {
                    securityElement.AddAttribute("AssemblyVersion", text);
                }
            }
            return(securityElement);
        }
Exemplo n.º 24
0
        public SecurityElement ToXml(PolicyLevel level)
        {
            // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
            SecurityElement se = MembershipConditionHelper.Element(typeof(StrongNameMembershipCondition), version);

            if (blob != null)
            {
                se.AddAttribute("PublicKeyBlob", blob.ToString());
            }
            if (name != null)
            {
                se.AddAttribute("Name", name);
            }
            if (assemblyVersion != null)
            {
                string v = assemblyVersion.ToString();
                if (v != "0.0")
                {
                    se.AddAttribute("AssemblyVersion", v);
                }
            }
            return(se);
        }
Exemplo n.º 25
0
 /// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary>
 /// <param name="e">The XML encoding to use to reconstruct the security object. </param>
 /// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context, used to resolve <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
 /// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception>
 /// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception>
 public void FromXml(SecurityElement e, PolicyLevel level)
 {
     MembershipConditionHelper.CheckSecurityElement(e, "e", this.version, this.version);
     this._site = e.Attribute("Site");
 }
Exemplo n.º 26
0
 public void FromXml(SecurityElement e, PolicyLevel level)
 {
     MembershipConditionHelper.CheckSecurityElement(e, "e", version, version);
 }
Exemplo n.º 27
0
 /// <summary>Creates an XML encoding of the security object and its current state, using the specified policy level context.</summary>
 /// <returns>A <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding of the security object, including any state information.</returns>
 /// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for resolving <see cref="T:System.Security.NamedPermissionSet" /> references. </param>
 public SecurityElement ToXml(PolicyLevel level)
 {
     return(MembershipConditionHelper.Element(typeof(GacMembershipCondition), this.version));
 }
Exemplo n.º 28
0
 public void FromXml(SecurityElement e, PolicyLevel level)
 {
     MembershipConditionHelper.CheckSecurityElement(e, "e", version, version);
     // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
 }