示例#1
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.");
            }
        }
示例#2
0
        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);
        }
示例#3
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 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);
 }
示例#4
0
 private bool BindCore(bool blocking, ref TempFile tempDeploy, ref TempDirectory tempAppDir, ref FileStream refTransaction, ref string productName)
 {
     try
     {
         long   num;
         Uri    uri2;
         string str2;
         if (this._deploySource == null)
         {
             return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName));
         }
         bool             flag         = false;
         AssemblyManifest manifest     = null;
         string           manifestPath = null;
         Uri sourceUri = this._deploySource;
         this._state = DeploymentProgressState.DownloadingDeploymentInformation;
         Logger.AddInternalState(this._log, "Internal state=" + this._state);
         manifest     = DownloadManager.DownloadDeploymentManifest(this._subStore, ref sourceUri, out tempDeploy, blocking ? null : this, this._downloadOptions);
         manifestPath = tempDeploy.Path;
         System.Deployment.Application.ActivationDescription actDesc = new System.Deployment.Application.ActivationDescription();
         actDesc.SetDeploymentManifest(manifest, sourceUri, manifestPath);
         Logger.SetDeploymentManifest(this._log, manifest);
         actDesc.IsUpdate = this._isupdate;
         if (actDesc.DeployManifest.Deployment == null)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_NotDeploymentOrShortcut"));
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         refTransaction = this._subStore.AcquireReferenceTransaction(out num);
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(actDesc.DeployManifest);
         if (((actDesc.DeployManifest.Deployment.Install && (actDesc.DeployManifest.Deployment.ProviderCodebaseUri == null)) && ((subscriptionState != null) && (subscriptionState.DeploymentProviderUri != null))) && !subscriptionState.DeploymentProviderUri.Equals(sourceUri))
         {
             throw new DeploymentException(ExceptionTypes.DeploymentUriDifferent, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DeploymentUriDifferentExText"), new object[] { actDesc.DeployManifest.Description.FilteredProduct, sourceUri.AbsoluteUri, subscriptionState.DeploymentProviderUri.AbsoluteUri }));
         }
         DefinitionAppId appId = null;
         try
         {
             appId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[] { actDesc.DeployManifest.Identity, new DefinitionIdentity(actDesc.DeployManifest.MainDependentAssembly.Identity) });
         }
         catch (COMException exception)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), exception);
         }
         catch (SEHException exception2)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), exception2);
         }
         Logger.AddInternalState(this._log, "expectedAppId=" + appId.ToString());
         flag = this._subStore.CheckAndReferenceApplication(subscriptionState, appId, num);
         if (flag && appId.Equals(subscriptionState.CurrentBind))
         {
             Logger.AddInternalState(this._log, "Application is found in store and it is the CurrentBind. Binding with appid.");
             this._bindAppId = appId;
             return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName));
         }
         if (flag)
         {
             Logger.AddInternalState(this._log, "Application is found in store but it is not the CurrentBind.");
         }
         else
         {
             Logger.AddInternalState(this._log, "Application is not found in store.");
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         this._state = DeploymentProgressState.DownloadingApplicationInformation;
         Logger.AddInternalState(this._log, "Internal state=" + this._state);
         tempAppDir = this._subStore.AcquireTempDirectory();
         AssemblyManifest appManifest = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, tempAppDir.Path, actDesc.DeploySourceUri, blocking ? null : this, this._downloadOptions, out uri2, out str2);
         AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, appManifest);
         Logger.SetApplicationManifest(this._log, appManifest);
         Logger.SetApplicationUrl(this._log, uri2);
         actDesc.SetApplicationManifest(appManifest, uri2, str2);
         actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[] { actDesc.DeployManifest.Identity, actDesc.AppManifest.Identity });
         flag          = this._subStore.CheckAndReferenceApplication(subscriptionState, actDesc.AppId, num);
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         Description effectiveDescription = actDesc.EffectiveDescription;
         productName  = effectiveDescription.Product;
         this._cached = flag;
         Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString());
         Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString());
         this._tempApplicationDirectory = tempAppDir;
         this._tempDeployment           = tempDeploy;
         this._referenceTransaction     = refTransaction;
         this._actCtx  = ConstructActivationContext(actDesc);
         this._actDesc = actDesc;
     }
     catch (Exception exception3)
     {
         this.LogError(Resources.GetString("Ex_FailedToDownloadManifest"), exception3);
         Logger.AddInternalState(this._log, "Exception thrown in  BindCore(): " + exception3.GetType().ToString() + " : " + exception3.Message + "\r\n" + exception3.StackTrace);
         throw;
     }
     return(false);
 }
示例#5
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);
        }
示例#6
0
        private static void ProcessDownloadedFile(object sender, DownloadEventArgs e)
        {
            if (e.Cookie == null)
            {
                return;
            }
            string         fileName   = Path.GetFileName(e.FileLocalPath);
            FileDownloader downloader = (FileDownloader)sender;

            if (e.FileResponseUri != (Uri)null && !e.FileResponseUri.Equals((object)e.FileSourceUri))
            {
                throw new InvalidDeploymentException(ExceptionTypes.AppFileLocationValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DownloadAppFileAsmRedirected"), new object[1]
                {
                    (object)fileName
                }));
            }
            DownloadManager.DependencyDownloadCookie cookie = (DownloadManager.DependencyDownloadCookie)e.Cookie;
            if (cookie.ManifestElement is DependentAssembly)
            {
                DependentAssembly manifestElement  = (DependentAssembly)cookie.ManifestElement;
                AssemblyManifest  deployManifest   = cookie.DeployManifest;
                AssemblyManifest  appManifest      = cookie.AppManifest;
                AssemblyManifest  assemblyManifest = new AssemblyManifest(e.FileLocalPath);
                if (!assemblyManifest.Identity.Matches(manifestElement.Identity, true))
                {
                    throw new InvalidDeploymentException(ExceptionTypes.RefDefValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DownloadRefDefMismatch"), new object[1]
                    {
                        (object)fileName
                    }));
                }
                if (assemblyManifest.Identity.Equals((object)deployManifest.Identity) || assemblyManifest.Identity.Equals((object)appManifest.Identity))
                {
                    throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_AppPrivAsmIdSameAsDeployOrApp"), new object[1]
                    {
                        (object)assemblyManifest.Identity.ToString()
                    }));
                }
                System.Deployment.Application.Manifest.File[] files = assemblyManifest.Files;
                for (int index = 0; index < files.Length; ++index)
                {
                    Uri fileSourceUri = DownloadManager.MapFileSourceUri(deployManifest, e.FileSourceUri, files[index].Name);
                    if (!fileSourceUri.AbsoluteUri.Equals(e.FileSourceUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase))
                    {
                        string directoryName = Path.GetDirectoryName(e.FileLocalPath);
                        DownloadManager.AddFileToDownloader(downloader, deployManifest, appManifest, (object)files[index], fileSourceUri, directoryName, files[index].NameFS, files[index].HashCollection);
                    }
                }
                downloader.ComponentVerifier.AddFileForVerification(e.FileLocalPath, manifestElement.HashCollection);
                if (assemblyManifest.Identity.PublicKeyToken == null)
                {
                    downloader.ComponentVerifier.AddSimplyNamedAssemblyForVerification(e.FileLocalPath, assemblyManifest);
                }
                else
                {
                    downloader.ComponentVerifier.AddStrongNameAssemblyForVerification(e.FileLocalPath, assemblyManifest);
                }
            }
            else
            {
                if (!(cookie.ManifestElement is System.Deployment.Application.Manifest.File))
                {
                    return;
                }
                System.Deployment.Application.Manifest.File manifestElement = (System.Deployment.Application.Manifest.File)cookie.ManifestElement;
                downloader.ComponentVerifier.AddFileForVerification(e.FileLocalPath, manifestElement.HashCollection);
            }
        }
示例#7
0
 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));
 }
示例#8
0
        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);
        }
示例#9
0
 public static AssemblyManifest DownloadDeploymentManifest(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile)
 {
     return(DownloadManager.DownloadDeploymentManifest(subStore, ref sourceUri, out tempFile, (IDownloadNotification)null, (DownloadOptions)null));
 }
示例#10
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);
        }
示例#11
0
 public static AssemblyManifest DownloadApplicationManifest(AssemblyManifest deploymentManifest, string targetDir, Uri deploymentUri, out Uri appSourceUri, out string appManifestPath)
 {
     return(DownloadManager.DownloadApplicationManifest(deploymentManifest, targetDir, deploymentUri, (IDownloadNotification)null, (DownloadOptions)null, out appSourceUri, out appManifestPath));
 }
示例#12
0
 private bool BindCore(bool blocking, ref TempFile tempDeploy, ref TempDirectory tempAppDir, ref FileStream refTransaction, ref string productName)
 {
     try
     {
         if (this._deploySource == (Uri)null)
         {
             return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName));
         }
         Uri deploySource = this._deploySource;
         this._state = DeploymentProgressState.DownloadingDeploymentInformation;
         Logger.AddInternalState(this._log, "Internal state=" + (object)this._state);
         AssemblyManifest      assemblyManifest1 = DownloadManager.DownloadDeploymentManifest(this._subStore, ref deploySource, out tempDeploy, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions);
         string                path    = tempDeploy.Path;
         ActivationDescription actDesc = new ActivationDescription();
         actDesc.SetDeploymentManifest(assemblyManifest1, deploySource, path);
         Logger.SetDeploymentManifest(this._log, assemblyManifest1);
         actDesc.IsUpdate = this._isupdate;
         if (actDesc.DeployManifest.Deployment == null)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_NotDeploymentOrShortcut"));
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         long transactionId;
         refTransaction = this._subStore.AcquireReferenceTransaction(out transactionId);
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(actDesc.DeployManifest);
         if (actDesc.DeployManifest.Deployment.Install && actDesc.DeployManifest.Deployment.ProviderCodebaseUri == (Uri)null && (subscriptionState != null && subscriptionState.DeploymentProviderUri != (Uri)null) && !subscriptionState.DeploymentProviderUri.Equals((object)deploySource))
         {
             throw new DeploymentException(ExceptionTypes.DeploymentUriDifferent, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DeploymentUriDifferentExText"), new object[3]
             {
                 (object)actDesc.DeployManifest.Description.FilteredProduct,
                 (object)deploySource.AbsoluteUri,
                 (object)subscriptionState.DeploymentProviderUri.AbsoluteUri
             }));
         }
         DefinitionAppId appId;
         try
         {
             appId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2]
             {
                 actDesc.DeployManifest.Identity,
                 new DefinitionIdentity(actDesc.DeployManifest.MainDependentAssembly.Identity)
             });
         }
         catch (COMException ex)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex);
         }
         catch (SEHException ex)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex);
         }
         Logger.AddInternalState(this._log, "expectedAppId=" + appId.ToString());
         bool flag1 = this._subStore.CheckAndReferenceApplication(subscriptionState, appId, transactionId);
         if (flag1 && appId.Equals((object)subscriptionState.CurrentBind))
         {
             Logger.AddInternalState(this._log, "Application is found in store and it is the CurrentBind. Binding with appid.");
             this._bindAppId = appId;
             return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName));
         }
         if (flag1)
         {
             Logger.AddInternalState(this._log, "Application is found in store but it is not the CurrentBind.");
         }
         else
         {
             Logger.AddInternalState(this._log, "Application is not found in store.");
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         this._state = DeploymentProgressState.DownloadingApplicationInformation;
         Logger.AddInternalState(this._log, "Internal state=" + (object)this._state);
         tempAppDir = this._subStore.AcquireTempDirectory();
         Uri              appSourceUri;
         string           appManifestPath;
         AssemblyManifest assemblyManifest2 = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, tempAppDir.Path, actDesc.DeploySourceUri, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions, out appSourceUri, out appManifestPath);
         AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, assemblyManifest2);
         Logger.SetApplicationManifest(this._log, assemblyManifest2);
         Logger.SetApplicationUrl(this._log, appSourceUri);
         actDesc.SetApplicationManifest(assemblyManifest2, appSourceUri, appManifestPath);
         actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2]
         {
             actDesc.DeployManifest.Identity,
             actDesc.AppManifest.Identity
         });
         bool flag2 = this._subStore.CheckAndReferenceApplication(subscriptionState, actDesc.AppId, transactionId);
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         Description effectiveDescription = actDesc.EffectiveDescription;
         productName  = effectiveDescription.Product;
         this._cached = flag2;
         Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString());
         Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString());
         this._tempApplicationDirectory = tempAppDir;
         this._tempDeployment           = tempDeploy;
         this._referenceTransaction     = refTransaction;
         this._actCtx  = DeploymentManager.ConstructActivationContext(actDesc);
         this._actDesc = actDesc;
     }
     catch (Exception ex)
     {
         this.LogError(Resources.GetString("Ex_FailedToDownloadManifest"), ex);
         Logger.AddInternalState(this._log, "Exception thrown in  BindCore(): " + ex.GetType().ToString() + " : " + ex.Message + "\r\n" + ex.StackTrace);
         throw;
     }
     return(false);
 }