O'Reilly logo

Programming .NET Security by Allen Jones, Adam Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending the .NET Framework

In Section 6.3.1.1, we developed the Author evidence class, which identifies the developer of an assembly. In this section, we extend CAS so that you can base policy resolution on the presence of Author evidence.

Custom Membership Conditions Explained

To enable Author evidence to drive policy resolution, first you create a custom membership condition class. Using the techniques described in Section 8.2, you can then use the custom membership condition in code groups to test the values of any Author evidence presented by an assembly or application domain. Here are the key requirements of a custom membership condition class:

Implement IMembershipCondition

Membership condition classes must implement the System.Security.Policy.IMembershipCondition interface, which extends both the System.Security.ISecurityPolicyEncodable and System.Security.ISecurityEncodeable interfaces. We summarize the members of each interface in Table 8-9.

Implement default constructor

Membership condition classes must implement a default (empty) constructor. The runtime uses this constructor when it needs to create a membership condition object from XML contained in the security policy files.

Make serializable

Membership condition classes must be serializable. Because of their simplicity, application of the System.SerializableAttribute is usually sufficient. Those membership condition classes that have more complex serialization requirements must implement the System.Runtime.Serialization.ISerializable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required