private CodeGroup CreateDefaultMachinePolicy()
 {
     UnionCodeGroup group = new UnionCodeGroup();
     group.FromXml(CreateCodeGroupElement("UnionCodeGroup", "Nothing", new AllMembershipCondition().ToXml()), this);
     group.Name = Environment.GetResourceString("Policy_AllCode_Name");
     group.Description = Environment.GetResourceString("Policy_AllCode_DescriptionNothing");
     UnionCodeGroup group2 = new UnionCodeGroup();
     group2.FromXml(CreateCodeGroupElement("UnionCodeGroup", "FullTrust", new ZoneMembershipCondition(SecurityZone.MyComputer).ToXml()), this);
     group2.Name = Environment.GetResourceString("Policy_MyComputer_Name");
     group2.Description = Environment.GetResourceString("Policy_MyComputer_Description");
     StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob("002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293");
     UnionCodeGroup group3 = new UnionCodeGroup();
     group3.FromXml(CreateCodeGroupElement("UnionCodeGroup", "FullTrust", new StrongNameMembershipCondition(blob, null, null).ToXml()), this);
     group3.Name = Environment.GetResourceString("Policy_Microsoft_Name");
     group3.Description = Environment.GetResourceString("Policy_Microsoft_Description");
     group2.AddChildInternal(group3);
     blob = new StrongNamePublicKeyBlob("00000000000000000400000000000000");
     UnionCodeGroup group4 = new UnionCodeGroup();
     group4.FromXml(CreateCodeGroupElement("UnionCodeGroup", "FullTrust", new StrongNameMembershipCondition(blob, null, null).ToXml()), this);
     group4.Name = Environment.GetResourceString("Policy_Ecma_Name");
     group4.Description = Environment.GetResourceString("Policy_Ecma_Description");
     group2.AddChildInternal(group4);
     group.AddChildInternal(group2);
     CodeGroup group5 = new UnionCodeGroup();
     group5.FromXml(CreateCodeGroupElement("UnionCodeGroup", "LocalIntranet", new ZoneMembershipCondition(SecurityZone.Intranet).ToXml()), this);
     group5.Name = Environment.GetResourceString("Policy_Intranet_Name");
     group5.Description = Environment.GetResourceString("Policy_Intranet_Description");
     CodeGroup group6 = new NetCodeGroup(new AllMembershipCondition()) {
         Name = Environment.GetResourceString("Policy_IntranetNet_Name"),
         Description = Environment.GetResourceString("Policy_IntranetNet_Description")
     };
     group5.AddChildInternal(group6);
     CodeGroup group7 = new FileCodeGroup(new AllMembershipCondition(), FileIOPermissionAccess.PathDiscovery | FileIOPermissionAccess.Read) {
         Name = Environment.GetResourceString("Policy_IntranetFile_Name"),
         Description = Environment.GetResourceString("Policy_IntranetFile_Description")
     };
     group5.AddChildInternal(group7);
     group.AddChildInternal(group5);
     CodeGroup group8 = new UnionCodeGroup();
     group8.FromXml(CreateCodeGroupElement("UnionCodeGroup", "Internet", new ZoneMembershipCondition(SecurityZone.Internet).ToXml()), this);
     group8.Name = Environment.GetResourceString("Policy_Internet_Name");
     group8.Description = Environment.GetResourceString("Policy_Internet_Description");
     CodeGroup group9 = new NetCodeGroup(new AllMembershipCondition()) {
         Name = Environment.GetResourceString("Policy_InternetNet_Name"),
         Description = Environment.GetResourceString("Policy_InternetNet_Description")
     };
     group8.AddChildInternal(group9);
     group.AddChildInternal(group8);
     CodeGroup group10 = new UnionCodeGroup();
     group10.FromXml(CreateCodeGroupElement("UnionCodeGroup", "Nothing", new ZoneMembershipCondition(SecurityZone.Untrusted).ToXml()), this);
     group10.Name = Environment.GetResourceString("Policy_Untrusted_Name");
     group10.Description = Environment.GetResourceString("Policy_Untrusted_Description");
     group.AddChildInternal(group10);
     CodeGroup group11 = new UnionCodeGroup();
     group11.FromXml(CreateCodeGroupElement("UnionCodeGroup", "Internet", new ZoneMembershipCondition(SecurityZone.Trusted).ToXml()), this);
     group11.Name = Environment.GetResourceString("Policy_Trusted_Name");
     group11.Description = Environment.GetResourceString("Policy_Trusted_Description");
     CodeGroup group12 = new NetCodeGroup(new AllMembershipCondition()) {
         Name = Environment.GetResourceString("Policy_TrustedNet_Name"),
         Description = Environment.GetResourceString("Policy_TrustedNet_Description")
     };
     group11.AddChildInternal(group12);
     group.AddChildInternal(group11);
     return group;
 }
Ejemplo n.º 2
0
        [System.Security.SecurityCritical]  // auto-generated
        private CodeGroup CreateDefaultMachinePolicy() {
            UnionCodeGroup root = new UnionCodeGroup();
            root.FromXml(CreateCodeGroupElement("UnionCodeGroup", "Nothing", new AllMembershipCondition().ToXml()), this);
            root.Name = Environment.GetResourceString("Policy_AllCode_Name");
            root.Description = Environment.GetResourceString("Policy_AllCode_DescriptionNothing");

            UnionCodeGroup myComputerCodeGroup = new UnionCodeGroup();
            myComputerCodeGroup.FromXml(CreateCodeGroupElement("UnionCodeGroup", "FullTrust", new ZoneMembershipCondition(SecurityZone.MyComputer).ToXml()), this);
            myComputerCodeGroup.Name = Environment.GetResourceString("Policy_MyComputer_Name");
            myComputerCodeGroup.Description = Environment.GetResourceString("Policy_MyComputer_Description");

            // This code give trust to anything StrongName signed by Microsoft.
            StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob(AssemblyRef.MicrosoftPublicKeyFull);
            UnionCodeGroup microsoft = new UnionCodeGroup();
            microsoft.FromXml(CreateCodeGroupElement("UnionCodeGroup", "FullTrust", new StrongNameMembershipCondition(blob, null, null).ToXml()), this);
            microsoft.Name = Environment.GetResourceString("Policy_Microsoft_Name");
            microsoft.Description = Environment.GetResourceString("Policy_Microsoft_Description");
            myComputerCodeGroup.AddChildInternal(microsoft);

            // This code give trust to anything StrongName signed using the ECMA
            // public key (core system assemblies).
            blob = new StrongNamePublicKeyBlob(AssemblyRef.EcmaPublicKeyFull);
            UnionCodeGroup ecma = new UnionCodeGroup();
            ecma.FromXml(CreateCodeGroupElement("UnionCodeGroup", "FullTrust", new StrongNameMembershipCondition(blob, null, null).ToXml()), this);
            ecma.Name = Environment.GetResourceString("Policy_Ecma_Name");
            ecma.Description = Environment.GetResourceString("Policy_Ecma_Description");
            myComputerCodeGroup.AddChildInternal(ecma);

            root.AddChildInternal(myComputerCodeGroup);

            // do the rest of the zones
            CodeGroup intranet = new UnionCodeGroup();
            intranet.FromXml(CreateCodeGroupElement("UnionCodeGroup", "LocalIntranet", new ZoneMembershipCondition(SecurityZone.Intranet).ToXml()), this);
            intranet.Name = Environment.GetResourceString("Policy_Intranet_Name");
            intranet.Description = Environment.GetResourceString("Policy_Intranet_Description");

            CodeGroup intranetNetCode = new NetCodeGroup(new AllMembershipCondition());
            intranetNetCode.Name = Environment.GetResourceString("Policy_IntranetNet_Name");
            intranetNetCode.Description = Environment.GetResourceString("Policy_IntranetNet_Description");
            intranet.AddChildInternal(intranetNetCode);

            CodeGroup intranetFileCode = new FileCodeGroup(new AllMembershipCondition(), FileIOPermissionAccess.Read | FileIOPermissionAccess.PathDiscovery);
            intranetFileCode.Name = Environment.GetResourceString("Policy_IntranetFile_Name");
            intranetFileCode.Description = Environment.GetResourceString("Policy_IntranetFile_Description");
            intranet.AddChildInternal(intranetFileCode);

            root.AddChildInternal(intranet);

            CodeGroup internet = new UnionCodeGroup();
            internet.FromXml(CreateCodeGroupElement("UnionCodeGroup", "Internet", new ZoneMembershipCondition(SecurityZone.Internet).ToXml()), this);
            internet.Name = Environment.GetResourceString("Policy_Internet_Name");
            internet.Description = Environment.GetResourceString("Policy_Internet_Description");

            CodeGroup internetNet = new NetCodeGroup(new AllMembershipCondition());
            internetNet.Name = Environment.GetResourceString("Policy_InternetNet_Name");
            internetNet.Description = Environment.GetResourceString("Policy_InternetNet_Description");
            internet.AddChildInternal(internetNet);

            root.AddChildInternal(internet);

            CodeGroup untrusted = new UnionCodeGroup();
            untrusted.FromXml(CreateCodeGroupElement("UnionCodeGroup", "Nothing", new ZoneMembershipCondition(SecurityZone.Untrusted).ToXml()), this);
            untrusted.Name = Environment.GetResourceString("Policy_Untrusted_Name");
            untrusted.Description = Environment.GetResourceString("Policy_Untrusted_Description");
            root.AddChildInternal(untrusted);

            CodeGroup trusted = new UnionCodeGroup();
            trusted.FromXml(CreateCodeGroupElement("UnionCodeGroup", "Internet", new ZoneMembershipCondition(SecurityZone.Trusted).ToXml()), this);
            trusted.Name = Environment.GetResourceString("Policy_Trusted_Name");
            trusted.Description = Environment.GetResourceString("Policy_Trusted_Description");
            CodeGroup trustedNet = new NetCodeGroup(new AllMembershipCondition());
            trustedNet.Name = Environment.GetResourceString("Policy_TrustedNet_Name");
            trustedNet.Description = Environment.GetResourceString("Policy_TrustedNet_Description");
            trusted.AddChildInternal(trustedNet);

            root.AddChildInternal(trusted);

            return root;
        }
Ejemplo n.º 3
0
        internal void SetDefaultCodeGroups()
        {
            // NOTE: if you are going to add references to any permission set
            // that references permissions outside of mscorlib, DO NOT
            // CALL GetNamedPermissionSetInternal().  You need to use
            // CreateCodeGroupElement() and AddChildInternal().

            // NOTE: any changes to this will require that you recontemplate
            // the quick cache data found in PolicyLevelData.

            // Before we call GetNamedPermissionSetInternal, make sure that we are "loaded"
            m_loaded = true;
            UnionCodeGroup root = new UnionCodeGroup();
            root.FromXml( CreateCodeGroupElement( "UnionCodeGroup", "Nothing", new AllMembershipCondition().ToXml() ), this );
            root.Name = Environment.GetResourceString( "Policy_AllCode_Name" );
            root.Description = Environment.GetResourceString( "Policy_AllCode_DescriptionNothing" );

            UnionCodeGroup myComputerCodeGroup = new UnionCodeGroup();
            myComputerCodeGroup.FromXml( CreateCodeGroupElement( "UnionCodeGroup", "FullTrust", new ZoneMembershipCondition( SecurityZone.MyComputer ).ToXml() ), this );
            myComputerCodeGroup.Name = Environment.GetResourceString( "Policy_MyComputer_Name" );
            myComputerCodeGroup.Description = Environment.GetResourceString( "Policy_MyComputer_Description" );

            // This code give trust to anything StrongName signed by Microsoft.
            StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob( AssemblyRef.MicrosoftPublicKeyFull );
            UnionCodeGroup microsoft = new UnionCodeGroup();
            microsoft.FromXml( CreateCodeGroupElement( "UnionCodeGroup", "FullTrust", new StrongNameMembershipCondition( blob, null, null ).ToXml() ), this );
            microsoft.Name = Environment.GetResourceString( "Policy_Microsoft_Name" );
            microsoft.Description = Environment.GetResourceString( "Policy_Microsoft_Description" );
            myComputerCodeGroup.AddChildInternal( microsoft );

            // This code give trust to anything StrongName signed using the ECMA
            // public key (core system assemblies).
            blob = new StrongNamePublicKeyBlob( AssemblyRef.EcmaPublicKeyFull );
            UnionCodeGroup ecma = new UnionCodeGroup();
            ecma.FromXml( CreateCodeGroupElement( "UnionCodeGroup", "FullTrust", new StrongNameMembershipCondition( blob, null, null ).ToXml() ), this );
            ecma.Name = Environment.GetResourceString( "Policy_Ecma_Name" );
            ecma.Description = Environment.GetResourceString( "Policy_Ecma_Description" );
            myComputerCodeGroup.AddChildInternal( ecma );

            root.AddChildInternal(myComputerCodeGroup);
            
            // do the rest of the zones
            CodeGroup intranet = new UnionCodeGroup();
            intranet.FromXml( CreateCodeGroupElement( "UnionCodeGroup", "LocalIntranet", new ZoneMembershipCondition( SecurityZone.Intranet ).ToXml() ), this );
            intranet.Name = Environment.GetResourceString( "Policy_Intranet_Name" );
            intranet.Description = Environment.GetResourceString( "Policy_Intranet_Description" );

            CodeGroup intranetNetCode = new NetCodeGroup( new AllMembershipCondition() );
            intranetNetCode.Name = Environment.GetResourceString( "Policy_IntranetNet_Name" );
            intranetNetCode.Description = Environment.GetResourceString( "Policy_IntranetNet_Description" );
            intranet.AddChildInternal( intranetNetCode );

            CodeGroup intranetFileCode = new FileCodeGroup( new AllMembershipCondition(), FileIOPermissionAccess.Read | FileIOPermissionAccess.PathDiscovery );
            intranetFileCode.Name = Environment.GetResourceString( "Policy_IntranetFile_Name" );
            intranetFileCode.Description = Environment.GetResourceString( "Policy_IntranetFile_Description" );
            intranet.AddChildInternal( intranetFileCode );

            root.AddChildInternal( intranet );

            CodeGroup internet = new UnionCodeGroup();
            internet.FromXml( CreateCodeGroupElement( "UnionCodeGroup", "Nothing", new ZoneMembershipCondition( SecurityZone.Internet ).ToXml() ), this );
            internet.Name = Environment.GetResourceString( "Policy_Internet_Name" );
            internet.Description = Environment.GetResourceString( "Policy_Internet_Description" );


            root.AddChildInternal( internet );

            CodeGroup untrusted = new UnionCodeGroup();
            untrusted.FromXml( CreateCodeGroupElement( "UnionCodeGroup", "Nothing", new ZoneMembershipCondition( SecurityZone.Untrusted ).ToXml() ), this );
            untrusted.Name = Environment.GetResourceString( "Policy_Untrusted_Name" );
            untrusted.Description = Environment.GetResourceString( "Policy_Untrusted_Description" );
            root.AddChildInternal( untrusted );

            CodeGroup trusted = new UnionCodeGroup();
            trusted.FromXml( CreateCodeGroupElement( "UnionCodeGroup", "Internet", new ZoneMembershipCondition( SecurityZone.Trusted ).ToXml() ), this );
            trusted.Name = Environment.GetResourceString( "Policy_Trusted_Name" );
            trusted.Description = Environment.GetResourceString( "Policy_Trusted_Description" );
            CodeGroup trustedNet = new NetCodeGroup( new AllMembershipCondition() );
            trustedNet.Name = Environment.GetResourceString( "Policy_TrustedNet_Name" );
            trustedNet.Description = Environment.GetResourceString( "Policy_TrustedNet_Description" );
            trusted.AddChildInternal( trustedNet );

            root.AddChildInternal( trusted );
            m_rootCodeGroup = root;
        }