private bool BindCoreWithAppId(bool blocking, ref FileStream refTransaction, ref string productName) { SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(this._bindAppId.DeploymentIdentity.ToSubscriptionId()); if (!subscriptionState.IsInstalled) { throw new InvalidDeploymentException(Resources.GetString("Ex_BindAppIdNotInstalled")); } if (!this._bindAppId.Equals((object)subscriptionState.CurrentBind)) { throw new InvalidDeploymentException(Resources.GetString("Ex_BindAppIdNotCurrrent")); } if (!blocking && this._cancellationPending) { return(true); } long transactionId; refTransaction = this._subStore.AcquireReferenceTransaction(out transactionId); bool flag = this._subStore.CheckAndReferenceApplication(subscriptionState, this._bindAppId, transactionId); ActivationDescription activationDescription = new ActivationDescription(); activationDescription.SetDeploymentManifest(subscriptionState.CurrentDeploymentManifest, subscriptionState.CurrentDeploymentSourceUri, (string)null); Logger.SetDeploymentManifest(this._log, subscriptionState.CurrentDeploymentManifest); activationDescription.IsUpdate = this._isupdate; activationDescription.SetApplicationManifest(subscriptionState.CurrentApplicationManifest, subscriptionState.CurrentApplicationSourceUri, (string)null); Logger.SetApplicationManifest(this._log, subscriptionState.CurrentApplicationManifest); Logger.SetApplicationUrl(this._log, subscriptionState.CurrentApplicationSourceUri); activationDescription.AppId = new DefinitionAppId(activationDescription.ToAppCodebase(), new DefinitionIdentity[2] { activationDescription.DeployManifest.Identity, activationDescription.AppManifest.Identity }); if (!blocking && this._cancellationPending) { return(true); } Description effectiveDescription = subscriptionState.EffectiveDescription; productName = effectiveDescription.Product; this._cached = flag; Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString()); Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString()); this._referenceTransaction = refTransaction; this._actCtx = DeploymentManager.ConstructActivationContextFromStore(activationDescription.AppId); this._actDesc = activationDescription; return(false); }
private void PerformDeploymentActivation(Uri activationUri, bool isShortcut, string textualSubId, string deploymentProviderUrlFromExtension, BrowserSettings browserSettings, ref string errorPageUrl) { TempFile deployFile = null; Logger.AddMethodCall("PerformDeploymentActivation called."); try { ActivationDescription description; string shortcutFile = null; Uri uri = null; bool flag = false; this._subStore = SubscriptionStore.CurrentUser; this._subStore.RefreshStorePointer(); Uri sourceUri = activationUri; bool flag2 = false; if (textualSubId != null) { Logger.AddInternalState("Activating through file association."); flag2 = true; description = this.ProcessOrFollowExtension(activationUri, textualSubId, deploymentProviderUrlFromExtension, ref errorPageUrl, out deployFile); if (description == null) { return; } } else if (isShortcut) { Logger.AddInternalState("Activating through shortcut."); shortcutFile = activationUri.LocalPath; description = this.ProcessOrFollowShortcut(shortcutFile, ref errorPageUrl, out deployFile); if (description == null) { return; } } else { SubscriptionState state; Logger.AddInternalState("Activating through deployment manifest."); Logger.AddInternalState("Start processing deployment manifest."); AssemblyManifest deploymentManifest = DownloadManager.DownloadDeploymentManifestBypass(this._subStore, ref sourceUri, out deployFile, out state, null, null); if ((browserSettings != null) && (deployFile != null)) { browserSettings.Validate(deployFile.Path); } if (deploymentManifest.Description != null) { errorPageUrl = deploymentManifest.Description.ErrorReportUrl; } description = new ActivationDescription(); if (state != null) { shortcutFile = null; description.SetApplicationManifest(state.CurrentApplicationManifest, null, null); description.AppId = state.CurrentBind; Logger.AddInternalState("Running from the store. Bypass further downloads and verifications."); flag = true; } else { shortcutFile = deployFile.Path; } Logger.SetDeploymentManifest(deploymentManifest); Logger.AddPhaseInformation(Resources.GetString("PhaseLog_ProcessingDeploymentManifestComplete")); Logger.AddInternalState("Processing of deployment manifest has successfully completed."); description.SetDeploymentManifest(deploymentManifest, sourceUri, shortcutFile); description.IsUpdate = false; description.ActType = ActivationType.InstallViaDotApplication; uri = activationUri; } if (this._ui.SplashCancelled()) { throw new DownloadCancelledException(); } if (description.DeployManifest.Deployment == null) { throw new DeploymentException(ExceptionTypes.Activation, Resources.GetString("Ex_NotDeploymentOrShortcut")); } bool flag3 = false; SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(description.DeployManifest); this.CheckDeploymentProviderValidity(description, subscriptionState); if (!flag) { Logger.AddInternalState("Could not find application in store. Continue with downloading application manifest."); flag3 = this.InstallApplication(ref subscriptionState, description); Logger.AddPhaseInformation(Resources.GetString("PhaseLog_InstallationComplete")); Logger.AddInternalState("Installation of application has successfully completed."); } else { this._subStore.SetLastCheckTimeToNow(subscriptionState); } if ((description.DeployManifest.Deployment.DisallowUrlActivation && !isShortcut) && (!activationUri.IsFile || activationUri.IsUnc)) { if (flag3) { this._ui.ShowMessage(Resources.GetString("Activation_DisallowUrlActivationMessageAfterInstall"), Resources.GetString("Activation_DisallowUrlActivationCaptionAfterInstall")); } else { this._ui.ShowMessage(Resources.GetString("Activation_DisallowUrlActivationMessage"), Resources.GetString("Activation_DisallowUrlActivationCaption")); } } else if (flag2) { this.Activate(description.AppId, description.AppManifest, activationUri.AbsoluteUri, true); } else if (isShortcut) { string activationParameter = null; int index = shortcutFile.IndexOf('|', 0); if ((index > 0) && ((index + 1) < shortcutFile.Length)) { activationParameter = shortcutFile.Substring(index + 1); } if (activationParameter == null) { this.Activate(description.AppId, description.AppManifest, null, false); } else { this.Activate(description.AppId, description.AppManifest, activationParameter, true); } } else { this.Activate(description.AppId, description.AppManifest, uri.AbsoluteUri, false); } } finally { if (deployFile != null) { deployFile.Dispose(); } } }
private bool BindCore(bool blocking, ref TempFile tempDeploy, ref TempDirectory tempAppDir, ref FileStream refTransaction, ref string productName) { try { if (this._deploySource == (Uri)null) { return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName)); } Uri deploySource = this._deploySource; this._state = DeploymentProgressState.DownloadingDeploymentInformation; Logger.AddInternalState(this._log, "Internal state=" + (object)this._state); AssemblyManifest assemblyManifest1 = DownloadManager.DownloadDeploymentManifest(this._subStore, ref deploySource, out tempDeploy, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions); string path = tempDeploy.Path; ActivationDescription actDesc = new ActivationDescription(); actDesc.SetDeploymentManifest(assemblyManifest1, deploySource, path); Logger.SetDeploymentManifest(this._log, assemblyManifest1); actDesc.IsUpdate = this._isupdate; if (actDesc.DeployManifest.Deployment == null) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_NotDeploymentOrShortcut")); } if (!blocking && this._cancellationPending) { return(true); } long transactionId; refTransaction = this._subStore.AcquireReferenceTransaction(out transactionId); SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(actDesc.DeployManifest); if (actDesc.DeployManifest.Deployment.Install && actDesc.DeployManifest.Deployment.ProviderCodebaseUri == (Uri)null && (subscriptionState != null && subscriptionState.DeploymentProviderUri != (Uri)null) && !subscriptionState.DeploymentProviderUri.Equals((object)deploySource)) { throw new DeploymentException(ExceptionTypes.DeploymentUriDifferent, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DeploymentUriDifferentExText"), new object[3] { (object)actDesc.DeployManifest.Description.FilteredProduct, (object)deploySource.AbsoluteUri, (object)subscriptionState.DeploymentProviderUri.AbsoluteUri })); } DefinitionAppId appId; try { appId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2] { actDesc.DeployManifest.Identity, new DefinitionIdentity(actDesc.DeployManifest.MainDependentAssembly.Identity) }); } catch (COMException ex) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex); } catch (SEHException ex) { throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex); } Logger.AddInternalState(this._log, "expectedAppId=" + appId.ToString()); bool flag1 = this._subStore.CheckAndReferenceApplication(subscriptionState, appId, transactionId); if (flag1 && appId.Equals((object)subscriptionState.CurrentBind)) { Logger.AddInternalState(this._log, "Application is found in store and it is the CurrentBind. Binding with appid."); this._bindAppId = appId; return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName)); } if (flag1) { Logger.AddInternalState(this._log, "Application is found in store but it is not the CurrentBind."); } else { Logger.AddInternalState(this._log, "Application is not found in store."); } if (!blocking && this._cancellationPending) { return(true); } this._state = DeploymentProgressState.DownloadingApplicationInformation; Logger.AddInternalState(this._log, "Internal state=" + (object)this._state); tempAppDir = this._subStore.AcquireTempDirectory(); Uri appSourceUri; string appManifestPath; AssemblyManifest assemblyManifest2 = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, tempAppDir.Path, actDesc.DeploySourceUri, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions, out appSourceUri, out appManifestPath); AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, assemblyManifest2); Logger.SetApplicationManifest(this._log, assemblyManifest2); Logger.SetApplicationUrl(this._log, appSourceUri); actDesc.SetApplicationManifest(assemblyManifest2, appSourceUri, appManifestPath); actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2] { actDesc.DeployManifest.Identity, actDesc.AppManifest.Identity }); bool flag2 = this._subStore.CheckAndReferenceApplication(subscriptionState, actDesc.AppId, transactionId); if (!blocking && this._cancellationPending) { return(true); } Description effectiveDescription = actDesc.EffectiveDescription; productName = effectiveDescription.Product; this._cached = flag2; Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString()); Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString()); this._tempApplicationDirectory = tempAppDir; this._tempDeployment = tempDeploy; this._referenceTransaction = refTransaction; this._actCtx = DeploymentManager.ConstructActivationContext(actDesc); this._actDesc = actDesc; } catch (Exception ex) { this.LogError(Resources.GetString("Ex_FailedToDownloadManifest"), ex); Logger.AddInternalState(this._log, "Exception thrown in BindCore(): " + ex.GetType().ToString() + " : " + ex.Message + "\r\n" + ex.StackTrace); throw; } return(false); }
private bool DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, long transactionId, out TempDirectory downloadTemp) { Uri uri; string str; bool flag = false; Logger.AddMethodCall("DownloadApplication called."); downloadTemp = this._subStore.AcquireTempDirectory(); Logger.AddInternalState("Start processing application manifest."); AssemblyManifest appManifest = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, downloadTemp.Path, actDesc.DeploySourceUri, out uri, out str); AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, appManifest); if (appManifest.EntryPoints[0].HostInBrowser) { throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_HostInBrowserAppNotSupported")); } if (appManifest.EntryPoints[0].CustomHostSpecified) { throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_CustomHostSpecifiedAppNotSupported")); } if (appManifest.EntryPoints[0].CustomUX && (((actDesc.ActType == ActivationType.InstallViaDotApplication) || (actDesc.ActType == ActivationType.InstallViaFileAssociation)) || ((actDesc.ActType == ActivationType.InstallViaShortcut) || (actDesc.ActType == ActivationType.None)))) { throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_CustomUXAppNotSupported")); } Logger.AddPhaseInformation(Resources.GetString("PhaseLog_ProcessingApplicationManifestComplete")); Logger.AddInternalState("Processing of application manifest has successfully completed."); actDesc.SetApplicationManifest(appManifest, uri, str); Logger.SetApplicationManifest(appManifest); this._subStore.CheckCustomUXFlag(subState, actDesc.AppManifest); actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[] { actDesc.DeployManifest.Identity, actDesc.AppManifest.Identity }); Logger.AddInternalState("Start request of trust and detection of platform."); if (appManifest.EntryPoints[0].CustomUX) { Logger.AddInternalState("This is a CustomUX application. Calling PersistTrustWithoutEvaluation."); actDesc.Trust = ApplicationTrust.PersistTrustWithoutEvaluation(actDesc.ToActivationContext()); } else { this._ui.Hide(); if (this._ui.SplashCancelled()) { throw new DownloadCancelledException(); } if (subState.IsInstalled && !string.Equals(subState.EffectiveCertificatePublicKeyToken, actDesc.EffectiveCertificatePublicKeyToken, StringComparison.Ordinal)) { Logger.AddInternalState("EffectiveCertificatePublicKeyToken has changed between versions: subState.EffectiveCertificatePublicKeyToken=" + subState.EffectiveCertificatePublicKeyToken + ",actDesc.EffectiveCertificatePublicKeyToken=" + actDesc.EffectiveCertificatePublicKeyToken); Logger.AddInternalState("Removing the cached trust decision for CurrentBind."); ApplicationTrust.RemoveCachedTrust(subState.CurrentBind); } try { actDesc.Trust = ApplicationTrust.RequestTrust(subState, actDesc.DeployManifest.Deployment.Install, actDesc.IsUpdate, actDesc.ToActivationContext()); } catch (Exception exception) { Logger.AddErrorInformation(Resources.GetString("Ex_DetermineTrustFailed"), exception); if (!(exception is TrustNotGrantedException)) { try { PlatformDetector.VerifyPlatformDependencies(actDesc.AppManifest, actDesc.DeployManifest, downloadTemp.Path); } catch (Exception exception2) { if (exception2 is DependentPlatformMissingException) { throw new DeploymentException(ExceptionTypes.TrustFailDependentPlatform, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_TrustFailDependentPlatformMissing"), new object[] { exception2.Message }), exception); } } } throw; } } this._fullTrust = actDesc.Trust.DefaultGrantSet.PermissionSet.IsUnrestricted(); Logger.AddInternalState("_fullTrust = " + this._fullTrust.ToString()); if (!this._fullTrust && (actDesc.AppManifest.FileAssociations.Length > 0)) { throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported")); } PlatformDetector.VerifyPlatformDependencies(actDesc.AppManifest, actDesc.DeployManifest, downloadTemp.Path); Logger.AddPhaseInformation(Resources.GetString("PhaseLog_PlatformDetectAndTrustGrantComplete")); Logger.AddInternalState("Request of trust and detection of platform is complete."); Logger.AddInternalState("Start downloading and verifying dependencies."); if (!this._subStore.CheckAndReferenceApplication(subState, actDesc.AppId, transactionId)) { flag = true; Description effectiveDescription = actDesc.EffectiveDescription; UserInterfaceInfo info = new UserInterfaceInfo { productName = effectiveDescription.Product }; if (actDesc.IsUpdate) { if (actDesc.IsRequiredUpdate) { info.formTitle = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_ProgressTitleRequiredUpdate"), new object[] { info.productName }); } else { info.formTitle = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_ProgressTitleUpdate"), new object[] { info.productName }); } } else if (!actDesc.DeployManifest.Deployment.Install) { info.formTitle = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_ProgressTitleDownload"), new object[] { info.productName }); } else { info.formTitle = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_ProgressTitleInstall"), new object[] { info.productName }); } info.supportUrl = effectiveDescription.SupportUrl; info.sourceSite = UserInterface.GetDisplaySite(actDesc.DeploySourceUri); if ((appManifest.Description != null) && (appManifest.Description.IconFileFS != null)) { info.iconFilePath = Path.Combine(downloadTemp.Path, appManifest.Description.IconFileFS); } ProgressPiece notification = this._ui.ShowProgress(info); DownloadOptions options = null; bool flag2 = !actDesc.DeployManifest.Deployment.Install; if (!this._fullTrust && flag2) { options = new DownloadOptions { EnforceSizeLimit = true, SizeLimit = this._subStore.GetSizeLimitInBytesForSemiTrustApps(), Size = actDesc.DeployManifest.SizeInBytes + actDesc.AppManifest.SizeInBytes }; } DownloadManager.DownloadDependencies(subState, actDesc.DeployManifest, actDesc.AppManifest, actDesc.AppSourceUri, downloadTemp.Path, null, notification, options); Logger.AddPhaseInformation(Resources.GetString("PhaseLog_DownloadDependenciesComplete")); actDesc.CommitApp = true; actDesc.AppPayloadPath = downloadTemp.Path; actDesc.AppGroup = null; } return flag; }