Ejemplo n.º 1
0
        private static PermissionSet GetNamedPermissionSet(string targetZone, ITaskItem[] dependencies, string targetFrameworkMoniker)
        {
            FrameworkNameVersioning fn = null;

            if (!string.IsNullOrEmpty(targetFrameworkMoniker))
            {
                fn = new FrameworkNameVersioning(targetFrameworkMoniker);
            }
            else
            {
                fn = new FrameworkNameVersioning(".NETFramework", s_dotNet40Version);
            }

            int majorVersion = fn.Version.Major;

            if (majorVersion == Fx2MajorVersion)
            {
                return(SecurityUtilities.XmlToPermissionSet((GetXmlElement(targetZone, majorVersion))));
            }
            else if (majorVersion == Fx3MajorVersion)
            {
                return(SecurityUtilities.XmlToPermissionSet((GetXmlElement(targetZone, majorVersion))));
            }
            else
            {
                return(SecurityUtilities.XmlToPermissionSet((GetXmlElement(targetZone, fn))));
            }
        }
Ejemplo n.º 2
0
 private PermissionSet GetInputPermissionSet()
 {
     if (_inputPermissionSet == null)
     {
         XmlElement psElement = GetInputPermissionSetElement();
         if (PreserveFullTrustPermissionSet)
         {
             XmlAttribute unrestrictedAttribute = (XmlAttribute)psElement.Attributes.GetNamedItem(XmlUtil.TrimPrefix(XPaths.unrestrictedAttribute));
             _isFullTrust = unrestrictedAttribute != null && Boolean.Parse(unrestrictedAttribute.Value);
             if (_isFullTrust)
             {
                 XmlDocument document = new XmlDocument();
                 document.AppendChild(document.ImportNode(psElement, true));
                 document.DocumentElement.Attributes.RemoveNamedItem(XmlUtil.TrimPrefix(XPaths.unrestrictedAttribute));
                 psElement = document.DocumentElement;
             }
             _inputPermissionSet = SecurityUtilities.XmlToPermissionSet(psElement);
         }
         else
         {
             _inputPermissionSet = SecurityUtilities.XmlToPermissionSet(psElement);
             _isFullTrust        = _inputPermissionSet.IsUnrestricted();
         }
     }
     return(_inputPermissionSet);
 }
Ejemplo n.º 3
0
 private System.Security.PermissionSet GetInputPermissionSet()
 {
     if (this._inputPermissionSet == null)
     {
         XmlElement inputPermissionSetElement = this.GetInputPermissionSetElement();
         if (this._preserveFullTrustPermissionSet)
         {
             XmlAttribute namedItem = (XmlAttribute)inputPermissionSetElement.Attributes.GetNamedItem(XmlUtil.TrimPrefix("asmv2:Unrestricted"));
             this._isFullTrust = (namedItem != null) && bool.Parse(namedItem.Value);
             if (this._isFullTrust)
             {
                 XmlDocument document = new XmlDocument();
                 document.AppendChild(document.ImportNode(inputPermissionSetElement, true));
                 document.DocumentElement.Attributes.RemoveNamedItem(XmlUtil.TrimPrefix("asmv2:Unrestricted"));
                 inputPermissionSetElement = document.DocumentElement;
             }
             this._inputPermissionSet = SecurityUtilities.XmlToPermissionSet(inputPermissionSetElement);
         }
         else
         {
             this._inputPermissionSet = SecurityUtilities.XmlToPermissionSet(inputPermissionSetElement);
             this._isFullTrust        = this._inputPermissionSet.IsUnrestricted();
         }
     }
     return(this._inputPermissionSet);
 }