29 using System.Collections;
31 using System.Reflection;
35 using OpenSim.Server.Base;
36 using OpenSim.Server.Handlers.Base;
37 using OpenSim.Services.Interfaces;
38 using OpenSim.Framework;
39 using OpenSim.Framework.Servers.HttpServer;
42 using OpenMetaverse.StructuredData;
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
60 m_LocalService = service;
66 Hashtable requestData = (Hashtable)request.Params[0];
67 if (m_Proxy && request.Params[3] != null)
69 IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]);
75 if (requestData != null)
91 if (requestData.ContainsKey(
"first") && requestData[
"first"] != null &&
92 requestData.ContainsKey(
"last") && requestData[
"last"] != null && (
93 (requestData.ContainsKey(
"passwd") && requestData[
"passwd"] != null) ||
94 (!requestData.ContainsKey(
"passwd") && requestData.ContainsKey(
"web_login_key") && requestData[
"web_login_key"] != null && requestData[
"web_login_key"].ToString() != UUID.Zero.ToString())
97 string first = requestData[
"first"].ToString();
98 string last = requestData[
"last"].ToString();
100 if (requestData.ContainsKey(
"passwd"))
102 passwd = requestData[
"passwd"].ToString();
104 else if (requestData.ContainsKey(
"web_login_key"))
106 passwd =
"$1$" + requestData[
"web_login_key"].ToString();
107 m_log.InfoFormat(
"[LOGIN]: XMLRPC Login Req key {0}", passwd);
109 string startLocation = string.Empty;
110 UUID scopeID = UUID.Zero;
111 if (requestData[
"scope_id"] != null)
112 scopeID =
new UUID(requestData[
"scope_id"].ToString());
113 if (requestData.ContainsKey(
"start"))
114 startLocation = requestData[
"start"].ToString();
116 string clientVersion =
"Unknown";
117 if (requestData.Contains(
"version") && requestData[
"version"] != null)
118 clientVersion = requestData[
"version"].ToString();
121 string channel =
"Unknown";
122 if (requestData.Contains(
"channel") && requestData[
"channel"] != null)
123 channel = requestData[
"channel"].ToString();
125 string mac =
"Unknown";
126 if (requestData.Contains(
"mac") && requestData[
"mac"] != null)
127 mac = requestData[
"mac"].ToString();
129 string id0 =
"Unknown";
130 if (requestData.Contains(
"id0") && requestData[
"id0"] != null)
131 id0 = requestData[
"id0"].ToString();
136 bool LibOMVclient =
false;
137 if (request.Params.Count > 4 && (
string)request.Params[4] ==
"gridproxy")
141 reply = m_LocalService.Login(first, last, passwd, startLocation, scopeID, clientVersion, channel, mac, id0, remoteClient, LibOMVclient);
143 XmlRpcResponse response =
new XmlRpcResponse();
144 response.Value = reply.ToHashtable();
150 return FailedXMLRPCResponse();
155 XmlRpcResponse response =
new XmlRpcResponse();
156 Hashtable resp =
new Hashtable();
158 resp[
"reason"] =
"presence";
159 resp[
"message"] =
"Logins are currently restricted. Please try again later.";
160 resp[
"login"] =
"false";
161 response.Value = resp;
167 Hashtable requestData = (Hashtable)request.Params[0];
169 if (requestData != null)
171 if (requestData.ContainsKey(
"first") && requestData[
"first"] != null &&
172 requestData.ContainsKey(
"last") && requestData[
"last"] != null &&
173 requestData.ContainsKey(
"level") && requestData[
"level"] != null &&
174 requestData.ContainsKey(
"passwd") && requestData[
"passwd"] != null)
176 string first = requestData[
"first"].ToString();
177 string last = requestData[
"last"].ToString();
178 string passwd = requestData[
"passwd"].ToString();
179 int level = Int32.Parse(requestData[
"level"].ToString());
181 m_log.InfoFormat(
"[LOGIN]: XMLRPC Set Level to {2} Requested by {0} {1}", first, last, level);
183 Hashtable reply = m_LocalService.SetLevel(first, last, passwd, level, remoteClient);
185 XmlRpcResponse response =
new XmlRpcResponse();
186 response.Value = reply;
193 XmlRpcResponse failResponse =
new XmlRpcResponse();
194 Hashtable failHash =
new Hashtable();
195 failHash[
"success"] =
"false";
196 failResponse.Value = failHash;
204 if (request.Type == OSDType.Map)
208 if (map.ContainsKey(
"first") && map.ContainsKey(
"last") && map.ContainsKey(
"passwd"))
210 string startLocation = string.Empty;
212 if (map.ContainsKey(
"start"))
213 startLocation = map[
"start"].AsString();
215 UUID scopeID = UUID.Zero;
217 if (map.ContainsKey(
"scope_id"))
218 scopeID =
new UUID(map[
"scope_id"].AsString());
220 m_log.Info(
"[LOGIN]: LLSD Login Requested for: '" + map[
"first"].AsString() +
"' '" + map[
"last"].AsString() +
"' / " + startLocation);
223 reply = m_LocalService.Login(map[
"first"].AsString(), map[
"last"].AsString(), map[
"passwd"].AsString(), startLocation, scopeID,
224 map[
"version"].AsString(), map[
"channel"].AsString(), map[
"mac"].AsString(), map[
"id0"].AsString(), remoteClient,
false);
225 return reply.ToOSDMap();
230 return FailedOSDResponse();
235 sock.MaxPayloadSize = 16384;
236 sock.InitialMsgTimeout = 5000;
237 sock.NoDelay_TCP_Nagle =
true;
239 sock.OnPing += delegate(
object sender,
PingEventArgs pingdata) { sock.Close(
"fail"); };
240 sock.OnPong += delegate(
object sender,
PongEventArgs pongdata) { sock.Close(
"fail"); };
246 request = OSDParser.DeserializeJson(text.Data);
249 sock.SendMessage(OSDParser.SerializeJsonString(FailedOSDResponse()));
253 OSDMap req = request as
OSDMap;
254 string first = req[
"firstname"].AsString();
255 string last = req[
"lastname"].AsString();
256 string passwd = req[
"passwd"].AsString();
257 string start = req[
"startlocation"].AsString();
258 string version = req[
"version"].AsString();
259 string channel = req[
"channel"].AsString();
260 string mac = req[
"mac"].AsString();
261 string id0 = req[
"id0"].AsString();
262 UUID scope = UUID.Zero;
263 IPEndPoint endPoint =
266 reply = m_LocalService.Login(first, last, passwd, start, scope, version,
267 channel, mac, id0, endPoint,
false);
268 sock.SendMessage(OSDParser.SerializeJsonString(reply.ToOSDMap()));
275 sock.SendMessage(OSDParser.SerializeJsonString(FailedOSDResponse()));
279 sock.Close(
"success");
283 sock.HandshakeAndUpgrade();
288 private XmlRpcResponse FailedXMLRPCResponse()
290 Hashtable hash =
new Hashtable();
291 hash[
"reason"] =
"key";
292 hash[
"message"] =
"Incomplete login credentials. Check your username and password.";
293 hash[
"login"] =
"false";
295 XmlRpcResponse response =
new XmlRpcResponse();
296 response.Value = hash;
301 private OSD FailedOSDResponse()
305 map[
"reason"] = OSD.FromString(
"key");
306 map[
"message"] = OSD.FromString(
"Invalid login credentials. Check your username and passwd.");
307 map[
"login"] = OSD.FromString(
"false");
XmlRpcResponse HandleXMLRPCLoginBlocked(XmlRpcRequest request, IPEndPoint client)
This class implements websockets. It grabs the network context from C::Webserver and utilizes it dire...
OpenMetaverse.StructuredData.OSDMap OSDMap
OSD HandleLLSDLogin(OSD request, IPEndPoint remoteClient)
LLLoginHandlers(ILoginService service, bool hasProxy)
XmlRpcResponse HandleXMLRPCSetLoginLevel(XmlRpcRequest request, IPEndPoint remoteClient)
OpenMetaverse.StructuredData.OSD OSD
Interactive OpenSim region server
void HandleWebSocketLoginEvents(string path, WebSocketHttpServerHandler sock)
XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)