Adding the deserializer for server form/xml replies

remotes/origin/0.6.7-post-fixes
Melanie 2009-09-19 18:06:25 +01:00
parent 2d9d25b367
commit 2f624800d3
3 changed files with 57 additions and 3 deletions

View File

@ -255,5 +255,47 @@ namespace OpenSim.Server.Base
parent.AppendChild(elem);
}
}
public static Dictionary<string, object> ParseXmlResponse(string data)
{
Dictionary<string, object> ret = new Dictionary<string, object>();
XmlDocument doc = new XmlDocument();
doc.LoadXml(data);
XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse");
if (rootL.Count != 1)
return ret;
XmlNode rootNode = rootL[0];
ret = ParseElement(rootNode);
return ret;
}
private static Dictionary<string, object> ParseElement(XmlNode element)
{
Dictionary<string, object> ret = new Dictionary<string, object>();
XmlNodeList partL = element.ChildNodes;
foreach (XmlNode part in partL)
{
XmlNode type = part.Attributes.GetNamedItem("Type");
if (type == null || type.Value != "List")
{
ret[part.Name] = part.InnerText;
}
else
{
ret[part.Name] = ParseElement(part);
}
}
return ret;
}
}
}

View File

@ -157,7 +157,7 @@ namespace OpenSim.Server.Handlers.Authentication
doc.AppendChild(xmlnode);
XmlElement rootElement = doc.CreateElement("", "Authentication",
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
"");
doc.AppendChild(rootElement);
@ -179,7 +179,7 @@ namespace OpenSim.Server.Handlers.Authentication
doc.AppendChild(xmlnode);
XmlElement rootElement = doc.CreateElement("", "Authentication",
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
"");
doc.AppendChild(rootElement);
@ -201,7 +201,7 @@ namespace OpenSim.Server.Handlers.Authentication
doc.AppendChild(xmlnode);
XmlElement rootElement = doc.CreateElement("", "Authentication",
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
"");
doc.AppendChild(rootElement);

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
using OpenMetaverse;
namespace OpenSim.Services.Connectors
@ -83,6 +84,17 @@ namespace OpenSim.Services.Connectors
public string Authenticate(UUID principalID, string password, int lifetime)
{
Dictionary<string, string> sendData = new Dictionary<string, string>();
sendData["LIFETIME"] = lifetime.ToString();
sendData["PRINCIPAL"] = principalID.ToString();
sendData["PASSWORD"] = password;
sendData["METHOD"] = "authenticate";
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/auth/plain",
ServerUtils.BuildQueryString(sendData));
return String.Empty;
}