HostSecurityManager.DetermineApplicationTrust(Evidence, Evidence, TrustManagerContext) HostSecurityManager.DetermineApplicationTrust(Evidence, Evidence, TrustManagerContext) HostSecurityManager.DetermineApplicationTrust(Evidence, Evidence, TrustManagerContext) HostSecurityManager.DetermineApplicationTrust(Evidence, Evidence, TrustManagerContext) Method

Определение

Определяет, должно ли выполняться приложение.Determines whether an application should be executed.

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
Public Overridable Function DetermineApplicationTrust (applicationEvidence As Evidence, activatorEvidence As Evidence, context As TrustManagerContext) As ApplicationTrust

Параметры

applicationEvidence
Evidence Evidence Evidence Evidence

Свидетельство для активируемого приложения.The evidence for the application to be activated.

activatorEvidence
Evidence Evidence Evidence Evidence

Свидетельство для активирующего домена приложения (необязательное).Optionally, the evidence for the activating application domain.

context
TrustManagerContext TrustManagerContext TrustManagerContext TrustManagerContext

Контекст доверия.The trust context.

Возвраты

Объект, содержащий сведения о доверии в отношении приложения.An object that contains trust information about the application.

Исключения

Свойство applicationEvidence имеет значение null.applicationEvidence is null.

Не удается найти в свидетельстве приложения объект ActivationArguments.An ActivationArguments object could not be found in the application evidence.

- или --or- Свойство ActivationContext в аргументах активации имеет значение null.The ActivationContext property in the activation arguments is null.

Набор разрешений ApplicationTrust не содержит минимального набора запросов, определенного в объекте ActivationContext.The ApplicationTrust grant set does not contain the minimum request set specified by the ActivationContext.

Примеры

В следующем примере показано, как переопределить DetermineApplicationTrust метод для пользовательского диспетчера безопасности узла.The following example shows how to override the DetermineApplicationTrust method for a custom host security manager. Этот пример является частью большого примера, HostSecurityManager приведенного для класса.This example is part of a larger example provided for the HostSecurityManager class.

[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

Комментарии

Этот метод может быть переопределен производным классом.This method can be overridden by a derived class. Базовая реализация вызывает диспетчер безопасности приложений, чтобы определить, должно ли выполняться приложение.The base implementation calls the application security manager to determine if the application should be executed.

Базовая реализация не использует свидетельство активатора.The base implementation does not use the activator evidence. Однако переопределенная реализация может использовать свидетельство активатора, чтобы определить свидетельство безопасности для домена приложения, пытающегося активировать приложение.However, an overridden implementation could use the activator evidence to determine the security evidence for the application domain attempting to activate the application.

Применяется к