public void DetermineApplicationTrust_DenyUnrestricted() { // documented as requiring ControlPolicy and ControlEvidence // possibly a linkdemand as only ControlPolicy seems check by the default // IApplicationTrustManager ApplicationSecurityManager.DetermineApplicationTrust(null, null); }
public static System.Security.Policy.ApplicationTrust RequestTrust(SubscriptionState subState, bool isShellVisible, bool isUpdate, ActivationContext actCtx, TrustManagerContext tmc) { Logger.AddMethodCall("ApplicationTrust.RequestTrust(isShellVisible=" + isShellVisible.ToString() + ", isUpdate=" + isUpdate.ToString() + ", subState.IsInstalled=" + subState.IsInstalled.ToString() + ") called."); if (!subState.IsInstalled || subState.IsShellVisible != isShellVisible) { tmc.IgnorePersistedDecision = true; } if (isUpdate) { tmc.PreviousApplicationIdentity = subState.CurrentBind.ToApplicationIdentity(); } bool applicationTrust1; try { Logger.AddInternalState("Calling ApplicationSecurityManager.DetermineApplicationTrust()."); Logger.AddInternalState("Trust Manager Context=" + Logger.Serialize(tmc)); applicationTrust1 = ApplicationSecurityManager.DetermineApplicationTrust(actCtx, tmc); } catch (TypeLoadException ex) { throw new InvalidDeploymentException(Resources.GetString("Ex_InvalidTrustInfo"), (Exception)ex); } if (!applicationTrust1) { throw new TrustNotGrantedException(Resources.GetString("Ex_NoTrust")); } Logger.AddInternalState("Trust granted."); System.Security.Policy.ApplicationTrust applicationTrust2 = (System.Security.Policy.ApplicationTrust)null; for (int index = 0; index < 5; ++index) { applicationTrust2 = ApplicationSecurityManager.UserApplicationTrusts[actCtx.Identity.FullName]; if (applicationTrust2 == null) { Thread.Sleep(10); } else { break; } } if (applicationTrust2 == null) { throw new InvalidDeploymentException(Resources.GetString("Ex_InvalidMatchTrust")); } return(applicationTrust2); }
public virtual ApplicationTrust DetermineApplicationTrust(Evidence applicationEvidence, Evidence activatorEvidence, TrustManagerContext context) { if (applicationEvidence == null) { throw new ArgumentNullException("applicationEvidence"); } ActivationArguments aa = null; foreach (object o in applicationEvidence) { aa = (o as ActivationArguments); if (aa != null) { break; } } if (aa == null) { string msg = Locale.GetText("No {0} found in {1}."); throw new ArgumentException(string.Format(msg, "ActivationArguments", "Evidence"), "applicationEvidence"); } if (aa.ActivationContext == null) { string msg = Locale.GetText("No {0} found in {1}."); throw new ArgumentException(string.Format(msg, "ActivationContext", "ActivationArguments"), "applicationEvidence"); } // FIXME: this part is still untested (requires manifest support) if (ApplicationSecurityManager.DetermineApplicationTrust(aa.ActivationContext, context)) { if (aa.ApplicationIdentity == null) { return(new ApplicationTrust()); } else { return(new ApplicationTrust(aa.ApplicationIdentity)); } } return(null); }
/// <summary>Determines whether an application should be executed.</summary> /// <returns>An <see cref="T:System.Security.Policy.ApplicationTrust" /> object that contains trust information about the application.</returns> /// <param name="applicationEvidence">The <see cref="T:System.Security.Policy.Evidence" /> for the application to be activated.</param> /// <param name="activatorEvidence">Optionally, the <see cref="T:System.Security.Policy.Evidence" /> for the activating application domain. </param> /// <param name="context">A <see cref="T:System.Security.Policy.TrustManagerContext" /> that specifies the trust context. </param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="applicationEvidence" /> is null.</exception> /// <exception cref="T:System.ArgumentException">An <see cref="T:System.Runtime.Hosting.ActivationArguments" /> object could not be found in the application evidence.-or-The <see cref="P:System.Runtime.Hosting.ActivationArguments.ActivationContext" /> property in the activation arguments is null.</exception> /// <exception cref="T:System.InvalidOperationException">The <see cref="T:System.Security.Policy.ApplicationTrust" /> grant set does not contain the minimum request set specified by the <see cref="T:System.ActivationContext" />.</exception> public virtual ApplicationTrust DetermineApplicationTrust(Evidence applicationEvidence, Evidence activatorEvidence, TrustManagerContext context) { if (applicationEvidence == null) { throw new ArgumentNullException("applicationEvidence"); } ActivationArguments activationArguments = null; foreach (object obj in applicationEvidence) { activationArguments = (obj as ActivationArguments); if (activationArguments != null) { break; } } if (activationArguments == null) { string text = Locale.GetText("No {0} found in {1}."); throw new ArgumentException(string.Format(text, "ActivationArguments", "Evidence"), "applicationEvidence"); } if (activationArguments.ActivationContext == null) { string text2 = Locale.GetText("No {0} found in {1}."); throw new ArgumentException(string.Format(text2, "ActivationContext", "ActivationArguments"), "applicationEvidence"); } if (!ApplicationSecurityManager.DetermineApplicationTrust(activationArguments.ActivationContext, context)) { return(null); } if (activationArguments.ApplicationIdentity == null) { return(new ApplicationTrust()); } return(new ApplicationTrust(activationArguments.ApplicationIdentity)); }
public void DetermineApplicationTrust_Null_TrustManagerContext() { ApplicationSecurityManager.DetermineApplicationTrust(null, new TrustManagerContext()); }
public void DetermineApplicationTrust_Null_Null() { ApplicationSecurityManager.DetermineApplicationTrust(null, null); }