Exemplo n.º 1
0
        public bool CheckAndReferenceApplication(SubscriptionState subState, DefinitionAppId appId, long transactionId)
        {
            DefinitionIdentity deploymentIdentity  = appId.DeploymentIdentity;
            DefinitionIdentity applicationIdentity = appId.ApplicationIdentity;

            if (!subState.IsInstalled || !this.IsAssemblyInstalled(deploymentIdentity))
            {
                return(false);
            }
            if (!this.IsAssemblyInstalled(applicationIdentity))
            {
                throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_IllegalApplicationId"));
            }
            if (!appId.Equals((object)subState.CurrentBind))
            {
                return(appId.Equals((object)subState.PreviousBind));
            }
            return(true);
        }
 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;
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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);
        }
 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;
 }
Exemplo n.º 6
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);
 }