aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs16
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs421
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs242
-rw-r--r--OpenSim/Services/Connectors/User/UserServiceConnector.cs114
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs274
-rw-r--r--OpenSim/Services/Interfaces/ILoginService.cs (renamed from OpenSim/Services/UserService/UserService.cs)56
-rw-r--r--OpenSim/Services/Interfaces/IPresenceService.cs68
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs10
-rw-r--r--OpenSim/Services/Interfaces/IUserAccountService.cs (renamed from OpenSim/Services/Interfaces/IUserService.cs)84
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs740
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs274
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs146
-rw-r--r--OpenSim/Services/PresenceService/PresenceServiceBase.cs2
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs184
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountServiceBase.cs (renamed from OpenSim/Services/UserService/UserServiceBase.cs)19
16 files changed, 2422 insertions, 234 deletions
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
index 50e817e..19bb3e2 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Services.Connectors
84 84
85 public string Authenticate(UUID principalID, string password, int lifetime) 85 public string Authenticate(UUID principalID, string password, int lifetime)
86 { 86 {
87 Dictionary<string, string> sendData = new Dictionary<string, string>(); 87 Dictionary<string, object> sendData = new Dictionary<string, object>();
88 sendData["LIFETIME"] = lifetime.ToString(); 88 sendData["LIFETIME"] = lifetime.ToString();
89 sendData["PRINCIPAL"] = principalID.ToString(); 89 sendData["PRINCIPAL"] = principalID.ToString();
90 sendData["PASSWORD"] = password; 90 sendData["PASSWORD"] = password;
@@ -106,7 +106,7 @@ namespace OpenSim.Services.Connectors
106 106
107 public bool Verify(UUID principalID, string token, int lifetime) 107 public bool Verify(UUID principalID, string token, int lifetime)
108 { 108 {
109 Dictionary<string, string> sendData = new Dictionary<string, string>(); 109 Dictionary<string, object> sendData = new Dictionary<string, object>();
110 sendData["LIFETIME"] = lifetime.ToString(); 110 sendData["LIFETIME"] = lifetime.ToString();
111 sendData["PRINCIPAL"] = principalID.ToString(); 111 sendData["PRINCIPAL"] = principalID.ToString();
112 sendData["TOKEN"] = token; 112 sendData["TOKEN"] = token;
@@ -128,7 +128,7 @@ namespace OpenSim.Services.Connectors
128 128
129 public bool Release(UUID principalID, string token) 129 public bool Release(UUID principalID, string token)
130 { 130 {
131 Dictionary<string, string> sendData = new Dictionary<string, string>(); 131 Dictionary<string, object> sendData = new Dictionary<string, object>();
132 sendData["PRINCIPAL"] = principalID.ToString(); 132 sendData["PRINCIPAL"] = principalID.ToString();
133 sendData["TOKEN"] = token; 133 sendData["TOKEN"] = token;
134 134
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index 02f2b79..99aa3fb 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -89,7 +89,7 @@ namespace OpenSim.Services.Connectors
89 public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) 89 public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
90 { 90 {
91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); 91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
92 Dictionary<string, string> sendData = new Dictionary<string,string>(); 92 Dictionary<string, object> sendData = new Dictionary<string,object>();
93 foreach (KeyValuePair<string, object> kvp in rinfo) 93 foreach (KeyValuePair<string, object> kvp in rinfo)
94 sendData[kvp.Key] = (string)kvp.Value; 94 sendData[kvp.Key] = (string)kvp.Value;
95 95
@@ -130,7 +130,7 @@ namespace OpenSim.Services.Connectors
130 130
131 public virtual bool DeregisterRegion(UUID regionID) 131 public virtual bool DeregisterRegion(UUID regionID)
132 { 132 {
133 Dictionary<string, string> sendData = new Dictionary<string, string>(); 133 Dictionary<string, object> sendData = new Dictionary<string, object>();
134 134
135 sendData["REGIONID"] = regionID.ToString(); 135 sendData["REGIONID"] = regionID.ToString();
136 136
@@ -162,7 +162,7 @@ namespace OpenSim.Services.Connectors
162 162
163 public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) 163 public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
164 { 164 {
165 Dictionary<string, string> sendData = new Dictionary<string, string>(); 165 Dictionary<string, object> sendData = new Dictionary<string, object>();
166 166
167 sendData["SCOPEID"] = scopeID.ToString(); 167 sendData["SCOPEID"] = scopeID.ToString();
168 sendData["REGIONID"] = regionID.ToString(); 168 sendData["REGIONID"] = regionID.ToString();
@@ -212,7 +212,7 @@ namespace OpenSim.Services.Connectors
212 212
213 public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 213 public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
214 { 214 {
215 Dictionary<string, string> sendData = new Dictionary<string, string>(); 215 Dictionary<string, object> sendData = new Dictionary<string, object>();
216 216
217 sendData["SCOPEID"] = scopeID.ToString(); 217 sendData["SCOPEID"] = scopeID.ToString();
218 sendData["REGIONID"] = regionID.ToString(); 218 sendData["REGIONID"] = regionID.ToString();
@@ -258,7 +258,7 @@ namespace OpenSim.Services.Connectors
258 258
259 public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 259 public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
260 { 260 {
261 Dictionary<string, string> sendData = new Dictionary<string, string>(); 261 Dictionary<string, object> sendData = new Dictionary<string, object>();
262 262
263 sendData["SCOPEID"] = scopeID.ToString(); 263 sendData["SCOPEID"] = scopeID.ToString();
264 sendData["X"] = x.ToString(); 264 sendData["X"] = x.ToString();
@@ -303,7 +303,7 @@ namespace OpenSim.Services.Connectors
303 303
304 public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) 304 public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
305 { 305 {
306 Dictionary<string, string> sendData = new Dictionary<string, string>(); 306 Dictionary<string, object> sendData = new Dictionary<string, object>();
307 307
308 sendData["SCOPEID"] = scopeID.ToString(); 308 sendData["SCOPEID"] = scopeID.ToString();
309 sendData["NAME"] = regionName; 309 sendData["NAME"] = regionName;
@@ -344,7 +344,7 @@ namespace OpenSim.Services.Connectors
344 344
345 public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) 345 public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
346 { 346 {
347 Dictionary<string, string> sendData = new Dictionary<string, string>(); 347 Dictionary<string, object> sendData = new Dictionary<string, object>();
348 348
349 sendData["SCOPEID"] = scopeID.ToString(); 349 sendData["SCOPEID"] = scopeID.ToString();
350 sendData["NAME"] = name; 350 sendData["NAME"] = name;
@@ -396,7 +396,7 @@ namespace OpenSim.Services.Connectors
396 396
397 public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 397 public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
398 { 398 {
399 Dictionary<string, string> sendData = new Dictionary<string, string>(); 399 Dictionary<string, object> sendData = new Dictionary<string, object>();
400 400
401 sendData["SCOPEID"] = scopeID.ToString(); 401 sendData["SCOPEID"] = scopeID.ToString();
402 sendData["XMIN"] = xmin.ToString(); 402 sendData["XMIN"] = xmin.ToString();
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
new file mode 100644
index 0000000..29cfd6e
--- /dev/null
+++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
@@ -0,0 +1,421 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base;
40using OpenMetaverse;
41
42namespace OpenSim.Services.Connectors
43{
44 public class PresenceServicesConnector : IPresenceService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private string m_ServerURI = String.Empty;
51
52 public PresenceServicesConnector()
53 {
54 }
55
56 public PresenceServicesConnector(string serverURI)
57 {
58 m_ServerURI = serverURI.TrimEnd('/');
59 }
60
61 public PresenceServicesConnector(IConfigSource source)
62 {
63 Initialise(source);
64 }
65
66 public virtual void Initialise(IConfigSource source)
67 {
68 IConfig gridConfig = source.Configs["PresenceService"];
69 if (gridConfig == null)
70 {
71 m_log.Error("[PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini");
72 throw new Exception("Presence connector init error");
73 }
74
75 string serviceURI = gridConfig.GetString("PresenceServerURI",
76 String.Empty);
77
78 if (serviceURI == String.Empty)
79 {
80 m_log.Error("[PRESENCE CONNECTOR]: No Server URI named in section PresenceService");
81 throw new Exception("Presence connector init error");
82 }
83 m_ServerURI = serviceURI;
84 }
85
86
87 #region IPresenceService
88
89 public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID)
90 {
91 Dictionary<string, object> sendData = new Dictionary<string, object>();
92 //sendData["SCOPEID"] = scopeID.ToString();
93 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
94 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
95 sendData["METHOD"] = "login";
96
97 sendData["UserID"] = userID;
98 sendData["SessionID"] = sessionID.ToString();
99 sendData["SecureSessionID"] = secureSessionID.ToString();
100
101 string reqString = ServerUtils.BuildQueryString(sendData);
102 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
103 try
104 {
105 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
106 m_ServerURI + "/presence",
107 reqString);
108 if (reply != string.Empty)
109 {
110 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
111
112 if (replyData.ContainsKey("result"))
113 {
114 if (replyData["result"].ToString().ToLower() == "success")
115 return true;
116 else
117 return false;
118 }
119 else
120 m_log.DebugFormat("[PRESENCE CONNECTOR]: LoginAgent reply data does not contain result field");
121
122 }
123 else
124 m_log.DebugFormat("[PRESENCE CONNECTOR]: LoginAgent received empty reply");
125 }
126 catch (Exception e)
127 {
128 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
129 }
130
131 return false;
132
133 }
134
135 public bool LogoutAgent(UUID sessionID)
136 {
137 Dictionary<string, object> sendData = new Dictionary<string, object>();
138 //sendData["SCOPEID"] = scopeID.ToString();
139 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
140 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
141 sendData["METHOD"] = "logout";
142
143 sendData["SessionID"] = sessionID.ToString();
144
145 string reqString = ServerUtils.BuildQueryString(sendData);
146 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
147 try
148 {
149 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
150 m_ServerURI + "/presence",
151 reqString);
152 if (reply != string.Empty)
153 {
154 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
155
156 if (replyData.ContainsKey("result"))
157 {
158 if (replyData["result"].ToString().ToLower() == "success")
159 return true;
160 else
161 return false;
162 }
163 else
164 m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutAgent reply data does not contain result field");
165
166 }
167 else
168 m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutAgent received empty reply");
169 }
170 catch (Exception e)
171 {
172 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
173 }
174
175 return false;
176 }
177
178 public bool LogoutRegionAgents(UUID regionID)
179 {
180 Dictionary<string, object> sendData = new Dictionary<string, object>();
181 //sendData["SCOPEID"] = scopeID.ToString();
182 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
183 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
184 sendData["METHOD"] = "logoutregion";
185
186 sendData["RegionID"] = regionID.ToString();
187
188 string reqString = ServerUtils.BuildQueryString(sendData);
189 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
190 try
191 {
192 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
193 m_ServerURI + "/presence",
194 reqString);
195 if (reply != string.Empty)
196 {
197 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
198
199 if (replyData.ContainsKey("result"))
200 {
201 if (replyData["result"].ToString().ToLower() == "success")
202 return true;
203 else
204 return false;
205 }
206 else
207 m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutRegionAgents reply data does not contain result field");
208
209 }
210 else
211 m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutRegionAgents received empty reply");
212 }
213 catch (Exception e)
214 {
215 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
216 }
217
218 return false;
219 }
220
221 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
222 {
223 Dictionary<string, object> sendData = new Dictionary<string, object>();
224 //sendData["SCOPEID"] = scopeID.ToString();
225 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
226 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
227 sendData["METHOD"] = "report";
228
229 sendData["SessionID"] = sessionID.ToString();
230 sendData["RegionID"] = regionID.ToString();
231 sendData["position"] = position.ToString();
232 sendData["lookAt"] = lookAt.ToString();
233
234 string reqString = ServerUtils.BuildQueryString(sendData);
235 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
236 try
237 {
238 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
239 m_ServerURI + "/presence",
240 reqString);
241 if (reply != string.Empty)
242 {
243 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
244
245 if (replyData.ContainsKey("result"))
246 {
247 if (replyData["result"].ToString().ToLower() == "success")
248 return true;
249 else
250 return false;
251 }
252 else
253 m_log.DebugFormat("[PRESENCE CONNECTOR]: ReportAgent reply data does not contain result field");
254
255 }
256 else
257 m_log.DebugFormat("[PRESENCE CONNECTOR]: ReportAgent received empty reply");
258 }
259 catch (Exception e)
260 {
261 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
262 }
263
264 return false;
265 }
266
267 public PresenceInfo GetAgent(UUID sessionID)
268 {
269 Dictionary<string, object> sendData = new Dictionary<string, object>();
270 //sendData["SCOPEID"] = scopeID.ToString();
271 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
272 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
273 sendData["METHOD"] = "getagent";
274
275 sendData["SessionID"] = sessionID.ToString();
276
277 string reply = string.Empty;
278 string reqString = ServerUtils.BuildQueryString(sendData);
279 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
280 try
281 {
282 reply = SynchronousRestFormsRequester.MakeRequest("POST",
283 m_ServerURI + "/presence",
284 reqString);
285 if (reply == null || (reply != null && reply == string.Empty))
286 {
287 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply");
288 return null;
289 }
290 }
291 catch (Exception e)
292 {
293 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
294 }
295
296 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
297 PresenceInfo pinfo = null;
298
299 if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
300 {
301 if (replyData["result"] is Dictionary<string, object>)
302 {
303 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
304 }
305 }
306
307 return pinfo;
308 }
309
310 public PresenceInfo[] GetAgents(string[] userIDs)
311 {
312 Dictionary<string, object> sendData = new Dictionary<string, object>();
313 //sendData["SCOPEID"] = scopeID.ToString();
314 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
315 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
316 sendData["METHOD"] = "getagents";
317
318 sendData["uuids"] = new List<string>(userIDs);
319
320 string reply = string.Empty;
321 string reqString = ServerUtils.BuildQueryString(sendData);
322 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
323 try
324 {
325 reply = SynchronousRestFormsRequester.MakeRequest("POST",
326 m_ServerURI + "/presence",
327 reqString);
328 if (reply == null || (reply != null && reply == string.Empty))
329 {
330 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply");
331 return null;
332 }
333 }
334 catch (Exception e)
335 {
336 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
337 }
338
339 List<PresenceInfo> rinfos = new List<PresenceInfo>();
340
341 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
342
343 if (replyData != null)
344 {
345 if (replyData.ContainsKey("result") &&
346 (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
347 {
348 return new PresenceInfo[0];
349 }
350
351 Dictionary<string, object>.ValueCollection pinfosList = replyData.Values;
352 //m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
353 foreach (object presence in pinfosList)
354 {
355 if (presence is Dictionary<string, object>)
356 {
357 PresenceInfo pinfo = new PresenceInfo((Dictionary<string, object>)presence);
358 rinfos.Add(pinfo);
359 }
360 else
361 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received invalid response type {0}",
362 presence.GetType());
363 }
364 }
365 else
366 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received null response");
367
368 return rinfos.ToArray();
369 }
370
371
372 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
373 {
374 Dictionary<string, object> sendData = new Dictionary<string, object>();
375 //sendData["SCOPEID"] = scopeID.ToString();
376 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
377 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
378 sendData["METHOD"] = "sethome";
379
380 sendData["UserID"] = userID;
381 sendData["RegionID"] = regionID.ToString();
382 sendData["position"] = position.ToString();
383 sendData["lookAt"] = lookAt.ToString();
384
385 string reqString = ServerUtils.BuildQueryString(sendData);
386 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
387 try
388 {
389 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
390 m_ServerURI + "/presence",
391 reqString);
392 if (reply != string.Empty)
393 {
394 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
395
396 if (replyData.ContainsKey("result"))
397 {
398 if (replyData["result"].ToString().ToLower() == "success")
399 return true;
400 else
401 return false;
402 }
403 else
404 m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation reply data does not contain result field");
405
406 }
407 else
408 m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation received empty reply");
409 }
410 catch (Exception e)
411 {
412 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
413 }
414
415 return false;
416 }
417
418 #endregion
419
420 }
421}
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
new file mode 100644
index 0000000..6f71197
--- /dev/null
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -0,0 +1,242 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using System.Text;
34
35using OpenSim.Framework;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38
39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
41using log4net;
42
43namespace OpenSim.Services.Connectors.Simulation
44{
45 public class SimulationServiceConnector : ISimulationService
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 private GridRegion m_Region;
50
51 public SimulationServiceConnector()
52 {
53 }
54
55 public SimulationServiceConnector(GridRegion region)
56 {
57 m_Region = region;
58 }
59
60 public IScene GetScene(ulong regionHandle)
61 {
62 return null;
63 }
64
65 #region Agents
66
67 public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason)
68 {
69 reason = String.Empty;
70
71 // Eventually, we want to use a caps url instead of the agentID
72 string uri = string.Empty;
73 try
74 {
75 uri = "http://" + m_Region.ExternalEndPoint.Address + ":" + m_Region.HttpPort + "/agent/" + aCircuit.AgentID + "/";
76 }
77 catch (Exception e)
78 {
79 m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message);
80 reason = e.Message;
81 return false;
82 }
83
84 //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri);
85
86 HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri);
87 AgentCreateRequest.Method = "POST";
88 AgentCreateRequest.ContentType = "application/json";
89 AgentCreateRequest.Timeout = 10000;
90 //AgentCreateRequest.KeepAlive = false;
91 //AgentCreateRequest.Headers.Add("Authorization", authKey);
92
93 // Fill it in
94 OSDMap args = null;
95 try
96 {
97 args = aCircuit.PackAgentCircuitData();
98 }
99 catch (Exception e)
100 {
101 m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message);
102 }
103 // Add the regionhandle and the name of the destination region
104 args["destination_handle"] = OSD.FromString(m_Region.RegionHandle.ToString());
105 args["destination_name"] = OSD.FromString(m_Region.RegionName);
106 args["teleport_flags"] = OSD.FromString(flags.ToString());
107
108 string strBuffer = "";
109 byte[] buffer = new byte[1];
110 try
111 {
112 strBuffer = OSDParser.SerializeJsonString(args);
113 Encoding str = Util.UTF8;
114 buffer = str.GetBytes(strBuffer);
115
116 }
117 catch (Exception e)
118 {
119 m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
120 // ignore. buffer will be empty, caller should check.
121 }
122
123 Stream os = null;
124 try
125 { // send the Post
126 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
127 os = AgentCreateRequest.GetRequestStream();
128 os.Write(buffer, 0, strBuffer.Length); //Send it
129 //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri);
130 }
131 //catch (WebException ex)
132 catch
133 {
134 //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message);
135 reason = "cannot contact remote region";
136 return false;
137 }
138 finally
139 {
140 if (os != null)
141 os.Close();
142 }
143
144 // Let's wait for the response
145 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
146
147 WebResponse webResponse = null;
148 StreamReader sr = null;
149 try
150 {
151 webResponse = AgentCreateRequest.GetResponse();
152 if (webResponse == null)
153 {
154 m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post");
155 }
156 else
157 {
158
159 sr = new StreamReader(webResponse.GetResponseStream());
160 string response = sr.ReadToEnd().Trim();
161 m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response);
162
163 if (!String.IsNullOrEmpty(response))
164 {
165 try
166 {
167 // we assume we got an OSDMap back
168 OSDMap r = Util.GetOSDMap(response);
169 bool success = r["success"].AsBoolean();
170 reason = r["reason"].AsString();
171 return success;
172 }
173 catch (NullReferenceException e)
174 {
175 m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
176
177 // check for old style response
178 if (response.ToLower().StartsWith("true"))
179 return true;
180
181 return false;
182 }
183 }
184 }
185 }
186 catch (WebException ex)
187 {
188 m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
189 // ignore, really
190 }
191 finally
192 {
193 if (sr != null)
194 sr.Close();
195 }
196
197 return true;
198 }
199
200 public bool UpdateAgent(ulong regionHandle, AgentData data)
201 {
202 return false;
203 }
204
205 public bool UpdateAgent(ulong regionHandle, AgentPosition data)
206 {
207 return false;
208 }
209
210 public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent)
211 {
212 agent = null;
213 return false;
214 }
215
216 public bool ReleaseAgent(ulong regionHandle, UUID id, string uri)
217 {
218 return false;
219 }
220
221 public bool CloseAgent(ulong regionHandle, UUID id)
222 {
223 return false;
224 }
225
226 #endregion Agents
227
228 #region Objects
229
230 public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall)
231 {
232 return false;
233 }
234
235 public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID)
236 {
237 return false;
238 }
239
240 #endregion Objects
241 }
242}
diff --git a/OpenSim/Services/Connectors/User/UserServiceConnector.cs b/OpenSim/Services/Connectors/User/UserServiceConnector.cs
deleted file mode 100644
index 683990f..0000000
--- a/OpenSim/Services/Connectors/User/UserServiceConnector.cs
+++ /dev/null
@@ -1,114 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using OpenMetaverse;
39
40namespace OpenSim.Services.Connectors
41{
42 public class UserServicesConnector : IUserAccountService
43 {
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48// private string m_ServerURI = String.Empty;
49
50 public UserServicesConnector()
51 {
52 }
53
54 public UserServicesConnector(string serverURI)
55 {
56// m_ServerURI = serverURI.TrimEnd('/');
57 }
58
59 public UserServicesConnector(IConfigSource source)
60 {
61 Initialise(source);
62 }
63
64 public virtual void Initialise(IConfigSource source)
65 {
66 IConfig assetConfig = source.Configs["UserService"];
67 if (assetConfig == null)
68 {
69 m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini");
70 throw new Exception("User connector init error");
71 }
72
73 string serviceURI = assetConfig.GetString("UserServerURI",
74 String.Empty);
75
76 if (serviceURI == String.Empty)
77 {
78 m_log.Error("[USER CONNECTOR]: No Server URI named in section UserService");
79 throw new Exception("User connector init error");
80 }
81 //m_ServerURI = serviceURI;
82 }
83
84 public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
85 {
86 return null;
87 }
88
89 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
90 {
91 return null;
92 }
93
94 public bool SetHomePosition(UserAccount data, UUID regionID, UUID regionSecret)
95 {
96 return false;
97 }
98
99 public bool SetUserAccount(UserAccount data, UUID principalID, string token)
100 {
101 return false;
102 }
103
104 public bool CreateUserAccount(UserAccount data, UUID principalID, string token)
105 {
106 return false;
107 }
108
109 public List<UserAccount> GetUserAccount(UUID scopeID, string query)
110 {
111 return null;
112 }
113 }
114}
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
new file mode 100644
index 0000000..46313d9
--- /dev/null
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
@@ -0,0 +1,274 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Server.Base;
38using OpenSim.Services.Interfaces;
39using OpenMetaverse;
40
41namespace OpenSim.Services.Connectors
42{
43 public class UserAccountServicesConnector : IUserAccountService
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(
47 MethodBase.GetCurrentMethod().DeclaringType);
48
49 private string m_ServerURI = String.Empty;
50
51 public UserAccountServicesConnector()
52 {
53 }
54
55 public UserAccountServicesConnector(string serverURI)
56 {
57 m_ServerURI = serverURI.TrimEnd('/');
58 }
59
60 public UserAccountServicesConnector(IConfigSource source)
61 {
62 Initialise(source);
63 }
64
65 public virtual void Initialise(IConfigSource source)
66 {
67 IConfig assetConfig = source.Configs["UserAccountService"];
68 if (assetConfig == null)
69 {
70 m_log.Error("[ACCOUNT CONNECTOR]: UserAccountService missing from OpenSim.ini");
71 throw new Exception("User account connector init error");
72 }
73
74 string serviceURI = assetConfig.GetString("UserAccountServerURI",
75 String.Empty);
76
77 if (serviceURI == String.Empty)
78 {
79 m_log.Error("[ACCOUNT CONNECTOR]: No Server URI named in section UserAccountService");
80 throw new Exception("User account connector init error");
81 }
82 m_ServerURI = serviceURI;
83 }
84
85 public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
86 {
87 Dictionary<string, object> sendData = new Dictionary<string, object>();
88 //sendData["SCOPEID"] = scopeID.ToString();
89 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
90 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
91 sendData["METHOD"] = "getaccount";
92
93 sendData["ScopeID"] = scopeID;
94 sendData["FirstName"] = firstName.ToString();
95 sendData["LastName"] = lastName.ToString();
96
97 return SendAndGetReply(sendData);
98 }
99
100 public UserAccount GetUserAccount(UUID scopeID, string email)
101 {
102 Dictionary<string, object> sendData = new Dictionary<string, object>();
103 //sendData["SCOPEID"] = scopeID.ToString();
104 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
105 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
106 sendData["METHOD"] = "getaccount";
107
108 sendData["ScopeID"] = scopeID;
109 sendData["Email"] = email;
110
111 return SendAndGetReply(sendData);
112 }
113
114 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
115 {
116 Dictionary<string, object> sendData = new Dictionary<string, object>();
117 //sendData["SCOPEID"] = scopeID.ToString();
118 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
119 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
120 sendData["METHOD"] = "getaccount";
121
122 sendData["ScopeID"] = scopeID;
123 sendData["UserID"] = userID.ToString();
124
125 return SendAndGetReply(sendData);
126 }
127
128 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
129 {
130 Dictionary<string, object> sendData = new Dictionary<string, object>();
131 //sendData["SCOPEID"] = scopeID.ToString();
132 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
133 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
134 sendData["METHOD"] = "getagents";
135
136 sendData["ScopeID"] = scopeID.ToString();
137 sendData["query"] = query;
138
139 string reply = string.Empty;
140 string reqString = ServerUtils.BuildQueryString(sendData);
141 // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
142 try
143 {
144 reply = SynchronousRestFormsRequester.MakeRequest("POST",
145 m_ServerURI + "/accounts",
146 reqString);
147 if (reply == null || (reply != null && reply == string.Empty))
148 {
149 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply");
150 return null;
151 }
152 }
153 catch (Exception e)
154 {
155 m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting accounts server: {0}", e.Message);
156 }
157
158 List<UserAccount> accounts = new List<UserAccount>();
159
160 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
161
162 if (replyData != null)
163 {
164 if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null")
165 {
166 return accounts;
167 }
168
169 Dictionary<string, object>.ValueCollection accountList = replyData.Values;
170 //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
171 foreach (object acc in accountList)
172 {
173 if (acc is Dictionary<string, object>)
174 {
175 UserAccount pinfo = new UserAccount((Dictionary<string, object>)acc);
176 accounts.Add(pinfo);
177 }
178 else
179 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received invalid response type {0}",
180 acc.GetType());
181 }
182 }
183 else
184 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetUserAccounts received null response");
185
186 return accounts;
187 }
188
189 public bool StoreUserAccount(UserAccount data)
190 {
191 Dictionary<string, object> sendData = new Dictionary<string, object>();
192 //sendData["SCOPEID"] = scopeID.ToString();
193 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
194 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
195 sendData["METHOD"] = "setaccount";
196
197 sendData["account"] = data.ToKeyValuePairs();
198
199 return SendAndGetBoolReply(sendData);
200 }
201
202 private UserAccount SendAndGetReply(Dictionary<string, object> sendData)
203 {
204 string reply = string.Empty;
205 string reqString = ServerUtils.BuildQueryString(sendData);
206 // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
207 try
208 {
209 reply = SynchronousRestFormsRequester.MakeRequest("POST",
210 m_ServerURI + "/accounts",
211 reqString);
212 if (reply == null || (reply != null && reply == string.Empty))
213 {
214 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply");
215 return null;
216 }
217 }
218 catch (Exception e)
219 {
220 m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user account server: {0}", e.Message);
221 }
222
223 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
224 UserAccount account = null;
225
226 if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
227 {
228 if (replyData["result"] is Dictionary<string, object>)
229 {
230 account = new UserAccount((Dictionary<string, object>)replyData["result"]);
231 }
232 }
233
234 return account;
235
236 }
237
238 private bool SendAndGetBoolReply(Dictionary<string, object> sendData)
239 {
240 string reqString = ServerUtils.BuildQueryString(sendData);
241 // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
242 try
243 {
244 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
245 m_ServerURI + "/accounts",
246 reqString);
247 if (reply != string.Empty)
248 {
249 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
250
251 if (replyData.ContainsKey("result"))
252 {
253 if (replyData["result"].ToString().ToLower() == "success")
254 return true;
255 else
256 return false;
257 }
258 else
259 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount reply data does not contain result field");
260
261 }
262 else
263 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount received empty reply");
264 }
265 catch (Exception e)
266 {
267 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Exception when contacting user account server: {0}", e.Message);
268 }
269
270 return false;
271 }
272
273 }
274}
diff --git a/OpenSim/Services/UserService/UserService.cs b/OpenSim/Services/Interfaces/ILoginService.cs
index e8b9fc3..0f82de5 100644
--- a/OpenSim/Services/UserService/UserService.cs
+++ b/OpenSim/Services/Interfaces/ILoginService.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -26,51 +26,27 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Collections;
30using Nini.Config;
31using OpenSim.Data;
32using OpenSim.Services.Interfaces;
33using System.Collections.Generic; 30using System.Collections.Generic;
34using OpenMetaverse;
35 31
36namespace OpenSim.Services.UserAccountService 32using OpenMetaverse.StructuredData;
33
34namespace OpenSim.Services.Interfaces
37{ 35{
38 public class UserAccountService : UserAccountServiceBase, IUserAccountService 36 public abstract class LoginResponse
39 { 37 {
40 public UserAccountService(IConfigSource config) : base(config) 38 public abstract Hashtable ToHashtable();
41 { 39 public abstract OSD ToOSDMap();
42 } 40 }
43
44 public UserAccount GetUserAccount(UUID scopeID, string firstName,
45 string lastName)
46 {
47 return null;
48 }
49
50 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
51 {
52 return null;
53 }
54 41
55 public bool SetHomePosition(UserAccount data, UUID regionID, UUID regionSecret) 42 public abstract class FailedLoginResponse : LoginResponse
56 { 43 {
57 return false; 44 }
58 }
59 45
60 public bool SetUserAccount(UserAccount data, UUID principalID, string token) 46 public interface ILoginService
61 { 47 {
62 return false; 48 LoginResponse Login(string firstName, string lastName, string passwd, string startLocation);
63 } 49 }
64 50
65 public bool CreateUserAccount(UserAccount data, UUID principalID, string token)
66 {
67 return false;
68 }
69 51
70 public List<UserAccount> GetUserAccount(UUID scopeID,
71 string query)
72 {
73 return null;
74 }
75 }
76} 52}
diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs
index aa1c5bf..2dad7e6 100644
--- a/OpenSim/Services/Interfaces/IPresenceService.cs
+++ b/OpenSim/Services/Interfaces/IPresenceService.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using OpenSim.Framework; 29using OpenSim.Framework;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using OpenMetaverse; 31using OpenMetaverse;
@@ -33,13 +34,74 @@ namespace OpenSim.Services.Interfaces
33{ 34{
34 public class PresenceInfo 35 public class PresenceInfo
35 { 36 {
36 public UUID PrincipalID; 37 public string UserID;
37 public UUID RegionID; 38 public UUID RegionID;
38 public Dictionary<string, string> Data; 39 public bool Online;
40 public DateTime Login;
41 public DateTime Logout;
42 public Vector3 Position;
43 public Vector3 LookAt;
44 public UUID HomeRegionID;
45 public Vector3 HomePosition;
46 public Vector3 HomeLookAt;
47
48 public PresenceInfo()
49 {
50 }
51
52 public PresenceInfo(Dictionary<string, object> kvp)
53 {
54 if (kvp.ContainsKey("UserID"))
55 UserID = kvp["UserID"].ToString();
56 if (kvp.ContainsKey("RegionID"))
57 UUID.TryParse(kvp["RegionID"].ToString(), out RegionID);
58 if (kvp.ContainsKey("login"))
59 DateTime.TryParse(kvp["login"].ToString(), out Login);
60 if (kvp.ContainsKey("logout"))
61 DateTime.TryParse(kvp["logout"].ToString(), out Logout);
62 if (kvp.ContainsKey("lookAt"))
63 Vector3.TryParse(kvp["lookAt"].ToString(), out LookAt);
64 if (kvp.ContainsKey("online"))
65 Boolean.TryParse(kvp["online"].ToString(), out Online);
66 if (kvp.ContainsKey("position"))
67 Vector3.TryParse(kvp["position"].ToString(), out Position);
68 if (kvp.ContainsKey("HomeRegionID"))
69 UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID);
70 if (kvp.ContainsKey("HomePosition"))
71 Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition);
72 if (kvp.ContainsKey("HomeLookAt"))
73 Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt);
74
75 }
76
77 public Dictionary<string, object> ToKeyValuePairs()
78 {
79 Dictionary<string, object> result = new Dictionary<string, object>();
80 result["UserID"] = UserID;
81 result["RegionID"] = RegionID.ToString();
82 result["online"] = Online.ToString();
83 result["login"] = Login.ToString();
84 result["logout"] = Logout.ToString();
85 result["position"] = Position.ToString();
86 result["lookAt"] = LookAt.ToString();
87 result["HomeRegionID"] = HomeRegionID.ToString();
88 result["HomePosition"] = HomePosition.ToString();
89 result["HomeLookAt"] = HomeLookAt.ToString();
90
91 return result;
92 }
39 } 93 }
40 94
41 public interface IPresenceService 95 public interface IPresenceService
42 { 96 {
43 bool Report(PresenceInfo presence); 97 bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID);
98 bool LogoutAgent(UUID sessionID);
99 bool LogoutRegionAgents(UUID regionID);
100
101 bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt);
102 bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt);
103
104 PresenceInfo GetAgent(UUID sessionID);
105 PresenceInfo[] GetAgents(string[] userIDs);
44 } 106 }
45} 107}
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index a169ab7..7ba3e66 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -33,9 +33,11 @@ namespace OpenSim.Services.Interfaces
33{ 33{
34 public interface ISimulationService 34 public interface ISimulationService
35 { 35 {
36 IScene GetScene(ulong regionHandle);
37
36 #region Agents 38 #region Agents
37 39
38 bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason); 40 bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason);
39 41
40 /// <summary> 42 /// <summary>
41 /// Full child agent update. 43 /// Full child agent update.
@@ -98,11 +100,5 @@ namespace OpenSim.Services.Interfaces
98 100
99 #endregion Objects 101 #endregion Objects
100 102
101 #region Regions
102
103 bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion);
104
105 #endregion Regions
106
107 } 103 }
108} 104}
diff --git a/OpenSim/Services/Interfaces/IUserService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs
index 92bd8ef..b2d5d48 100644
--- a/OpenSim/Services/Interfaces/IUserService.cs
+++ b/OpenSim/Services/Interfaces/IUserAccountService.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
30 31
@@ -36,68 +37,67 @@ namespace OpenSim.Services.Interfaces
36 { 37 {
37 } 38 }
38 39
39 public UserAccount(UUID userID, UUID homeRegionID, float homePositionX, 40 public UserAccount(UUID principalID)
40 float homePositionY, float homePositionZ, float homeLookAtX,
41 float homeLookAtY, float homeLookAtZ)
42 { 41 {
43 UserID = userID; 42 PrincipalID = principalID;
44 HomeRegionID = homeRegionID;
45 HomePositionX = homePositionX;
46 HomePositionY = homePositionY;
47 HomePositionZ = homePositionZ;
48 HomeLookAtX = homeLookAtX;
49 HomeLookAtY = homeLookAtY;
50 HomeLookAtZ = homeLookAtZ;
51 } 43 }
52 44
53 public string FirstName; 45 public string FirstName;
54 public string LastName; 46 public string LastName;
55 public UUID UserID; 47 public string Email;
48 public UUID PrincipalID;
56 public UUID ScopeID; 49 public UUID ScopeID;
57 50
58 // For informational purposes only! 51 public Dictionary<string, object> ServiceURLs;
59 //
60 public string HomeRegionName;
61 52
62 public UUID HomeRegionID; 53 public int Created;
63 public float HomePositionX;
64 public float HomePositionY;
65 public float HomePositionZ;
66 public float HomeLookAtX;
67 public float HomeLookAtY;
68 public float HomeLookAtZ;
69 54
70 // These are here because they 55 public UserAccount(Dictionary<string, object> kvp)
71 // concern the account rather than 56 {
72 // the profile. They just happen to 57 if (kvp.ContainsKey("FirstName"))
73 // be used in the Linden profile as well 58 FirstName = kvp["FirstName"].ToString();
74 // 59 if (kvp.ContainsKey("LastName"))
75 public int GodLevel; 60 LastName = kvp["LastName"].ToString();
76 public int UserFlags; 61 if (kvp.ContainsKey("Email"))
77 public string AccountType; 62 Email = kvp["Email"].ToString();
63 if (kvp.ContainsKey("PrincipalID"))
64 UUID.TryParse(kvp["PrincipalID"].ToString(), out PrincipalID);
65 if (kvp.ContainsKey("ScopeID"))
66 UUID.TryParse(kvp["ScopeID"].ToString(), out ScopeID);
67 if (kvp.ContainsKey("Created"))
68 Convert.ToInt32(kvp["Created"].ToString());
69 if (kvp.ContainsKey("ServiceURLs") && kvp["ServiceURLs"] != null && (kvp["ServiceURLs"] is Dictionary<string, string>))
70 ServiceURLs = (Dictionary<string, object>)kvp["ServiceURLs"];
71 }
72
73 public Dictionary<string, object> ToKeyValuePairs()
74 {
75 Dictionary<string, object> result = new Dictionary<string, object>();
76 result["FirstName"] = FirstName;
77 result["LastName"] = LastName;
78 result["Email"] = Email;
79 result["PrincipalID"] = PrincipalID.ToString();
80 result["ScopeID"] = ScopeID.ToString();
81 result["Created"] = Created.ToString();
82 result["ServiceURLs"] = ServiceURLs;
78 83
84 return result;
85 }
79 }; 86 };
80 87
81 public interface IUserAccountService 88 public interface IUserAccountService
82 { 89 {
83 UserAccount GetUserAccount(UUID scopeID, UUID userID); 90 UserAccount GetUserAccount(UUID scopeID, UUID userID);
84 UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName); 91 UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName);
92 UserAccount GetUserAccount(UUID scopeID, string Email);
85 // Returns the list of avatars that matches both the search 93 // Returns the list of avatars that matches both the search
86 // criterion and the scope ID passed 94 // criterion and the scope ID passed
87 // 95 //
88 List<UserAccount> GetUserAccount(UUID scopeID, string query); 96 List<UserAccount> GetUserAccounts(UUID scopeID, string query);
89
90
91 // This will set only the home region portion of the data!
92 // Can't be used to set god level, flags, type or change the name!
93 //
94 bool SetHomePosition(UserAccount data, UUID RegionID, UUID RegionSecret);
95 97
96 // Update all updatable fields 98 // Store the data given, wich replaces the sotred data, therefore
99 // must be complete.
97 // 100 //
98 bool SetUserAccount(UserAccount data, UUID PrincipalID, string token); 101 bool StoreUserAccount(UserAccount data);
99
100 // Creates a user data record
101 bool CreateUserAccount(UserAccount data, UUID PrincipalID, string token);
102 } 102 }
103} 103}
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
new file mode 100644
index 0000000..fbce63f
--- /dev/null
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -0,0 +1,740 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using OpenSim.Framework;
33using log4net;
34using OpenMetaverse;
35using OpenMetaverse.StructuredData;
36
37namespace OpenSim.Services.LLLoginService
38{
39 public class LLFailedLoginResponse : OpenSim.Services.Interfaces.FailedLoginResponse
40 {
41 string m_key;
42 string m_value;
43 string m_login;
44
45 public static LLFailedLoginResponse UserProblem;
46 public static LLFailedLoginResponse GridProblem;
47 public static LLFailedLoginResponse InventoryProblem;
48 public static LLFailedLoginResponse DeadRegionProblem;
49 public static LLFailedLoginResponse LoginBlockedProblem;
50 public static LLFailedLoginResponse AlreadyLoggedInProblem;
51 public static LLFailedLoginResponse InternalError;
52
53 static LLFailedLoginResponse()
54 {
55 UserProblem = new LLFailedLoginResponse("key",
56 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
57 "false");
58 GridProblem = new LLFailedLoginResponse("key",
59 "Error connecting to grid. Could not percieve credentials from login XML.",
60 "false");
61 InventoryProblem = new LLFailedLoginResponse("key",
62 "The inventory service is not responding. Please notify your login region operator.",
63 "false");
64 DeadRegionProblem = new LLFailedLoginResponse("key",
65 "The region you are attempting to log into is not responding. Please select another region and try again.",
66 "false");
67 LoginBlockedProblem = new LLFailedLoginResponse("presence",
68 "Logins are currently restricted. Please try again later.",
69 "false");
70 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
71 "You appear to be already logged in. " +
72 "If this is not the case please wait for your session to timeout. " +
73 "If this takes longer than a few minutes please contact the grid owner. " +
74 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.",
75 "false");
76 InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false");
77 }
78
79 public LLFailedLoginResponse(string key, string value, string login)
80 {
81 m_key = key;
82 m_value = value;
83 m_login = login;
84 }
85
86 public override Hashtable ToHashtable()
87 {
88 Hashtable loginError = new Hashtable();
89 loginError["reason"] = m_key;
90 loginError["message"] = m_value;
91 loginError["login"] = m_login;
92 return loginError;
93 }
94
95 public override OSD ToOSDMap()
96 {
97 OSDMap map = new OSDMap();
98
99 map["reason"] = OSD.FromString(m_key);
100 map["message"] = OSD.FromString(m_value);
101 map["login"] = OSD.FromString(m_login);
102
103 return map;
104 }
105 }
106
107 /// <summary>
108 /// A class to handle LL login response.
109 /// </summary>
110 public class LLLoginResponse : OpenSim.Services.Interfaces.LoginResponse
111 {
112 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
113 private static Hashtable globalTexturesHash;
114 // Global Textures
115 private static string sunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
116 private static string cloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621";
117 private static string moonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621";
118
119 private Hashtable loginFlagsHash;
120 private Hashtable uiConfigHash;
121
122 private ArrayList loginFlags;
123 private ArrayList globalTextures;
124 private ArrayList eventCategories;
125 private ArrayList uiConfig;
126 private ArrayList classifiedCategories;
127 private ArrayList inventoryRoot;
128 private ArrayList initialOutfit;
129 private ArrayList agentInventory;
130 private ArrayList inventoryLibraryOwner;
131 private ArrayList inventoryLibRoot;
132 private ArrayList inventoryLibrary;
133 private ArrayList activeGestures;
134
135 private UserInfo userProfile;
136
137 private UUID agentID;
138 private UUID sessionID;
139 private UUID secureSessionID;
140
141 // Login Flags
142 private string dst;
143 private string stipendSinceLogin;
144 private string gendered;
145 private string everLoggedIn;
146 private string login;
147 private uint simPort;
148 private uint simHttpPort;
149 private string simAddress;
150 private string agentAccess;
151 private string agentAccessMax;
152 private Int32 circuitCode;
153 private uint regionX;
154 private uint regionY;
155
156 // Login
157 private string firstname;
158 private string lastname;
159
160 // Error Flags
161 private string errorReason;
162 private string errorMessage;
163
164 private string welcomeMessage;
165 private string startLocation;
166 private string allowFirstLife;
167 private string home;
168 private string seedCapability;
169 private string lookAt;
170
171 private BuddyList m_buddyList = null;
172
173 static LLLoginResponse()
174 {
175 // This is being set, but it's not used
176 // not sure why.
177 globalTexturesHash = new Hashtable();
178 globalTexturesHash["sun_texture_id"] = sunTexture;
179 globalTexturesHash["cloud_texture_id"] = cloudTexture;
180 globalTexturesHash["moon_texture_id"] = moonTexture;
181 }
182
183 public LLLoginResponse()
184 {
185 loginFlags = new ArrayList();
186 globalTextures = new ArrayList();
187 eventCategories = new ArrayList();
188 uiConfig = new ArrayList();
189 classifiedCategories = new ArrayList();
190
191 uiConfigHash = new Hashtable();
192
193 // defaultXmlRpcResponse = new XmlRpcResponse();
194 userProfile = new UserInfo();
195 inventoryRoot = new ArrayList();
196 initialOutfit = new ArrayList();
197 agentInventory = new ArrayList();
198 inventoryLibrary = new ArrayList();
199 inventoryLibraryOwner = new ArrayList();
200 activeGestures = new ArrayList();
201
202 SetDefaultValues();
203 }
204
205 private void SetDefaultValues()
206 {
207 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
208 StipendSinceLogin = "N";
209 Gendered = "Y";
210 EverLoggedIn = "Y";
211 login = "false";
212 firstname = "Test";
213 lastname = "User";
214 agentAccess = "M";
215 agentAccessMax = "A";
216 startLocation = "last";
217 allowFirstLife = "Y";
218
219 ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
220 ErrorReason = "key";
221 welcomeMessage = "Welcome to OpenSim!";
222 seedCapability = String.Empty;
223 home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" +
224 userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" +
225 userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" +
226 userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}";
227 lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
228 RegionX = (uint) 255232;
229 RegionY = (uint) 254976;
230
231 // Classifieds;
232 AddClassifiedCategory((Int32) 1, "Shopping");
233 AddClassifiedCategory((Int32) 2, "Land Rental");
234 AddClassifiedCategory((Int32) 3, "Property Rental");
235 AddClassifiedCategory((Int32) 4, "Special Attraction");
236 AddClassifiedCategory((Int32) 5, "New Products");
237 AddClassifiedCategory((Int32) 6, "Employment");
238 AddClassifiedCategory((Int32) 7, "Wanted");
239 AddClassifiedCategory((Int32) 8, "Service");
240 AddClassifiedCategory((Int32) 9, "Personal");
241
242 SessionID = UUID.Random();
243 SecureSessionID = UUID.Random();
244 AgentID = UUID.Random();
245
246 Hashtable InitialOutfitHash = new Hashtable();
247 InitialOutfitHash["folder_name"] = "Nightclub Female";
248 InitialOutfitHash["gender"] = "female";
249 initialOutfit.Add(InitialOutfitHash);
250 }
251
252
253 public override Hashtable ToHashtable()
254 {
255 try
256 {
257 Hashtable responseData = new Hashtable();
258
259 loginFlagsHash = new Hashtable();
260 loginFlagsHash["daylight_savings"] = DST;
261 loginFlagsHash["stipend_since_login"] = StipendSinceLogin;
262 loginFlagsHash["gendered"] = Gendered;
263 loginFlagsHash["ever_logged_in"] = EverLoggedIn;
264 loginFlags.Add(loginFlagsHash);
265
266 responseData["first_name"] = Firstname;
267 responseData["last_name"] = Lastname;
268 responseData["agent_access"] = agentAccess;
269 responseData["agent_access_max"] = agentAccessMax;
270
271 globalTextures.Add(globalTexturesHash);
272 // this.eventCategories.Add(this.eventCategoriesHash);
273
274 AddToUIConfig("allow_first_life", allowFirstLife);
275 uiConfig.Add(uiConfigHash);
276
277 responseData["sim_port"] = (Int32) SimPort;
278 responseData["sim_ip"] = SimAddress;
279 responseData["http_port"] = (Int32)SimHttpPort;
280
281 responseData["agent_id"] = AgentID.ToString();
282 responseData["session_id"] = SessionID.ToString();
283 responseData["secure_session_id"] = SecureSessionID.ToString();
284 responseData["circuit_code"] = CircuitCode;
285 responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
286 responseData["login-flags"] = loginFlags;
287 responseData["global-textures"] = globalTextures;
288 responseData["seed_capability"] = seedCapability;
289
290 responseData["event_categories"] = eventCategories;
291 responseData["event_notifications"] = new ArrayList(); // todo
292 responseData["classified_categories"] = classifiedCategories;
293 responseData["ui-config"] = uiConfig;
294
295 if (agentInventory != null)
296 {
297 responseData["inventory-skeleton"] = agentInventory;
298 responseData["inventory-root"] = inventoryRoot;
299 }
300 responseData["inventory-skel-lib"] = inventoryLibrary;
301 responseData["inventory-lib-root"] = inventoryLibRoot;
302 responseData["gestures"] = activeGestures;
303 responseData["inventory-lib-owner"] = inventoryLibraryOwner;
304 responseData["initial-outfit"] = initialOutfit;
305 responseData["start_location"] = startLocation;
306 responseData["seed_capability"] = seedCapability;
307 responseData["home"] = home;
308 responseData["look_at"] = lookAt;
309 responseData["message"] = welcomeMessage;
310 responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize);
311 responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize);
312
313 if (m_buddyList != null)
314 {
315 responseData["buddy-list"] = m_buddyList.ToArray();
316 }
317
318 responseData["login"] = "true";
319
320 return responseData;
321 }
322 catch (Exception e)
323 {
324 m_log.Warn("[CLIENT]: LoginResponse: Error creating Hashtable Response: " + e.Message);
325
326 return LLFailedLoginResponse.InternalError.ToHashtable();
327 }
328 }
329
330 public override OSD ToOSDMap()
331 {
332 try
333 {
334 OSDMap map = new OSDMap();
335
336 map["first_name"] = OSD.FromString(Firstname);
337 map["last_name"] = OSD.FromString(Lastname);
338 map["agent_access"] = OSD.FromString(agentAccess);
339 map["agent_access_max"] = OSD.FromString(agentAccessMax);
340
341 map["sim_port"] = OSD.FromInteger(SimPort);
342 map["sim_ip"] = OSD.FromString(SimAddress);
343
344 map["agent_id"] = OSD.FromUUID(AgentID);
345 map["session_id"] = OSD.FromUUID(SessionID);
346 map["secure_session_id"] = OSD.FromUUID(SecureSessionID);
347 map["circuit_code"] = OSD.FromInteger(CircuitCode);
348 map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
349
350 #region Login Flags
351
352 OSDMap loginFlagsLLSD = new OSDMap();
353 loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST);
354 loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin);
355 loginFlagsLLSD["gendered"] = OSD.FromString(Gendered);
356 loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn);
357 map["login-flags"] = WrapOSDMap(loginFlagsLLSD);
358
359 #endregion Login Flags
360
361 #region Global Textures
362
363 OSDMap globalTexturesLLSD = new OSDMap();
364 globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture);
365 globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture);
366 globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture);
367
368 map["global-textures"] = WrapOSDMap(globalTexturesLLSD);
369
370 #endregion Global Textures
371
372 map["seed_capability"] = OSD.FromString(seedCapability);
373
374 map["event_categories"] = ArrayListToOSDArray(eventCategories);
375 //map["event_notifications"] = new OSDArray(); // todo
376 map["classified_categories"] = ArrayListToOSDArray(classifiedCategories);
377
378 #region UI Config
379
380 OSDMap uiConfigLLSD = new OSDMap();
381 uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife);
382 map["ui-config"] = WrapOSDMap(uiConfigLLSD);
383
384 #endregion UI Config
385
386 #region Inventory
387
388 map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory);
389
390 map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary);
391 map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ;
392 map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot);
393 map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner);
394
395 #endregion Inventory
396
397 map["gestures"] = ArrayListToOSDArray(activeGestures);
398
399 map["initial-outfit"] = ArrayListToOSDArray(initialOutfit);
400 map["start_location"] = OSD.FromString(startLocation);
401
402 map["seed_capability"] = OSD.FromString(seedCapability);
403 map["home"] = OSD.FromString(home);
404 map["look_at"] = OSD.FromString(lookAt);
405 map["message"] = OSD.FromString(welcomeMessage);
406 map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize);
407 map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize);
408
409 if (m_buddyList != null)
410 {
411 map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray());
412 }
413
414 map["login"] = OSD.FromString("true");
415
416 return map;
417 }
418 catch (Exception e)
419 {
420 m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message);
421
422 return LLFailedLoginResponse.InternalError.ToOSDMap();
423 }
424 }
425
426 public OSDArray ArrayListToOSDArray(ArrayList arrlst)
427 {
428 OSDArray llsdBack = new OSDArray();
429 foreach (Hashtable ht in arrlst)
430 {
431 OSDMap mp = new OSDMap();
432 foreach (DictionaryEntry deHt in ht)
433 {
434 mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value));
435 }
436 llsdBack.Add(mp);
437 }
438 return llsdBack;
439 }
440
441 private static OSDArray WrapOSDMap(OSDMap wrapMe)
442 {
443 OSDArray array = new OSDArray();
444 array.Add(wrapMe);
445 return array;
446 }
447
448 public void SetEventCategories(string category, string value)
449 {
450 // this.eventCategoriesHash[category] = value;
451 //TODO
452 }
453
454 public void AddToUIConfig(string itemName, string item)
455 {
456 uiConfigHash[itemName] = item;
457 }
458
459 public void AddClassifiedCategory(Int32 ID, string categoryName)
460 {
461 Hashtable hash = new Hashtable();
462 hash["category_name"] = categoryName;
463 hash["category_id"] = ID;
464 classifiedCategories.Add(hash);
465 // this.classifiedCategoriesHash.Clear();
466 }
467
468 #region Properties
469
470 public string Login
471 {
472 get { return login; }
473 set { login = value; }
474 }
475
476 public string DST
477 {
478 get { return dst; }
479 set { dst = value; }
480 }
481
482 public string StipendSinceLogin
483 {
484 get { return stipendSinceLogin; }
485 set { stipendSinceLogin = value; }
486 }
487
488 public string Gendered
489 {
490 get { return gendered; }
491 set { gendered = value; }
492 }
493
494 public string EverLoggedIn
495 {
496 get { return everLoggedIn; }
497 set { everLoggedIn = value; }
498 }
499
500 public uint SimPort
501 {
502 get { return simPort; }
503 set { simPort = value; }
504 }
505
506 public uint SimHttpPort
507 {
508 get { return simHttpPort; }
509 set { simHttpPort = value; }
510 }
511
512 public string SimAddress
513 {
514 get { return simAddress; }
515 set { simAddress = value; }
516 }
517
518 public UUID AgentID
519 {
520 get { return agentID; }
521 set { agentID = value; }
522 }
523
524 public UUID SessionID
525 {
526 get { return sessionID; }
527 set { sessionID = value; }
528 }
529
530 public UUID SecureSessionID
531 {
532 get { return secureSessionID; }
533 set { secureSessionID = value; }
534 }
535
536 public Int32 CircuitCode
537 {
538 get { return circuitCode; }
539 set { circuitCode = value; }
540 }
541
542 public uint RegionX
543 {
544 get { return regionX; }
545 set { regionX = value; }
546 }
547
548 public uint RegionY
549 {
550 get { return regionY; }
551 set { regionY = value; }
552 }
553
554 public string SunTexture
555 {
556 get { return sunTexture; }
557 set { sunTexture = value; }
558 }
559
560 public string CloudTexture
561 {
562 get { return cloudTexture; }
563 set { cloudTexture = value; }
564 }
565
566 public string MoonTexture
567 {
568 get { return moonTexture; }
569 set { moonTexture = value; }
570 }
571
572 public string Firstname
573 {
574 get { return firstname; }
575 set { firstname = value; }
576 }
577
578 public string Lastname
579 {
580 get { return lastname; }
581 set { lastname = value; }
582 }
583
584 public string AgentAccess
585 {
586 get { return agentAccess; }
587 set { agentAccess = value; }
588 }
589
590 public string AgentAccessMax
591 {
592 get { return agentAccessMax; }
593 set { agentAccessMax = value; }
594 }
595
596 public string StartLocation
597 {
598 get { return startLocation; }
599 set { startLocation = value; }
600 }
601
602 public string LookAt
603 {
604 get { return lookAt; }
605 set { lookAt = value; }
606 }
607
608 public string SeedCapability
609 {
610 get { return seedCapability; }
611 set { seedCapability = value; }
612 }
613
614 public string ErrorReason
615 {
616 get { return errorReason; }
617 set { errorReason = value; }
618 }
619
620 public string ErrorMessage
621 {
622 get { return errorMessage; }
623 set { errorMessage = value; }
624 }
625
626 public ArrayList InventoryRoot
627 {
628 get { return inventoryRoot; }
629 set { inventoryRoot = value; }
630 }
631
632 public ArrayList InventorySkeleton
633 {
634 get { return agentInventory; }
635 set { agentInventory = value; }
636 }
637
638 public ArrayList InventoryLibrary
639 {
640 get { return inventoryLibrary; }
641 set { inventoryLibrary = value; }
642 }
643
644 public ArrayList InventoryLibraryOwner
645 {
646 get { return inventoryLibraryOwner; }
647 set { inventoryLibraryOwner = value; }
648 }
649
650 public ArrayList InventoryLibRoot
651 {
652 get { return inventoryLibRoot; }
653 set { inventoryLibRoot = value; }
654 }
655
656 public ArrayList ActiveGestures
657 {
658 get { return activeGestures; }
659 set { activeGestures = value; }
660 }
661
662 public string Home
663 {
664 get { return home; }
665 set { home = value; }
666 }
667
668 public string Message
669 {
670 get { return welcomeMessage; }
671 set { welcomeMessage = value; }
672 }
673
674 public BuddyList BuddList
675 {
676 get { return m_buddyList; }
677 set { m_buddyList = value; }
678 }
679
680 #endregion
681
682 public class UserInfo
683 {
684 public string firstname;
685 public string lastname;
686 public ulong homeregionhandle;
687 public Vector3 homepos;
688 public Vector3 homelookat;
689 }
690
691 public class BuddyList
692 {
693 public List<BuddyInfo> Buddies = new List<BuddyInfo>();
694
695 public void AddNewBuddy(BuddyInfo buddy)
696 {
697 if (!Buddies.Contains(buddy))
698 {
699 Buddies.Add(buddy);
700 }
701 }
702
703 public ArrayList ToArray()
704 {
705 ArrayList buddyArray = new ArrayList();
706 foreach (BuddyInfo buddy in Buddies)
707 {
708 buddyArray.Add(buddy.ToHashTable());
709 }
710 return buddyArray;
711 }
712
713 public class BuddyInfo
714 {
715 public int BuddyRightsHave = 1;
716 public int BuddyRightsGiven = 1;
717 public UUID BuddyID;
718
719 public BuddyInfo(string buddyID)
720 {
721 BuddyID = new UUID(buddyID);
722 }
723
724 public BuddyInfo(UUID buddyID)
725 {
726 BuddyID = buddyID;
727 }
728
729 public Hashtable ToHashTable()
730 {
731 Hashtable hTable = new Hashtable();
732 hTable["buddy_rights_has"] = BuddyRightsHave;
733 hTable["buddy_rights_given"] = BuddyRightsGiven;
734 hTable["buddy_id"] = BuddyID.ToString();
735 return hTable;
736 }
737 }
738 }
739 }
740}
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
new file mode 100644
index 0000000..25a65b5
--- /dev/null
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -0,0 +1,274 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using System.Text.RegularExpressions;
5
6using log4net;
7using Nini.Config;
8using OpenMetaverse;
9
10using OpenSim.Framework;
11using OpenSim.Server.Base;
12using OpenSim.Services.Interfaces;
13using GridRegion = OpenSim.Services.Interfaces.GridRegion;
14
15namespace OpenSim.Services.LLLoginService
16{
17 public class LLLoginService : ILoginService
18 {
19 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
20
21 private IUserAccountService m_UserAccountService;
22 private IAuthenticationService m_AuthenticationService;
23 private IInventoryService m_InventoryService;
24 private IGridService m_GridService;
25 private IPresenceService m_PresenceService;
26 private ISimulationService m_LocalSimulationService;
27
28 private string m_DefaultRegionName;
29 private string m_RemoteSimulationDll;
30
31 public LLLoginService(IConfigSource config, ISimulationService simService)
32 {
33 IConfig serverConfig = config.Configs["LoginService"];
34 if (serverConfig == null)
35 throw new Exception(String.Format("No section LoginService in config file"));
36
37 string accountService = serverConfig.GetString("UserAccountService", String.Empty);
38 string authService = serverConfig.GetString("AuthenticationService", String.Empty);
39 string invService = serverConfig.GetString("InventoryService", String.Empty);
40 string gridService = serverConfig.GetString("GridService", String.Empty);
41 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
42
43 m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty);
44 m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty);
45
46 // These 3 are required; the other 2 aren't
47 if (accountService == string.Empty || authService == string.Empty ||
48 invService == string.Empty)
49 throw new Exception("LoginService is missing service specifications");
50
51 Object[] args = new Object[] { config };
52 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
53 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
54 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
55 if (gridService != string.Empty)
56 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
57 if (presenceService != string.Empty)
58 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
59 m_LocalSimulationService = simService;
60
61 }
62
63 public LLLoginService(IConfigSource config) : this(config, null)
64 {
65 }
66
67 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation)
68 {
69 bool success = false;
70
71 // Get the account and check that it exists
72 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
73 if (account == null)
74 return LLFailedLoginResponse.UserProblem;
75
76 // Authenticate this user
77 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30);
78 UUID secureSession = UUID.Zero;
79 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
80 return LLFailedLoginResponse.UserProblem;
81
82 // Get the user's inventory
83 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
84 if ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))
85 return LLFailedLoginResponse.InventoryProblem;
86
87 // Login the presence
88 UUID session = UUID.Random();
89 if (m_PresenceService != null)
90 {
91 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
92 if (!success)
93 return LLFailedLoginResponse.GridProblem;
94 }
95
96 // Find the destination region/grid
97 string where = string.Empty;
98 Vector3 position = Vector3.Zero;
99 Vector3 lookAt = Vector3.Zero;
100 GridRegion destination = FindDestination(account, session, startLocation, out where, out position, out lookAt);
101 if (destination == null)
102 {
103 m_PresenceService.LogoutAgent(session);
104 return LLFailedLoginResponse.GridProblem;
105 }
106
107 // Instantiate/get the simulation interface and launch an agent at the destination
108 ISimulationService simConnector = null;
109 success = false;
110 string reason = string.Empty;
111 Object[] args = new Object[] { destination };
112 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
113 // non-HG standalones have just a localSimulationDll
114 // independent login servers have just a remoteSimulationDll
115 if (!startLocation.Contains("@") && (m_LocalSimulationService != null))
116 simConnector = m_LocalSimulationService;
117 else if (m_RemoteSimulationDll != string.Empty)
118 simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
119 if (simConnector != null)
120 success = LaunchAgent(simConnector, destination, account, session, out reason);
121 if (!success)
122 {
123 m_PresenceService.LogoutAgent(session);
124 return LLFailedLoginResponse.GridProblem;
125 }
126
127 // Finally, fill out the response and return it
128 LLLoginResponse response = new LLLoginResponse();
129 //....
130 return response;
131 }
132
133 private GridRegion FindDestination(UserAccount account, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt)
134 {
135 where = "home";
136 position = new Vector3(128, 128, 0);
137 lookAt = new Vector3(0, 1, 0);
138 if (startLocation.Equals("home"))
139 {
140 // logging into home region
141 if (m_PresenceService == null || m_GridService == null)
142 return null;
143
144 GridRegion region = null;
145 PresenceInfo pinfo = m_PresenceService.GetAgent(sessionID);
146 // this should succeed; if it doesn't there's something wrong with this grid
147 if (pinfo == null)
148 return null;
149
150 if (pinfo.HomeRegionID.Equals(UUID.Zero))
151 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
152 else
153 region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID);
154
155 return region;
156 }
157 else if (startLocation.Equals("last"))
158 {
159 // logging into last visited region
160 where = "last";
161 if (m_PresenceService == null || m_GridService == null)
162 return null;
163
164 GridRegion region = null;
165 PresenceInfo pinfo = m_PresenceService.GetAgent(sessionID);
166 // this should succeed; if it doesn't there's something wrong with this grid
167 if (pinfo == null)
168 return null;
169
170 if (pinfo.RegionID.Equals(UUID.Zero))
171 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
172 else
173 {
174 region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID);
175 position = pinfo.Position;
176 lookAt = pinfo.LookAt;
177 }
178 return region;
179
180 }
181 else
182 {
183 // free uri form
184 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34
185 where = "url";
186 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
187 Match uriMatch = reURI.Match(startLocation);
188 if (uriMatch == null)
189 {
190 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation);
191 return null;
192 }
193 else
194 {
195 position = new Vector3(float.Parse(uriMatch.Groups["x"].Value),
196 float.Parse(uriMatch.Groups["y"].Value),
197 float.Parse(uriMatch.Groups["z"].Value));
198
199 string regionName = uriMatch.Groups["region"].ToString();
200 if (regionName != null)
201 {
202 if (!regionName.Contains("@"))
203 {
204 List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1);
205 if ((regions == null) || (regions != null && regions.Count == 0))
206 {
207 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName);
208 return null;
209 }
210 return regions[0];
211 }
212 else
213 {
214 string[] parts = regionName.Split(new char[] { '@' });
215 if (parts.Length < 2)
216 {
217 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName);
218 return null;
219 }
220 // Valid specification of a remote grid
221 regionName = parts[0];
222 string domainLocator = parts[1];
223 parts = domainLocator.Split(new char[] {':'});
224 string domainName = parts[0];
225 uint port = 0;
226 if (parts.Length > 1)
227 UInt32.TryParse(parts[1], out port);
228 GridRegion region = new GridRegion();
229 region.ExternalHostName = domainName;
230 region.HttpPort = port;
231 region.RegionName = regionName;
232 return region;
233 }
234
235 }
236 else
237 {
238 if (m_PresenceService == null || m_GridService == null)
239 return null;
240
241 return m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
242
243 }
244 }
245 //response.LookAt = "[r0,r1,r0]";
246 //// can be: last, home, safe, url
247 //response.StartLocation = "url";
248
249 }
250
251 }
252
253 private bool LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account, UUID session, out string reason)
254 {
255 reason = string.Empty;
256 AgentCircuitData aCircuit = new AgentCircuitData();
257 aCircuit.AgentID = account.PrincipalID;
258 //aCircuit.Appearance = optional
259 //aCircuit.BaseFolder = irrelevant
260 //aCircuit.CapsPath = required
261 aCircuit.child = false;
262 //aCircuit.circuitcode = required
263 aCircuit.firstname = account.FirstName;
264 //aCircuit.InventoryFolder = irrelevant
265 aCircuit.lastname = account.LastName;
266 //aCircuit.SecureSessionID = required
267 aCircuit.SessionID = session;
268 //aCircuit.startpos = required
269
270 return simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason);
271
272 }
273 }
274}
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index 2157462..fc6a6e1 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -41,27 +41,151 @@ namespace OpenSim.Services.PresenceService
41{ 41{
42 public class PresenceService : PresenceServiceBase, IPresenceService 42 public class PresenceService : PresenceServiceBase, IPresenceService
43 { 43 {
44// private static readonly ILog m_log = 44 private static readonly ILog m_log =
45// LogManager.GetLogger( 45 LogManager.GetLogger(
46// MethodBase.GetCurrentMethod().DeclaringType); 46 MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 public PresenceService(IConfigSource config) 48 public PresenceService(IConfigSource config)
49 : base(config) 49 : base(config)
50 { 50 {
51 m_log.Debug("[PRESENCE SERVICE]: Starting presence service");
51 } 52 }
52 53
53 public bool Report(PresenceInfo presence) 54 public bool LoginAgent(string userID, UUID sessionID,
55 UUID secureSessionID)
54 { 56 {
55 PresenceData p = new PresenceData(); 57 m_Database.Prune(userID);
56 p.Data = new Dictionary<string, string>();
57 58
58 p.UUID = presence.PrincipalID; 59 PresenceData[] d = m_Database.Get("UserID", userID);
59 p.currentRegion = presence.RegionID;
60 60
61 foreach (KeyValuePair<string, string> kvp in presence.Data) 61 PresenceData data = new PresenceData();
62 p.Data[kvp.Key] = kvp.Value;
63 62
64 return false; 63 data.UserID = userID;
64 data.RegionID = UUID.Zero;
65 data.SessionID = sessionID;
66 data.Data["SecureSessionID"] = secureSessionID.ToString();
67 data.Data["Online"] = "true";
68 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
69 if (d.Length > 0)
70 {
71 data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"];
72 data.Data["HomePosition"] = d[0].Data["HomePosition"];
73 data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"];
74 }
75
76 m_Database.Store(data);
77
78 return true;
79 }
80
81 public bool LogoutAgent(UUID sessionID)
82 {
83 PresenceData data = m_Database.Get(sessionID);
84 if (data == null)
85 return false;
86
87 PresenceData[] d = m_Database.Get("UserID", data.UserID);
88
89 if (d.Length > 1)
90 {
91 m_Database.Delete("SessionID", sessionID.ToString());
92 }
93
94 data.Data["Online"] = "false";
95 data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString();
96
97 m_Database.Store(data);
98
99 return true;
100 }
101
102 public bool LogoutRegionAgents(UUID regionID)
103 {
104 m_Database.LogoutRegionAgents(regionID);
105
106 return true;
107 }
108
109
110 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
111 {
112 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID);
113 PresenceData pdata = m_Database.Get(sessionID);
114 if (pdata == null)
115 return false;
116 if (pdata.Data["Online"] == "false")
117 return false;
118
119 return m_Database.ReportAgent(sessionID, regionID,
120 position.ToString(), lookAt.ToString());
121 }
122
123 public PresenceInfo GetAgent(UUID sessionID)
124 {
125 PresenceInfo ret = new PresenceInfo();
126
127 PresenceData data = m_Database.Get(sessionID);
128 if (data == null)
129 return null;
130
131 ret.UserID = data.UserID;
132 ret.RegionID = data.RegionID;
133 if (data.Data.ContainsKey("Online"))
134 ret.Online = bool.Parse(data.Data["Online"]);
135 if (data.Data.ContainsKey("Login"))
136 ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"]));
137 if (data.Data.ContainsKey("Logout"))
138 ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"]));
139 if (data.Data.ContainsKey("Position"))
140 ret.Position = Vector3.Parse(data.Data["Position"]);
141 if (data.Data.ContainsKey("LookAt"))
142 ret.LookAt = Vector3.Parse(data.Data["LookAt"]);
143 if (data.Data.ContainsKey("HomeRegionID"))
144 ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]);
145 if (data.Data.ContainsKey("HomePosition"))
146 ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]);
147 if (data.Data.ContainsKey("HomeLookAt"))
148 ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]);
149
150 return ret;
151 }
152
153 public PresenceInfo[] GetAgents(string[] userIDs)
154 {
155 List<PresenceInfo> info = new List<PresenceInfo>();
156
157 foreach (string userIDStr in userIDs)
158 {
159 PresenceData[] data = m_Database.Get("UserID",
160 userIDStr);
161
162 foreach (PresenceData d in data)
163 {
164 PresenceInfo ret = new PresenceInfo();
165
166 ret.UserID = d.UserID;
167 ret.RegionID = d.RegionID;
168 ret.Online = bool.Parse(d.Data["Online"]);
169 ret.Login = Util.ToDateTime(Convert.ToInt32(
170 d.Data["Login"]));
171 ret.Logout = Util.ToDateTime(Convert.ToInt32(
172 d.Data["Logout"]));
173 ret.Position = Vector3.Parse(d.Data["Position"]);
174 ret.LookAt = Vector3.Parse(d.Data["LookAt"]);
175 ret.HomeRegionID = new UUID(d.Data["HomeRegionID"]);
176 ret.HomePosition = Vector3.Parse(d.Data["HomePosition"]);
177 ret.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]);
178
179 info.Add(ret);
180 }
181 }
182
183 return info.ToArray();
184 }
185
186 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
187 {
188 return m_Database.SetHomeLocation(userID, regionID, position, lookAt);
65 } 189 }
66 } 190 }
67} 191}
diff --git a/OpenSim/Services/PresenceService/PresenceServiceBase.cs b/OpenSim/Services/PresenceService/PresenceServiceBase.cs
index 60a246b..3ca70c1 100644
--- a/OpenSim/Services/PresenceService/PresenceServiceBase.cs
+++ b/OpenSim/Services/PresenceService/PresenceServiceBase.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Services.PresenceService
44 { 44 {
45 string dllName = String.Empty; 45 string dllName = String.Empty;
46 string connString = String.Empty; 46 string connString = String.Empty;
47 string realm = "agents"; 47 string realm = "presence";
48 48
49 // 49 //
50 // Try reading the [DatabaseService] section, if it exists 50 // Try reading the [DatabaseService] section, if it exists
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
new file mode 100644
index 0000000..c14651d
--- /dev/null
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -0,0 +1,184 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using Nini.Config;
31using OpenSim.Data;
32using OpenSim.Services.Interfaces;
33using System.Collections.Generic;
34using OpenMetaverse;
35
36namespace OpenSim.Services.UserAccountService
37{
38 public class UserAccountService : UserAccountServiceBase, IUserAccountService
39 {
40 public UserAccountService(IConfigSource config) : base(config)
41 {
42 }
43
44 public UserAccount GetUserAccount(UUID scopeID, string firstName,
45 string lastName)
46 {
47 UserAccountData[] d;
48
49 if (scopeID != UUID.Zero)
50 {
51 d = m_Database.Get(
52 new string[] {"ScopeID", "FirstName", "LastName"},
53 new string[] {scopeID.ToString(), firstName, lastName});
54 }
55 else
56 {
57 d = m_Database.Get(
58 new string[] {"FirstName", "LastName"},
59 new string[] {firstName, lastName});
60 }
61
62 if (d.Length < 1)
63 return null;
64
65 return MakeUserAccount(d[0]);
66 }
67
68 private UserAccount MakeUserAccount(UserAccountData d)
69 {
70 UserAccount u = new UserAccount();
71 u.FirstName = d.FirstName;
72 u.LastName = d.LastName;
73 u.PrincipalID = d.PrincipalID;
74 u.ScopeID = d.ScopeID;
75 u.Email = d.Data["Email"].ToString();
76 u.Created = Convert.ToInt32(d.Data["Created"].ToString());
77
78 string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '});
79 u.ServiceURLs = new Dictionary<string, object>();
80
81 foreach(string url in URLs)
82 {
83 string[] parts = url.Split(new char[] {'='});
84
85 if (parts.Length != 2)
86 continue;
87
88 string name = System.Web.HttpUtility.UrlDecode(parts[0]);
89 string val = System.Web.HttpUtility.UrlDecode(parts[1]);
90
91 u.ServiceURLs[name] = val;
92 }
93
94 return u;
95 }
96
97 public UserAccount GetUserAccount(UUID scopeID, string email)
98 {
99 UserAccountData[] d;
100
101 if (scopeID != UUID.Zero)
102 {
103 d = m_Database.Get(
104 new string[] {"ScopeID", "Email"},
105 new string[] {scopeID.ToString(), email});
106 }
107 else
108 {
109 d = m_Database.Get(
110 new string[] {"Email"},
111 new string[] {email});
112 }
113
114 if (d.Length < 1)
115 return null;
116
117 return MakeUserAccount(d[0]);
118 }
119
120 public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
121 {
122 UserAccountData[] d;
123
124 if (scopeID != UUID.Zero)
125 {
126 d = m_Database.Get(
127 new string[] {"ScopeID", "PrincipalID"},
128 new string[] {scopeID.ToString(), principalID.ToString()});
129 }
130 else
131 {
132 d = m_Database.Get(
133 new string[] {"PrincipalID"},
134 new string[] {principalID.ToString()});
135 }
136
137 if (d.Length < 1)
138 return null;
139
140 return MakeUserAccount(d[0]);
141 }
142
143 public bool StoreUserAccount(UserAccount data)
144 {
145 UserAccountData d = new UserAccountData();
146
147 d.FirstName = data.FirstName;
148 d.LastName = data.LastName;
149 d.PrincipalID = data.PrincipalID;
150 d.ScopeID = data.ScopeID;
151 d.Data = new Dictionary<string,string>();
152 d.Data["Email"] = data.Email;
153 d.Data["Created"] = data.Created.ToString();
154
155 List<string> parts = new List<string>();
156
157 foreach (KeyValuePair<string,object> kvp in data.ServiceURLs)
158 {
159 string key = System.Web.HttpUtility.UrlEncode(kvp.Key);
160 string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
161 parts.Add(key + "=" + val);
162 }
163
164 d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray());
165
166 return m_Database.Store(d);
167 }
168
169 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
170 {
171 UserAccountData[] d = m_Database.GetUsers(scopeID, query);
172
173 if (d == null)
174 return new List<UserAccount>();
175
176 List<UserAccount> ret = new List<UserAccount>();
177
178 foreach (UserAccountData data in d)
179 ret.Add(MakeUserAccount(data));
180
181 return ret;
182 }
183 }
184}
diff --git a/OpenSim/Services/UserService/UserServiceBase.cs b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs
index fea8b01..70ed594 100644
--- a/OpenSim/Services/UserService/UserServiceBase.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs
@@ -40,20 +40,29 @@ namespace OpenSim.Services.UserAccountService
40 40
41 public UserAccountServiceBase(IConfigSource config) : base(config) 41 public UserAccountServiceBase(IConfigSource config) : base(config)
42 { 42 {
43 string dllName = String.Empty;
44 string connString = String.Empty;
45 string realm = "useraccounts";
46
47 IConfig dbConfig = config.Configs["DatabaseService"];
48 if (dbConfig != null)
49 {
50 dllName = dbConfig.GetString("StorageProvider", String.Empty);
51 connString = dbConfig.GetString("ConnectionString", String.Empty);
52 }
53
43 IConfig userConfig = config.Configs["UserAccountService"]; 54 IConfig userConfig = config.Configs["UserAccountService"];
44 if (userConfig == null) 55 if (userConfig == null)
45 throw new Exception("No UserAccountService configuration"); 56 throw new Exception("No UserAccountService configuration");
46 57
47 string dllName = userConfig.GetString("StorageProvider", 58 dllName = userConfig.GetString("StorageProvider", dllName);
48 String.Empty);
49 59
50 if (dllName == String.Empty) 60 if (dllName == String.Empty)
51 throw new Exception("No StorageProvider configured"); 61 throw new Exception("No StorageProvider configured");
52 62
53 string connString = userConfig.GetString("ConnectionString", 63 connString = userConfig.GetString("ConnectionString", connString);
54 String.Empty);
55 64
56 string realm = userConfig.GetString("Realm", "users"); 65 realm = userConfig.GetString("Realm", realm);
57 66
58 m_Database = LoadPlugin<IUserAccountData>(dllName, new Object[] {connString, realm}); 67 m_Database = LoadPlugin<IUserAccountData>(dllName, new Object[] {connString, realm});
59 68