Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        private static void VerifyRequestedPrivilegesSupport(AssemblyManifest appManifest, string targetDirectory)
        {
            if (appManifest.EntryPoints[0].CustomHostSpecified)
            {
                return;
            }
            string str = Path.Combine(targetDirectory, appManifest.EntryPoints[0].Assembly.Codebase);

            if (System.IO.File.Exists(str))
            {
                AssemblyManifest assemblyManifest = new AssemblyManifest(str);
                if (!assemblyManifest.Id1ManifestPresent || assemblyManifest.Id1RequestedExecutionLevel == null)
                {
                    return;
                }
                DownloadManager.VerifyRequestedPrivilegesSupport(assemblyManifest.Id1RequestedExecutionLevel);
            }
            else
            {
                Logger.AddInternalState("Main exe=" + str + " does not exist. No Requested Priviliges Verification done.");
            }
        }
Exemplo n.º 3
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);
        }