예제 #1
0
파일: security.cs 프로젝트: dotnet/wpf-test
        /// <summary>
        /// Creates a PermissionSet from its xml'ed description
        /// </summary>
        /// <param name="s">xml string</param>
        /// <returns>a new PermissionSet</returns>
        internal static PermissionSet PermissionSetFromString(string s)
        {
            StringReader    reader  = new StringReader(s);
            SecurityElement secelem = SecurityElementBuilder.SecurityElementFromXml(reader);
            PermissionSet   perm    = new PermissionSet(PermissionState.None);

            perm.FromXml(secelem);
            return(perm);
        }
예제 #2
0
파일: security.cs 프로젝트: dotnet/wpf-test
        /// <summary>
        /// Creates a Sandbox object based on a TextReader containing an xml'ed permission set
        /// </summary>
        /// <param name="permissionSetStream">a text reader representing a xml'ed permission set</param>
        /// <param name="fullTrustAssembliesPath" />
        private void BuildSandbox(TextReader permissionSetStream, string fullTrustAssembliesPath)
        {
            PermissionSet permSet = null;

            // if there isn't a stream with a permission set, no sandbox => full trust permission set
            if (permissionSetStream != null)
            {
                //create permission set from stream
                SecurityElement secelem = SecurityElementBuilder.SecurityElementFromXml(permissionSetStream);
                permSet = new PermissionSet(PermissionState.None);
                permSet.FromXml(secelem);
            }
            else
            {
                permSet = new PermissionSet(PermissionState.Unrestricted);
            }

            //create sandbox app domain. This method doesn't use the full trust assemblies, they are used by the policy level
            CreateSandboxedDomain(permSet, fullTrustAssembliesPath);
        }