System.Security.Permissions.SecurityPermission Class

public sealed class SecurityPermission : CodeAccessPermission

Base Types

Object
  CodeAccessPermission
    SecurityPermission

This type implements IPermission.

Assembly

mscorlib

Library

BCL

Summary

Describes a set of security permissions applied to code.

Description

The SecurityPermissionFlag enumeration defines the permissions secured by this class.

The XML encoding of a SecurityPermission instance is defined below in EBNF format. The following conventions are used:

The following meta-language symbols are used:

BuildVersion refers to the build version of the shipping CLI. This is a dotted build number such as '2412.0' .

ECMAPubKeyToken ::= b77a5c561934e089

SecurityPermissionFlag = Assertion | ControlThread | Execution | SkipVerification | UnmanagedCode

Each SecurityPermissionFlag literal can appear in the XML no more than once. For example, Flags=Assertion,Assertion is illegal.

SecurityPermission ::=

<IPermission

class="

System.Security.Permissions.SecurityPermission,

mscorlib,

Version=1.0. BuildVersion,

Culture=neutral,

PublicKeyToken= ECMAPubKeyToken"

version="1"

(

Unrestricted="true"

)

|

(

Flags=" SecurityPermissionFlag (, SecurityPermissionFlag)* " )

| ()

/>

See Also

System.Security.Permissions Namespace

Members

SecurityPermission Constructors

SecurityPermission(System.Security.Permissions.PermissionState) Constructor
SecurityPermission(System.Security.Permissions.SecurityPermissionFlag) Constructor

SecurityPermission Methods

SecurityPermission.Copy Method
SecurityPermission.FromXml Method
SecurityPermission.Intersect Method
SecurityPermission.IsSubsetOf Method
SecurityPermission.ToXml Method
SecurityPermission.Union Method


SecurityPermission(System.Security.Permissions.PermissionState) Constructor

public SecurityPermission(PermissionState state);

Summary

Constructs a new instance of the SecurityPermission class with the specified PermissionState value.

Parameters

state
A PermissionState value. This value is either System.Security.Permissions.PermissionState.None or System.Security.Permissions.PermissionState.Unrestricted, respectively yielding fully restricted or fully unrestricted access to all security variables.

Exceptions

Exception TypeCondition
ArgumentExceptionstate is not a valid PermissionState value.

See Also

System.Security.Permissions.SecurityPermission Class, System.Security.Permissions Namespace

SecurityPermission(System.Security.Permissions.SecurityPermissionFlag) Constructor

public SecurityPermission(SecurityPermissionFlag flag);

Summary

Constructs a new instance of the SecurityPermission class with the specified SecurityPermissionFlag value.

Parameters

flag
One or more SecurityPermissionFlag values. Specify multiple values for flag using the bitwise OR operator.

Exceptions

Exception TypeCondition
ArgumentExceptionflag is not a valid SecurityPermissionFlag value.

See Also

System.Security.Permissions.SecurityPermission Class, System.Security.Permissions Namespace

SecurityPermission.Copy Method

public override IPermission Copy();

Summary

Returns a SecurityPermission object containing the same values as the current instance.

Return Value

A new SecurityPermission instance containing the same values as the current instance.

Description

[Note: The object returned by this method represents the same access to resources as the current instance.

This method overrides System.Security.CodeAccessPermission.Copy and is implemented to support the IPermission interface.

]

See Also

System.Security.Permissions.SecurityPermission Class, System.Security.Permissions Namespace

SecurityPermission.FromXml Method

public override void FromXml(SecurityElement esd);

Summary

Reconstructs the state of a SecurityPermission object using the specified XML encoding.

Parameters

esd
A SecurityElement instance containing the XML encoding to use to reconstruct the state of a SecurityPermission object.

Exceptions

Exception TypeCondition
ArgumentNullExceptionesd is null .
ArgumentExceptionesd does not contain the encoding for a SecurityPermission instance.

The version number of esd is not valid.

Description

The state of the current instance is changed to the state encoded in esd.

[Note: For the XML encoding for this class, see the SecurityPermission class page.

This method overrides System.Security.CodeAccessPermission.FromXml(System.Security.SecurityElement) .

]

See Also

System.Security.Permissions.SecurityPermission Class, System.Security.Permissions Namespace

SecurityPermission.Intersect Method

public override IPermission Intersect(IPermission target);

Summary

Returns a SecurityPermission object that is the intersection of the current instance and the specified object.

Parameters

target
A SecurityPermission object that is of the same type as the current instance to be intersected with the current instance.

Return Value

A new SecurityPermission instance that represents the intersection of the current instance and target. If the intersection is empty, or target is null , returns null .

Exceptions

Exception TypeCondition
ArgumentExceptiontarget is not null and is not of type SecurityPermission .

Description

[Note: The intersection of two permissions is a permission that secures the resources and operations secured by both permissions. Specifically, it represents the minimum permission such that any demand that passes both permissions will also pass their intersection.

This method overrides System.Security.CodeAccessPermission.Intersect(System.Security.IPermission) and is implemented to support the IPermission interface.

]

See Also

System.Security.Permissions.SecurityPermission Class, System.Security.Permissions Namespace

SecurityPermission.IsSubsetOf Method

public override bool IsSubsetOf(IPermission target);

Summary

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

Parameters

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

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 was initialized with System.Security.Permissions.SecurityPermissionFlag.NoFlags, returns true . If target is null and the current instance was initialized with any value other than NoFlags , returns false .

Exceptions

Exception TypeCondition
ArgumentExceptiontarget is not null and is not of type SecurityPermission .

Description

[Note: The current instance is a subset of target if the current instance specifies a set of accesses to resources 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.

This method overrides System.Security.CodeAccessPermission.IsSubsetOf(System.Security.IPermission) and is implemented to support the IPermission interface.

]

See Also

System.Security.Permissions.SecurityPermission Class, System.Security.Permissions Namespace

SecurityPermission.ToXml Method

public override SecurityElement ToXml();

Summary

Returns the XML encoding of the current instance.

Return Value

A SecurityElement containing an XML encoding of the state of the current instance.

Description

[Note: For the XML encoding for this class, see the SecurityPermission class page.

This method overrides System.Security.CodeAccessPermission.ToXml .

]

See Also

System.Security.Permissions.SecurityPermission Class, System.Security.Permissions Namespace

SecurityPermission.Union Method

public override IPermission Union(IPermission target);

Summary

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

Parameters

target
A SecurityPermission object of the same type as the current instance to be combined with the current instance.

Return Value

A new SecurityPermission instance that represents the union of the current instance and target. If the current instance or target is unrestricted, returns a SecurityPermission instance that is unrestricted. If target is null , returns a copy of the current instance using the System.Security.IPermission.Copy method.

Exceptions

Exception TypeCondition
ArgumentExceptiontarget is not null and is not of type SecurityPermission .

Description

[Note: The result of a call to System.Security.Permissions.SecurityPermission.Union(System.Security.IPermission) is a permission that represents all of the access to security permissions represented by the current instance as well as the security permissions represented by target. Any demand that passes either the current instance or target passes their union.

This method overrides System.Security.CodeAccessPermission.Union(System.Security.IPermission) and is implemented to support the IPermission interface.

]

See Also

System.Security.Permissions.SecurityPermission Class, System.Security.Permissions Namespace