private static SamlDetail ExtractInformation(XmlDocument doc)
{
var detail = new SamlDetail();
var conditionsElement = doc.SelectSingleNode("//*[local-name()='Conditions']");
if (conditionsElement != null)
{
detail.NotBefore = XmlConvert.ToDateTime(conditionsElement.Attributes["NotBefore"].Value, XmlDateTimeSerializationMode.Utc);
detail.NotOnOrAfter = XmlConvert.ToDateTime(conditionsElement.Attributes["NotOnOrAfter"].Value, XmlDateTimeSerializationMode.Utc);
}
var nameIdElement = doc.SelectSingleNode("//*[local-name()='Subject']/*[local-name()='NameID']");
if (nameIdElement == null)
{
ThrowAndLog("NameID Claim Policy not configured correctly.");
}
detail.SubjectNameId = nameIdElement.InnerText;
var issuerElement = doc.SelectSingleNode("//*[local-name()='Issuer']");
detail.Issuer = issuerElement.InnerText;
var audienceElements = doc.SelectNodes("//*[local-name()='Conditions']/*[local-name()='AudienceRestriction']/*[local-name()='Audience']");
detail.AudienceRestrictions = new List<string>();
if (audienceElements != null)
{
foreach (var audienceElement in audienceElements)
detail.AudienceRestrictions.Add(((XmlNode)audienceElement).InnerText);
}
return detail;
}