HostSecurityManager.DetermineApplicationTrust Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menentukan apakah aplikasi harus dijalankan.
public:
virtual System::Security::Policy::ApplicationTrust ^ DetermineApplicationTrust(System::Security::Policy::Evidence ^ applicationEvidence, System::Security::Policy::Evidence ^ activatorEvidence, System::Security::Policy::TrustManagerContext ^ context);
public virtual System.Security.Policy.ApplicationTrust DetermineApplicationTrust (System.Security.Policy.Evidence applicationEvidence, System.Security.Policy.Evidence activatorEvidence, System.Security.Policy.TrustManagerContext context);
[System.Security.SecurityCritical]
public virtual System.Security.Policy.ApplicationTrust DetermineApplicationTrust (System.Security.Policy.Evidence applicationEvidence, System.Security.Policy.Evidence activatorEvidence, System.Security.Policy.TrustManagerContext context);
abstract member DetermineApplicationTrust : System.Security.Policy.Evidence * System.Security.Policy.Evidence * System.Security.Policy.TrustManagerContext -> System.Security.Policy.ApplicationTrust
override this.DetermineApplicationTrust : System.Security.Policy.Evidence * System.Security.Policy.Evidence * System.Security.Policy.TrustManagerContext -> System.Security.Policy.ApplicationTrust
[<System.Security.SecurityCritical>]
abstract member DetermineApplicationTrust : System.Security.Policy.Evidence * System.Security.Policy.Evidence * System.Security.Policy.TrustManagerContext -> System.Security.Policy.ApplicationTrust
override this.DetermineApplicationTrust : System.Security.Policy.Evidence * System.Security.Policy.Evidence * System.Security.Policy.TrustManagerContext -> System.Security.Policy.ApplicationTrust
Public Overridable Function DetermineApplicationTrust (applicationEvidence As Evidence, activatorEvidence As Evidence, context As TrustManagerContext) As ApplicationTrust
Parameter
- applicationEvidence
- Evidence
Bukti untuk aplikasi diaktifkan.
- activatorEvidence
- Evidence
Secara opsional, bukti untuk domain aplikasi pengaktifan.
- context
- TrustManagerContext
Konteks kepercayaan.
Mengembalikan
Objek yang berisi informasi kepercayaan tentang aplikasi.
- Atribut
Pengecualian
applicationEvidence
adalah null
.
Objek ActivationArguments tidak dapat ditemukan dalam bukti aplikasi.
-atau-
Properti ActivationContext dalam argumen aktivasi adalah null
.
Set ApplicationTrust pemberian tidak berisi set permintaan minimum yang ditentukan oleh ActivationContext.
Contoh
Contoh berikut menunjukkan cara mengambil alih DetermineApplicationTrust metode untuk manajer keamanan host kustom. Contoh ini adalah bagian dari contoh yang lebih besar yang disediakan untuk HostSecurityManager kelas .
[SecurityPermissionAttribute(SecurityAction.Demand, Execution = true)]
[SecurityPermissionAttribute(SecurityAction.Assert, Unrestricted = true)]
public override ApplicationTrust DetermineApplicationTrust(Evidence applicationEvidence, Evidence activatorEvidence, TrustManagerContext context)
{
if (applicationEvidence == null)
throw new ArgumentNullException("applicationEvidence");
// Get the activation context from the application evidence.
// This HostSecurityManager does not examine the activator evidence
// nor is it concerned with the TrustManagerContext;
// it simply grants the requested grant in the application manifest.
IEnumerator enumerator = applicationEvidence.GetHostEnumerator();
ActivationArguments activationArgs = null;
while (enumerator.MoveNext())
{
activationArgs = enumerator.Current as ActivationArguments;
if (activationArgs != null)
break;
}
if (activationArgs == null)
return null;
ActivationContext activationContext = activationArgs.ActivationContext;
if (activationContext == null)
return null;
ApplicationTrust trust = new ApplicationTrust(activationContext.Identity);
ApplicationSecurityInfo asi = new ApplicationSecurityInfo(activationContext);
trust.DefaultGrantSet = new PolicyStatement(asi.DefaultRequestSet, PolicyStatementAttribute.Nothing);
trust.IsApplicationTrustedToRun = true;
return trust;
}
<SecurityPermissionAttribute(SecurityAction.Demand, Execution:=True), SecurityPermissionAttribute(SecurityAction.Assert, Unrestricted:=True)> _
Public Overrides Function DetermineApplicationTrust(ByVal applicationEvidence As Evidence, ByVal activatorEvidence As Evidence, ByVal context As TrustManagerContext) As ApplicationTrust
If applicationEvidence Is Nothing Then
Throw New ArgumentNullException("applicationEvidence")
End If
' Get the activation context from the application evidence.
' This HostSecurityManager does not examine the activator evidence
' nor is it concerned with the TrustManagerContext;
' it simply grants the requested grant in the application manifest.
Dim enumerator As IEnumerator = applicationEvidence.GetHostEnumerator()
Dim activationArgs As ActivationArguments = Nothing
While enumerator.MoveNext()
activationArgs = enumerator.Current '
If Not (activationArgs Is Nothing) Then
Exit While
End If
End While
If activationArgs Is Nothing Then
Return Nothing
End If
Dim activationContext As ActivationContext = activationArgs.ActivationContext
If activationContext Is Nothing Then
Return Nothing
End If
Dim trust As New ApplicationTrust(activationContext.Identity)
Dim asi As New ApplicationSecurityInfo(activationContext)
trust.DefaultGrantSet = New PolicyStatement(asi.DefaultRequestSet, PolicyStatementAttribute.Nothing)
trust.IsApplicationTrustedToRun = True
Return trust
End Function 'DetermineApplicationTrust
End Class
Keterangan
Metode ini dapat ditimpa oleh kelas turunan. Implementasi dasar memanggil manajer keamanan aplikasi untuk menentukan apakah aplikasi harus dijalankan.
Implementasi dasar tidak menggunakan bukti aktivator. Namun, implementasi yang ditimpa dapat menggunakan bukti aktivator untuk menentukan bukti keamanan untuk domain aplikasi yang mencoba mengaktifkan aplikasi.