Game Development Reference
In-Depth Information
private void EnforceSecurityPolicy()
{
IMembershipCondition condition;
PolicyStatement statement;
PolicyLevel policyLevel = PolicyLevel.CreateAppDomainLevel();
PermissionSet permissionSet = new PermissionSet(PermissionState.None);
SecurityPermission permission
= new SecurityPermission(SecurityPermissionFlag.Execution)
permissionSet.AddPermission(permission);
condition = new AllMembershipCondition();
statement = new PolicyStatement(permissionSet,
PolicyStatementAttribute.Nothing);
// The root code group of the policy level combines all
// permissions of its children.
UnionCodeGroup codeGroup = new UnionCodeGroup(condition, statement);
NamedPermissionSet localIntranet
= FindNamedPermissionSet(“LocalIntranet”);
condition = new ZoneMembershipCondition(SecurityZone.MyComputer);
statement = new PolicyStatement(localIntranet,
PolicyStatementAttribute.Nothing);
// The following code limits all code on this machine
// to local intranet permissions when running in this
// application domain.
UnionCodeGroup virtualIntranet = new UnionCodeGroup(condition,
statement);
virtualIntranet.Name = “Virtual Intranet”;
// Add the code groups to the policy level.
codeGroup.AddChild(virtualIntranet);
policyLevel.RootCodeGroup = codeGroup;
appDomain.SetAppDomainPolicy(policyLevel);
}
Search Nedrilad ::




Custom Search