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