StrongNameIdentityPermission 类

定义

注意

Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}

定义强名称的标识权限。Defines the identity permission for strong names. 此类不能被继承。This class cannot be inherited.

public ref class StrongNameIdentityPermission sealed : System::Security::CodeAccessPermission
public sealed class StrongNameIdentityPermission : System.Security.CodeAccessPermission
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class StrongNameIdentityPermission : System.Security.CodeAccessPermission
[System.Serializable]
public sealed class StrongNameIdentityPermission : System.Security.CodeAccessPermission
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class StrongNameIdentityPermission : System.Security.CodeAccessPermission
type StrongNameIdentityPermission = class
    inherit CodeAccessPermission
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type StrongNameIdentityPermission = class
    inherit CodeAccessPermission
[<System.Serializable>]
type StrongNameIdentityPermission = class
    inherit CodeAccessPermission
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type StrongNameIdentityPermission = class
    inherit CodeAccessPermission
Public NotInheritable Class StrongNameIdentityPermission
Inherits CodeAccessPermission
继承
StrongNameIdentityPermission
属性

注解

重要

从开始 .NET Framework 4.NET Framework 4 ,不使用标识权限。Starting with the .NET Framework 4.NET Framework 4, identity permissions are not used.

在 .NET Framework 版本1.0 和1.1 中,标识权限不能具有 Unrestricted 权限状态值。In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an Unrestricted permission state value. 在 .NET Framework 版本2.0 及更高版本中,标识权限可以具有任何权限状态值。In the .NET Framework version 2.0 and later, identity permissions can have any permission state value. 这意味着在版本2.0 及更高版本中,标识权限与实现接口的权限具有相同的行为 IUnrestrictedPermissionThis means that in version 2.0 and later versions, identity permissions have the same behavior as permissions that implement the IUnrestrictedPermission interface. 也就是说,如果程序集已被授予完全信任,则标识的请求始终会成功,无论程序集的标识如何都是如此。That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.

使用 StrongNameIdentityPermission 确认调用代码位于特定的强名称代码程序集中。Use StrongNameIdentityPermission to confirm that the calling code is in a particular strong-named code assembly. StrongNameIdentityPermission仅当堆栈中的所有程序集都具有可满足需求的正确证据时,完全要求才能成功。Full demands for StrongNameIdentityPermission succeed only if all the assemblies in the stack have the correct evidence to satisfy the demand. StrongNameIdentityPermissionAttribute仅当直接调用方具有正确的证据时,使用特性的链接要求才会成功。Link demands that use the StrongNameIdentityPermissionAttribute attribute succeed only if the immediate caller has the correct evidence.

强名称标识基于名为二进制大型对象 (BLOB) 的加密公钥,可以选择将其与特定程序集的名称和版本结合使用。A strong name identity is based on a cryptographic public key called a binary large object (BLOB), which is optionally combined with the name and version of a specific assembly. 该键定义唯一命名空间,并提供强验证,因为名称的定义必须在由相应私钥签名的程序集中。The key defines a unique namespace and provides strong verification that the name is genuine, because the definition of the name must be in an assembly that is signed by the corresponding private key.

请注意,强名称密钥的有效性不依赖于信任关系,也不依赖于任何为密钥颁发的证书。Note that the validity of the strong name key is not dependent on a trust relationship or on any certificate necessarily being issued for the key.

在 .NET Framework 版本1.0 和1.1 中,即使调用程序集是完全受信任的,对标识权限的要求仍有效。In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective even when the calling assembly is fully trusted. 也就是说,即使调用程序集具有完全信任,如果程序集不满足要求的条件,也会失败。That is, even if the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. 在 .NET Framework 版本2.0 及更高版本中,如果调用程序集具有完全信任,则标识权限要求将无效。In the .NET Framework version 2.0 and later, demands for identity permissions are ineffective if the calling assembly has full trust. 这可确保所有权限的一致性,并避免将标识权限视为一种特殊情况。This ensures consistency for all permissions and eliminates the treatment of identity permissions as a special case.

有关强名称的完整说明,请参阅 StrongName 引用页。For a complete description of strong names, see the StrongName reference page. 有关强名称程序集的详细信息,请参阅 具有强名称的程序集For more information about strong-named assemblies, see Strong-named assemblies.

StrongNameIdentityPermission类用于定义用于访问类型的公共成员的强名称要求。The StrongNameIdentityPermission class is used to define strong-name requirements for accessing the public members of a type. StrongNameIdentityPermissionAttribute特性可用于在程序集级别定义强名称要求。The StrongNameIdentityPermissionAttribute attribute can be used to define strong-name requirements at the assembly level. 在 .NET Framework 版本2.0 及更高版本中,还可以使用 InternalsVisibleToAttribute 属性指定该程序集中的所有非公共类型对另一个程序集可见。In the .NET Framework version 2.0 and later, you can also use the InternalsVisibleToAttribute attribute to specify that all nonpublic types in that assembly are visible to another assembly. 有关详细信息,请参阅 友元程序集For more information, see Friend assemblies.

构造函数

StrongNameIdentityPermission(PermissionState)

使用指定的 StrongNameIdentityPermission 初始化 PermissionState 类的新实例。Initializes a new instance of the StrongNameIdentityPermission class with the specified PermissionState.

StrongNameIdentityPermission(StrongNamePublicKeyBlob, String, Version)

为指定的强名称标识初始化 StrongNameIdentityPermission 类的新实例。Initializes a new instance of the StrongNameIdentityPermission class for the specified strong name identity.

属性

Name

获取或设置强名称标识的简单名称部分。Gets or sets the simple name portion of the strong name identity.

PublicKey

获取或设置定义强名称标识命名空间的公钥 blob。Gets or sets the public key blob that defines the strong name identity namespace.

Version

获取或设置标识的版本号。Gets or sets the version number of the identity.

方法

Assert()

声明调用代码能够通过调用此方法的代码,访问受权限请求保护的资源,即使未对堆栈中处于较高位置的调用方授予访问该资源的权限。Declares that the calling code can access the resource protected by a permission demand through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. 使用 Assert() 会引起安全问题。Using Assert() can create security issues.

(继承自 CodeAccessPermission)
Copy()

创建并返回当前权限的相同副本。Creates and returns an identical copy of the current permission.

Demand()

如果未对调用堆栈中处于较高位置的所有调用方授予当前实例所指定的权限,则在运行时强制 SecurityExceptionForces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance.

(继承自 CodeAccessPermission)
Deny()
已过时。
已过时。

防止处于调用堆栈较高位置的调用函数使用可以调用此方法来访问当前实例指定资源的代码。Prevents callers higher in the call stack from using the code that calls this method to access the resource specified by the current instance.

(继承自 CodeAccessPermission)
Equals(Object)

确定指定的 CodeAccessPermission 对象是否等于当前的 CodeAccessPermissionDetermines whether the specified CodeAccessPermission object is equal to the current CodeAccessPermission.

(继承自 CodeAccessPermission)
FromXml(SecurityElement)

从 XML 编码重新构造具有指定状态的权限。Reconstructs a permission with a specified state from an XML encoding.

GetHashCode()

获取 CodeAccessPermission 对象的哈希代码,此代码适合在哈希算法和数据结构(例如哈希表)中使用。Gets a hash code for the CodeAccessPermission object that is suitable for use in hashing algorithms and data structures such as a hash table.

(继承自 CodeAccessPermission)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Intersect(IPermission)

创建并返回一个权限,该权限是当前权限与指定权限的交集。Creates and returns a permission that is the intersection of the current permission and the specified permission.

IsSubsetOf(IPermission)

确定当前权限是否为指定权限的子集。Determines whether the current permission is a subset of the specified permission.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
PermitOnly()

防止处于调用堆栈较高位置的调用函数使用此代码,此代码将调用此方法来访问除当前实例指定的资源以外的所有资源。Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance.

(继承自 CodeAccessPermission)
ToString()

创建并返回当前权限对象的字符串表示形式。Creates and returns a string representation of the current permission object.

(继承自 CodeAccessPermission)
ToXml()

创建权限及其当前状态的 XML 编码。Creates an XML encoding of the permission and its current state.

Union(IPermission)

创建一个权限,该权限是当前权限与指定权限的并集。Creates a permission that is the union of the current permission and the specified permission.

显式接口实现

IPermission.Demand()

如果不满足安全要求,则会在运行时引发 SecurityExceptionThrows a SecurityException at run time if the security requirement is not met.

(继承自 CodeAccessPermission)
IStackWalk.Assert()

断言调用代码可以访问当前权限对象所标识的资源,即使尚未对堆栈中的高级调用方授予访问该资源的权限。Asserts that the calling code can access the resource identified by the current permission object, even if callers higher in the stack have not been granted permission to access the resource.

(继承自 CodeAccessPermission)
IStackWalk.Demand()

在运行时确定调用堆栈中的所有调用方是否已被授予当前权限对象所指定的权限。Determines at run time whether all callers in the call stack have been granted the permission specified by the current permission object.

(继承自 CodeAccessPermission)
IStackWalk.Deny()

将导致通过调用代码传递的当前对象的每个 Demand() 失败。Causes every Demand() for the current object that passes through the calling code to fail.

(继承自 CodeAccessPermission)
IStackWalk.PermitOnly()

导致所有对象的每个 Demand()(除了通过调用代码的当前那个)失败,即使调用堆栈中较高级别的代码已被授予访问其他资源的权限也是如此。Causes every Demand() for all objects except the current one that pass through the calling code to fail, even if code higher in the call stack has been granted permission to access other resources.

(继承自 CodeAccessPermission)

适用于

另请参阅