public interface IPermission
mscorlib
BCL
Defines methods implemented by permission types.
[Note: Permission types describe a level of access to secured operations or resources, such as files or environment variables. Permission instances do not confer the right to access a resource or perform an operation; the security system determines whether or not requested permissions are granted. Permissions are used by both application code and the security system in the following ways:
]
- Code requests the permissions it needs in order to run.
- Permissions are granted by the security system.
- Code demands that calling code has a permission.
- Code alters the default behavior of the security system by asserting or denying permissions.
System.Security Namespace
IPermission Methods
IPermission.Copy Method
IPermission.Demand Method
IPermission.Intersect Method
IPermission.IsSubsetOf Method
IPermission.Union Method
IPermission Copy();
Returns a IPermission object of the same type and containing the same values as the current instance.
A new IPermission object of the same type and containing the same values as the current instance.
[Behaviors: The object returned by this method is required to be a deep copy of the current instance; any objects referenced by the current instance are duplicated in the copy.]
[Overrides: Implement this method to provide the system with a means of duplicating permission objects.]
[Usage: Use this method to obtain a copy of the current instance that is identical to the current instance.]
System.Security.IPermission Interface, System.Security Namespace
void Demand();
Forces a SecurityException if all callers do not have the permission specified by the current instance.
Exception Type Condition SecurityException A caller does not have the permission specified by the current instance.
The permission check for System.Security.IPermission.Demand begins with the immediate caller of the code that calls this method and continues until all callers have been checked or a caller has been found that is not granted the demanded permission, in which case a SecurityException exception is thrown.[Behaviors: Notifies the system that a security check is required for all callers of the method that invokes System.Security.IPermission.Demand. All callers are required to have the permissions described by the current instance. If one of the callers asserts the permissions and that caller has the permissions, the system is required to allow all callers that have not been checked to bypass the security check. If the security check fails, a SecurityException is thrown by the system.]
[Usage: Use this method to ensure that callers that call the method containing a System.Security.IPermission.Demand call have the permissions described by the current instance.]
System.Security.IPermission Interface, System.Security Namespace
IPermission Intersect(IPermission target);
Returns an object that is the intersection of the current instance and the specified IPermission object.
- target
- An object of the same type as the current instance to intersect with the current instance.
A new IPermission object that is the same type as the current instance and represents the intersection of the current instance and target. If the intersection is empty, or target isnull
, returnsnull
.
Exception Type Condition ArgumentException target is not null
and is not of the same type as the current instance.
The object returns by System.Security.IPermission.Intersect(System.Security.IPermission) is a permission that secures the resources and operations secured by two IPermission objects: a demand passes the intersection of two objects only if it passes both of the objects.[Behaviors: If target is not
null
and is not of the same type as the current instance, a ArgumentException exception is required to be thrown.The following statements are required to be true for all implementations of the System.Security.IPermission.Intersect(System.Security.IPermission) method. X and Y represent non-null IPermission object references.
]
- X.Intersect(X) returns a value equal to X.
- X.Intersect(Y) returns the same value as Y.Intersect(X).
- X.Intersect(
null
) returnsnull
.[Usage: Use this method to obtain the set of permissions that are described both by the current instance and the specified object.]
System.Security.IPermission Interface, System.Security Namespace
bool IsSubsetOf(IPermission target);
Determines whether the current instance is a subset of the specified object.
- target
- A IPermission object of the same type as the current instance that is to be tested for the subset relationship.
true
if the current instance is a subset of target ; otherwise,false
. If the current instance is unrestricted, and target is not, returnsfalse
. If target is unrestricted, returnstrue
. If target isnull
and the current instance does not secure any resources or operations, returnstrue
. If target isnull
and the current instance secures one or more resources or operations, returnsfalse
.
Exception Type Condition ArgumentException target is not null
and is not of the same type as the current instance.
The current instance is a subset of target if the current instance specifies a set of accesses to resources or operations that is wholly contained by target. For example, a permission that represents read access to a file is a subset of a permission that represents read and write access to the file.[Behaviors: If target is not
null
and is not of the same type as the current instance, a ArgumentException exception is required to be thrown.The following statements are required to be true for all implementations of the System.Security.IPermission.IsSubsetOf(System.Security.IPermission) method. X, Y, and Z represent non-null IPermission objects.
]
- X.IsSubsetOf(X ) returns
true
.- X.IsSubsetOf(Y) returns the same value as Y.IsSubsetOf(X) if and only if X and Y represent the same set of permissions.
- if X.IsSubsetOf(Y) and Y.IsSubsetOf(Z ) both return
true
, X.IsSubsetOf(Z ) returnstrue
.[Usage: Use this method to determine if the permissions described by the current instance are also described by the specified object.]
System.Security.IPermission Interface, System.Security Namespace
IPermission Union(IPermission target);
Returns an object that is the union of the current instance and the specified object.
- target
- A IPermission object of the same type as the current instance to combine with the current instance.
A new IPermission object of the same type as the current instance that represents the union of the current instance and target.
Exception Type Condition ArgumentException target is not null
and is not of the same type as the current instance.
The object returned by System.Security.IPermission.Union(System.Security.IPermission) is a permission that represents the permissions described by the current instance and those described by target . Any demand that passes either the current instance or target is required to pass the union of the two.[Behaviors: If target is not
null
and is not of the same type as the current instance, a ArgumentException exception is required to be thrown.The following statements are required to be true for all implementations of the System.Security.IPermission.Union(System.Security.IPermission) method. X and Y represent non-null IPermission objects.
]
- X.Union(X) returns an object that is value-equal to X.
- X.Union(Y) returns an object that is value-equal to the object returned by Y.Union(X).
- X.Union(
null
) returns an object that is value-equal to X .[Usage: Use this method to obtain a IPermission object of the same type as the current instance and target that describes the permissions described by the current instance and those described by target.]
System.Security.IPermission Interface, System.Security Namespace