Action, ., .
Action - 3 SecurityAction:
-SecurityAction.ReguestMinimum , .
CAS, . .-System.Security.Policy.PolicyException.
- SecurityAction.ReguestOptional , - ReguestOptional ReguestMinimum.
., , .
CAS, . .- => . .
- SecurityAction.ReguestRefuse , .
. , , ., . - .
.
, , CAS.
Using System;
Using System.Security.Permissions;
[assembly: File IOPermissionAttribute
(Security Action.RequestMinimum, Read= @ C:\ boot.ini)]namespace NS {}
, CAS C:\ boot.ini. . SecurityAction.RequestOption SecurityAction.RequesRefuse - - Action.
.
[assembly: Reqistry Permission (SecurityAction.RequestMinnimum, Read=@HKE_local_Machine\Software)]
[assembly: Reqistry Permission (SecurityAction.RequestOptional, Read=@HKE_local_Machine\Software)]
HKE_local_Machine\Software . , - .
IequestOptimal Request- ReqeustOptional.
[assembly:Printing Permission
(Security.Action.RequetMinimum)]
[assembly:FileIOPermissionAttribute
(securityAction.RequstOptional,Read=@C\)]
[assembly:FileIOPermissionAttribute
(securityAction.RequstRefuse,Read
=@C\Windows)]
.. , CAS . .. CAS, . C\Windows . CAS, :
1. RequestMinimum, , .
|
|
2. RequesrOptinal? . . .
3. RequestReftion, RequstOptional.
9.
.
RBS,CAS . , CAS , .
.
6 :
1.assert- , , . assert any Permission That has been Granted.
2.demand- , , .
3. deny- , .
4.Inheritance Demand- , .
5.Link Demand- , , .
6. PermitOnly- .
Security.Actional 2 CodeAccessPermission , CAS:Demand Link.
/ , Demand , , LinkDemand , , , . System.Security.SecurityManadgere.IsGranted.
Security Actional CAS:Deny PermitOnly. , Demand( ReqestRefuse) , PermitOnly .
10. CAS
6 :
1.assert- , , . assert any Permission That has been Granted.
2.demand- , , .
3. deny- , .
4.Inheritance Demand- , .
5.Link Demand- , , .
|
|
6. PermitOnly- .
Security.Actional 2 CodeAccessPermission , CAS:Demand Link.
/ , Demand , , LinkDemand , , , . System.Security.SecurityManadgere.IsGranted.
Security Actional CAS:Deny PermitOnly. , Demand( ReqestRefuse) , PermitOnly .
11. CAS
6 :
1.assert- , , . assert any Permission That has been Granted.
2.demand- , , .
3. deny- , .
4.Inheritance Demand- , .
5.Link Demand- , , .
6. PermitOnly- .
Security.Actional 2 CodeAccessPermission , CAS:Demand Link.
/ , Demand , , LinkDemand , , , . System.Security.SecurityManadgere.IsGranted.
Security Actional CAS:Deny PermitOnly. , Demand( ReqestRefuse) , PermitOnly .
12.
, .NET, , , , . Win32 , , , .NET .
.
, ( ). , , , ( , ) , .NET. .NET . , , . , . , Win32 CLR. , , ( , ).
|
|
13. . . .
: 8 . 7- :
1.AllMemberShipCondition
2.AppLocationDirectoryMemberShipCondition
3.HashMemberShipCondition
4.PublisherMemberShipCondition
5.SiteMemberShipCondition
6.StrongNameMemberShipCondition
7.UrlMemberShipCondition
8.ZoneMemberShipCondition
. . , . .
AllMemberShipCondition .. .
:
1.FileCodeGroup- . . . FileIOPermission .
2.FirstMarchCodeGroup- . .
3.NetCodeGroupe- . WebPermission .
4.UnionCodeGroupe- , UnionCodeGroup.
:
, . - . . URL Internet:
UrlMembershipCondition safeMembership = new UrlMembershipCondition("http://www.microsoft.com/assembly.exe");
PemissionSet safePermissionSet = PolicyLevel.CreateAppDomainLevel().GetNamedPermissionSet("lnternet");
PolicyStatement safePolicyStatement = new PolicyStatement(safePermissionSet);
CodeGroup safeCodeGroup = new UnionCodeGroup (safeMembership, safePolicyStatement);
Police.Level . Police.Level , Police.Level.Root.Code.Group. . , , .
PolicyLevel safePolicyLevel = PolicyLevel.CreateAppDomainLevel();
safePolicyLevel.RootCodeGroup = safeCodeGroup;
AppDomain myDomain = AppDomain.CreateDomain (MyDomain);
myDomain.SetAppDomainPolicy(safePolicyLevel);