/// <summary>Loads the trusted issuers from configuration.</summary> /// <param name="customConfiguration">The XML that represents the map of trusted issuers that is specified in the configuration file.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="customConfiguration" /> is <see langword="null" />.</exception> /// <exception cref="T:System.InvalidOperationException">The configuration contains one or more elements that are not recognized.</exception> public void LoadCustomConfiguration(XmlNodeList customConfiguration) { if (customConfiguration == null) { throw new ArgumentNullException(nameof(customConfiguration)); } List <XmlElement> xmlElements = Exml.GetXmlElements(customConfiguration); if (xmlElements.Count != 1) { throw new InvalidOperationException("Issuer registry config invalid"); } XmlElement xmlElement1 = xmlElements[0]; if (!StringComparer.Ordinal.Equals(xmlElement1.LocalName, "trustedIssuers")) { throw new InvalidOperationException("trustedIssuers"); } foreach (XmlNode childNode in xmlElement1.ChildNodes) { XmlElement xmlElement2 = childNode as XmlElement; if (xmlElement2 != null) { if (StringComparer.Ordinal.Equals(xmlElement2.LocalName, "add")) { XmlNode namedItem1 = xmlElement2.Attributes.GetNamedItem("thumbprint"); XmlNode namedItem2 = xmlElement2.Attributes.GetNamedItem("name"); if (xmlElement2.Attributes.Count > 2 || namedItem1 == null) { throw new Exception("add thumbprint/name does not match"); } this._configuredTrustedIssuers.Add(namedItem1.Value.Replace(" ", ""), namedItem2 == null || string.IsNullOrEmpty(namedItem2.Value) ? string.Empty : string.Intern(namedItem2.Value)); } else if (StringComparer.Ordinal.Equals(xmlElement2.LocalName, "remove")) { if (xmlElement2.Attributes.Count != 1 || !StringComparer.Ordinal.Equals(xmlElement2.Attributes[0].LocalName, "thumbprint")) { throw new Exception("remove thumbprint deosn't work"); } this._configuredTrustedIssuers.Remove(xmlElement2.Attributes.GetNamedItem("thumbprint").Value.Replace(" ", "")); } else if (StringComparer.Ordinal.Equals(xmlElement2.LocalName, "clear")) { this._configuredTrustedIssuers.Clear(); } else { throw new Exception("unknown element type"); } } } }