SecurityManager.CurrentThreadRequiresSecurityContextCapture 方法

定義

判斷當前執行緒若安全狀態需在後續時間重建,是否需要安全上下文擷取。

public:
 static bool CurrentThreadRequiresSecurityContextCapture();
[System.Security.SecurityCritical]
public static bool CurrentThreadRequiresSecurityContextCapture();
[<System.Security.SecurityCritical>]
static member CurrentThreadRequiresSecurityContextCapture : unit -> bool
Public Shared Function CurrentThreadRequiresSecurityContextCapture () As Boolean

傳回

false 若堆疊中沒有部分受信任的應用域、部分受信任的組合語言,也沒有目前啟用 PermitOnly()Deny() 修飾符; true 如果通用語言執行時無法保證堆疊中沒有這些。

屬性

備註

你可以在成功達成安全要求後,先用這種 CurrentThreadRequiresSecurityContextCapture 方法來快取敏感資料。

Assert 方法在堆疊上方被呼叫,資料不應在未捕捉對應安全上下文的情況下快取。 否則,根據 取得 Assert 的敏感資料可能會被已不再執行該系統 Assert 的程式碼所取得。

Important

回傳值只有在 時 false才可靠,這表示執行緒保證不需要安全上下文擷取。 當不需要安全上下文擷取時,該方法可能會回傳真值,以避免安全漏洞。

CurrentThreadRequiresSecurityContextCapture 是安全性關鍵,因為它的主要用途是避免不必要的安全上下文擷取,這表示使用該程式碼具有安全敏感性,必須進行稽核。

適用於