示例#1
0
        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);
        }
示例#2
0
        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);
        }