Overview Security Classes in VB.NET: Part 1
In this article I will explain you about Security Classes in VB.NET.
System.Security: The System.Security namespace provides the underlying structure of the VB.NET Framework security system. It includes interfaces, attributes, exceptions, and base classes for permissions, as well as the CodeAccessPermission class, which defines the underlying structure of all code access permissions.
Many Permission classes implement the IPermission interface, which takes the form shown in Listing 22.12.
Listing 22.12: IPermission Interface
Private Interface IPermission
Function IsSubsetOf(ByVal target As IPermission) As Boolean
Function Copy() As IPermission
Function Intersect(ByVal target As IPermission) As IPermission
Function Union(ByVal target As IPermission) As IPermission
The ISecurityEncodable interface is implemented to serialize permissions to and from XML format. Listing 22.13 shows the typical structure of the interface.
Listing 22.13: ISecurityEncodable Interface
Private Interface ISecurityEncodable
Sub FromXml(ByVal e As SecurityElement)
Function ToXml() As SecurityElement
Listing 22.14 provides an example of XML security serialization.
Listing 22.14: XML Security Serialization
// code to show XML serialization
Dim ps As New PermissionSet(PermissionState.None)
Dim myDOM__1 As SecurityElement = ps.ToXml()
All of the classes listed in Table 22.4 are derived from the CodeAccessPermission class.
Table 22.4: Permission Classes in the System.Security Namespace
Hope this article would have helped you in understanding Security Classes in VB.NET. The second part of this article you will see in my next article.