StrongNameIdentityPermission 類別

定義

警告

Code Access Security is not supported or honored by the runtime.

定義強式名稱的識別權限。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 開始,就不會使用身分識別許可權。Starting with the .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類別是用來定義存取型別之 public 成員的強式名稱需求。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. 如需詳細資訊,請參閱 Friend 元件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()

如果不符合安全性要求,在 Run Time 時會擲回 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)

適用於

另請參閱