System.Security.IPermission Interface

public interface IPermission

Assembly

mscorlib

Library

BCL

Summary

Defines methods implemented by permission types.

Description

[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:

]

See Also

System.Security Namespace

Members

IPermission Methods

IPermission.Copy Method
IPermission.Demand Method
IPermission.Intersect Method
IPermission.IsSubsetOf Method
IPermission.Union Method


IPermission.Copy Method

IPermission Copy();

Summary

Returns a IPermission object of the same type and containing the same values as the current instance.

Return Value

A new IPermission object of the same type and containing the same values as the current instance.

Description

[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.]

See Also

System.Security.IPermission Interface, System.Security Namespace

IPermission.Demand Method

void Demand();

Summary

Forces a SecurityException if all callers do not have the permission specified by the current instance.

Exceptions

Exception TypeCondition
SecurityException A caller does not have the permission specified by the current instance.

Description

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.]

See Also

System.Security.IPermission Interface, System.Security Namespace

IPermission.Intersect Method

IPermission Intersect(IPermission target);

Summary

Returns an object that is the intersection of the current instance and the specified IPermission object.

Parameters

target
An object of the same type as the current instance to intersect with the current instance.

Return Value

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 is null , returns null . If the current instance is unrestricted, returns a copy of target. If target is unrestricted, returns a copy of the current instance.

Exceptions

Exception TypeCondition
ArgumentExceptiontarget is not null and is not of the same type as the current instance.

Description

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.

]

[Usage: Use this method to obtain the set of permissions that are described both by the current instance and the specified object.]

See Also

System.Security.IPermission Interface, System.Security Namespace

IPermission.IsSubsetOf Method

bool IsSubsetOf(IPermission target);

Summary

Determines whether the current instance is a subset of the specified object.

Parameters

target
A IPermission object of the same type as the current instance that is to be tested for the subset relationship.

Return Value

true if the current instance is a subset of target ; otherwise, false . If the current instance is unrestricted, and target is not, returns false . If target is unrestricted, returns true . If target is null and the current instance does not secure any resources or operations, returns true . If target is null and the current instance secures one or more resources or operations, returns false .

Exceptions

Exception TypeCondition
ArgumentExceptiontarget is not null and is not of the same type as the current instance.

Description

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.

]

[Usage: Use this method to determine if the permissions described by the current instance are also described by the specified object.]

See Also

System.Security.IPermission Interface, System.Security Namespace

IPermission.Union Method

IPermission Union(IPermission target);

Summary

Returns an object that is the union of the current instance and the specified object.

Parameters

target
A IPermission object of the same type as the current instance to combine with the current instance.

Return Value

A new IPermission object of the same type as the current instance that represents the union of the current instance and target.

Exceptions

Exception TypeCondition
ArgumentExceptiontarget is not null and is not of the same type as the current instance.

Description

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.

]

[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.]

See Also

System.Security.IPermission Interface, System.Security Namespace