public static AssemblyManifest DownloadApplicationManifest(AssemblyManifest deploymentManifest, string targetDir, Uri deploymentUri, IDownloadNotification notification, DownloadOptions options, out Uri appSourceUri, out string appManifestPath) { ServerInformation information; Logger.AddMethodCall("DownloadApplicationManifest called."); DependentAssembly mainDependentAssembly = deploymentManifest.MainDependentAssembly; if ((mainDependentAssembly == null) || (mainDependentAssembly.Codebase == null)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } appSourceUri = new Uri(deploymentUri, mainDependentAssembly.Codebase); Zone zone = Zone.CreateFromUrl(deploymentUri.AbsoluteUri); Zone zone2 = Zone.CreateFromUrl(appSourceUri.AbsoluteUri); if (!zone.Equals(zone2)) { Logger.AddInternalState(string.Concat(new object[] { "Deployment and application does not have matching security zones. deploymentZone=", zone, ",applicationZone=", zone2 })); throw new InvalidDeploymentException(ExceptionTypes.Zone, Resources.GetString("Ex_DeployAppZoneMismatch")); } appManifestPath = Path.Combine(targetDir, mainDependentAssembly.Identity.Name + ".manifest"); AssemblyManifest manifest = DownloadManifest(ref appSourceUri, appManifestPath, notification, options, AssemblyManifest.ManifestType.Application, out information); Logger.SetApplicationUrl(appSourceUri); Logger.SetApplicationServerInformation(information); zone2 = Zone.CreateFromUrl(appSourceUri.AbsoluteUri); if (!zone.Equals(zone2)) { Logger.AddInternalState(string.Concat(new object[] { "Deployment and application does not have matching security zones. deploymentZone=", zone, ",applicationZone=", zone2 })); throw new InvalidDeploymentException(ExceptionTypes.Zone, Resources.GetString("Ex_DeployAppZoneMismatch")); } if (manifest.Identity.Equals(deploymentManifest.Identity)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DepSameDeploymentAndApplicationIdentity"), new object[] { manifest.Identity.ToString() })); } if (!manifest.Identity.Matches(mainDependentAssembly.Identity, manifest.Application)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_RefDefMismatch")); } if (!PolicyKeys.SkipApplicationDependencyHashCheck()) { try { ComponentVerifier.VerifyFileHash(appManifestPath, mainDependentAssembly.HashCollection); } catch (InvalidDeploymentException exception) { if (exception.SubType == ExceptionTypes.HashValidation) { throw new InvalidDeploymentException(ExceptionTypes.HashValidation, Resources.GetString("Ex_AppManInvalidHash"), exception); } throw; } } if (manifest.RequestedExecutionLevel != null) { Logger.AddInternalState("Application manifest has RequestedExecutionLevel specified. Check requested privileges."); VerifyRequestedPrivilegesSupport(manifest.RequestedExecutionLevel); } return manifest; }
public static bool FollowDeploymentProviderUri(SubscriptionStore subStore, ref AssemblyManifest deployment, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("FollowDeploymentProviderUri called."); tempFile = (TempFile)null; bool flag1 = false; Zone fromUrl1 = Zone.CreateFromUrl(sourceUri.AbsoluteUri); bool flag2 = false; if (fromUrl1.SecurityZone != SecurityZone.MyComputer) { Logger.AddInternalState("Deployment manifest zone is not local machine. Zone = " + (object)fromUrl1.SecurityZone); flag2 = true; } else { Logger.AddInternalState("Deployment manifest zone is local machine. Zone = " + (object)fromUrl1.SecurityZone); DependentAssembly dependentAssembly = deployment.MainDependentAssembly; if (dependentAssembly == null || dependentAssembly.Codebase == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } Uri uri = new Uri(sourceUri, dependentAssembly.Codebase); Zone fromUrl2 = Zone.CreateFromUrl(uri.AbsoluteUri); if (fromUrl2.SecurityZone == SecurityZone.MyComputer) { Logger.AddInternalState("Application manifest zone is local machine. Zone = " + (object)fromUrl2.SecurityZone); if (!System.IO.File.Exists(uri.LocalPath)) { Logger.AddInternalState(uri.LocalPath + " does not exist in local machine."); flag2 = true; } } } if (flag2) { Uri providerCodebaseUri = deployment.Deployment.ProviderCodebaseUri; Logger.SetDeploymentProviderUrl(providerCodebaseUri); Logger.AddInternalState("providerUri=" + (object)providerCodebaseUri + ",sourceUri=" + (object)sourceUri); if (!PolicyKeys.SkipDeploymentProvider() && providerCodebaseUri != (Uri)null && !providerCodebaseUri.Equals((object)sourceUri)) { ServerInformation serverInformation; AssemblyManifest deployment1; try { deployment1 = DownloadManager.DownloadDeploymentManifestDirect(subStore, ref providerCodebaseUri, out tempFile, notification, options, out serverInformation); } catch (InvalidDeploymentException ex) { if (ex.SubType == ExceptionTypes.Manifest || ex.SubType == ExceptionTypes.ManifestLoad || (ex.SubType == ExceptionTypes.ManifestParse || ex.SubType == ExceptionTypes.ManifestSemanticValidation)) { throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_InvalidProviderManifest"), (Exception)ex); } throw; } Logger.SetDeploymentProviderServerInformation(serverInformation); SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment); if (!subStore.GetSubscriptionState(deployment1).SubscriptionId.Equals((object)subscriptionState.SubscriptionId)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_ProviderNotInSubscription")); } Logger.AddInternalState("Deployment provider followed: " + (object)providerCodebaseUri); deployment = deployment1; sourceUri = providerCodebaseUri; flag1 = true; } } if (!flag1) { Logger.AddInternalState("Deployment provider not followed."); } return(flag1); }
private static void DownloadManifestAsRawFile(ref Uri sourceUri, string targetPath, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation) { Logger.AddMethodCall("DownloadManifestAsRawFile called."); FileDownloader fileDownloader = FileDownloader.Create(); fileDownloader.Options = options; if (notification != null) { fileDownloader.AddNotification(notification); } try { fileDownloader.AddFile(sourceUri, targetPath, 16777216); fileDownloader.Download((SubscriptionState)null, DownloadManager.ClientCertificate); sourceUri = fileDownloader.DownloadResults[0].ResponseUri; serverInformation = fileDownloader.DownloadResults[0].ServerInformation; DownloadManager.ClientCertificate = fileDownloader.ClientCertificate; } finally { if (notification != null) { fileDownloader.RemoveNotification(notification); } } }
public static AssemblyManifest DownloadDeploymentManifestBypass(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, out SubscriptionState subState, IDownloadNotification notification, DownloadOptions options) { AssemblyManifest manifest; Logger.AddMethodCall("DownloadDeploymentManifestBypass called."); tempFile = null; subState = null; TempFile file = null; TempFile file2 = null; try { ServerInformation information; manifest = DownloadDeploymentManifestDirectBypass(subStore, ref sourceUri, out file, out subState, notification, options, out information); Logger.SetSubscriptionServerInformation(information); if (subState != null) { tempFile = file; return(manifest); } bool flag = FollowDeploymentProviderUri(subStore, ref manifest, ref sourceUri, out file2, notification, options); tempFile = flag ? file2 : file; } finally { if ((file != null) && (file != tempFile)) { file.Dispose(); } if ((file2 != null) && (file2 != tempFile)) { file2.Dispose(); } } return(manifest); }
public static bool FollowDeploymentProviderUri(SubscriptionStore subStore, ref AssemblyManifest deployment, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("FollowDeploymentProviderUri called."); tempFile = null; bool flag = false; Zone zone = Zone.CreateFromUrl(sourceUri.AbsoluteUri); bool flag2 = false; if (zone.SecurityZone != SecurityZone.MyComputer) { Logger.AddInternalState("Deployment manifest zone is not local machine. Zone = " + zone.SecurityZone); flag2 = true; } else { Logger.AddInternalState("Deployment manifest zone is local machine. Zone = " + zone.SecurityZone); DependentAssembly mainDependentAssembly = deployment.MainDependentAssembly; if ((mainDependentAssembly == null) || (mainDependentAssembly.Codebase == null)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } Uri uri = new Uri(sourceUri, mainDependentAssembly.Codebase); Zone zone2 = Zone.CreateFromUrl(uri.AbsoluteUri); if (zone2.SecurityZone == SecurityZone.MyComputer) { Logger.AddInternalState("Application manifest zone is local machine. Zone = " + zone2.SecurityZone); if (!System.IO.File.Exists(uri.LocalPath)) { Logger.AddInternalState(uri.LocalPath + " does not exist in local machine."); flag2 = true; } } } if (flag2) { Uri providerCodebaseUri = deployment.Deployment.ProviderCodebaseUri; Logger.SetDeploymentProviderUrl(providerCodebaseUri); Logger.AddInternalState(string.Concat(new object[] { "providerUri=", providerCodebaseUri, ",sourceUri=", sourceUri })); if ((!PolicyKeys.SkipDeploymentProvider() && (providerCodebaseUri != null)) && !providerCodebaseUri.Equals(sourceUri)) { ServerInformation information; AssemblyManifest manifest = null; try { manifest = DownloadDeploymentManifestDirect(subStore, ref providerCodebaseUri, out tempFile, notification, options, out information); } catch (InvalidDeploymentException exception) { if (((exception.SubType != ExceptionTypes.Manifest) && (exception.SubType != ExceptionTypes.ManifestLoad)) && ((exception.SubType != ExceptionTypes.ManifestParse) && (exception.SubType != ExceptionTypes.ManifestSemanticValidation))) { throw; } throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_InvalidProviderManifest"), exception); } Logger.SetDeploymentProviderServerInformation(information); SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment); if (!subStore.GetSubscriptionState(manifest).SubscriptionId.Equals(subscriptionState.SubscriptionId)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_ProviderNotInSubscription")); } Logger.AddInternalState("Deployment provider followed: " + providerCodebaseUri); deployment = manifest; sourceUri = providerCodebaseUri; flag = true; } } if (!flag) { Logger.AddInternalState("Deployment provider not followed."); } return flag; }
private static AssemblyManifest DownloadManifest(ref Uri sourceUri, string targetPath, IDownloadNotification notification, DownloadOptions options, AssemblyManifest.ManifestType manifestType, out ServerInformation serverInformation) { Logger.AddMethodCall("DownloadManifest called."); DownloadManifestAsRawFile(ref sourceUri, targetPath, notification, options, out serverInformation); return ManifestReader.FromDocument(targetPath, manifestType, sourceUri); }
private static AssemblyManifest DownloadDeploymentManifestDirect(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation) { Logger.AddMethodCall("DownloadDeploymentManifestDirect(" + sourceUri + ") called."); tempFile = subStore.AcquireTempFile(".application"); AssemblyManifest manifest = DownloadManifest(ref sourceUri, tempFile.Path, notification, options, AssemblyManifest.ManifestType.Deployment, out serverInformation); if (manifest.Identity.Version == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_DeploymentManifestNoVersion")); } if (manifest.Deployment == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_InvalidDeploymentManifest")); } return manifest; }
public static AssemblyManifest DownloadDeploymentManifest(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { AssemblyManifest manifest; Logger.AddMethodCall("DownloadDeploymentManifest called."); Logger.AddInternalState("SourceUri=" + sourceUri); Logger.AddInternalState("DownloadOptions=" + ((options != null) ? options.ToString() : "null")); tempFile = null; TempFile file = null; TempFile file2 = null; try { ServerInformation information; manifest = DownloadDeploymentManifestDirect(subStore, ref sourceUri, out file, notification, options, out information); Logger.SetSubscriptionServerInformation(information); bool flag = FollowDeploymentProviderUri(subStore, ref manifest, ref sourceUri, out file2, notification, options); tempFile = flag ? file2 : file; } finally { if ((file != null) && (file != tempFile)) { file.Dispose(); file = null; } if ((file2 != null) && (file2 != tempFile)) { file2.Dispose(); file2 = null; } } return manifest; }
public static AssemblyManifest DownloadApplicationManifest(AssemblyManifest deploymentManifest, string targetDir, Uri deploymentUri, IDownloadNotification notification, DownloadOptions options, out Uri appSourceUri, out string appManifestPath) { Logger.AddMethodCall("DownloadApplicationManifest called."); DependentAssembly dependentAssembly = deploymentManifest.MainDependentAssembly; if (dependentAssembly == null || dependentAssembly.Codebase == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } appSourceUri = new Uri(deploymentUri, dependentAssembly.Codebase); Zone fromUrl1 = Zone.CreateFromUrl(deploymentUri.AbsoluteUri); Zone fromUrl2 = Zone.CreateFromUrl(appSourceUri.AbsoluteUri); if (!fromUrl1.Equals((object)fromUrl2)) { Logger.AddInternalState("Deployment and application does not have matching security zones. deploymentZone=" + (object)fromUrl1 + ",applicationZone=" + (object)fromUrl2); throw new InvalidDeploymentException(ExceptionTypes.Zone, Resources.GetString("Ex_DeployAppZoneMismatch")); } appManifestPath = Path.Combine(targetDir, dependentAssembly.Identity.Name + ".manifest"); ServerInformation serverInformation; AssemblyManifest assemblyManifest = DownloadManager.DownloadManifest(ref appSourceUri, appManifestPath, notification, options, AssemblyManifest.ManifestType.Application, out serverInformation); Logger.SetApplicationUrl(appSourceUri); Logger.SetApplicationServerInformation(serverInformation); Zone fromUrl3 = Zone.CreateFromUrl(appSourceUri.AbsoluteUri); if (!fromUrl1.Equals((object)fromUrl3)) { Logger.AddInternalState("Deployment and application does not have matching security zones. deploymentZone=" + (object)fromUrl1 + ",applicationZone=" + (object)fromUrl3); throw new InvalidDeploymentException(ExceptionTypes.Zone, Resources.GetString("Ex_DeployAppZoneMismatch")); } if (assemblyManifest.Identity.Equals((object)deploymentManifest.Identity)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DepSameDeploymentAndApplicationIdentity"), new object[1] { (object)assemblyManifest.Identity.ToString() })); } if (!assemblyManifest.Identity.Matches(dependentAssembly.Identity, assemblyManifest.Application)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_RefDefMismatch")); } if (!PolicyKeys.SkipApplicationDependencyHashCheck()) { try { ComponentVerifier.VerifyFileHash(appManifestPath, dependentAssembly.HashCollection); } catch (InvalidDeploymentException ex) { if (ex.SubType == ExceptionTypes.HashValidation) { throw new InvalidDeploymentException(ExceptionTypes.HashValidation, Resources.GetString("Ex_AppManInvalidHash"), (Exception)ex); } throw; } } if (assemblyManifest.RequestedExecutionLevel != null) { Logger.AddInternalState("Application manifest has RequestedExecutionLevel specified. Check requested privileges."); DownloadManager.VerifyRequestedPrivilegesSupport(assemblyManifest.RequestedExecutionLevel); } return(assemblyManifest); }
public static AssemblyManifest DownloadDeploymentManifestBypass(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, out SubscriptionState subState, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("DownloadDeploymentManifestBypass called."); tempFile = (TempFile)null; subState = (SubscriptionState)null; TempFile tempFile1 = (TempFile)null; TempFile tempFile2 = (TempFile)null; DownloadManager.ClientCertificate = (X509Certificate2)null; AssemblyManifest deployment; try { ServerInformation serverInformation; deployment = DownloadManager.DownloadDeploymentManifestDirectBypass(subStore, ref sourceUri, out tempFile1, out subState, notification, options, out serverInformation); Logger.SetSubscriptionServerInformation(serverInformation); if (subState != null) { tempFile = tempFile1; return(deployment); } bool flag = DownloadManager.FollowDeploymentProviderUri(subStore, ref deployment, ref sourceUri, out tempFile2, notification, options); tempFile = flag ? tempFile2 : tempFile1; } finally { if (tempFile1 != null && tempFile1 != tempFile) { tempFile1.Dispose(); } if (tempFile2 != null && tempFile2 != tempFile) { tempFile2.Dispose(); } } return(deployment); }
public void RemoveNotification(IDownloadNotification notification) { this.DownloadModified -= new FileDownloader.DownloadModifiedEventHandler(notification.DownloadModified); this.DownloadCompleted -= new FileDownloader.DownloadCompletedEventHandler(notification.DownloadCompleted); }
public void AddNotification(IDownloadNotification notification) { this.DownloadCompleted += new DownloadCompletedEventHandler(notification.DownloadCompleted); this.DownloadModified += new DownloadModifiedEventHandler(notification.DownloadModified); }
public static bool FollowDeploymentProviderUri(SubscriptionStore subStore, ref AssemblyManifest deployment, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("FollowDeploymentProviderUri called."); tempFile = null; bool flag = false; Zone zone = Zone.CreateFromUrl(sourceUri.AbsoluteUri); bool flag2 = false; if (zone.SecurityZone != SecurityZone.MyComputer) { Logger.AddInternalState("Deployment manifest zone is not local machine. Zone = " + zone.SecurityZone); flag2 = true; } else { Logger.AddInternalState("Deployment manifest zone is local machine. Zone = " + zone.SecurityZone); DependentAssembly mainDependentAssembly = deployment.MainDependentAssembly; if ((mainDependentAssembly == null) || (mainDependentAssembly.Codebase == null)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } Uri uri = new Uri(sourceUri, mainDependentAssembly.Codebase); Zone zone2 = Zone.CreateFromUrl(uri.AbsoluteUri); if (zone2.SecurityZone == SecurityZone.MyComputer) { Logger.AddInternalState("Application manifest zone is local machine. Zone = " + zone2.SecurityZone); if (!System.IO.File.Exists(uri.LocalPath)) { Logger.AddInternalState(uri.LocalPath + " does not exist in local machine."); flag2 = true; } } } if (flag2) { Uri providerCodebaseUri = deployment.Deployment.ProviderCodebaseUri; Logger.SetDeploymentProviderUrl(providerCodebaseUri); Logger.AddInternalState(string.Concat(new object[] { "providerUri=", providerCodebaseUri, ",sourceUri=", sourceUri })); if ((!PolicyKeys.SkipDeploymentProvider() && (providerCodebaseUri != null)) && !providerCodebaseUri.Equals(sourceUri)) { ServerInformation information; AssemblyManifest manifest = null; try { manifest = DownloadDeploymentManifestDirect(subStore, ref providerCodebaseUri, out tempFile, notification, options, out information); } catch (InvalidDeploymentException exception) { if (((exception.SubType != ExceptionTypes.Manifest) && (exception.SubType != ExceptionTypes.ManifestLoad)) && ((exception.SubType != ExceptionTypes.ManifestParse) && (exception.SubType != ExceptionTypes.ManifestSemanticValidation))) { throw; } throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_InvalidProviderManifest"), exception); } Logger.SetDeploymentProviderServerInformation(information); SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment); if (!subStore.GetSubscriptionState(manifest).SubscriptionId.Equals(subscriptionState.SubscriptionId)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_ProviderNotInSubscription")); } Logger.AddInternalState("Deployment provider followed: " + providerCodebaseUri); deployment = manifest; sourceUri = providerCodebaseUri; flag = true; } } if (!flag) { Logger.AddInternalState("Deployment provider not followed."); } return(flag); }
private static void DownloadManifestAsRawFile(ref Uri sourceUri, string targetPath, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation) { Logger.AddMethodCall("DownloadManifestAsRawFile called."); FileDownloader downloader = FileDownloader.Create(); downloader.Options = options; if (notification != null) { downloader.AddNotification(notification); } try { downloader.AddFile(sourceUri, targetPath, 0x1000000); downloader.Download(null); sourceUri = downloader.DownloadResults[0].ResponseUri; serverInformation = downloader.DownloadResults[0].ServerInformation; } finally { if (notification != null) { downloader.RemoveNotification(notification); } } }
public void RemoveNotification(IDownloadNotification notification) { this.DownloadModified -= new DownloadModifiedEventHandler(notification.DownloadModified); this.DownloadCompleted -= new DownloadCompletedEventHandler(notification.DownloadCompleted); }
public static void DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, string targetDirectory, string group, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("DownloadDependencies called."); Logger.AddInternalState("sourceUriBase=" + sourceUriBase); Logger.AddInternalState("targetDirectory=" + targetDirectory); Logger.AddInternalState("group=" + group); Logger.AddInternalState("DownloadOptions=" + options); FileDownloader downloader = FileDownloader.Create(); downloader.Options = options; if (group == null) { downloader.CheckForSizeLimit(appManifest.CalculateDependenciesSize(), false); } AddDependencies(downloader, deployManifest, appManifest, sourceUriBase, targetDirectory, group); downloader.DownloadModified += new FileDownloader.DownloadModifiedEventHandler(DownloadManager.ProcessDownloadedFile); if (notification != null) { downloader.AddNotification(notification); } try { downloader.Download(subState); downloader.ComponentVerifier.VerifyComponents(); VerifyRequestedPrivilegesSupport(appManifest, targetDirectory); } finally { if (notification != null) { downloader.RemoveNotification(notification); } downloader.DownloadModified -= new FileDownloader.DownloadModifiedEventHandler(DownloadManager.ProcessDownloadedFile); } }
public static void DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, string targetDirectory, string group, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("DownloadDependencies called."); Logger.AddInternalState("sourceUriBase=" + (object)sourceUriBase); Logger.AddInternalState("targetDirectory=" + targetDirectory); Logger.AddInternalState("group=" + group); Logger.AddInternalState("DownloadOptions=" + (object)options); FileDownloader downloader = FileDownloader.Create(); downloader.Options = options; if (group == null) { downloader.CheckForSizeLimit(appManifest.CalculateDependenciesSize(), false); } DownloadManager.AddDependencies(downloader, deployManifest, appManifest, sourceUriBase, targetDirectory, group); downloader.DownloadModified += new FileDownloader.DownloadModifiedEventHandler(DownloadManager.ProcessDownloadedFile); if (notification != null) { downloader.AddNotification(notification); } try { downloader.Download(subState, DownloadManager.ClientCertificate); downloader.ComponentVerifier.VerifyComponents(); DownloadManager.VerifyRequestedPrivilegesSupport(appManifest, targetDirectory); } finally { if (notification != null) { downloader.RemoveNotification(notification); } downloader.DownloadModified -= new FileDownloader.DownloadModifiedEventHandler(DownloadManager.ProcessDownloadedFile); } }
public static AssemblyManifest DownloadDeploymentManifestBypass(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, out SubscriptionState subState, IDownloadNotification notification, DownloadOptions options) { AssemblyManifest manifest; Logger.AddMethodCall("DownloadDeploymentManifestBypass called."); tempFile = null; subState = null; TempFile file = null; TempFile file2 = null; try { ServerInformation information; manifest = DownloadDeploymentManifestDirectBypass(subStore, ref sourceUri, out file, out subState, notification, options, out information); Logger.SetSubscriptionServerInformation(information); if (subState != null) { tempFile = file; return manifest; } bool flag = FollowDeploymentProviderUri(subStore, ref manifest, ref sourceUri, out file2, notification, options); tempFile = flag ? file2 : file; } finally { if ((file != null) && (file != tempFile)) { file.Dispose(); } if ((file2 != null) && (file2 != tempFile)) { file2.Dispose(); } } return manifest; }
public static AssemblyManifest DownloadDeploymentManifest(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("DownloadDeploymentManifest called."); Logger.AddInternalState("SourceUri=" + (object)sourceUri); Logger.AddInternalState("DownloadOptions=" + (options != null ? options.ToString() : "null")); tempFile = (TempFile)null; TempFile tempFile1 = (TempFile)null; TempFile tempFile2 = (TempFile)null; DownloadManager.ClientCertificate = (X509Certificate2)null; AssemblyManifest deployment; try { ServerInformation serverInformation; deployment = DownloadManager.DownloadDeploymentManifestDirect(subStore, ref sourceUri, out tempFile1, notification, options, out serverInformation); Logger.SetSubscriptionServerInformation(serverInformation); bool flag = DownloadManager.FollowDeploymentProviderUri(subStore, ref deployment, ref sourceUri, out tempFile2, notification, options); tempFile = flag ? tempFile2 : tempFile1; } finally { if (tempFile1 != null && tempFile1 != tempFile) { tempFile1.Dispose(); } if (tempFile2 != null && tempFile2 != tempFile) { tempFile2.Dispose(); } } return(deployment); }
private static AssemblyManifest DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, out SubscriptionState subState, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation) { Logger.AddMethodCall("DownloadDeploymentManifestDirectBypass called."); subState = null; tempFile = subStore.AcquireTempFile(".application"); DownloadManifestAsRawFile(ref sourceUri, tempFile.Path, notification, options, out serverInformation); bool flag = false; AssemblyManifest deployment = null; DefinitionIdentity identity = null; DefinitionIdentity identity2 = null; DefinitionAppId appId = null; try { deployment = ManifestReader.FromDocumentNoValidation(tempFile.Path); identity = deployment.Identity; identity2 = new DefinitionIdentity(deployment.MainDependentAssembly.Identity); Uri uri = ((sourceUri.Query != null) && (sourceUri.Query.Length > 0)) ? new Uri(sourceUri.GetLeftPart(UriPartial.Path)) : sourceUri; appId = new DefinitionAppId(uri.AbsoluteUri, new DefinitionIdentity[] { identity, identity2 }); Logger.AddInternalState("expectedAppId=" + appId.ToString()); } catch (InvalidDeploymentException) { flag = true; } catch (COMException) { flag = true; } catch (SEHException) { flag = true; } catch (IndexOutOfRangeException) { flag = true; } if (!flag) { long num; SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment); bool flag2 = false; using (subStore.AcquireReferenceTransaction(out num)) { flag2 = subStore.CheckAndReferenceApplication(subscriptionState, appId, num); } if (flag2 && appId.Equals(subscriptionState.CurrentBind)) { Logger.AddInternalState("Application is found in store and it is the CurrentBind, bypass validation and further downloads."); subState = subscriptionState; return subState.CurrentDeploymentManifest; } flag = true; if (flag2) { Logger.AddInternalState("Application is found in store and but it is not the CurrentBind."); } } else { Logger.AddInternalState("Application is not found in store."); } Logger.AddInternalState("Reparse the deployment manifest for validations."); AssemblyManifest manifest2 = ManifestReader.FromDocument(tempFile.Path, AssemblyManifest.ManifestType.Deployment, sourceUri); if (manifest2.Identity.Version == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_DeploymentManifestNoVersion")); } if (manifest2.Deployment == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_InvalidDeploymentManifest")); } return manifest2; }
private static AssemblyManifest DownloadDeploymentManifestDirect(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation) { Logger.AddMethodCall("DownloadDeploymentManifestDirect(" + (object)sourceUri + ") called."); tempFile = subStore.AcquireTempFile(".application"); AssemblyManifest assemblyManifest = DownloadManager.DownloadManifest(ref sourceUri, tempFile.Path, notification, options, AssemblyManifest.ManifestType.Deployment, out serverInformation); if (assemblyManifest.Identity.Version == (Version)null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_DeploymentManifestNoVersion")); } if (assemblyManifest.Deployment == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_InvalidDeploymentManifest")); } return(assemblyManifest); }
private static AssemblyManifest DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, out SubscriptionState subState, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation) { Logger.AddMethodCall("DownloadDeploymentManifestDirectBypass called."); subState = (SubscriptionState)null; tempFile = subStore.AcquireTempFile(".application"); DownloadManager.DownloadManifestAsRawFile(ref sourceUri, tempFile.Path, notification, options, out serverInformation); bool flag1 = false; AssemblyManifest deployment = (AssemblyManifest)null; DefinitionAppId appId = (DefinitionAppId)null; try { deployment = ManifestReader.FromDocumentNoValidation(tempFile.Path); DefinitionIdentity identity = deployment.Identity; DefinitionIdentity definitionIdentity = new DefinitionIdentity(deployment.MainDependentAssembly.Identity); appId = new DefinitionAppId((sourceUri.Query == null || sourceUri.Query.Length <= 0 ? sourceUri : new Uri(sourceUri.GetLeftPart(UriPartial.Path))).AbsoluteUri, new DefinitionIdentity[2] { identity, definitionIdentity }); Logger.AddInternalState("expectedAppId=" + appId.ToString()); } catch (InvalidDeploymentException ex) { flag1 = true; } catch (COMException ex) { flag1 = true; } catch (SEHException ex) { flag1 = true; } catch (IndexOutOfRangeException ex) { flag1 = true; } if (!flag1) { SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment); bool flag2 = false; long transactionId; using (subStore.AcquireReferenceTransaction(out transactionId)) flag2 = subStore.CheckAndReferenceApplication(subscriptionState, appId, transactionId); if (!flag2 || !appId.Equals((object)subscriptionState.CurrentBind)) { if (flag2) { Logger.AddInternalState("Application is found in store and but it is not the CurrentBind."); } } else { Logger.AddInternalState("Application is found in store and it is the CurrentBind, bypass validation and further downloads."); subState = subscriptionState; return(subState.CurrentDeploymentManifest); } } else { Logger.AddInternalState("Application is not found in store."); } Logger.AddInternalState("Reparse the deployment manifest for validations."); AssemblyManifest assemblyManifest = ManifestReader.FromDocument(tempFile.Path, AssemblyManifest.ManifestType.Deployment, sourceUri); if (assemblyManifest.Identity.Version == (Version)null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_DeploymentManifestNoVersion")); } if (assemblyManifest.Deployment == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_InvalidDeploymentManifest")); } return(assemblyManifest); }
private static AssemblyManifest DownloadManifest(ref Uri sourceUri, string targetPath, IDownloadNotification notification, DownloadOptions options, AssemblyManifest.ManifestType manifestType, out ServerInformation serverInformation) { Logger.AddMethodCall("DownloadManifest called."); DownloadManager.DownloadManifestAsRawFile(ref sourceUri, targetPath, notification, options, out serverInformation); return(ManifestReader.FromDocument(targetPath, manifestType, sourceUri)); }
public static AssemblyManifest DownloadDeploymentManifest(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { AssemblyManifest manifest; Logger.AddMethodCall("DownloadDeploymentManifest called."); Logger.AddInternalState("SourceUri=" + sourceUri); Logger.AddInternalState("DownloadOptions=" + ((options != null) ? options.ToString() : "null")); tempFile = null; TempFile file = null; TempFile file2 = null; try { ServerInformation information; manifest = DownloadDeploymentManifestDirect(subStore, ref sourceUri, out file, notification, options, out information); Logger.SetSubscriptionServerInformation(information); bool flag = FollowDeploymentProviderUri(subStore, ref manifest, ref sourceUri, out file2, notification, options); tempFile = flag ? file2 : file; } finally { if ((file != null) && (file != tempFile)) { file.Dispose(); file = null; } if ((file2 != null) && (file2 != tempFile)) { file2.Dispose(); file2 = null; } } return(manifest); }