Advanced .NET Programming

Overview

The .NET Framework offers a rich security infrastructure based on both the identity of the code (code access security, or CAS) and the identity of the account under which it is running (role-based security). In this chapter, we will examine how code access security works, with a particular focus on looking under the hood. Because security is not generally a well-understood subject amongst many developers, I don't assume any prior knowledge of CAS, and will start by explaining the basic concepts. However, in keeping with the advanced nature of this book, I will tour through the basic concepts and syntax fairly quickly, so that we can get on to presenting some examples of applications that take advantage of CAS in fairly sophisticated ways, including defining our own custom permissions.

Given that the CLR offers both role-based and code access security, you might wonder why the security chapter of this book is exclusively concerned with code access security. Unfortunately, it's simply not possible in one chapter to do justice to the entire .NET security infrastructure, especially if we wish to do so at an advanced level. And although role-based security is important, it does to a large extent serve the same role as Windows OS security - it provides protection based on the identity of the process running an application. It is in code access security that the bulk of the new security concepts introduced by .NET can be found, which is why we will focus our attention there. However, role-based security is exposed to code in a very similar manner to CAS, using classes that are specified in XML files, which means that if you have a sound grasp of CAS, you should find it relatively simple to use role-based security as well.

We'll be covering the following topics:

Категории