Namespace: System.Security.Permissions
What is Declarative Code Access Security?
Declarative
Code Access security helps in restricting access to different resources; it
also intimates the user if assembly required resource can’t be granted at the
time of loading; it also helps in predetermining the resources an application
require to run and it also protects system and resource from an attacker who
intends to access unintended/protected resources. It also makes fine-tuned
permission outline to make your application run in partially-trusted zone.
Because permission attribute classes are inherited from CodeAccesSecurityAttribute they share the following two
most common properties.
Action: Specifies the security action
to take. Use SecurityAction enumeration.
Unrestricted: Set it to true if you want to give complete
access to the specified resource.
Types of Assembly Permission Declaration:
Set
action property of the all CAS security attributes to one the following when
using:
1. SecurityAction.RequestMinimum
The resource is very critical to run
the application. Runtime will throw exception if it is not granted.
2. SecurityAction.RequestOptional
Refuse all permission except
specified with RequestMinimum and RequestOptional. It is similar to saying
RefuseAllExcept. Runtime will not throw exception if it is not granted.
3. SecurityAction.RequestRefuse
Reduce the access to specified
resources.
Use [assembly:
UIPermission(SecurityAction.RequestMinimum, Unrestricted = true)] to
enable application debugging, If you used SecrityAction.RequestionOptional.
Comments