public XmlDocument CreateMessage(SamlOptions options, SamlLogoutRequestMessage message) { var doc = new XmlDocument(); var logoutRequestElement = doc.CreateElement(SamlAuthenticationDefaults.SamlProtocolNsPrefix, "LogoutRequest", SamlAuthenticationDefaults.SamlProtocolNamespace); SamlXmlExtensions.PropagateStandardElements(logoutRequestElement, message); var nameIdElement = doc.CreateElement(SamlAuthenticationDefaults.SamlAssertionNsPrefix, "NameID", SamlAuthenticationDefaults.SamlAssertionNamespace); nameIdElement.InnerText = message.NameId; var sessionIndexElement = doc.CreateElement(SamlAuthenticationDefaults.SamlProtocolNsPrefix, "SessionIndex", SamlAuthenticationDefaults.SamlProtocolNamespace); sessionIndexElement.InnerText = message.SessionIndex; logoutRequestElement.AppendChild(nameIdElement); logoutRequestElement.AppendChild(sessionIndexElement); doc.AppendChild(logoutRequestElement); if (options.SignOutgoingMessages) { SamlXmlExtensions.SignElement(logoutRequestElement, options); } return(doc); }
public XmlDocument CreateMessage(SamlOptions options, SamlLogoutResponseMessage message) { var doc = new XmlDocument(); var logoutResponseElement = doc.CreateElement(SamlAuthenticationDefaults.SamlProtocolNsPrefix, "LogoutResponse", SamlAuthenticationDefaults.SamlProtocolNamespace); SamlXmlExtensions.PropagateStandardElements(logoutResponseElement, message); if (message.InResponseTo != null) { logoutResponseElement.SetAttribute("InResponseTo", message.InResponseTo); } var statusvalue = (message.Success) ? "urn:oasis:names:tc:SAML:2.0:status:Success" : "urn:oasis:names:tc:SAML:2.0:status:Responder"; var statusElement = doc.CreateElement(SamlAuthenticationDefaults.SamlProtocolNsPrefix, "Status", SamlAuthenticationDefaults.SamlProtocolNamespace); var statusCodeElement = doc.CreateElement(SamlAuthenticationDefaults.SamlProtocolNsPrefix, "StatusCode", SamlAuthenticationDefaults.SamlProtocolNamespace); statusCodeElement.SetAttribute("Value", statusvalue); statusElement.AppendChild(statusCodeElement); logoutResponseElement.AppendChild(statusElement); doc.AppendChild(logoutResponseElement); if (options.SignOutgoingMessages) { SamlXmlExtensions.SignElement(logoutResponseElement, options); } return(doc); }
public XmlDocument CreateMessage(SamlOptions options, SamlAuthnRequestMessage authnRequestMessage) { var doc = new XmlDocument(); var authnRequestElement = doc.CreateElement(SamlAuthenticationDefaults.SamlProtocolNsPrefix, "AuthnRequest", SamlAuthenticationDefaults.SamlProtocolNamespace); SamlXmlExtensions.PropagateStandardElements(authnRequestElement, authnRequestMessage); authnRequestElement.SetAttribute("AssertionConsumerServiceURL", authnRequestMessage.AssertionConsumerServiceUrl); doc.AppendChild(authnRequestElement); if (options.SignOutgoingMessages) { SamlXmlExtensions.SignElement(authnRequestElement, options); } return(doc); }