Csharp/CSharp Tutorial/Security/PolicyStatement — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:17, 26 мая 2010

Manufacture and print an example policy

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Security;
using System.Security.AccessControl;
using System.Security.Policy;
using System.Security.Permissions;
using System.Security.Principal;
using System.Text;
public class MainClass
{
    public static void Main()
    {
        PolicyStatement policy = new PolicyStatement(new PermissionSet(PermissionState.Unrestricted), new PolicyStatementAttribute());
        UnionCodeGroup group = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Internet), policy);
        group.Name = "nfex";
        UnionCodeGroup childGroup = new UnionCodeGroup(new UrlMembershipCondition("http://www.nfex.ru/"), policy);
        group.AddChild(childGroup);
        Console.WriteLine(group.ToXml().ToString());
    }
}
<IMembershipCondition class="System.Security.Policy.ZoneMembershipCondition, mscorlib, Version=2.0.0
.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Zone="Internet"/>
<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>

<IMembershipCondition class="System.Security.Policy.UrlMembershipCondition, mscorlib, Version=2.0.0.
0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Url="http://www.nfex.ru/"/>
<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
</CodeGroup>
</CodeGroup>