private SubscriptionState GetSubscriptionState(string textualSubId) { if (textualSubId == null) { throw new ArgumentNullException("textualSubId", Resources.GetString("Ex_ComArgSubIdentityNull")); } DefinitionIdentity subId; try { subId = new DefinitionIdentity(textualSubId); } catch (COMException ex) { throw new DeploymentException(ExceptionTypes.SubscriptionState, string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1] { (object)textualSubId }), (Exception)ex); } catch (SEHException ex) { throw new DeploymentException(ExceptionTypes.SubscriptionState, string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.GetString("Ex_ComArgSubIdentityNotValid"), new object[1] { (object)textualSubId }), (Exception)ex); } if (subId.Version != (Version)null) { throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_ComArgSubIdentityWithVersion")); } SubscriptionStore currentUser = SubscriptionStore.CurrentUser; currentUser.RefreshStorePointer(); return(currentUser.GetSubscriptionState(subId)); }
/// <summary>Removes a previously installed user-defined component of an application.</summary> /// <param name="subscriptionId">A string that contains a subscription identifier, which indicates the add-in to remove.</param> /// <exception cref="T:System.ArgumentException"> /// <paramref name="subscriptionId" /> is not a valid subscription identity, or does not include a name, public key token, processor architecture, and version number.</exception> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="subscriptionId" /> is null.</exception> public static void UninstallCustomAddIn(string subscriptionId) { DefinitionIdentity subIdAndValidate = InPlaceHostingManager.GetSubIdAndValidate(subscriptionId); SubscriptionStore currentUser = SubscriptionStore.CurrentUser; currentUser.RefreshStorePointer(); SubscriptionState subscriptionState = currentUser.GetSubscriptionState(subIdAndValidate); subscriptionState.SubscriptionStore.UninstallCustomHostSpecifiedSubscription(subscriptionState); }
public static void UninstallCustomUXApplication(string subscriptionId) { DefinitionIdentity subId = null; subId = GetSubIdAndValidate(subscriptionId); SubscriptionStore currentUser = SubscriptionStore.CurrentUser; currentUser.RefreshStorePointer(); SubscriptionState subscriptionState = currentUser.GetSubscriptionState(subId); subscriptionState.SubscriptionStore.UninstallCustomUXSubscription(subscriptionState); }
public static bool FollowDeploymentProviderUri(SubscriptionStore subStore, ref AssemblyManifest deployment, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("FollowDeploymentProviderUri called."); tempFile = null; bool flag = false; Zone zone = Zone.CreateFromUrl(sourceUri.AbsoluteUri); bool flag2 = false; if (zone.SecurityZone != SecurityZone.MyComputer) { Logger.AddInternalState("Deployment manifest zone is not local machine. Zone = " + zone.SecurityZone); flag2 = true; } else { Logger.AddInternalState("Deployment manifest zone is local machine. Zone = " + zone.SecurityZone); DependentAssembly mainDependentAssembly = deployment.MainDependentAssembly; if ((mainDependentAssembly == null) || (mainDependentAssembly.Codebase == null)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } Uri uri = new Uri(sourceUri, mainDependentAssembly.Codebase); Zone zone2 = Zone.CreateFromUrl(uri.AbsoluteUri); if (zone2.SecurityZone == SecurityZone.MyComputer) { Logger.AddInternalState("Application manifest zone is local machine. Zone = " + zone2.SecurityZone); if (!System.IO.File.Exists(uri.LocalPath)) { Logger.AddInternalState(uri.LocalPath + " does not exist in local machine."); flag2 = true; } } } if (flag2) { Uri providerCodebaseUri = deployment.Deployment.ProviderCodebaseUri; Logger.SetDeploymentProviderUrl(providerCodebaseUri); Logger.AddInternalState(string.Concat(new object[] { "providerUri=", providerCodebaseUri, ",sourceUri=", sourceUri })); if ((!PolicyKeys.SkipDeploymentProvider() && (providerCodebaseUri != null)) && !providerCodebaseUri.Equals(sourceUri)) { ServerInformation information; AssemblyManifest manifest = null; try { manifest = DownloadDeploymentManifestDirect(subStore, ref providerCodebaseUri, out tempFile, notification, options, out information); } catch (InvalidDeploymentException exception) { if (((exception.SubType != ExceptionTypes.Manifest) && (exception.SubType != ExceptionTypes.ManifestLoad)) && ((exception.SubType != ExceptionTypes.ManifestParse) && (exception.SubType != ExceptionTypes.ManifestSemanticValidation))) { throw; } throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_InvalidProviderManifest"), exception); } Logger.SetDeploymentProviderServerInformation(information); SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment); if (!subStore.GetSubscriptionState(manifest).SubscriptionId.Equals(subscriptionState.SubscriptionId)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_ProviderNotInSubscription")); } Logger.AddInternalState("Deployment provider followed: " + providerCodebaseUri); deployment = manifest; sourceUri = providerCodebaseUri; flag = true; } } if (!flag) { Logger.AddInternalState("Deployment provider not followed."); } return flag; }
private static AssemblyManifest 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; }
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); }
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); }
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); }