protected override XmlDocument WindowsLiveIdMethod(LiveIdInstanceType liveIdInstanceType) { XmlDocument xmlDocument = null; using (AppIDServiceAPISoapServer appIDServiceAPISoapServer = LiveServicesHelper.ConnectToAppIDService(liveIdInstanceType)) { base.WriteVerbose(Strings.AppIDServiceUrl(appIDServiceAPISoapServer.Url.ToString())); if (!string.IsNullOrEmpty(this.Uri)) { new Uri(this.Uri, UriKind.RelativeOrAbsolute); string text = string.Format(GetWindowsLiveIdApplicationIdentity.AppIDFindTemplate, this.Uri); string xml = appIDServiceAPISoapServer.FindApplication(text); XmlDocument xmlDocument2 = new SafeXmlDocument(); xmlDocument2.LoadXml(xml); XmlNode xmlNode = xmlDocument2.SelectSingleNode("AppidData/Application/ID"); if (xmlNode == null) { base.WriteVerbose(Strings.AppIdElementIsEmpty); throw new LiveServicesException(Strings.AppIdElementIsEmpty); } base.WriteVerbose(Strings.FoundAppId(xmlNode.InnerText)); this.AppId = xmlNode.InnerText; } if (!string.IsNullOrEmpty(this.AppId)) { xmlDocument = new SafeXmlDocument(); xmlDocument.LoadXml(appIDServiceAPISoapServer.GetApplicationEntity(new tagPASSID(), this.AppId)); } } return(xmlDocument); }
internal static WindowsLiveIdNamespace ParseXml(LiveIdInstanceType liveIdInstanceType, XmlDocument xml) { WindowsLiveIdNamespace windowsLiveIdNamespace = new WindowsLiveIdNamespace(); windowsLiveIdNamespace.InstanceType = liveIdInstanceType; XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xml.NameTable); LiveServicesHelper.AddNamespaces(xml, xmlNamespaceManager); XmlNode xmlNode = xml.SelectSingleNode("p:Namespace/p:name", xmlNamespaceManager); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdNamespace.Name = xmlNode.InnerText; } xmlNode = xml.SelectSingleNode("p:Namespace/p:ID", xmlNamespaceManager); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdNamespace.propertyBag[SimpleProviderObjectSchema.Identity] = new WindowsLiveIdIdentity(xmlNode.InnerText); windowsLiveIdNamespace.ID = xmlNode.InnerText; } xmlNode = xml.SelectSingleNode(WindowsLiveIdNamespace.GetPropertyXPath("SiteID"), xmlNamespaceManager); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdNamespace.SiteID = xmlNode.InnerText; } xmlNode = xml.SelectSingleNode(WindowsLiveIdNamespace.GetPropertyXPath("AppID"), xmlNamespaceManager); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdNamespace.AppID = xmlNode.InnerText; } xmlNode = xml.SelectSingleNode(WindowsLiveIdNamespace.GetPropertyXPath("URI"), xmlNamespaceManager); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { Uri uri = null; if (Uri.TryCreate(xmlNode.InnerText, UriKind.RelativeOrAbsolute, out uri)) { windowsLiveIdNamespace.Uri = uri; } } xmlNode = xml.SelectSingleNode(WindowsLiveIdNamespace.GetPropertyXPath("Certificate"), xmlNamespaceManager); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdNamespace.Certificate = WindowsLiveIdApplicationCertificate.CertificateFromBase64(xmlNode.InnerText); } xmlNode = xml.SelectSingleNode(WindowsLiveIdNamespace.GetPropertyXPath("NextCertificate"), xmlNamespaceManager); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdNamespace.NextCertificate = WindowsLiveIdApplicationCertificate.CertificateFromBase64(xmlNode.InnerText); } windowsLiveIdNamespace.RawXml = xml.DocumentElement.InnerXml; return(windowsLiveIdNamespace); }
protected override XmlDocument WindowsLiveIdMethod(LiveIdInstanceType liveIdInstanceType) { XmlDocument xmlDocument = null; using (NamespaceServiceAPISoapServer namespaceServiceAPISoapServer = LiveServicesHelper.ConnectToNamespaceService(liveIdInstanceType)) { base.WriteVerbose(Strings.NamespaceServiceUrl(namespaceServiceAPISoapServer.Url.ToString())); string namespaceAttributes = namespaceServiceAPISoapServer.GetNamespaceAttributes(this.Namespace, string.Empty); xmlDocument = new SafeXmlDocument(); xmlDocument.LoadXml(namespaceAttributes); } return(xmlDocument); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); foreach (object obj in Enum.GetValues(typeof(LiveIdInstanceType))) { LiveIdInstanceType liveIdInstanceType = (LiveIdInstanceType)obj; XmlDocument xmlDocument = null; if (this.TryExecuteWebMethod(liveIdInstanceType, out xmlDocument) && xmlDocument != null) { base.WriteObject(this.ParseResponse(liveIdInstanceType, xmlDocument)); } } TaskLogger.LogExit(); }
internal bool TryExecuteWebMethod(LiveIdInstanceType liveIdInstanceType, out XmlDocument xmlDocument) { bool result = false; xmlDocument = null; try { xmlDocument = this.WindowsLiveIdMethod(liveIdInstanceType); result = true; } catch (UriFormatException exception) { this.LogError(exception, ErrorCategory.InvalidArgument); } catch (XmlException exception2) { this.LogError(exception2, ErrorCategory.InvalidResult); } catch (SoapException ex) { if (!ex.Detail.InnerText.Contains("0x80045a64") && !ex.Detail.InnerText.Contains("0x80048163")) { this.LogError(ex, ErrorCategory.InvalidOperation); } } catch (WebException exception3) { this.LogError(exception3, ErrorCategory.InvalidOperation); } catch (LiveServicesHelperConfigException exception4) { this.LogError(exception4, ErrorCategory.MetadataError); } catch (LiveServicesException exception5) { this.LogError(exception5, ErrorCategory.MetadataError); } catch (XPathException exception6) { this.LogError(exception6, ErrorCategory.InvalidResult); } return(result); }
private void UpdateRpsServerConfig(string xmlConfigFile, string xmlTargetFile, string certificateName, LiveIdInstanceType instance, TargetEnvironment environment, string proxy, uint siteId, string siteName, uint accrualSiteId, string accrualSiteName, string rpsNetworkProd, string rpsNetworkInt, string internalSiteName, string o365SiteName) { base.WriteVerbose(Strings.AboutToUpdateCongigFile(xmlConfigFile, siteId.ToString())); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(xmlConfigFile); XmlElement documentElement = xmlDocument.DocumentElement; try { string text = "/RPSServer/CryptoParams/CryptoEncCertName"; XmlNode xmlNode = documentElement.SelectSingleNode(text); if (xmlNode == null) { throw new XmlMissingElementException(new LocalizedString(text)); } xmlNode.InnerText = certificateName; text = "/RPSServer/CryptoParams/CryptoSignCertName"; xmlNode = documentElement.SelectSingleNode(text); if (xmlNode == null) { throw new XmlMissingElementException(new LocalizedString(text)); } xmlNode.InnerText = certificateName; if (!string.IsNullOrEmpty(rpsNetworkProd)) { text = "/RPSServer/Environment/Production"; xmlNode = documentElement.SelectSingleNode(text); if (xmlNode == null) { throw new XmlMissingElementException(new LocalizedString(text)); } xmlNode.InnerText = rpsNetworkProd; } if (!string.IsNullOrEmpty(rpsNetworkInt)) { text = "/RPSServer/Environment/INT"; xmlNode = documentElement.SelectSingleNode(text); if (xmlNode == null) { throw new XmlMissingElementException(new LocalizedString(text)); } xmlNode.InnerText = rpsNetworkInt; } text = "/RPSServer/NetworkServices/Url"; xmlNode = documentElement.SelectSingleNode(text); if (xmlNode == null) { throw new XmlMissingElementException(new LocalizedString(text)); } switch (environment) { case TargetEnvironment.Integration: if (string.IsNullOrEmpty(rpsNetworkInt)) { xmlNode.InnerText = xmlNode.InnerText.Replace("-ppe", "-int"); } else { xmlNode.InnerText = rpsNetworkInt; } break; case TargetEnvironment.Production: if (string.IsNullOrEmpty(rpsNetworkProd)) { xmlNode.InnerText = xmlNode.InnerText.Replace("-ppe", ""); } else { xmlNode.InnerText = rpsNetworkProd; } break; } text = "/RPSServer/NetworkServices/Proxy"; xmlNode = documentElement.SelectSingleNode(text); if (xmlNode == null) { throw new XmlMissingElementException(new LocalizedString(text)); } if (!string.IsNullOrEmpty(proxy)) { xmlNode.InnerText = proxy; } else { xmlNode.InnerText = ""; } xmlNode = null; XmlNode xmlNode2 = null; XmlNode xmlNode3 = null; List <XmlNode> list = new List <XmlNode>(2); text = "/RPSServer/Sites/Site"; using (XmlNodeList xmlNodeList = documentElement.SelectNodes(text)) { if (xmlNodeList == null) { throw new XmlMissingElementException(new LocalizedString(text)); } foreach (object obj in xmlNodeList) { XmlElement xmlElement = (XmlElement)obj; xmlNode2 = xmlElement; string text2 = xmlElement.GetAttribute("SiteName"); if (text2 != null) { text2 = text2.Trim(); if (text2 != null && text2.Equals("default")) { xmlNode3 = xmlElement; } else { switch (environment) { case TargetEnvironment.Integration: if (text2.IndexOf("INT") == -1) { list.Add(xmlElement); } else { xmlNode = xmlElement; } break; case TargetEnvironment.Preproduction: if (text2.IndexOf("PPE") == -1) { list.Add(xmlElement); } else { xmlNode = xmlElement; } break; case TargetEnvironment.Production: if (text2.IndexOf("PRODUCTION") == -1) { list.Add(xmlElement); } else { xmlNode = xmlElement; } break; } } } } } if (xmlNode != null) { xmlNode2 = xmlNode; } xmlNode = documentElement.SelectSingleNode("/RPSServer/Sites"); foreach (XmlNode oldChild in list) { xmlNode.RemoveChild(oldChild); } xmlNode = xmlNode2; this.UpdateSiteInformation(xmlNode, certificateName, siteId, siteName, "https://" + siteName + "/owa", siteName, siteName, siteName); if (xmlNode3 == null) { throw new XmlMissingElementException(new LocalizedString("/RPSServer/Sites/Site/")); } this.UpdateSiteInformation(xmlNode3, certificateName, siteId, "default", "", "", "", ""); if (instance == LiveIdInstanceType.Consumer) { XmlNode xmlNode4 = xmlNode.Clone(); this.UpdateSiteInformation(xmlNode4, certificateName, accrualSiteId, accrualSiteName, "https://" + accrualSiteName + "/owa", siteName, siteName, siteName); documentElement.SelectSingleNode("/RPSServer/Sites").AppendChild(xmlNode4); } if (!string.IsNullOrEmpty(internalSiteName)) { XmlNode xmlNode5 = xmlNode.Clone(); this.UpdateSiteInformation(xmlNode5, certificateName, siteId, internalSiteName, "https://" + internalSiteName + "/owa", internalSiteName, internalSiteName, internalSiteName); documentElement.SelectSingleNode("/RPSServer/Sites").AppendChild(xmlNode5); } if (!string.IsNullOrEmpty(o365SiteName)) { XmlNode xmlNode6 = xmlNode.Clone(); this.UpdateSiteInformation(xmlNode6, certificateName, siteId, o365SiteName, "https://" + o365SiteName + "/owa", o365SiteName, o365SiteName, o365SiteName); documentElement.SelectSingleNode("/RPSServer/Sites").AppendChild(xmlNode6); } xmlDocument.Save(xmlTargetFile); } catch (XmlMissingElementException ex) { base.WriteError(new ArgumentException(Strings.CannotFindXPath(xmlConfigFile, ex.Message)), ErrorCategory.InvalidArgument, null); } }
internal static WindowsLiveIdApplicationIdentity ParseXml(LiveIdInstanceType liveIdInstanceType, XmlDocument xml) { WindowsLiveIdApplicationIdentity windowsLiveIdApplicationIdentity = new WindowsLiveIdApplicationIdentity(); windowsLiveIdApplicationIdentity.InstanceType = liveIdInstanceType; XmlNode xmlNode = xml.SelectSingleNode("AppidData/Application/Name"); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdApplicationIdentity.Name = xmlNode.InnerText; } xmlNode = xml.SelectSingleNode("AppidData/Application/ID"); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdApplicationIdentity.propertyBag[SimpleProviderObjectSchema.Identity] = new WindowsLiveIdIdentity(xmlNode.InnerText); windowsLiveIdApplicationIdentity.Id = xmlNode.InnerText; } xmlNode = xml.SelectSingleNode(WindowsLiveIdApplicationIdentity.GetPropertyXPath("Status")); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { windowsLiveIdApplicationIdentity.Status = xmlNode.InnerText; } using (XmlNodeList xmlNodeList = xml.SelectNodes("AppidData/Application/URIs/URI/URIAddress")) { if (xmlNodeList != null) { foreach (object obj in xmlNodeList) { XmlNode xmlNode2 = (XmlNode)obj; if (!string.IsNullOrEmpty(xmlNode2.InnerText)) { Uri item = null; if (Uri.TryCreate(xmlNode2.InnerText, UriKind.RelativeOrAbsolute, out item)) { windowsLiveIdApplicationIdentity.UriCollection.Add(item); } } } } } using (XmlNodeList xmlNodeList2 = xml.SelectNodes("AppidData/Application/Certificates/Certificate")) { if (xmlNodeList2 != null) { foreach (object obj2 in xmlNodeList2) { XmlNode xmlNode3 = (XmlNode)obj2; string name = string.Empty; X509Certificate2 x509Certificate = null; bool isCurrent = false; XmlNode xmlNode4 = xmlNode3.SelectSingleNode("CertificateName"); if (xmlNode4 != null) { name = xmlNode4.InnerText; } xmlNode4 = xmlNode3.SelectSingleNode("CertificateData"); if (xmlNode4 != null && !string.IsNullOrEmpty(xmlNode4.InnerText)) { x509Certificate = WindowsLiveIdApplicationCertificate.CertificateFromBase64(xmlNode4.InnerText); } xmlNode4 = xmlNode3.SelectSingleNode("CertificateIsCurrent"); if (xmlNode4 != null && !string.IsNullOrEmpty(xmlNode4.InnerText) && !bool.TryParse(xmlNode4.InnerText, out isCurrent)) { isCurrent = false; } if (x509Certificate != null) { windowsLiveIdApplicationIdentity.CertificateCollection.Add(new WindowsLiveIdApplicationCertificate(name, isCurrent, x509Certificate)); } } } } xmlNode = xml.SelectSingleNode(WindowsLiveIdApplicationIdentity.GetPropertyXPath("Key")); if (xmlNode != null && !string.IsNullOrEmpty(xmlNode.InnerText)) { xmlNode.InnerText = "*****"; } windowsLiveIdApplicationIdentity.RawXml = xml.DocumentElement.InnerXml; return(windowsLiveIdApplicationIdentity); }
protected override ConfigurableObject ParseResponse(LiveIdInstanceType liveIdInstanceType, XmlDocument xmlResponse) { return(WindowsLiveIdApplicationIdentity.ParseXml(liveIdInstanceType, xmlResponse)); }
protected abstract ConfigurableObject ParseResponse(LiveIdInstanceType liveIdInstanceType, XmlDocument xmlResponse);
protected abstract XmlDocument WindowsLiveIdMethod(LiveIdInstanceType liveIdInstanceType);
protected override ConfigurableObject ParseResponse(LiveIdInstanceType liveIdInstanceType, XmlDocument xmlResponse) { return(WindowsLiveIdNamespace.ParseXml(liveIdInstanceType, xmlResponse)); }