public string GetRequest(LogoutRequestFormat format) { using (StringWriter sw = new StringWriter()) { XmlWriterSettings xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; using (XmlWriter xw = XmlWriter.Create(sw, xws)) { xw.WriteStartElement("samlp", "LogoutRequest", "urn:oasis:names:tc:SAML:2.0:protocol"); xw.WriteAttributeString("ID", id); xw.WriteAttributeString("Version", "2.0"); xw.WriteAttributeString("IssueInstant", issue_instant); xw.WriteAttributeString("SingleLogoutServiceUrl", appSettings.singleLogoutServiceUrl); xw.WriteAttributeString("SingleLogoutServiceBinding", "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); xw.WriteStartElement("saml", "Issuer", "urn:oasis:names:tc:SAML:2.0:assertion"); xw.WriteString(appSettings.issuer); xw.WriteEndElement(); xw.WriteStartElement("saml", "NameID", "urn:oasis:names:tc:SAML:2.0:assertion"); xw.WriteAttributeString("Format", "urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified"); xw.WriteString("idp-user"); xw.WriteEndElement(); xw.WriteStartElement("samlp", "SessionIndex", "urn:oasis:names:tc:SAML:2.0:protocol"); xw.WriteString(id); //please check this xw.WriteEndElement(); xw.WriteEndElement(); } if (format == LogoutRequestFormat.Base64) { byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(sw.ToString()); return(System.Convert.ToBase64String(toEncodeAsBytes)); } return(null); } }
public string GetRequest(LogoutRequestFormat format) { using (StringWriter sw = new StringWriter()) { XmlWriterSettings xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; using (XmlWriter xw = XmlWriter.Create(sw, xws)) { xw.WriteStartElement("samlp", "LogoutRequest", "urn:oasis:names:tc:SAML:2.0:protocol"); xw.WriteAttributeString("ID", id); xw.WriteAttributeString("Version", "2.0"); xw.WriteAttributeString("IssueInstant", issue_instant); xw.WriteAttributeString("SingleLogoutServiceUrl", appSettings.singleLogoutServiceUrl); xw.WriteAttributeString("SingleLogoutServiceBinding", "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); xw.WriteStartElement("saml", "Issuer", "urn:oasis:names:tc:SAML:2.0:assertion"); xw.WriteString(appSettings.issuer); xw.WriteEndElement(); xw.WriteStartElement("saml", "NameID", "urn:oasis:names:tc:SAML:2.0:assertion"); xw.WriteAttributeString("Format", "urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified"); xw.WriteString("idp-user"); xw.WriteEndElement(); xw.WriteStartElement("samlp", "SessionIndex", "urn:oasis:names:tc:SAML:2.0:protocol"); xw.WriteString(id); //please check this xw.WriteEndElement(); xw.WriteEndElement(); } if (format == LogoutRequestFormat.Base64) { byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(sw.ToString()); return System.Convert.ToBase64String(toEncodeAsBytes); } return null; } }