From 2f624800d37bae36cecf1bff191b646d59d86746 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Sep 2009 18:06:25 +0100 Subject: Adding the deserializer for server form/xml replies --- OpenSim/Server/Base/ServerUtils.cs | 42 ++++++++++++++++++++++ .../AuthenticationServerPostHandler.cs | 6 ++-- .../AuthenticationServiceConnector.cs | 12 +++++++ 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index ae7ec0f..6c2b3ed 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -255,5 +255,47 @@ namespace OpenSim.Server.Base parent.AppendChild(elem); } } + + public static Dictionary ParseXmlResponse(string data) + { + Dictionary ret = new Dictionary(); + + 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 ParseElement(XmlNode element) + { + Dictionary ret = new Dictionary(); + + 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; + } } } diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 6cf7d56..490a13a 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs @@ -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); diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs index 053d27c..35f96a1 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs @@ -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 sendData = new Dictionary(); + 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; } -- cgit v1.1