public static System.Security.Policy.ApplicationTrust RequestTrust(SubscriptionState subState, bool isShellVisible, bool isUpdate, ActivationContext actCtx)
 {
     TrustManagerContext tmc = new TrustManagerContext {
         IgnorePersistedDecision = false,
         NoPrompt = false,
         Persist = true
     };
     return RequestTrust(subState, isShellVisible, isUpdate, actCtx, tmc);
 }
 public SubscriptionStateInternal(SubscriptionState subState)
 {
     this.IsInstalled = subState.IsInstalled;
     this.IsShellVisible = subState.IsShellVisible;
     this.CurrentBind = subState.CurrentBind;
     this.PreviousBind = subState.PreviousBind;
     this.PendingBind = subState.PreviousBind;
     this.PendingDeployment = subState.PendingDeployment;
     this.ExcludedDeployment = subState.ExcludedDeployment;
     this.DeploymentProviderUri = subState.DeploymentProviderUri;
     this.MinimumRequiredVersion = subState.MinimumRequiredVersion;
     this.LastCheckTime = subState.LastCheckTime;
     this.UpdateSkippedDeployment = subState.UpdateSkippedDeployment;
     this.UpdateSkipTime = subState.UpdateSkipTime;
     this.appType = subState.appType;
 }
 public static System.Security.Policy.ApplicationTrust RequestTrust(SubscriptionState subState, bool isShellVisible, bool isUpdate, ActivationContext actCtx, TrustManagerContext tmc)
 {
     Logger.AddMethodCall("ApplicationTrust.RequestTrust(isShellVisible=" + isShellVisible.ToString() + ", isUpdate=" + isUpdate.ToString() + ", subState.IsInstalled=" + subState.IsInstalled.ToString() + ") called.");
     if (!subState.IsInstalled || (subState.IsShellVisible != isShellVisible))
     {
         tmc.IgnorePersistedDecision = true;
     }
     if (isUpdate)
     {
         tmc.PreviousApplicationIdentity = subState.CurrentBind.ToApplicationIdentity();
     }
     bool flag = false;
     try
     {
         Logger.AddInternalState("Calling ApplicationSecurityManager.DetermineApplicationTrust().");
         Logger.AddInternalState("Trust Manager Context=" + Logger.Serialize(tmc));
         flag = ApplicationSecurityManager.DetermineApplicationTrust(actCtx, tmc);
     }
     catch (TypeLoadException exception)
     {
         throw new InvalidDeploymentException(Resources.GetString("Ex_InvalidTrustInfo"), exception);
     }
     if (!flag)
     {
         throw new TrustNotGrantedException(Resources.GetString("Ex_NoTrust"));
     }
     Logger.AddInternalState("Trust granted.");
     System.Security.Policy.ApplicationTrust trust = null;
     for (int i = 0; i < 5; i++)
     {
         trust = ApplicationSecurityManager.UserApplicationTrusts[actCtx.Identity.FullName];
         if (trust != null)
         {
             break;
         }
         Thread.Sleep(10);
     }
     if (trust == null)
     {
         throw new InvalidDeploymentException(Resources.GetString("Ex_InvalidMatchTrust"));
     }
     return trust;
 }
Esempio n. 4
0
 public bool CheckGroupInstalled(SubscriptionState subState, DefinitionAppId appId, AssemblyManifest appManifest, string groupName)
 {
     using (this.AcquireSubscriptionReaderLock(subState))
         return(this._compStore.CheckGroupInstalled(appId, appManifest, groupName));
 }
Esempio n. 5
0
        public Version CheckUpdateInManifest(SubscriptionState subState, Uri updateCodebaseUri, AssemblyManifest deployment, Version currentVersion)
        {
            bool bUpdateInPKTGroup = false;

            return(this.CheckUpdateInManifest(subState, updateCodebaseUri, deployment, currentVersion, ref bUpdateInPKTGroup));
        }
Esempio n. 6
0
        private static void UpdateShortcuts(SubscriptionState subState, ref ShellExposureInformation shellExposureInformation)
        {
            string      strA = string.Format("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
            Description effectiveDescription = subState.EffectiveDescription;

            if (shellExposureInformation != null)
            {
                bool flag  = true;
                bool flag2 = true;
                bool flag3 = true;
                bool flag4 = true;
                if (string.Compare(effectiveDescription.FilteredPublisher, shellExposureInformation.AppVendor, StringComparison.Ordinal) == 0)
                {
                    flag = false;
                    if (Utilities.CompareWithNullEqEmpty(effectiveDescription.FilteredSuiteName, shellExposureInformation.AppSuiteName, StringComparison.Ordinal) == 0)
                    {
                        flag2 = false;
                        if (string.Compare(effectiveDescription.FilteredProduct, shellExposureInformation.AppProduct, StringComparison.Ordinal) == 0)
                        {
                            flag3 = false;
                            if (string.Compare(strA, shellExposureInformation.ShortcutAppId, StringComparison.Ordinal) == 0)
                            {
                                flag4 = false;
                            }
                        }
                    }
                }
                if (((!flag && !flag2) && (!flag3 && !flag4)) && System.IO.File.Exists(shellExposureInformation.ApplicationShortcutPath))
                {
                    Logger.AddInternalState("Shortcut folder and files are not updated and application shortcut file already exists: " + shellExposureInformation.ApplicationShortcutPath);
                    return;
                }
                if (flag3)
                {
                    UnpinShortcut(shellExposureInformation.ApplicationShortcutPath);
                    MoveDeleteFile(shellExposureInformation.ApplicationShortcutPath);
                    MoveDeleteFile(shellExposureInformation.SupportShortcutPath);
                    MoveDeleteFile(shellExposureInformation.DesktopShortcutPath);
                    Logger.AddInternalState("Shortcut files deleted:" + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath);
                }
                if (flag2)
                {
                    Logger.AddInternalState("Attempt deleting shortcut folder:" + shellExposureInformation.ApplicationFolderPath);
                    MoveDeleteEmptyFolder(shellExposureInformation.ApplicationFolderPath);
                }
                if (flag)
                {
                    Logger.AddInternalState("Attempt deleting shortcut root folder:" + shellExposureInformation.ApplicationRootFolderPath);
                    MoveDeleteEmptyFolder(shellExposureInformation.ApplicationRootFolderPath);
                }
                if ((flag || flag2) || flag3)
                {
                    shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, strA);
                }
                else
                {
                    Logger.AddInternalState("Shortcut app id has changed. Old value=" + shellExposureInformation.ShortcutAppId + ",New value=" + strA);
                    shellExposureInformation.ShortcutAppId = strA;
                }
            }
            else
            {
                shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, strA);
            }
            try
            {
                Logger.AddInternalState("Create the shortcut directory : " + shellExposureInformation.ApplicationFolderPath);
                Directory.CreateDirectory(shellExposureInformation.ApplicationFolderPath);
                GenerateAppShortcut(subState, shellExposureInformation);
                GenerateSupportShortcut(subState, shellExposureInformation);
            }
            catch (Exception)
            {
                RemoveShortcuts(shellExposureInformation);
                throw;
            }
        }
 private static void UpdateShortcuts(SubscriptionState subState, ref ShellExposureInformation shellExposureInformation)
 {
     string strA = string.Format("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
     Description effectiveDescription = subState.EffectiveDescription;
     if (shellExposureInformation != null)
     {
         bool flag = true;
         bool flag2 = true;
         bool flag3 = true;
         bool flag4 = true;
         if (string.Compare(effectiveDescription.FilteredPublisher, shellExposureInformation.AppVendor, StringComparison.Ordinal) == 0)
         {
             flag = false;
             if (Utilities.CompareWithNullEqEmpty(effectiveDescription.FilteredSuiteName, shellExposureInformation.AppSuiteName, StringComparison.Ordinal) == 0)
             {
                 flag2 = false;
                 if (string.Compare(effectiveDescription.FilteredProduct, shellExposureInformation.AppProduct, StringComparison.Ordinal) == 0)
                 {
                     flag3 = false;
                     if (string.Compare(strA, shellExposureInformation.ShortcutAppId, StringComparison.Ordinal) == 0)
                     {
                         flag4 = false;
                     }
                 }
             }
         }
         if (((!flag && !flag2) && (!flag3 && !flag4)) && System.IO.File.Exists(shellExposureInformation.ApplicationShortcutPath))
         {
             Logger.AddInternalState("Shortcut folder and files are not updated and application shortcut file already exists: " + shellExposureInformation.ApplicationShortcutPath);
             return;
         }
         if (flag3)
         {
             UnpinShortcut(shellExposureInformation.ApplicationShortcutPath);
             MoveDeleteFile(shellExposureInformation.ApplicationShortcutPath);
             MoveDeleteFile(shellExposureInformation.SupportShortcutPath);
             MoveDeleteFile(shellExposureInformation.DesktopShortcutPath);
             Logger.AddInternalState("Shortcut files deleted:" + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath);
         }
         if (flag2)
         {
             Logger.AddInternalState("Attempt deleting shortcut folder:" + shellExposureInformation.ApplicationFolderPath);
             MoveDeleteEmptyFolder(shellExposureInformation.ApplicationFolderPath);
         }
         if (flag)
         {
             Logger.AddInternalState("Attempt deleting shortcut root folder:" + shellExposureInformation.ApplicationRootFolderPath);
             MoveDeleteEmptyFolder(shellExposureInformation.ApplicationRootFolderPath);
         }
         if ((flag || flag2) || flag3)
         {
             shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, strA);
         }
         else
         {
             Logger.AddInternalState("Shortcut app id has changed. Old value=" + shellExposureInformation.ShortcutAppId + ",New value=" + strA);
             shellExposureInformation.ShortcutAppId = strA;
         }
     }
     else
     {
         shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, strA);
     }
     try
     {
         Logger.AddInternalState("Create the shortcut directory : " + shellExposureInformation.ApplicationFolderPath);
         Directory.CreateDirectory(shellExposureInformation.ApplicationFolderPath);
         GenerateAppShortcut(subState, shellExposureInformation);
         GenerateSupportShortcut(subState, shellExposureInformation);
     }
     catch (Exception)
     {
         RemoveShortcuts(shellExposureInformation);
         throw;
     }
 }
 internal static void RemovePins(SubscriptionState subState)
 {
     Logger.AddInternalState("Attempting to remove shell pins.");
     ShellExposureInformation information = ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
     if (information == null)
     {
         Logger.AddInternalState("shellExposureInformation is null.");
     }
     else if (System.IO.File.Exists(information.ApplicationShortcutPath))
     {
         UnpinShortcut(information.ApplicationShortcutPath);
     }
 }
 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;
 }
Esempio n. 10
0
 public void CommitApplication(ref SubscriptionState subState, CommitApplicationParams commitParams)
 {
     Logger.AddMethodCall("CommitApplication called.");
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         if (commitParams.CommitDeploy)
         {
             Logger.AddInternalState("Commiting Deployment :  subscription metadata.");
             UriHelper.ValidateSupportedScheme(commitParams.DeploySourceUri);
             this.CheckDeploymentSubscriptionState(subState, commitParams.DeployManifest);
             this.ValidateFileAssoctiation(subState, commitParams);
             if (commitParams.IsUpdate && !commitParams.IsUpdateInPKTGroup)
             {
                 SubscriptionStore.CheckInstalled(subState);
             }
         }
         if (commitParams.CommitApp)
         {
             Logger.AddInternalState("Commiting Application:  application binaries.");
             UriHelper.ValidateSupportedScheme(commitParams.AppSourceUri);
             if (commitParams.AppGroup != null)
             {
                 SubscriptionStore.CheckInstalled(subState);
             }
             this.CheckApplicationPayload(commitParams);
         }
         bool      flag = false;
         bool      identityGroupFound       = false;
         bool      locationGroupFound       = false;
         string    identityGroupProductName = "";
         ArrayList arrayList = this._compStore.CollectCrossGroupApplications(commitParams.DeploySourceUri, commitParams.DeployManifest.Identity, ref identityGroupFound, ref locationGroupFound, ref identityGroupProductName);
         if (arrayList.Count > 0)
         {
             flag = true;
             Logger.AddInternalState("This installation is a Cross Group: identityGroupFound=" + identityGroupFound.ToString() + ",locationGroupFound=" + locationGroupFound.ToString());
         }
         if (subState.IsShellVisible & identityGroupFound & locationGroupFound)
         {
             throw new DeploymentException(ExceptionTypes.GroupMultipleMatch, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_GroupMultipleMatch"), new object[1]
             {
                 (object)identityGroupProductName
             }));
         }
         subState = this.GetSubscriptionState(commitParams.DeployManifest);
         this._compStore.CommitApplication(subState, commitParams);
         if (flag)
         {
             Logger.AddInternalState("Performing cross group migration.");
             IActContext actContext = IsolationInterop.CreateActContext(subState.CurrentBind.ComPointer);
             actContext.PrepareForExecution(IntPtr.Zero, IntPtr.Zero);
             uint ulDisposition;
             actContext.SetApplicationRunningState(0U, 1U, out ulDisposition);
             actContext.SetApplicationRunningState(0U, 2U, out ulDisposition);
             Logger.AddInternalState("Uninstalling all cross groups.");
             foreach (ComponentStore.CrossGroupApplicationData groupApplicationData in arrayList)
             {
                 if (groupApplicationData.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.LocationGroup)
                 {
                     if (groupApplicationData.SubState.appType == AppType.CustomHostSpecified)
                     {
                         Logger.AddInternalState("UninstallCustomHostSpecifiedSubscription : " + (groupApplicationData.SubState.SubscriptionId != null ? groupApplicationData.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomHostSpecifiedSubscription(groupApplicationData.SubState);
                     }
                     else if (groupApplicationData.SubState.appType == AppType.CustomUX)
                     {
                         Logger.AddInternalState("UninstallCustomUXSubscription : " + (groupApplicationData.SubState.SubscriptionId != null ? groupApplicationData.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomUXSubscription(groupApplicationData.SubState);
                     }
                     else if (groupApplicationData.SubState.IsShellVisible)
                     {
                         Logger.AddInternalState("UninstallSubscription : " + (groupApplicationData.SubState.SubscriptionId != null ? groupApplicationData.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallSubscription(groupApplicationData.SubState);
                     }
                 }
                 else if (groupApplicationData.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.IdentityGroup)
                 {
                     Logger.AddInternalState("Not uninstalled :" + (groupApplicationData.SubState.SubscriptionId != null ? groupApplicationData.SubState.SubscriptionId.ToString() : "null") + ". It is in the identity group.");
                 }
             }
         }
         if (commitParams.IsConfirmed && subState.IsInstalled && (subState.IsShellVisible && commitParams.appType != AppType.CustomUX))
         {
             this.UpdateSubscriptionExposure(subState);
         }
         if (commitParams.appType == AppType.CustomUX)
         {
             ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
             ShellExposure.UpdateShellExtensions(subState, ref exposureInformation);
         }
         SubscriptionStore.OnDeploymentAdded(subState);
     }
 }
 public void SetUpdateSkipTime(SubscriptionState subState, System.Deployment.Application.DefinitionIdentity updateSkippedDeployment, DateTime updateSkipTime)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         this._compStore.SetUpdateSkipTime(subState, updateSkippedDeployment, updateSkipTime);
     }
 }
 public void SetPendingDeployment(SubscriptionState subState, System.Deployment.Application.DefinitionIdentity deployId, DateTime checkTime)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         this._compStore.SetPendingDeployment(subState, deployId, checkTime);
     }
 }
 public void SetLastCheckTimeToNow(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         CheckInstalled(subState);
         this._compStore.SetPendingDeployment(subState, null, DateTime.UtcNow);
     }
 }
 public void RollbackSubscription(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         if (subState.RollbackDeployment == null)
         {
             throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_SubNoRollbackDeployment"));
         }
         if (subState.CurrentApplicationManifest != null)
         {
             string productName = null;
             if ((subState.CurrentDeploymentManifest != null) && (subState.CurrentDeploymentManifest.Description != null))
             {
                 productName = subState.CurrentDeploymentManifest.Description.Product;
             }
             if (productName == null)
             {
                 productName = subState.SubscriptionId.Name;
             }
             ShellExposure.RemoveShellExtensions(subState.SubscriptionId, subState.CurrentApplicationManifest, productName);
         }
         this._compStore.RollbackSubscription(subState);
         this.UpdateSubscriptionExposure(subState);
         OnDeploymentRemoved(subState);
     }
 }
Esempio n. 15
0
 private void PatchFiles(SubscriptionState subState)
 {
     if (!subState.IsInstalled)
     {
         Logger.AddInternalState("Subscription is not installed. No patching.");
     }
     else
     {
         Store.IPathLock pathLock1 = (Store.IPathLock)null;
         Store.IPathLock pathLock2 = (Store.IPathLock)null;
         using (subState.SubscriptionStore.AcquireSubscriptionReaderLock(subState))
         {
             if (!subState.IsInstalled)
             {
                 Logger.AddInternalState("Subscription is not installed. No patching.");
                 return;
             }
             Hashtable hashtable = new Hashtable();
             try
             {
                 pathLock1 = subState.SubscriptionStore.LockApplicationPath(subState.CurrentBind);
                 FileDownloader.AddFilesInHashtable(hashtable, subState.CurrentApplicationManifest, pathLock1.Path);
                 try
                 {
                     if (subState.PreviousBind != null)
                     {
                         pathLock2 = subState.SubscriptionStore.LockApplicationPath(subState.PreviousBind);
                         FileDownloader.AddFilesInHashtable(hashtable, subState.PreviousApplicationManifest, pathLock2.Path);
                     }
                     Queue queue = new Queue();
                     do
                     {
                         FileDownloader.DownloadQueueItem downloadQueueItem = (FileDownloader.DownloadQueueItem)null;
                         lock (this._fileQueue)
                         {
                             if (this._fileQueue.Count > 0)
                             {
                                 downloadQueueItem = (FileDownloader.DownloadQueueItem) this._fileQueue.Dequeue();
                             }
                         }
                         if (downloadQueueItem != null)
                         {
                             if (!this.PatchSingleFile(downloadQueueItem, hashtable))
                             {
                                 queue.Enqueue((object)downloadQueueItem);
                             }
                         }
                         else
                         {
                             break;
                         }
                     }while (!this._fCancelPending);
                     lock (this._fileQueue)
                     {
                         while (this._fileQueue.Count > 0)
                         {
                             queue.Enqueue(this._fileQueue.Dequeue());
                         }
                         this._fileQueue = queue;
                     }
                 }
                 finally
                 {
                     if (pathLock2 != null)
                     {
                         pathLock2.Dispose();
                     }
                 }
             }
             finally
             {
                 if (pathLock1 != null)
                 {
                     pathLock1.Dispose();
                 }
             }
         }
         if (this._fCancelPending)
         {
             throw new DownloadCancelledException();
         }
     }
 }
Esempio n. 16
0
        private static void UpdateArpEntry(SubscriptionState subState, ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            DefinitionIdentity subscriptionId = subState.SubscriptionId;
            string             str1           = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[1]
            {
                (object)subscriptionId.ToString()
            });
            string           str2 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]);
            AssemblyManifest deploymentManifest   = subState.CurrentDeploymentManifest;
            Description      effectiveDescription = subState.EffectiveDescription;

            using (RegistryKey subKey1 = ShellExposure.UninstallRoot.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"))
            {
                using (RegistryKey subKey2 = subKey1.CreateSubKey(ShellExposure.GenerateArpKeyName(subscriptionId)))
                {
                    string[] strArray = new string[24]
                    {
                        "DisplayName",
                        shellExposureInformation.ARPDisplayName,
                        "DisplayIcon",
                        str2,
                        "DisplayVersion",
                        deploymentManifest.Identity.Version.ToString(),
                        "Publisher",
                        effectiveDescription.FilteredPublisher,
                        "UninstallString",
                        str1,
                        "HelpLink",
                        effectiveDescription.SupportUrl,
                        "UrlUpdateInfo",
                        subState.DeploymentProviderUri.AbsoluteUri,
                        "ShortcutFolderName",
                        shellExposureInformation.AppVendor,
                        "ShortcutFileName",
                        shellExposureInformation.AppProduct,
                        "ShortcutSuiteName",
                        shellExposureInformation.AppSuiteName,
                        "SupportShortcutFileName",
                        shellExposureInformation.AppSupportShortcut,
                        "ShortcutAppId",
                        shellExposureInformation.ShortcutAppId
                    };
                    Logger.AddInternalState("Updating ARP entry.");
                    int index = strArray.Length - 2;
                    while (index >= 0)
                    {
                        string name = strArray[index];
                        string str3 = strArray[index + 1];
                        if (str3 != null)
                        {
                            subKey2.SetValue(name, (object)str3);
                        }
                        else
                        {
                            subKey2.DeleteValue(name, false);
                        }
                        index -= 2;
                    }
                }
            }
        }
Esempio n. 17
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);
 }
Esempio n. 18
0
 private static void CheckInstalledAndUpdateableConflict(SubscriptionState subState, AssemblyManifest deployment)
 {
 }
Esempio n. 19
0
 private static void RemoveSubscriptionExposure(SubscriptionState subState)
 {
     ShellExposure.RemoveSubscriptionShellExposure(subState);
 }
 public void UninstallCustomHostSpecifiedSubscription(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         CheckInstalled(subState);
         if (subState.appType != AppType.CustomHostSpecified)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_CannotCallUninstallCustomAddIn"));
         }
         this._compStore.RemoveSubscription(subState);
         OnDeploymentRemoved(subState);
     }
 }
 private void PatchFiles(SubscriptionState subState)
 {
     if (!subState.IsInstalled)
     {
         Logger.AddInternalState("Subscription is not installed. No patching.");
     }
     else
     {
         System.Deployment.Internal.Isolation.Store.IPathLock @lock = null;
         System.Deployment.Internal.Isolation.Store.IPathLock lock2 = null;
         using (subState.SubscriptionStore.AcquireSubscriptionReaderLock(subState))
         {
             if (!subState.IsInstalled)
             {
                 Logger.AddInternalState("Subscription is not installed. No patching.");
                 return;
             }
             Hashtable hashtable = new Hashtable();
             try
             {
                 @lock = subState.SubscriptionStore.LockApplicationPath(subState.CurrentBind);
                 AddFilesInHashtable(hashtable, subState.CurrentApplicationManifest, @lock.Path);
                 try
                 {
                     if (subState.PreviousBind != null)
                     {
                         lock2 = subState.SubscriptionStore.LockApplicationPath(subState.PreviousBind);
                         AddFilesInHashtable(hashtable, subState.PreviousApplicationManifest, lock2.Path);
                     }
                     Queue queue = new Queue();
                     do
                     {
                         DownloadQueueItem item = null;
                         lock (this._fileQueue)
                         {
                             if (this._fileQueue.Count > 0)
                             {
                                 item = (DownloadQueueItem)this._fileQueue.Dequeue();
                             }
                         }
                         if (item == null)
                         {
                             break;
                         }
                         if (!this.PatchSingleFile(item, hashtable))
                         {
                             queue.Enqueue(item);
                         }
                     }while (!this._fCancelPending);
                     lock (this._fileQueue)
                     {
                         while (this._fileQueue.Count > 0)
                         {
                             queue.Enqueue(this._fileQueue.Dequeue());
                         }
                         this._fileQueue = queue;
                     }
                 }
                 finally
                 {
                     if (lock2 != null)
                     {
                         lock2.Dispose();
                     }
                 }
             }
             finally
             {
                 if (@lock != null)
                 {
                     @lock.Dispose();
                 }
             }
         }
         if (this._fCancelPending)
         {
             throw new DownloadCancelledException();
         }
     }
 }
 public void UninstallCustomUXSubscription(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         CheckInstalled(subState);
         if (subState.appType != AppType.CustomUX)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_CannotCallUninstallCustomUXApplication"));
         }
         if (subState.CurrentApplicationManifest != null)
         {
             string productName = null;
             if ((subState.CurrentDeploymentManifest != null) && (subState.CurrentDeploymentManifest.Description != null))
             {
                 productName = subState.CurrentDeploymentManifest.Description.Product;
             }
             if (productName == null)
             {
                 productName = subState.SubscriptionId.Name;
             }
             ShellExposure.RemoveShellExtensions(subState.SubscriptionId, subState.CurrentApplicationManifest, productName);
         }
         this._compStore.RemoveSubscription(subState);
         OnDeploymentRemoved(subState);
     }
 }
 private static void GenerateAppShortcut(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
 {
     using (StreamWriter writer = new StreamWriter(shellExposureInformation.ApplicationShortcutPath, false, Encoding.Unicode))
     {
         writer.Write("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
     }
     Logger.AddInternalState("Shortcut file created: " + shellExposureInformation.ApplicationShortcutPath);
     if (subState.CurrentDeploymentManifest.Deployment.CreateDesktopShortcut)
     {
         using (StreamWriter writer2 = new StreamWriter(shellExposureInformation.DesktopShortcutPath, false, Encoding.Unicode))
         {
             writer2.Write("{0}#{1}", subState.DeploymentProviderUri.AbsoluteUri, subState.SubscriptionId.ToString());
         }
         Logger.AddInternalState("Desktop Shortcut file created: " + shellExposureInformation.DesktopShortcutPath);
     }
 }
 public void UninstallSubscription(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         if (subState.CurrentApplicationManifest != null)
         {
             string productName = null;
             if ((subState.CurrentDeploymentManifest != null) && (subState.CurrentDeploymentManifest.Description != null))
             {
                 productName = subState.CurrentDeploymentManifest.Description.Product;
             }
             if (productName == null)
             {
                 productName = subState.SubscriptionId.Name;
             }
             ShellExposure.RemoveShellExtensions(subState.SubscriptionId, subState.CurrentApplicationManifest, productName);
             ShellExposure.RemovePins(subState);
         }
         this._compStore.RemoveSubscription(subState);
         RemoveSubscriptionExposure(subState);
         OnDeploymentRemoved(subState);
     }
 }
 private static void UpdateArpEntry(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
 {
     DefinitionIdentity subscriptionId = subState.SubscriptionId;
     string str = string.Format(CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[] { subscriptionId.ToString() });
     string str2 = string.Format(CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]);
     AssemblyManifest currentDeploymentManifest = subState.CurrentDeploymentManifest;
     Description effectiveDescription = subState.EffectiveDescription;
     using (RegistryKey key = UninstallRoot.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
     {
         using (RegistryKey key2 = key.CreateSubKey(GenerateArpKeyName(subscriptionId)))
         {
             string[] strArray = new string[] { 
                 "DisplayName", shellExposureInformation.ARPDisplayName, "DisplayIcon", str2, "DisplayVersion", currentDeploymentManifest.Identity.Version.ToString(), "Publisher", effectiveDescription.FilteredPublisher, "UninstallString", str, "HelpLink", effectiveDescription.SupportUrl, "UrlUpdateInfo", subState.DeploymentProviderUri.AbsoluteUri, "ShortcutFolderName", shellExposureInformation.AppVendor, 
                 "ShortcutFileName", shellExposureInformation.AppProduct, "ShortcutSuiteName", shellExposureInformation.AppSuiteName, "SupportShortcutFileName", shellExposureInformation.AppSupportShortcut, "ShortcutAppId", shellExposureInformation.ShortcutAppId
              };
             Logger.AddInternalState("Updating ARP entry.");
             for (int i = strArray.Length - 2; i >= 0; i -= 2)
             {
                 string name = strArray[i];
                 string str4 = strArray[i + 1];
                 if (str4 != null)
                 {
                     key2.SetValue(name, str4);
                 }
                 else
                 {
                     key2.DeleteValue(name, false);
                 }
             }
         }
     }
 }
 private void UpdateSubscriptionExposure(SubscriptionState subState)
 {
     this.CheckInstalledAndShellVisible(subState);
     ShellExposure.UpdateSubscriptionShellExposure(subState);
 }
        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);
        }
 public void ValidateFileAssoctiation(SubscriptionState subState, CommitApplicationParams commitParams)
 {
     if (((commitParams.DeployManifest != null) && (commitParams.AppManifest != null)) && (!commitParams.DeployManifest.Deployment.Install && (commitParams.AppManifest.FileAssociations.Length > 0)))
     {
         throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_OnlineAppWithFileAssociation"));
     }
 }
Esempio n. 29
0
 public SubscriptionStateInternal GetSubscriptionStateInternal(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionReaderLock(subState))
         return(this._compStore.GetSubscriptionStateInternal(subState));
 }
 public IDisposable AcquireSubscriptionWriterLock(SubscriptionState subState)
 {
     subState.Invalidate();
     return this.AcquireStoreWriterLock();
 }
Esempio n. 31
0
 public void CheckInstalledAndShellVisible(SubscriptionState subState)
 {
     SubscriptionStore.CheckInstalled(subState);
     SubscriptionStore.CheckShellVisible(subState);
 }
 public bool CheckAndReferenceApplication(SubscriptionState subState, System.Deployment.Application.DefinitionAppId appId, long transactionId)
 {
     System.Deployment.Application.DefinitionIdentity deploymentIdentity = appId.DeploymentIdentity;
     System.Deployment.Application.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(subState.CurrentBind))
     {
         return appId.Equals(subState.PreviousBind);
     }
     return true;
 }
Esempio n. 33
0
 public IDisposable AcquireSubscriptionWriterLock(SubscriptionState subState)
 {
     subState.Invalidate();
     return(this.AcquireStoreWriterLock());
 }
 private ApplicationDeployment(string fullAppId)
 {
     if (fullAppId.Length > 0x10000)
     {
         throw new InvalidDeploymentException(Resources.GetString("Ex_AppIdTooLong"));
     }
     try
     {
         this._fullAppId = new DefinitionAppId(fullAppId);
     }
     catch (COMException exception)
     {
         throw new InvalidDeploymentException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_SubAppIdNotValid"), new object[] { fullAppId }), exception);
     }
     catch (SEHException exception2)
     {
         throw new InvalidDeploymentException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_SubAppIdNotValid"), new object[] { fullAppId }), exception2);
     }
     DefinitionIdentity deploymentIdentity = this._fullAppId.DeploymentIdentity;
     this._currentVersion = deploymentIdentity.Version;
     DefinitionIdentity subId = deploymentIdentity.ToSubscriptionId();
     this._subStore = SubscriptionStore.CurrentUser;
     this._subState = this._subStore.GetSubscriptionState(subId);
     if (!this._subState.IsInstalled)
     {
         throw new InvalidDeploymentException(Resources.GetString("Ex_SubNotInstalled"));
     }
     if (!this._fullAppId.Equals(this._subState.CurrentBind))
     {
         throw new InvalidDeploymentException(Resources.GetString("Ex_AppIdNotMatchInstalled"));
     }
     Uri uri = new Uri(this._fullAppId.Codebase);
     if (uri.IsFile)
     {
         this.accessPermission = new FileIOPermission(FileIOPermissionAccess.Read, uri.LocalPath);
     }
     else
     {
         this.accessPermission = new WebPermission(NetworkAccess.Connect, this._fullAppId.Codebase);
     }
     this.accessPermission.Demand();
     this._events = new EventHandlerList();
     this.asyncOperation = AsyncOperationManager.CreateOperation(null);
 }
Esempio n. 35
0
 private void UpdateSubscriptionExposure(SubscriptionState subState)
 {
     this.CheckInstalledAndShellVisible(subState);
     ShellExposure.UpdateSubscriptionShellExposure(subState);
 }
 public bool Update()
 {
     new NamedPermissionSet("FullTrust").Demand();
     if (Interlocked.CompareExchange(ref this._guard, 2, 0) != 0)
     {
         throw new InvalidOperationException(Resources.GetString("Ex_SingleOperation"));
     }
     this._cancellationPending = false;
     try
     {
         using (DeploymentManager manager = this.CreateDeploymentManager())
         {
             manager.Bind();
             UpdateCheckInfo info = this.DetermineUpdateCheckResult(manager.ActivationDescription);
             if (info.UpdateAvailable)
             {
                 manager.DeterminePlatformRequirements();
                 try
                 {
                     TrustParams trustParams = new TrustParams {
                         NoPrompt = true
                     };
                     manager.DetermineTrust(trustParams);
                 }
                 catch (TrustNotGrantedException)
                 {
                     if (!manager.ActivationDescription.IsUpdateInPKTGroup)
                     {
                         throw;
                     }
                 }
             }
             this.ProcessUpdateCheckResult(info, manager.ActivationDescription);
             if (!info.UpdateAvailable)
             {
                 return false;
             }
             manager.Synchronize();
             if (manager.ActivationDescription.IsUpdateInPKTGroup)
             {
                 this._subState = this._subStore.GetSubscriptionState(manager.ActivationDescription.DeployManifest);
             }
         }
     }
     finally
     {
         Interlocked.Exchange(ref this._guard, 0);
     }
     return true;
 }
Esempio n. 37
0
 private static void OnDeploymentRemoved(SubscriptionState subState)
 {
 }
 private void PatchFiles(SubscriptionState subState)
 {
     if (!subState.IsInstalled)
     {
         Logger.AddInternalState("Subscription is not installed. No patching.");
     }
     else
     {
         System.Deployment.Internal.Isolation.Store.IPathLock @lock = null;
         System.Deployment.Internal.Isolation.Store.IPathLock lock2 = null;
         using (subState.SubscriptionStore.AcquireSubscriptionReaderLock(subState))
         {
             if (!subState.IsInstalled)
             {
                 Logger.AddInternalState("Subscription is not installed. No patching.");
                 return;
             }
             Hashtable hashtable = new Hashtable();
             try
             {
                 @lock = subState.SubscriptionStore.LockApplicationPath(subState.CurrentBind);
                 AddFilesInHashtable(hashtable, subState.CurrentApplicationManifest, @lock.Path);
                 try
                 {
                     if (subState.PreviousBind != null)
                     {
                         lock2 = subState.SubscriptionStore.LockApplicationPath(subState.PreviousBind);
                         AddFilesInHashtable(hashtable, subState.PreviousApplicationManifest, lock2.Path);
                     }
                     Queue queue = new Queue();
                     do
                     {
                         DownloadQueueItem item = null;
                         lock (this._fileQueue)
                         {
                             if (this._fileQueue.Count > 0)
                             {
                                 item = (DownloadQueueItem) this._fileQueue.Dequeue();
                             }
                         }
                         if (item == null)
                         {
                             break;
                         }
                         if (!this.PatchSingleFile(item, hashtable))
                         {
                             queue.Enqueue(item);
                         }
                     }
                     while (!this._fCancelPending);
                     lock (this._fileQueue)
                     {
                         while (this._fileQueue.Count > 0)
                         {
                             queue.Enqueue(this._fileQueue.Dequeue());
                         }
                         this._fileQueue = queue;
                     }
                 }
                 finally
                 {
                     if (lock2 != null)
                     {
                         lock2.Dispose();
                     }
                 }
             }
             finally
             {
                 if (@lock != null)
                 {
                     @lock.Dispose();
                 }
             }
         }
         if (this._fCancelPending)
         {
             throw new DownloadCancelledException();
         }
     }
 }
 private void UpdateBindCompletedEventHandler(object sender, BindCompletedEventArgs e)
 {
     Exception error = null;
     DeploymentManager dm = null;
     bool flag = false;
     new NamedPermissionSet("FullTrust").Assert();
     try
     {
         dm = (DeploymentManager) sender;
         if ((e.Error == null) && !e.Cancelled)
         {
             UpdateCheckInfo info = this.DetermineUpdateCheckResult(dm.ActivationDescription);
             if (info.UpdateAvailable)
             {
                 dm.DeterminePlatformRequirements();
                 try
                 {
                     TrustParams trustParams = new TrustParams {
                         NoPrompt = true
                     };
                     dm.DetermineTrust(trustParams);
                 }
                 catch (TrustNotGrantedException)
                 {
                     if (!dm.ActivationDescription.IsUpdateInPKTGroup)
                     {
                         throw;
                     }
                 }
             }
             this.ProcessUpdateCheckResult(info, dm.ActivationDescription);
             if (info.UpdateAvailable)
             {
                 flag = true;
                 dm.SynchronizeAsync();
             }
             if (dm.ActivationDescription.IsUpdateInPKTGroup)
             {
                 this._subState = this._subStore.GetSubscriptionState(dm.ActivationDescription.DeployManifest);
             }
         }
         else
         {
             error = e.Error;
         }
     }
     catch (Exception exception2)
     {
         if (ExceptionUtility.IsHardException(exception2))
         {
             throw;
         }
         error = exception2;
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
         if (!flag)
         {
             this.EndUpdateAsync(dm, error, e.Cancelled);
         }
     }
 }
        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);
        }
 public void Download(SubscriptionState subState)
 {
     try
     {
         this.OnModified();
         if (subState != null)
         {
             CodeMarker_Singleton.Instance.CodeMarker(CodeMarkerEvent.perfCopyBegin);
             this.PatchFiles(subState);
             CodeMarker_Singleton.Instance.CodeMarker(CodeMarkerEvent.perfCopyEnd);
         }
         this.DownloadAllFiles();
     }
     finally
     {
         this.OnCompleted();
     }
 }
Esempio n. 42
0
        private void UpdateBindCompletedEventHandler(object sender, BindCompletedEventArgs e)
        {
            Exception         error = (Exception)null;
            DeploymentManager dm    = (DeploymentManager)null;
            bool flag = false;

            new NamedPermissionSet("FullTrust").Assert();
            try
            {
                dm = (DeploymentManager)sender;
                if (e.Error == null && !e.Cancelled)
                {
                    UpdateCheckInfo updateCheckResult = this.DetermineUpdateCheckResult(dm.ActivationDescription);
                    if (updateCheckResult.UpdateAvailable)
                    {
                        dm.DeterminePlatformRequirements();
                        try
                        {
                            dm.DetermineTrust(new TrustParams()
                            {
                                NoPrompt = true
                            });
                        }
                        catch (TrustNotGrantedException ex)
                        {
                            if (!dm.ActivationDescription.IsUpdateInPKTGroup)
                            {
                                throw;
                            }
                        }
                    }
                    this.ProcessUpdateCheckResult(updateCheckResult, dm.ActivationDescription);
                    if (updateCheckResult.UpdateAvailable)
                    {
                        flag = true;
                        dm.SynchronizeAsync();
                    }
                    if (!dm.ActivationDescription.IsUpdateInPKTGroup)
                    {
                        return;
                    }
                    this._subState = this._subStore.GetSubscriptionState(dm.ActivationDescription.DeployManifest);
                }
                else
                {
                    error = e.Error;
                }
            }
            catch (Exception ex)
            {
                if (ExceptionUtility.IsHardException(ex))
                {
                    throw;
                }
                else
                {
                    error = ex;
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
                if (!flag)
                {
                    this.EndUpdateAsync(dm, error, e.Cancelled);
                }
            }
        }
 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);
     }
 }
Esempio n. 44
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);
        }
 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;
 }
Esempio n. 46
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 static void GenerateSupportShortcut(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
 {
     Description effectiveDescription = subState.EffectiveDescription;
     if (effectiveDescription.SupportUri != null)
     {
         using (StreamWriter writer = new StreamWriter(shellExposureInformation.SupportShortcutPath, false, Encoding.ASCII))
         {
             writer.WriteLine("[Default]");
             writer.WriteLine("BASEURL=" + effectiveDescription.SupportUri.AbsoluteUri);
             writer.WriteLine("[InternetShortcut]");
             writer.WriteLine("URL=" + effectiveDescription.SupportUri.AbsoluteUri);
             writer.WriteLine();
             writer.WriteLine("IconFile=" + System.Deployment.Application.PathHelper.ShortShimDllPath);
             writer.WriteLine("IconIndex=" + 0.ToString(CultureInfo.InvariantCulture));
             writer.WriteLine();
         }
         Logger.AddInternalState("Support shortcut file created: " + shellExposureInformation.SupportShortcutPath);
     }
 }
Esempio n. 48
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);
        }
 public static void RemoveSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         DefinitionIdentity subscriptionId = subState.SubscriptionId;
         bool flag = false;
         ShellExposureInformation shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(subscriptionId);
         if (shellExposureInformation == null)
         {
             flag = true;
         }
         else
         {
             for (int i = 1; i <= 2; i++)
             {
                 try
                 {
                     RemoveShortcuts(shellExposureInformation);
                     break;
                 }
                 catch (DeploymentException)
                 {
                     Logger.AddInternalState("Remove shortcut entries Failed: " + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath + "," + shellExposureInformation.ApplicationFolderPath + "," + shellExposureInformation.ApplicationRootFolderPath);
                     if (i >= 2)
                     {
                         throw;
                     }
                     Thread.Sleep(0x3e8);
                 }
             }
         }
         RemoveArpEntry(subscriptionId);
         if (flag)
         {
             throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ShortcutRemovalFailureDueToInvalidPublisherProduct"));
         }
     }
 }
Esempio n. 50
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);
 }
 public static void UpdateShellExtensions(SubscriptionState subState, ref ShellExposureInformation shellExposureInformation)
 {
     string productName = null;
     if (shellExposureInformation != null)
     {
         productName = shellExposureInformation.AppProduct;
     }
     if (productName == null)
     {
         productName = subState.SubscriptionId.Name;
     }
     if (subState.PreviousBind != null)
     {
         Logger.AddInternalState("Removing file associations if existed for the previous version.");
         RemoveShellExtensions(subState.SubscriptionId, subState.PreviousApplicationManifest, productName);
     }
     Logger.AddInternalState("Registering file associations if there is any in the manifest for the new version. ");
     AddShellExtensions(subState.SubscriptionId, subState.DeploymentProviderUri, subState.CurrentApplicationManifest);
     System.Deployment.Application.NativeMethods.SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
 }
Esempio n. 52
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);
 }
 public static void UpdateSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         ShellExposureInformation shellExposureInformation = ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
         UpdateShortcuts(subState, ref shellExposureInformation);
         UpdateShellExtensions(subState, ref shellExposureInformation);
         UpdateArpEntry(subState, shellExposureInformation);
     }
 }
Esempio n. 54
0
        private void MaintainSubscriptionInternal(string textualSubId)
        {
            bool flag = false;

            string[]  strArray       = new string[] { "Maintain_Exception", "Maintain_Completed", "Maintain_Failed", "Maintain_FailedMsg" };
            bool      flag2          = false;
            Exception exception      = null;
            bool      flag3          = false;
            bool      flag4          = false;
            string    linkUrlMessage = Resources.GetString("ErrorMessage_GenericLinkUrlMessage");
            string    linkUrl        = null;
            string    errorReportUrl = null;

            Logger.StartCurrentThreadLogging();
            Logger.SetTextualSubscriptionIdentity(textualSubId);
            using (UserInterface interface2 = new UserInterface())
            {
                MaintenanceInfo maintenanceInfo = new MaintenanceInfo();
                try
                {
                    UserInterfaceInfo info = new UserInterfaceInfo();
                    Logger.AddPhaseInformation(Resources.GetString("PhaseLog_StoreQueryForMaintenanceInfo"));
                    SubscriptionState subscriptionState = this.GetSubscriptionState(textualSubId);
                    try
                    {
                        subscriptionState.SubscriptionStore.CheckInstalledAndShellVisible(subscriptionState);
                        if (subscriptionState.RollbackDeployment == null)
                        {
                            maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RemoveSelected;
                        }
                        else
                        {
                            maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RestorationPossible;
                            maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RestoreSelected;
                        }
                        AssemblyManifest currentDeploymentManifest = subscriptionState.CurrentDeploymentManifest;
                        if ((currentDeploymentManifest != null) && (currentDeploymentManifest.Description != null))
                        {
                            errorReportUrl = currentDeploymentManifest.Description.ErrorReportUrl;
                        }
                        Description effectiveDescription = subscriptionState.EffectiveDescription;
                        info.productName = effectiveDescription.Product;
                        info.supportUrl  = effectiveDescription.SupportUrl;
                        info.formTitle   = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_MaintenanceTitle"), new object[] { info.productName });
                        flag3            = true;
                    }
                    catch (DeploymentException exception2)
                    {
                        flag3 = false;
                        Logger.AddErrorInformation(Resources.GetString("MaintainLogMsg_FailedStoreLookup"), exception2);
                        maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RemoveSelected;
                    }
                    catch (FormatException exception3)
                    {
                        flag3 = false;
                        Logger.AddErrorInformation(Resources.GetString("MaintainLogMsg_FailedStoreLookup"), exception3);
                        maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RemoveSelected;
                    }
                    bool flag5 = false;
                    if (flag3)
                    {
                        if (interface2.ShowMaintenance(info, maintenanceInfo) == UserInterfaceModalResult.Ok)
                        {
                            flag5 = true;
                        }
                    }
                    else
                    {
                        maintenanceInfo.maintenanceFlags = MaintenanceFlags.RemoveSelected;
                        flag5 = true;
                    }
                    if (flag5)
                    {
                        flag2 = true;
                        if ((maintenanceInfo.maintenanceFlags & MaintenanceFlags.RestoreSelected) != MaintenanceFlags.ClearFlag)
                        {
                            strArray = new string[] { "Rollback_Exception", "Rollback_Completed", "Rollback_Failed", "Rollback_FailedMsg" };
                            subscriptionState.SubscriptionStore.RollbackSubscription(subscriptionState);
                            flag2 = false;
                            interface2.ShowMessage(Resources.GetString("UI_RollbackCompletedMsg"), Resources.GetString("UI_RollbackCompletedTitle"));
                        }
                        else if ((maintenanceInfo.maintenanceFlags & MaintenanceFlags.RemoveSelected) != MaintenanceFlags.ClearFlag)
                        {
                            strArray = new string[] { "Uninstall_Exception", "Uninstall_Completed", "Uninstall_Failed", "Uninstall_FailedMsg" };
                            try
                            {
                                subscriptionState.SubscriptionStore.UninstallSubscription(subscriptionState);
                                flag2 = false;
                            }
                            catch (DeploymentException exception4)
                            {
                                Logger.AddErrorInformation(Resources.GetString("MaintainLogMsg_UninstallFailed"), exception4);
                                flag4 = true;
                                ShellExposure.RemoveSubscriptionShellExposure(subscriptionState);
                                flag4 = false;
                            }
                        }
                        flag = true;
                    }
                }
                catch (DeploymentException exception5)
                {
                    Logger.AddErrorInformation(exception5, Resources.GetString(strArray[0]), new object[] { textualSubId });
                    exception = exception5;
                }
                finally
                {
                    Logger.AddPhaseInformation(Resources.GetString(flag ? strArray[1] : strArray[2]), new object[] { textualSubId });
                    if ((((maintenanceInfo.maintenanceFlags & MaintenanceFlags.RestoreSelected) != MaintenanceFlags.ClearFlag) && flag2) || ((((maintenanceInfo.maintenanceFlags & MaintenanceFlags.RemoveSelected) != MaintenanceFlags.ClearFlag) && flag4) && flag2))
                    {
                        string logFilePath = Logger.GetLogFilePath();
                        if (!Logger.FlushCurrentThreadLogs())
                        {
                            logFilePath = null;
                        }
                        if ((errorReportUrl != null) && (exception != null))
                        {
                            Exception innerMostException = this.GetInnerMostException(exception);
                            linkUrl = string.Format("{0}?outer={1}&&inner={2}&&msg={3}", new object[] { errorReportUrl, exception.GetType().ToString(), innerMostException.GetType().ToString(), innerMostException.Message });
                            if (linkUrl.Length > 0x800)
                            {
                                linkUrl = linkUrl.Substring(0, 0x800);
                            }
                        }
                        interface2.ShowError(Resources.GetString("UI_MaintenceErrorTitle"), Resources.GetString(strArray[3]), logFilePath, linkUrl, linkUrlMessage);
                    }
                    Logger.EndCurrentThreadLogging();
                }
            }
        }