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;
 }
 private bool SynchronizeCore(bool blocking)
 {
     try
     {
         AssemblyManifest deployManifest = this._actDesc.DeployManifest;
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(deployManifest);
         this._subStore.CheckDeploymentSubscriptionState(subscriptionState, deployManifest);
         this._subStore.CheckCustomUXFlag(subscriptionState, this._actDesc.AppManifest);
         if (this._actDesc.DeployManifestPath != null)
         {
             this._actDesc.CommitDeploy = true;
             this._actDesc.IsConfirmed = this._isConfirmed;
             this._actDesc.TimeStamp = DateTime.UtcNow;
         }
         else
         {
             this._actDesc.CommitDeploy = false;
         }
         if (!blocking && this._cancellationPending)
         {
             return true;
         }
         if (!this._cached)
         {
             Logger.AddInternalState(this._log, "Application is not cached.");
             bool flag = false;
             if (this._actDesc.appType != AppType.CustomHostSpecified)
             {
                 if (this._actDesc.Trust != null)
                 {
                     bool flag2 = this._actDesc.Trust.DefaultGrantSet.PermissionSet.IsUnrestricted();
                     Logger.AddInternalState(this._log, "fullTrust=" + flag2.ToString());
                     if (!flag2 && (this._actDesc.AppManifest.FileAssociations.Length > 0))
                     {
                         throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
                     }
                     bool flag3 = !this._actDesc.DeployManifest.Deployment.Install;
                     if (!flag2 && flag3)
                     {
                         Logger.AddInternalState(this._log, "Application is semi-trust and online. Size limits will be checked during download.");
                         if (this._downloadOptions == null)
                         {
                             this._downloadOptions = new DownloadOptions();
                         }
                         this._downloadOptions.EnforceSizeLimit = true;
                         this._downloadOptions.SizeLimit = this._subStore.GetSizeLimitInBytesForSemiTrustApps();
                         this._downloadOptions.Size = this._actDesc.DeployManifest.SizeInBytes + this._actDesc.AppManifest.SizeInBytes;
                     }
                 }
                 else
                 {
                     flag = true;
                 }
             }
             DownloadManager.DownloadDependencies(subscriptionState, this._actDesc.DeployManifest, this._actDesc.AppManifest, this._actDesc.AppSourceUri, this._tempApplicationDirectory.Path, null, blocking ? null : this, this._downloadOptions);
             if (!blocking && this._cancellationPending)
             {
                 return true;
             }
             this.WaitForAssertApplicationRequirements();
             if (flag)
             {
                 this.CheckSizeLimit();
             }
             this._actDesc.CommitApp = true;
             this._actDesc.AppPayloadPath = this._tempApplicationDirectory.Path;
         }
         else
         {
             Logger.AddInternalState(this._log, "Application is cached.");
             this.WaitForAssertApplicationRequirements();
         }
         if (this._actDesc.CommitDeploy || this._actDesc.CommitApp)
         {
             this._subStore.CommitApplication(ref subscriptionState, this._actDesc);
             Logger.AddInternalState(this._log, "Application is successfully committed to the store.");
         }
         if (this._tempApplicationDirectory != null)
         {
             this._tempApplicationDirectory.Dispose();
             this._tempApplicationDirectory = null;
         }
         if (this._tempDeployment != null)
         {
             this._tempDeployment.Dispose();
             this._tempDeployment = null;
         }
         if (this._referenceTransaction != null)
         {
             this._referenceTransaction.Close();
             this._referenceTransaction = null;
         }
         Logger.AddInternalState(this._log, "Refreshing ActivationContext from store.");
         ActivationContext context = this._actCtx;
         this._actCtx = ConstructActivationContextFromStore(this._actDesc.AppId);
         context.Dispose();
         this._cached = true;
     }
     catch (Exception exception)
     {
         this.LogError(Resources.GetString("Ex_DownloadApplicationFailed"), exception);
         Logger.AddInternalState(this._log, "Exception thrown in  SynchronizeCore(): " + exception.GetType().ToString() + " : " + exception.Message + "\r\n" + exception.StackTrace);
         throw;
     }
     return false;
 }
 internal DeploymentManager(Uri deploymentSource, bool isUpdate, bool isConfirmed, DownloadOptions downloadOptions, AsyncOperation optionalAsyncOp)
 {
     this._trustNotGrantedEvent = new ManualResetEvent(false);
     this._trustGrantedEvent = new ManualResetEvent(false);
     this._platformRequirementsFailedEvent = new ManualResetEvent(false);
     this._isConfirmed = true;
     this._state = DeploymentProgressState.DownloadingApplicationFiles;
     this._deploySource = deploymentSource;
     this._isupdate = isUpdate;
     this._isConfirmed = isConfirmed;
     this._downloadOptions = downloadOptions;
     this._events = new EventHandlerList();
     this._syncGroupMap = CollectionsUtil.CreateCaseInsensitiveHashtable();
     this._subStore = SubscriptionStore.CurrentUser;
     this.bindWorker = new ThreadStart(this.BindAsyncWorker);
     this.synchronizeWorker = new ThreadStart(this.SynchronizeAsyncWorker);
     this.synchronizeGroupWorker = new WaitCallback(this.SynchronizeGroupAsyncWorker);
     this.bindCompleted = new SendOrPostCallback(this.BindAsyncCompleted);
     this.synchronizeCompleted = new SendOrPostCallback(this.SynchronizeAsyncCompleted);
     this.progressReporter = new SendOrPostCallback(this.ProgressReporter);
     if (optionalAsyncOp == null)
     {
         this.asyncOperation = AsyncOperationManager.CreateOperation(null);
     }
     else
     {
         this.asyncOperation = optionalAsyncOp;
     }
     this._log = Logger.StartLogging();
     if (deploymentSource != null)
     {
         Logger.SetSubscriptionUrl(this._log, deploymentSource);
     }
     this._assertApplicationReqEvents = new ManualResetEvent[] { this._trustNotGrantedEvent, this._platformRequirementsFailedEvent, this._trustGrantedEvent };
     this._callerType = CallerType.Other;
     PolicyKeys.SkipApplicationDependencyHashCheck();
     PolicyKeys.SkipDeploymentProvider();
     PolicyKeys.SkipSchemaValidation();
     PolicyKeys.SkipSemanticValidation();
     PolicyKeys.SkipSignatureValidation();
 }
        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 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)
        {
            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 = 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);
                }
            }
        }
 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 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(" + 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 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);
        }
 private bool SynchronizeGroupCore(bool blocking, SyncGroupHelper sgh)
 {
     TempDirectory directory = null;
     try
     {
         string group = sgh.Group;
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(this._actDesc.DeployManifest);
         if (this._subStore.CheckGroupInstalled(subscriptionState, this._actDesc.AppId, this._actDesc.AppManifest, group))
         {
             return false;
         }
         bool flag = AppDomain.CurrentDomain.ApplicationTrust.DefaultGrantSet.PermissionSet.IsUnrestricted();
         if (!flag && (this._actDesc.AppManifest.FileAssociations.Length > 0))
         {
             throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
         }
         bool flag2 = !this._actDesc.DeployManifest.Deployment.Install;
         if (!flag && flag2)
         {
             if (this._downloadOptions == null)
             {
                 this._downloadOptions = new DownloadOptions();
             }
             this._downloadOptions.EnforceSizeLimit = true;
             this._downloadOptions.SizeLimit = this._subStore.GetSizeLimitInBytesForSemiTrustApps();
             this._downloadOptions.Size = this._subStore.GetPrivateSize(this._actDesc.AppId);
         }
         directory = this._subStore.AcquireTempDirectory();
         DownloadManager.DownloadDependencies(subscriptionState, this._actDesc.DeployManifest, this._actDesc.AppManifest, this._actDesc.AppSourceUri, directory.Path, group, blocking ? null : sgh, this._downloadOptions);
         if (!blocking && sgh.CancellationPending)
         {
             return true;
         }
         CommitApplicationParams commitParams = new CommitApplicationParams(this._actDesc) {
             CommitApp = true,
             AppPayloadPath = directory.Path,
             AppManifestPath = null,
             AppGroup = group,
             CommitDeploy = false
         };
         this._subStore.CommitApplication(ref subscriptionState, commitParams);
     }
     finally
     {
         this.DetachFromGroup(sgh);
         if (directory != null)
         {
             directory.Dispose();
         }
     }
     return false;
 }
 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);
     }
 }
 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;
 }
 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;
 }
Beispiel #20
0
 internal DeploymentManager(Uri deploymentSource, bool isUpdate, bool isConfirmed, DownloadOptions downloadOptions, AsyncOperation optionalAsyncOp)
 {
     this._deploySource          = deploymentSource;
     this._isupdate              = isUpdate;
     this._isConfirmed           = isConfirmed;
     this._downloadOptions       = downloadOptions;
     this._events                = new EventHandlerList();
     this._syncGroupMap          = CollectionsUtil.CreateCaseInsensitiveHashtable();
     this._subStore              = SubscriptionStore.CurrentUser;
     this.bindWorker             = new ThreadStart(this.BindAsyncWorker);
     this.synchronizeWorker      = new ThreadStart(this.SynchronizeAsyncWorker);
     this.synchronizeGroupWorker = new WaitCallback(this.SynchronizeGroupAsyncWorker);
     this.bindCompleted          = new SendOrPostCallback(this.BindAsyncCompleted);
     this.synchronizeCompleted   = new SendOrPostCallback(this.SynchronizeAsyncCompleted);
     this.progressReporter       = new SendOrPostCallback(this.ProgressReporter);
     this.asyncOperation         = optionalAsyncOp != null ? optionalAsyncOp : AsyncOperationManager.CreateOperation((object)null);
     this._log = Logger.StartLogging();
     if (deploymentSource != (Uri)null)
     {
         Logger.SetSubscriptionUrl(this._log, deploymentSource);
     }
     this._assertApplicationReqEvents    = new ManualResetEvent[3];
     this._assertApplicationReqEvents[0] = this._trustNotGrantedEvent;
     this._assertApplicationReqEvents[1] = this._platformRequirementsFailedEvent;
     this._assertApplicationReqEvents[2] = this._trustGrantedEvent;
     this._callerType = DeploymentManager.CallerType.Other;
     PolicyKeys.SkipApplicationDependencyHashCheck();
     PolicyKeys.SkipDeploymentProvider();
     PolicyKeys.SkipSchemaValidation();
     PolicyKeys.SkipSemanticValidation();
     PolicyKeys.SkipSignatureValidation();
 }
 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;
 }
Beispiel #22
0
 internal DeploymentManager(string appId, bool isUpdate, bool isConfirmed, DownloadOptions downloadOptions, AsyncOperation optionalAsyncOp)
     : this((Uri)null, isUpdate, isConfirmed, downloadOptions, optionalAsyncOp)
 {
     this._bindAppId = new DefinitionAppId(appId);
 }
 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);
         }
     }
 }
Beispiel #24
0
 private bool SynchronizeCore(bool blocking)
 {
     try
     {
         AssemblyManifest  deployManifest    = this._actDesc.DeployManifest;
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(deployManifest);
         this._subStore.CheckDeploymentSubscriptionState(subscriptionState, deployManifest);
         this._subStore.CheckCustomUXFlag(subscriptionState, this._actDesc.AppManifest);
         if (this._actDesc.DeployManifestPath != null)
         {
             this._actDesc.CommitDeploy = true;
             this._actDesc.IsConfirmed  = this._isConfirmed;
             this._actDesc.TimeStamp    = DateTime.UtcNow;
         }
         else
         {
             this._actDesc.CommitDeploy = false;
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         if (!this._cached)
         {
             Logger.AddInternalState(this._log, "Application is not cached.");
             bool flag1 = false;
             if (this._actDesc.appType != AppType.CustomHostSpecified)
             {
                 if (this._actDesc.Trust != null)
                 {
                     bool flag2 = this._actDesc.Trust.DefaultGrantSet.PermissionSet.IsUnrestricted();
                     Logger.AddInternalState(this._log, "fullTrust=" + flag2.ToString());
                     if (!flag2 && this._actDesc.AppManifest.FileAssociations.Length != 0)
                     {
                         throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
                     }
                     bool flag3 = !this._actDesc.DeployManifest.Deployment.Install;
                     if (!flag2 & flag3)
                     {
                         Logger.AddInternalState(this._log, "Application is semi-trust and online. Size limits will be checked during download.");
                         if (this._downloadOptions == null)
                         {
                             this._downloadOptions = new DownloadOptions();
                         }
                         this._downloadOptions.EnforceSizeLimit = true;
                         this._downloadOptions.SizeLimit        = this._subStore.GetSizeLimitInBytesForSemiTrustApps();
                         this._downloadOptions.Size             = this._actDesc.DeployManifest.SizeInBytes + this._actDesc.AppManifest.SizeInBytes;
                     }
                 }
                 else
                 {
                     flag1 = true;
                 }
             }
             DownloadManager.DownloadDependencies(subscriptionState, this._actDesc.DeployManifest, this._actDesc.AppManifest, this._actDesc.AppSourceUri, this._tempApplicationDirectory.Path, (string)null, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions);
             if (!blocking && this._cancellationPending)
             {
                 return(true);
             }
             this.WaitForAssertApplicationRequirements();
             if (flag1)
             {
                 this.CheckSizeLimit();
             }
             this._actDesc.CommitApp      = true;
             this._actDesc.AppPayloadPath = this._tempApplicationDirectory.Path;
         }
         else
         {
             Logger.AddInternalState(this._log, "Application is cached.");
             this.WaitForAssertApplicationRequirements();
         }
         if (this._actDesc.CommitDeploy || this._actDesc.CommitApp)
         {
             this._subStore.CommitApplication(ref subscriptionState, (CommitApplicationParams)this._actDesc);
             Logger.AddInternalState(this._log, "Application is successfully committed to the store.");
         }
         if (this._tempApplicationDirectory != null)
         {
             this._tempApplicationDirectory.Dispose();
             this._tempApplicationDirectory = (TempDirectory)null;
         }
         if (this._tempDeployment != null)
         {
             this._tempDeployment.Dispose();
             this._tempDeployment = (TempFile)null;
         }
         if (this._referenceTransaction != null)
         {
             this._referenceTransaction.Close();
             this._referenceTransaction = (FileStream)null;
         }
         Logger.AddInternalState(this._log, "Refreshing ActivationContext from store.");
         ActivationContext actCtx = this._actCtx;
         this._actCtx = DeploymentManager.ConstructActivationContextFromStore(this._actDesc.AppId);
         actCtx.Dispose();
         this._cached = true;
     }
     catch (Exception ex)
     {
         this.LogError(Resources.GetString("Ex_DownloadApplicationFailed"), ex);
         Logger.AddInternalState(this._log, "Exception thrown in  SynchronizeCore(): " + ex.GetType().ToString() + " : " + ex.Message + "\r\n" + ex.StackTrace);
         throw;
     }
     return(false);
 }
 internal DeploymentManager(string appId, bool isUpdate, bool isConfirmed, DownloadOptions downloadOptions, AsyncOperation optionalAsyncOp) : this((Uri) null, isUpdate, isConfirmed, downloadOptions, optionalAsyncOp)
 {
     this._bindAppId = new DefinitionAppId(appId);
 }
        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);
            }
        }