CasPolicy Class

Represents the policy for Code Access Security (CAS) for network operations. This class is used to define and manage the security permissions granted to code that performs network-related operations. It allows for fine-grained control over what network resources and operations are accessible.

API Reference

  • System.Net.Security.CasPolicy

Summary

The CasPolicy class provides a mechanism to associate specific Code Access Security (CAS) policies with network operations. This is particularly useful in scenarios where an application needs to enforce different security contexts for various network activities, such as establishing secure SSL/TLS connections or making HTTP requests.

By leveraging CAS, developers can implement a robust security model that limits the potential damage from malicious or buggy code, ensuring that network-bound operations are performed only with the necessary privileges.

Properties

  • PolicyLevel Level { get; }: Retrieves the current security policy level associated with the network operation.
  • PermissionState State { get; }: Indicates whether the permission is in an unrestricted or restricted state.

Methods

  • CasPolicy(PermissionState state): Initializes a new instance of the CasPolicy class with the specified permission state.
  • Copy() : IPermission: Creates and returns an identical copy of the current permission.
  • Intersect(IPermission target) : IPermission: Creates and returns a new permission that represents the intersection of the current permission and the specified permission.
  • IsSubsetOf(IPermission target) : bool: Determines whether the current permission is a subset of the specified permission.
  • IsUnrestricted() : bool: Indicates whether the current permission is unrestricted.
  • ToXml() : SecurityElement: Returns a SecurityElement representing the permission.
  • FromXml(SecurityElement element) : void: Reconstructs a permission from the specified SecurityElement.

Important Note

The use of Code Access Security (CAS) in .NET Framework applications is deprecated and is not recommended for new development. Consider alternative security models such as role-based security or Windows authentication.

Requirements

Namespace: System.Net.Security
Assembly: System.dll