.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Security >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Assembly Permissions are Determined by using Evidence Types.

Posted By:Ravi Ranjan Kumar       Posted Date: August 31, 2012    Points: 200    Category: Security    URL: http://www.dotnetspark.com  

This Article enable you to learn basics of Assembly Permissions by Evidence Types.
 

Introduction 

Code access security uses the evidence(Evidence is the Information about an assembly that describes its identity and source) provided by an assembly and the current security policy implemented on the computer to determine what permission are granted. 

What are Evidence Types 

There are two main types of evidence, host evidence and assembly evidence. By default .Net framework uses only host evidence, which is the evidence from the application domain or host in which an assembly executes. Typically, the host evidence describe the origin of the code and indicates if it has been singned. 
 
TypeDescription
Siteresponsible to signifies the website from where the code was launched.
URLresponsible to signifies the URL from where the code was launched
Zoneresponsible to signifies the zone which the code was launched. Example Internet Zone, Intranet Zone, and the trusted Zone.
Application DirectoryIndicate the location of application
String NameIndicate the strong name of application, if it has one.
PublisherResponsible to signifies the authenticated signature of the publisher. if there is one exist.
Hashresponsible tosignifies the assembly hash created by using cryptographic algorithms such as SHA1 or MD5 responsible
The other kind of evidence are assembly evidence which is used to supplied in the assembly itself and must be user defined. In the .Net Framework, The

System.Security
and 
System.Security.Policy 
namespace offer the IEvidenceFactory interface and two main classes for managing evidence, Evidence and PermissionRequestEvidence. the following table describes the component of the System.Security and System.Security.Policy namespace. 

ComponentWhats Use
Evidence ClassThe Evidence class is a collection class designed for holding items of evidence that can be used for making security policy decisions
PermissionRequestEvidence ClassYou use the PermissionRequestEvidence clas to construct a set of permission that you can use to make code access security requests. The request can specify permissions that are either required or optional, and also the ones that should be refused. means Required, Optional, can refused.
IEvidenceFactoryThe IEvidenceFactory class is a MustInherit interface provided by assemblies and application domains allowing code to inspect the evidence information contained in these objects.

How to Implement Evidence Types. 

Lets take an consideration where you want to examine host or assembly evidence. The following code can show you a sample to accomplish your task to find how list the evidence of the currently executing assembly.

Add given namespace in your program
using System.Security.Policy;
using System.Reflection;
then try given code for a glimpse 
 static void Main(string[] args)
        {
            Assembly objAssembly = Assembly.GetExecutingAssembly();
            Evidence objEvidence = objAssembly.Evidence;
            IEnumerator e = objEvidence.GetEnumerator();
            while (e.MoveNext())
            {
                Console.WriteLine("Evidence is {0}", e.Current.ToString());
            }
            Console.ReadLine();
        }

Further Reading 

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend