Represents a single statement in a Code Access Security (CAS) policy. This class cannot be inherited.
Syntax
public sealed class PolicyStatementEntry : System.Security.Policy.PolicyStatement
Remarks
Code Access Security (CAS) enables an application domain to enforce granular security policies,
preventing code from performing potentially malicious operations.
The PolicyStatementEntry class is a fundamental component of this system,
allowing developers to define and manage specific security permissions granted or denied to code.
Each PolicyStatementEntry associates a CodeGroup with a set of permissions.
This class is typically used in conjunction with other CAS policy objects like
CodeGroup, IMembershipCondition, and IIdentityPermissionFactory
to build comprehensive security policies.
Inheritance Hierarchy
System.Object
System.Security.Policy.PolicyStatement
System.Net.Security.PolicyStatementEntry
Requirements
.NET Framework 1.1
Members
Constructors
-
public PolicyStatementEntry(System.Security.Policy.IMembershipCondition membershipCondition, System.Security.Policy.PolicyStatement policyStatement)
Initializes a new instance of the PolicyStatementEntry class with the specified membership condition and policy statement.
Properties
-
public System.Security.Policy.IMembershipCondition MembershipCondition { get; set; }
Gets or sets the membership condition that determines whether code belongs to the code group.
-
public System.Security.Policy.PolicyStatement PolicyStatement { get; set; }
Gets or sets the policy statement associated with the code group.
Methods
-
public override bool Equals(object obj)
Determines whether the specified object is equal to the current object.
-
public override int GetHashCode()
Serves as the default hash function.
-
public object Clone()
Creates a new object that is a copy of the current instance.
Example
The following example demonstrates how to create and configure a PolicyStatementEntry.
using System;
using System.Security.Policy;
using System.Security.Permissions;
public class Example
{
public static void Main()
{
UrlMembershipCondition urlCondition = new UrlMembershipCondition("http://www.contoso.com/*");
PermissionSet permissionSet = new PermissionSet(System.Security.Permissions.PermissionState.Unrestricted);
permissionSet.AddPermission(new FileIOPermission(System.Security.Permissions.PermissionState.Unrestricted));
PolicyStatement statement = new PolicyStatement(permissionSet, PolicyStatementAttribute.Nothing);
PolicyStatementEntry entry = new PolicyStatementEntry(urlCondition, statement);
Console.WriteLine("PolicyStatementEntry created successfully.");
Console.WriteLine($"Membership Condition: {entry.MembershipCondition.ToString()}");
Console.WriteLine($"Permissions granted: {entry.PolicyStatement.PermissionSet.ToString()}");
}
}