- Part 4
- Topic 4
Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace)
- SecurityPermission class
- PrincipalPermission class
- FileIOPermission class
- StrongNameIdentityPermission class
- UIPermission class
- UrlIdentityPermission class
- PublisherIdentityPermission class
- GacIdentityPermission class
- FileDialogPermission class
- DataProtectionPermission class
- EnvironmentPermission class
- IUnrestrictedPermission interface
- RegistryPermission class
- IsolatedStorageFilePermission class
- KeyContainerPermission class
- ReflectionPermission class
- StorePermission class
- SiteIdentityPermission class
Summary
This section deals with asserting or demanding code access code to different resources. The SecurityPermission Class defines a set of permissions to applied to code. It exposes methods like Assert and Demand allow you to write the code that requires the permission to access the registry, call unmanaged code among other tasks.
The PrinciplePermission Class can be used to verify that a user is in a particular group. The FileIOPermission Class can be used to impose code permissions on files and directories. The StrongNameIdentityPermission Class can be used to ensure that calling code is in a particular strong named assembly. The UIPermission Class is used to for access to windows and the clipboard. The UrlIdentityPermission Class is used to ensure access to a web based url. The PublisherIdentityClass can be used to ensure the publisher of an assembly.
The GacIdentityPermission Class is new to .Net 2.0 and can be used to ensure the assembly is in the GAC. The FileDialogPermission is used to ensure access to a file though the a file dialog and is usually used when file permission has been denied. The DataProtectionPermission class is new to .Net 2.0 is used to ensure access to encrypted files or memory. The EnvironmentPermission class is used to ensure access to user and environment variables.
The IUnrestrictedPermission Interface is used to define an unrestricted state through code access security. To implement this interface implement a method IsRestricted which returns true or false. The RegistryPermission Class is used to ensure access to the registry. The IsolatedStorageFilePermission Class is used to ensure access to Isolated Storage capabilities. The KeyContainerPermission Class is new to .Net 2.0 and is used to ensure access to key containers. The ReflectionPermission Class is used to ensure access to metadata through Reflection.
The StorePermission Class is new to .Net 2.0 and is used to ensure access to Stores that contain X509 certificates. The SiteIdentityPermission is used to ensure access to the web site from which the code originates.
Other Resources & Links:
Understanding .Net Security
http://www.c-sharpcorner.com/Tutorials/DotNetSecurityVP001.asp
SecurityPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.securitypermission(VS.80).aspx
PrinciplePermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.principalpermission(VS.80).aspx
FileIOPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.fileiopermission(VS.80).aspx
StrongNameIdentityPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.strongnameidentitypermission(VS.80).aspx
UIPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.uipermission(VS.80).aspx
UrlIdentityPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.urlidentitypermission(VS.80).aspx
PublisherIdentityPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.publisheridentitypermission(VS.80).aspx
GacIdentityPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.gacidentitypermission(VS.80).aspx
FileDialogPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.filedialogpermission(VS.80).aspx
DataProtectionPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.dataprotectionpermission(VS.80).aspx
EnvironmentPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.environmentpermission(VS.80).aspx
IUnrestrictedPermission Interface
http://msdn2.microsoft.com/en-us/library/system.security.permissions.iunrestrictedpermission(VS.80).aspx
RegistryPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.registrypermission(VS.80).aspx
IsolatedStorageFilePermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.isolatedstoragepermission(VS.80).aspx
KeyContainerPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.keycontainerpermission(VS.80).aspx
ReflectionPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.reflectionpermission(VS.80).aspx
StorePermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.storepermission(VS.80).aspx
SiteIdentityPermission Class
http://msdn2.microsoft.com/en-us/library/system.security.permissions.siteidentitypermission(VS.80).aspx