private bool EnsureXmlObject(bool forceCreateDefaultObject) { bool result = false; string text = null; if (this.configXmlDoc != null) { result = true; } else { if (string.IsNullOrEmpty(this.encodedRawConfig) || !AdfsAuthenticationConfig.TryDecode(this.encodedRawConfig, out text)) { if (!forceCreateDefaultObject) { return(result); } } try { this.configXmlDoc = new SafeXmlDocument(); this.configXmlDoc.LoadXml(string.IsNullOrEmpty(text) ? "<service> <federatedAuthentication> <wsFederation passiveRedirectEnabled=\"true\" issuer=\"\" realm=\"https://fakerealm/\" requireHttps=\"true\" /> <cookieHandler requireSsl=\"true\" path=\"/\" /> </federatedAuthentication> <certificateValidation certificateValidationMode=\"PeerOrChainTrust\" /> <audienceUris></audienceUris> <issuerNameRegistry type=\"Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\"> <trustedIssuers></trustedIssuers> </issuerNameRegistry></service>" : text); result = true; } catch (XmlException) { this.configXmlDoc = null; } } return(result); }
internal static bool Validate(string encodedRawConfig) { AdfsAuthenticationConfig adfsAuthenticationConfig = new AdfsAuthenticationConfig(encodedRawConfig); List <ValidationError> list = new List <ValidationError>(); adfsAuthenticationConfig.Validate(list); return(list.Count == 0); }
private static XmlNode GetOrAppendNode(XmlNode parentNode, bool isAttribute, string name, string value = null) { IEnumerable enumerable; if (!isAttribute) { IEnumerable childNodes = parentNode.ChildNodes; enumerable = childNodes; } else { enumerable = parentNode.Attributes; } IEnumerable enumerable2 = enumerable; XmlNode xmlNode = null; using (enumerable2 as IDisposable) { xmlNode = AdfsAuthenticationConfig.SearchNodeByName(enumerable2, name); } if (xmlNode == null) { if (isAttribute) { xmlNode = parentNode.OwnerDocument.CreateAttribute(name); parentNode.Attributes.Append((XmlAttribute)xmlNode); } else { xmlNode = parentNode.OwnerDocument.CreateElement(name); parentNode.AppendChild((XmlElement)xmlNode); } if (isAttribute && value != null) { xmlNode.Value = value; } } return(xmlNode); }