private System.Xml.XmlDocument getSecurityHeaderXML(str _username, str _passwordDigest, | |
str _encodedNonce, str _creationDate) | |
{ | |
System.Xml.XmlDocument xDoc; | |
System.Xml.XmlNode xmlRoot; | |
System.Xml.XmlElement securityElement; | |
System.Xml.XmlElement usernameTokenElement; | |
System.Xml.XmlElement usernameElement; | |
System.Xml.XmlElement passwordElement; | |
System.Xml.XmlElement nonceElement; | |
System.Xml.XmlElement createdElement; | |
str username = _username; | |
str passwordDigest = _passwordDigest; | |
str encodedNonce = _encodedNonce; | |
str creationDate = _creationDate; | |
xDoc = new System.Xml.XmlDocument(); | |
xmlRoot = xDoc.CreateElement("root"); | |
xDoc.AppendChild(xmlRoot); | |
usernameTokenElement = xDoc.CreateElement("wsse", "UsernameToken", | |
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); | |
xmlRoot.AppendChild(usernameTokenElement); | |
usernameElement = xDoc.CreateElement("wsse", "Username", | |
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); | |
usernameElement.set_InnerText(username); | |
usernameTokenElement.AppendChild(usernameElement); | |
passwordElement = xDoc.CreateElement("wsse", "Password", | |
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); | |
passwordElement.set_InnerText(passwordDigest); | |
passwordElement.SetAttribute("Type", | |
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-tokenprofile-1.0#PasswordDigest"); | |
usernameTokenElement.AppendChild(passwordElement); | |
nonceElement = xDoc.CreateElement("wsse", "Nonce", | |
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); | |
nonceElement.set_InnerText(encodedNonce); | |
nonceElement.SetAttribute("EncodingType", | |
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-messagesecurity-1.0#Base64Binary"); | |
usernameTokenElement.AppendChild(nonceElement); | |
createdElement = xDoc.CreateElement("wsu", "Created", | |
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); | |
createdElement.set_InnerText(creationDate); | |
usernameTokenElement.AppendChild(createdElement); | |
return xDoc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment