public void TestActivationArgumentsConstructor03() { try { ActivationArguments activationArguments = new ActivationArguments(null, null, null); } catch (Exception e) { Fail("Test should not have thrown an " + e.GetType().Name); } }
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); }
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); }
public override EvidenceBase Clone() { ActivationArguments arguments = new ActivationArguments { m_useFusionActivationContext = this.m_useFusionActivationContext, m_activateInstance = this.m_activateInstance, m_appFullName = this.m_appFullName }; if (this.m_appManifestPaths != null) { arguments.m_appManifestPaths = new string[this.m_appManifestPaths.Length]; Array.Copy(this.m_appManifestPaths, arguments.m_appManifestPaths, arguments.m_appManifestPaths.Length); } if (this.m_activationData != null) { arguments.m_activationData = new string[this.m_activationData.Length]; Array.Copy(this.m_activationData, arguments.m_activationData, arguments.m_activationData.Length); } arguments.m_activateInstance = this.m_activateInstance; arguments.m_appFullName = this.m_appFullName; arguments.m_useFusionActivationContext = this.m_useFusionActivationContext; return arguments; }
public virtual ApplicationTrust DetermineApplicationTrust(Evidence applicationEvidence, Evidence activatorEvidence, TrustManagerContext context) { if (applicationEvidence == null) { throw new ArgumentNullException("applicationEvidence"); } ActivationArguments hostEvidence = applicationEvidence.GetHostEvidence <ActivationArguments>(); if (hostEvidence == null) { throw new ArgumentException(Environment.GetResourceString("Policy_MissingActivationContextInAppEvidence")); } ActivationContext activationContext = hostEvidence.ActivationContext; if (activationContext == null) { throw new ArgumentException(Environment.GetResourceString("Policy_MissingActivationContextInAppEvidence")); } ApplicationTrust applicationTrust = applicationEvidence.GetHostEvidence <ApplicationTrust>(); if (applicationTrust != null && !CmsUtils.CompareIdentities(applicationTrust.ApplicationIdentity, hostEvidence.ApplicationIdentity, ApplicationVersionMatch.MatchExactVersion)) { applicationTrust = (ApplicationTrust)null; } if (applicationTrust == null) { applicationTrust = AppDomain.CurrentDomain.ApplicationTrust == null || !CmsUtils.CompareIdentities(AppDomain.CurrentDomain.ApplicationTrust.ApplicationIdentity, hostEvidence.ApplicationIdentity, ApplicationVersionMatch.MatchExactVersion) ? ApplicationSecurityManager.DetermineApplicationTrustInternal(activationContext, context) : AppDomain.CurrentDomain.ApplicationTrust; } ApplicationSecurityInfo applicationSecurityInfo = new ApplicationSecurityInfo(activationContext); if (applicationTrust != null && applicationTrust.IsApplicationTrustedToRun && !applicationSecurityInfo.DefaultRequestSet.IsSubsetOf(applicationTrust.DefaultGrantSet.PermissionSet)) { throw new InvalidOperationException(Environment.GetResourceString("Policy_AppTrustMustGrantAppRequest")); } return(applicationTrust); }
/// <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 static void Main(string[] args) { //<Snippet2> // Get the AppDomainManager from the current domain. AppDomainManager domainMgr = AppDomain.CurrentDomain.DomainManager; // Get the ApplicationActivator from the AppDomainManager. ApplicationActivator appActivator = domainMgr.ApplicationActivator; Console.WriteLine("Assembly qualified name from the application activator."); Console.WriteLine(appActivator.GetType().AssemblyQualifiedName); //</Snippet2> //<Snippet3> //<Snippet4> // Get the ActivationArguments from the SetupInformation property of the domain. ActivationArguments activationArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments; //</Snippet3> // Get the ActivationContext from the ActivationArguments. ActivationContext actContext = activationArgs.ActivationContext; Console.WriteLine("The ActivationContext.Form property value is: " + activationArgs.ActivationContext.Form); //</Snippet4> Console.Read(); }
public AppDomainSetup (ActivationArguments activationArguments) { _activationArguments = activationArguments; }
internal static string GetEntryPointFullPath (ActivationArguments activationArguments) { return GetEntryPointFullPath(activationArguments.ActivationContext); }
public virtual ApplicationTrust DetermineApplicationTrust(Evidence applicationEvidence, Evidence activatorEvidence, TrustManagerContext context) { if (applicationEvidence == null) { throw new ArgumentNullException("applicationEvidence"); } Contract.EndContractBlock(); // This method looks for a trust decision for the ActivationContext in three locations, in order // of preference: // // 1. Supplied by the host in the AppDomainSetup. If the host supplied a decision this way, it // will be in the applicationEvidence. // 2. Reuse the ApplicationTrust from the current AppDomain // 3. Ask the TrustManager for a trust decision // get the activation context from the application evidence. // The default HostSecurityManager does not examine the activatorEvidence // but other security managers could use it to figure out the // evidence of the domain attempting to activate the application. ActivationArguments activationArgs = applicationEvidence.GetHostEvidence <ActivationArguments>(); if (activationArgs == null) { throw new ArgumentException(Environment.GetResourceString("Policy_MissingActivationContextInAppEvidence")); } ActivationContext actCtx = activationArgs.ActivationContext; if (actCtx == null) { throw new ArgumentException(Environment.GetResourceString("Policy_MissingActivationContextInAppEvidence")); } // Make sure that any ApplicationTrust we find applies to the ActivationContext we're // creating the new AppDomain for. ApplicationTrust appTrust = applicationEvidence.GetHostEvidence <ApplicationTrust>(); if (appTrust != null && !CmsUtils.CompareIdentities(appTrust.ApplicationIdentity, activationArgs.ApplicationIdentity, ApplicationVersionMatch.MatchExactVersion)) { appTrust = null; } // If there was not a trust decision supplied in the Evidence, we can reuse the existing trust // decision from this domain if its identity matches the ActivationContext of the new domain. // Otherwise consult the TrustManager for a trust decision if (appTrust == null) { if (AppDomain.CurrentDomain.ApplicationTrust != null && CmsUtils.CompareIdentities(AppDomain.CurrentDomain.ApplicationTrust.ApplicationIdentity, activationArgs.ApplicationIdentity, ApplicationVersionMatch.MatchExactVersion)) { appTrust = AppDomain.CurrentDomain.ApplicationTrust; } else { appTrust = ApplicationSecurityManager.DetermineApplicationTrustInternal(actCtx, context); } } // If the trust decision allows the application to run, then it should also have a permission set // which is at least the permission set the application requested. ApplicationSecurityInfo appRequest = new ApplicationSecurityInfo(actCtx); if (appTrust != null && appTrust.IsApplicationTrustedToRun && !appRequest.DefaultRequestSet.IsSubsetOf(appTrust.DefaultGrantSet.PermissionSet)) { throw new InvalidOperationException(Environment.GetResourceString("Policy_AppTrustMustGrantAppRequest")); } return(appTrust); }
public void TestActivationArgumentsActivationData02() { ActivationArguments activationArguments; String[] strings = { "A", "B" }; try { activationArguments = new ActivationArguments("Test", null, strings); AssertEquals("ActivationData 1:", activationArguments.ActivationData.Length, 2); AssertEquals("ActivationData 2:", activationArguments.ActivationData[0], strings[0]); AssertEquals("ActivationData 3:", activationArguments.ActivationData[1], strings[1]); strings[0] = "C"; AssertEquals("ActivationData 4:", activationArguments.ActivationData[0], "C"); } catch (Exception e) { Fail("Test should not have thrown an " + e.GetType().Name + " at\n" + e.StackTrace); } }
[System.Security.SecuritySafeCritical] // auto-generated public AppDomainSetup (ActivationArguments activationArguments) { if (activationArguments == null) throw new ArgumentNullException("activationArguments"); Contract.EndContractBlock(); _LoaderOptimization = LoaderOptimization.NotSpecified; ActivationArguments = activationArguments; Contract.Assert(activationArguments.ActivationContext != null, "Cannot set base directory without activation context"); string entryPointPath = CmsUtils.GetEntryPointFullPath(activationArguments); if (!String.IsNullOrEmpty(entryPointPath)) SetupDefaults(entryPointPath); else ApplicationBase = activationArguments.ActivationContext.ApplicationDirectory; }
internal AppDomainSetup (AppDomainSetup setup) { application_base = setup.application_base; application_name = setup.application_name; cache_path = setup.cache_path; configuration_file = setup.configuration_file; dynamic_base = setup.dynamic_base; license_file = setup.license_file; private_bin_path = setup.private_bin_path; private_bin_path_probe = setup.private_bin_path_probe; shadow_copy_directories = setup.shadow_copy_directories; shadow_copy_files = setup.shadow_copy_files; publisher_policy = setup.publisher_policy; path_changed = setup.path_changed; loader_optimization = setup.loader_optimization; disallow_binding_redirects = setup.disallow_binding_redirects; disallow_code_downloads = setup.disallow_code_downloads; _activationArguments = setup._activationArguments; domain_initializer = setup.domain_initializer; application_trust = setup.application_trust; domain_initializer_args = setup.domain_initializer_args; disallow_appbase_probe = setup.disallow_appbase_probe; configuration_bytes = setup.configuration_bytes; }
public void TestActivationArgumentsFullName01() { ActivationArguments activationArguments; try { activationArguments = new ActivationArguments("Test"); AssertEquals("Fullname 1:", activationArguments.ApplicationFullName, "Test"); activationArguments.ApplicationFullName = "Test1"; AssertEquals("Fullname 2:", activationArguments.ApplicationFullName, "Test1"); AssertNull("Fullname 3:", activationArguments.ApplicationManifestPaths); AssertNull("Fullname 4:", activationArguments.ActivationData); try { activationArguments.ApplicationFullName = null; Fail("Test Fullname 3 should have thrown an ArgumentNullException"); } catch (ArgumentNullException) { // success } activationArguments.ApplicationFullName = String.Empty; AssertEquals("Fullname 2:", activationArguments.ApplicationFullName, String.Empty); } catch (Exception e) { Fail("Test should not have thrown an " + e.GetType().Name + " at\n" + e.StackTrace); } }
internal AppDomainSetup(AppDomainSetup copy, bool copyDomainBoundData) { string[] mine = Value; if(copy != null) { string[] other = copy.Value; int mineSize = _Entries.Length; int otherSize = other.Length; int size = (otherSize < mineSize) ? otherSize : mineSize; for (int i = 0; i < size; i++) mine[i] = other[i]; if (size < mineSize) { // This case can happen when the copy is a deserialized version of // an AppDomainSetup object serialized by Everett. for (int i = size; i < mineSize; i++) mine[i] = null; } _LoaderOptimization = copy._LoaderOptimization; _AppDomainInitializerArguments = copy.AppDomainInitializerArguments; #if FEATURE_CLICKONCE _ActivationArguments = copy.ActivationArguments; #endif _ApplicationTrust = copy._ApplicationTrust; if (copyDomainBoundData) _AppDomainInitializer = copy.AppDomainInitializer; else _AppDomainInitializer = null; _ConfigurationBytes = copy.GetConfigurationBytes(); #if FEATURE_COMINTEROP _DisableInterfaceCache = copy._DisableInterfaceCache; #endif // FEATURE_COMINTEROP _AppDomainManagerAssembly = copy.AppDomainManagerAssembly; _AppDomainManagerType = copy.AppDomainManagerType; #if FEATURE_APTCA _AptcaVisibleAssemblies = copy.PartialTrustVisibleAssemblies; #endif if (copy._CompatFlags != null) { SetCompatibilitySwitches(copy._CompatFlags.Keys); } #if !FEATURE_CORECLR if(copy._AppDomainSortingSetupInfo != null) { _AppDomainSortingSetupInfo = new AppDomainSortingSetupInfo(copy._AppDomainSortingSetupInfo); } #endif _TargetFrameworkName = copy._TargetFrameworkName; #if FEATURE_RANDOMIZED_STRING_HASHING _UseRandomizedStringHashing = copy._UseRandomizedStringHashing; #endif } else _LoaderOptimization = LoaderOptimization.NotSpecified; }
public void TestActivationArgumentsManifestPaths01() { ActivationArguments activationArguments; try { activationArguments = new ActivationArguments("Test", null); AssertNull("ApplicationManifestPaths 1:", activationArguments.ApplicationManifestPaths); activationArguments.ApplicationManifestPaths = null; AssertNull("ApplicationManifestPaths 2:", activationArguments.ApplicationManifestPaths); // MS docs say this should be an Array with two items but it // does not throw an exception in this case activationArguments.ApplicationManifestPaths = new String[] { null }; AssertNotNull("ApplicationManifestPaths 3:", activationArguments.ApplicationManifestPaths); AssertEquals("ApplicationManifestPaths 4:", activationArguments.ApplicationManifestPaths.Length, 1); AssertNull("ApplicationManifestPaths 5:", activationArguments.ApplicationManifestPaths[0]); activationArguments.ApplicationManifestPaths = new String[] { null, null }; AssertNotNull("ApplicationManifestPaths 6:", activationArguments.ApplicationManifestPaths); AssertEquals("ApplicationManifestPaths 7:", activationArguments.ApplicationManifestPaths.Length, 2); AssertNull("ApplicationManifestPaths 8:", activationArguments.ApplicationManifestPaths[0]); AssertNull("ApplicationManifestPaths 9:", activationArguments.ApplicationManifestPaths[1]); // MS docs say this should be an Array with two items but // it does not throw an exception in this case activationArguments.ApplicationManifestPaths = new String[] { null, null, null }; AssertNotNull("ApplicationManifestPaths 10:", activationArguments.ApplicationManifestPaths); AssertEquals("ApplicationManifestPaths 11:", activationArguments.ApplicationManifestPaths.Length, 3); AssertNull("ApplicationManifestPaths 12:", activationArguments.ApplicationManifestPaths[0]); AssertNull("ApplicationManifestPaths 13:", activationArguments.ApplicationManifestPaths[1]); AssertNull("ApplicationManifestPaths 13:", activationArguments.ApplicationManifestPaths[2]); } catch (Exception e) { Fail("Test should not have thrown an " + e.GetType().Name + " at\n" + e.StackTrace); } }
internal AppDomainSetup(AppDomainSetup copy, bool copyDomainBoundData) { string[] mine = Value; if(copy != null) { string[] other = copy.Value; int mineSize = _Entries.Length; int otherSize = other.Length; int size = (otherSize < mineSize) ? otherSize : mineSize; for (int i = 0; i < size; i++) mine[i] = other[i]; if (size < mineSize) { for (int i = size; i < mineSize; i++) mine[i] = null; } _LoaderOptimization = copy._LoaderOptimization; _AppDomainInitializerArguments = copy.AppDomainInitializerArguments; _ActivationArguments = copy.ActivationArguments; if (copyDomainBoundData) _AppDomainInitializer = copy.AppDomainInitializer; else _AppDomainInitializer = null; _ConfigurationBytes = copy.GetConfigurationBytes(); } else _LoaderOptimization = LoaderOptimization.NotSpecified; }
public void TestActivationArgumentsManifestPaths02() { ActivationArguments activationArguments; String[] strings = { "A", "B" }; try { activationArguments = new ActivationArguments("Test", strings); AssertEquals("activationArguments 1:", activationArguments.ApplicationManifestPaths.Length, 2); AssertEquals("activationArguments 2:", activationArguments.ApplicationManifestPaths[0], strings[0]); AssertEquals("activationArguments 3:", activationArguments.ApplicationManifestPaths[1], strings[1]); strings[0] = "C"; AssertEquals("activationArguments 3:", activationArguments.ApplicationManifestPaths[0], "C"); } catch (Exception e) { Fail("Test should not have thrown an " + e.GetType().Name + " at\n" + e.StackTrace); } }
public AppDomainSetup (ActivationContext activationContext) { _activationArguments = new ActivationArguments (activationContext); }
public void TestActivationArgumentsConstructor11() { try { ActivationArguments activationArguments = new ActivationArguments("Test", new String[] { "A", "B", "C" }, new String[] { null }); } catch (Exception e) { Fail("Test should not have thrown an " + e.GetType().Name); } }
private void DeserializeNonPrimitives () { lock (this) { if (serialized_non_primitives == null) return; BinaryFormatter bf = new BinaryFormatter (); MemoryStream ms = new MemoryStream (serialized_non_primitives); object [] arr = (object []) bf.Deserialize (ms); _activationArguments = (ActivationArguments) arr [0]; domain_initializer = (AppDomainInitializer) arr [1]; application_trust = (ApplicationTrust) arr [2]; serialized_non_primitives = null; } }
internal AppDomainSetup(AppDomainSetup copy, bool copyDomainBoundData) { string[] value = this.Value; if (copy != null) { string[] value2 = copy.Value; int num = this._Entries.Length; int num2 = value2.Length; int num3 = (num2 < num) ? num2 : num; for (int i = 0; i < num3; i++) { value[i] = value2[i]; } if (num3 < num) { for (int j = num3; j < num; j++) { value[j] = null; } } this._LoaderOptimization = copy._LoaderOptimization; this._AppDomainInitializerArguments = copy.AppDomainInitializerArguments; this._ActivationArguments = copy.ActivationArguments; this._ApplicationTrust = copy._ApplicationTrust; if (copyDomainBoundData) { this._AppDomainInitializer = copy.AppDomainInitializer; } else { this._AppDomainInitializer = null; } this._ConfigurationBytes = copy.GetConfigurationBytes(); this._DisableInterfaceCache = copy._DisableInterfaceCache; this._AppDomainManagerAssembly = copy.AppDomainManagerAssembly; this._AppDomainManagerType = copy.AppDomainManagerType; this._AptcaVisibleAssemblies = copy.PartialTrustVisibleAssemblies; if (copy._CompatFlags != null) { this._CompatFlags = new Dictionary<string, object>(copy._CompatFlags); return; } } else { this._LoaderOptimization = LoaderOptimization.NotSpecified; } }
public MainViewModel(Client apiClient, System.Runtime.Hosting.ActivationArguments args) { m_Args = args; m_ApiClient = apiClient; PropertyChanged += MainViewModel_PropertyChanged; }
public AppDomainSetup(ActivationArguments activationArguments) { if (activationArguments == null) { throw new ArgumentNullException("activationArguments"); } this._LoaderOptimization = LoaderOptimization.NotSpecified; this.ActivationArguments = activationArguments; string entryPointFullPath = CmsUtils.GetEntryPointFullPath(activationArguments); if (!string.IsNullOrEmpty(entryPointFullPath)) { this.SetupDefaults(entryPointFullPath); return; } this.ApplicationBase = activationArguments.ActivationContext.ApplicationDirectory; }
internal static string GetEntryPointFullPath(ActivationArguments activationArguments) { return(GetEntryPointFullPath(activationArguments.ActivationContext)); }
public void TestActivationArgumentsActivationData01() { ActivationArguments activationArguments; try { activationArguments = new ActivationArguments("Test", null, null); AssertNull("ActivationData 1:", activationArguments.ActivationData); activationArguments.ActivationData = null; AssertNull("ActivationData 2:", activationArguments.ActivationData); activationArguments.ActivationData = new String[] { "A" }; AssertNotNull("ActivationData 3:", activationArguments.ActivationData); AssertEquals("ActivationData 4:", activationArguments.ActivationData.Length, 1); AssertEquals("ActivationData 5:", activationArguments.ActivationData[0], "A"); } catch (Exception e) { Fail("Test should not have thrown an " + e.GetType().Name + " at\n" + e.StackTrace); } }