aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorTeravus Ovares2008-01-05 06:05:25 +0000
committerTeravus Ovares2008-01-05 06:05:25 +0000
commitdb3edff5d5f1c9a31f377db77d1ac4e1fa685623 (patch)
tree5b2066a5556b3eff8f0152bdb3ce109b428081fe /OpenSim/Framework/Communications
parent* Added shell Messaging Server. Don't run the MessagingServer yet or you mig... (diff)
downloadopensim-SC-db3edff5d5f1c9a31f377db77d1ac4e1fa685623.zip
opensim-SC-db3edff5d5f1c9a31f377db77d1ac4e1fa685623.tar.gz
opensim-SC-db3edff5d5f1c9a31f377db77d1ac4e1fa685623.tar.bz2
opensim-SC-db3edff5d5f1c9a31f377db77d1ac4e1fa685623.tar.xz
* Applying jhurliman's LLSD login enablement patch.
* I'm keeping it deactivated until some issues are resolved. * I'm patching it in deactivated so the patch doesn't get outdated * I've deactivated it by commenting out the handler for the application/xml+llsd content type. * While I've tested this as much as possible on my setup and found the deactivated code doesn't cause any problems, consider this update experimental (event though it's deactivated)
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/LoginResponse.cs161
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs132
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs38
3 files changed, 329 insertions, 2 deletions
diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs
index 954aecb..2239a9c 100644
--- a/OpenSim/Framework/Communications/LoginResponse.cs
+++ b/OpenSim/Framework/Communications/LoginResponse.cs
@@ -30,6 +30,7 @@ using System;
30using System.Collections; 30using System.Collections;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using libsecondlife; 32using libsecondlife;
33using libsecondlife.StructuredData;
33using Nwc.XmlRpc; 34using Nwc.XmlRpc;
34using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
35 36
@@ -197,11 +198,31 @@ namespace OpenSim.Framework.UserManagement
197 return (xmlRpcResponse); 198 return (xmlRpcResponse);
198 } // GenerateResponse 199 } // GenerateResponse
199 200
201 public LLSD GenerateFailureResponseLLSD(string reason, string message, string login)
202 {
203 LLSDMap map = new LLSDMap();
204
205 // Ensure Login Failed message/reason;
206 ErrorMessage = message;
207 ErrorReason = reason;
208
209 map["reason"] = LLSD.FromString(ErrorReason);
210 map["message"] = LLSD.FromString(ErrorMessage);
211 map["login"] = LLSD.FromString(login);
212
213 return map;
214 }
215
200 public XmlRpcResponse CreateFailedResponse() 216 public XmlRpcResponse CreateFailedResponse()
201 { 217 {
202 return (CreateLoginFailedResponse()); 218 return (CreateLoginFailedResponse());
203 } // CreateErrorConnectingToGridResponse() 219 } // CreateErrorConnectingToGridResponse()
204 220
221 public LLSD CreateFailedResponseLLSD()
222 {
223 return CreateLoginFailedResponseLLSD();
224 }
225
205 public XmlRpcResponse CreateLoginFailedResponse() 226 public XmlRpcResponse CreateLoginFailedResponse()
206 { 227 {
207 return 228 return
@@ -210,6 +231,14 @@ namespace OpenSim.Framework.UserManagement
210 "false")); 231 "false"));
211 } // LoginFailedResponse 232 } // LoginFailedResponse
212 233
234 public LLSD CreateLoginFailedResponseLLSD()
235 {
236 return GenerateFailureResponseLLSD(
237 "key",
238 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
239 "false");
240 }
241
213 public XmlRpcResponse CreateAlreadyLoggedInResponse() 242 public XmlRpcResponse CreateAlreadyLoggedInResponse()
214 { 243 {
215 return 244 return
@@ -218,6 +247,14 @@ namespace OpenSim.Framework.UserManagement
218 "false")); 247 "false"));
219 } // CreateAlreadyLoggedInResponse() 248 } // CreateAlreadyLoggedInResponse()
220 249
250 public LLSD CreateAlreadyLoggedInResponseLLSD()
251 {
252 return GenerateFailureResponseLLSD(
253 "presence",
254 "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner",
255 "false");
256 }
257
221 public XmlRpcResponse CreateDeadRegionResponse() 258 public XmlRpcResponse CreateDeadRegionResponse()
222 { 259 {
223 return 260 return
@@ -226,6 +263,14 @@ namespace OpenSim.Framework.UserManagement
226 "false")); 263 "false"));
227 } 264 }
228 265
266 public LLSD CreateDeadRegionResponseLLSD()
267 {
268 return GenerateFailureResponseLLSD(
269 "key",
270 "The region you are attempting to log into is not responding. Please select another region and try again.",
271 "false");
272 }
273
229 public XmlRpcResponse CreateGridErrorResponse() 274 public XmlRpcResponse CreateGridErrorResponse()
230 { 275 {
231 return 276 return
@@ -234,6 +279,14 @@ namespace OpenSim.Framework.UserManagement
234 "false")); 279 "false"));
235 } 280 }
236 281
282 public LLSD CreateGridErrorResponseLLSD()
283 {
284 return GenerateFailureResponseLLSD(
285 "key",
286 "Error connecting to grid. Could not percieve credentials from login XML.",
287 "false");
288 }
289
237 #endregion 290 #endregion
238 291
239 public XmlRpcResponse ToXmlRpcResponse() 292 public XmlRpcResponse ToXmlRpcResponse()
@@ -317,6 +370,112 @@ namespace OpenSim.Framework.UserManagement
317 } 370 }
318 } // ToXmlRpcResponse 371 } // ToXmlRpcResponse
319 372
373 public LLSD ToLLSDResponse()
374 {
375 try
376 {
377 LLSDMap map = new LLSDMap();
378
379 map["first_name"] = LLSD.FromString(Firstname);
380 map["last_name"] = LLSD.FromString(Lastname);
381 map["agent_access"] = LLSD.FromString(agentAccess);
382
383 map["sim_port"] = LLSD.FromInteger(SimPort);
384 map["sim_ip"] = LLSD.FromString(SimAddress);
385
386 map["agent_id"] = LLSD.FromUUID(AgentID);
387 map["session_id"] = LLSD.FromUUID(SessionID);
388 map["secure_session_id"] = LLSD.FromUUID(SecureSessionID);
389 map["circuit_code"] = LLSD.FromInteger(CircuitCode);
390 map["seconds_since_epoch"] = LLSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
391
392 #region Login Flags
393
394 LLSDMap loginFlagsLLSD = new LLSDMap();
395 loginFlagsLLSD["daylight_savings"] = LLSD.FromString(DST);
396 loginFlagsLLSD["stipend_since_login"] = LLSD.FromString(StipendSinceLogin);
397 loginFlagsLLSD["gendered"] = LLSD.FromString(Gendered);
398 loginFlagsLLSD["ever_logged_in"] = LLSD.FromString(EverLoggedIn);
399 map["login-flags"] = WrapLLSDMap(loginFlagsLLSD);
400
401 #endregion Login Flags
402
403 #region Global Textures
404
405 LLSDMap globalTexturesLLSD = new LLSDMap();
406 globalTexturesLLSD["sun_texture_id"] = LLSD.FromString(SunTexture);
407 globalTexturesLLSD["cloud_texture_id"] = LLSD.FromString(CloudTexture);
408 globalTexturesLLSD["moon_texture_id"] = LLSD.FromString(MoonTexture);
409
410 map["global-textures"] = WrapLLSDMap(globalTexturesLLSD);
411
412 #endregion Global Textures
413
414 map["seed_capability"] = LLSD.FromString(seedCapability);
415
416 // FIXME: Need a function that will convert these ArrayLists in to LLSDArrays,
417 // and convert the data inside them to LLSD objects as well
418
419 //map["event_categories"] = eventCategories;
420 //map["event_notifications"] = new LLSDArray(); // todo
421 //map["classified_categories"] = classifiedCategories;
422
423 #region UI Config
424
425 LLSDMap uiConfigLLSD = new LLSDMap();
426 uiConfigLLSD["allow_first_life"] = LLSD.FromString(allowFirstLife);
427 map["ui-config"] = WrapLLSDMap(uiConfigLLSD);
428
429 #endregion UI Config
430
431 #region Inventory
432
433 //map["inventory-skeleton"] = agentInventory;
434 //map["inventory-skel-lib"] = inventoryLibrary;
435 //map["inventory-root"] = inventoryRoot;
436 //map["inventory-lib-root"] = inventoryLibRoot;
437 //map["inventory-lib-owner"] = inventoryLibraryOwner;
438
439 #endregion Inventory
440
441 map["gestures"] = new LLSDArray(); // todo
442
443 //responseData["initial-outfit"] = initialOutfit;
444 //responseData["start_location"] = startLocation;
445
446 map["seed_capability"] = LLSD.FromString(seedCapability);
447 map["home"] = LLSD.FromString(home);
448 map["look_at"] = LLSD.FromString(lookAt);
449 map["message"] = LLSD.FromString(welcomeMessage);
450 map["region_x"] = LLSD.FromInteger(RegionX * 256);
451 map["region_y"] = LLSD.FromInteger(RegionY * 256);
452
453 if (m_buddyList != null)
454 {
455 //map["buddy-list"] = m_buddyList.ToArray();
456 }
457
458 map["login"] = LLSD.FromString("true");
459
460 return map;
461 }
462 catch (Exception e)
463 {
464 MainLog.Instance.Warn(
465 "CLIENT",
466 "LoginResponse: Error creating XML-RPC Response: " + e.Message
467 );
468 return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false");
469 }
470 }
471
472 private LLSDArray WrapLLSDMap(LLSDMap wrapMe)
473 {
474 LLSDArray array = new LLSDArray();
475 array.Add(wrapMe);
476 return array;
477 }
478
320 public void SetEventCategories(string category, string value) 479 public void SetEventCategories(string category, string value)
321 { 480 {
322 // this.eventCategoriesHash[category] = value; 481 // this.eventCategoriesHash[category] = value;
@@ -591,4 +750,4 @@ namespace OpenSim.Framework.UserManagement
591 } 750 }
592 } 751 }
593 } 752 }
594} \ No newline at end of file 753}
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 0531d6a..9cfac1c 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -31,6 +31,7 @@ using System.Collections;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Threading; 32using System.Threading;
33using libsecondlife; 33using libsecondlife;
34using libsecondlife.StructuredData;
34using Nwc.XmlRpc; 35using Nwc.XmlRpc;
35 36
36using OpenSim.Framework.Communications.Cache; 37using OpenSim.Framework.Communications.Cache;
@@ -198,6 +199,132 @@ namespace OpenSim.Framework.UserManagement
198 } 199 }
199 } 200 }
200 201
202 public LLSD LLSDLoginMethod(LLSD request)
203 {
204 // Temporary fix
205 m_loginMutex.WaitOne();
206
207 try
208 {
209 bool GoodLogin = false;
210
211 UserProfileData userProfile = null;
212 LoginResponse logResponse = new LoginResponse();
213
214 if (request.Type == LLSDType.Map)
215 {
216 LLSDMap map = (LLSDMap)request;
217
218 if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd"))
219 {
220 string firstname = map["first"].AsString();
221 string lastname = map["last"].AsString();
222 string passwd = map["passwd"].AsString();
223
224 userProfile = GetTheUser(firstname, lastname);
225 if (userProfile == null)
226 {
227 MainLog.Instance.Verbose(
228 "LOGIN",
229 "Could not find a profile for " + firstname + " " + lastname);
230
231 return logResponse.CreateLoginFailedResponseLLSD();
232 }
233
234 GoodLogin = AuthenticateUser(userProfile, passwd);
235 }
236 }
237
238 if (!GoodLogin)
239 {
240 return logResponse.CreateLoginFailedResponseLLSD();
241 }
242 else
243 {
244 // If we already have a session...
245 if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline)
246 {
247 userProfile.currentAgent = null;
248 m_userManager.CommitAgent(ref userProfile);
249
250 // Reject the login
251 return logResponse.CreateAlreadyLoggedInResponseLLSD();
252 }
253
254 // Otherwise...
255 // Create a new agent session
256 CreateAgent(userProfile, request);
257
258 try
259 {
260 LLUUID agentID = userProfile.UUID;
261
262 // Inventory Library Section
263 InventoryData inventData = CreateInventoryData(agentID);
264 ArrayList AgentInventoryArray = inventData.InventoryArray;
265
266 Hashtable InventoryRootHash = new Hashtable();
267 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
268 ArrayList InventoryRoot = new ArrayList();
269 InventoryRoot.Add(InventoryRootHash);
270 userProfile.rootInventoryFolderID = inventData.RootFolderID;
271
272 // Circuit Code
273 uint circode = (uint)(Util.RandomClass.Next());
274
275 logResponse.Lastname = userProfile.surname;
276 logResponse.Firstname = userProfile.username;
277 logResponse.AgentID = agentID.ToString();
278 logResponse.SessionID = userProfile.currentAgent.sessionID.ToString();
279 logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToString();
280 logResponse.InventoryRoot = InventoryRoot;
281 logResponse.InventorySkeleton = AgentInventoryArray;
282 logResponse.InventoryLibrary = GetInventoryLibrary();
283
284 Hashtable InventoryLibRootHash = new Hashtable();
285 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
286 ArrayList InventoryLibRoot = new ArrayList();
287 InventoryLibRoot.Add(InventoryLibRootHash);
288 logResponse.InventoryLibRoot = InventoryLibRoot;
289
290 logResponse.InventoryLibraryOwner = GetLibraryOwner();
291 logResponse.CircuitCode = (Int32)circode;
292 //logResponse.RegionX = 0; //overwritten
293 //logResponse.RegionY = 0; //overwritten
294 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
295 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
296 //logResponse.SimAddress = "127.0.0.1"; //overwritten
297 //logResponse.SimPort = 0; //overwritten
298 logResponse.Message = GetMessage();
299 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
300
301 try
302 {
303 CustomiseResponse(logResponse, userProfile);
304 }
305 catch (Exception ex)
306 {
307 MainLog.Instance.Verbose("LOGIN", ex.ToString());
308 return logResponse.CreateDeadRegionResponseLLSD();
309 }
310
311 CommitAgent(ref userProfile);
312
313 return logResponse.ToLLSDResponse();
314 }
315 catch (Exception ex)
316 {
317 MainLog.Instance.Verbose("LOGIN", ex.ToString());
318 return logResponse.CreateFailedResponseLLSD();
319 }
320 }
321 }
322 finally
323 {
324 m_loginMutex.ReleaseMutex();
325 }
326 }
327
201 /// <summary> 328 /// <summary>
202 /// Customises the login response and fills in missing values. 329 /// Customises the login response and fills in missing values.
203 /// </summary> 330 /// </summary>
@@ -246,6 +373,11 @@ namespace OpenSim.Framework.UserManagement
246 m_userManager.CreateAgent(profile, request); 373 m_userManager.CreateAgent(profile, request);
247 } 374 }
248 375
376 public void CreateAgent(UserProfileData profile, LLSD request)
377 {
378 m_userManager.CreateAgent(profile, request);
379 }
380
249 /// <summary> 381 /// <summary>
250 /// 382 ///
251 /// </summary> 383 /// </summary>
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index 5d62e5e..bea56ea 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Security.Cryptography; 32using System.Security.Cryptography;
33using libsecondlife; 33using libsecondlife;
34using libsecondlife.StructuredData;
34using Nwc.XmlRpc; 35using Nwc.XmlRpc;
35using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
36 37
@@ -394,6 +395,41 @@ namespace OpenSim.Framework.UserManagement
394 profile.currentAgent = agent; 395 profile.currentAgent = agent;
395 } 396 }
396 397
398 public void CreateAgent(UserProfileData profile, LLSD request)
399 {
400 UserAgentData agent = new UserAgentData();
401
402 // User connection
403 agent.agentOnline = true;
404
405 // Generate sessions
406 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
407 byte[] randDataS = new byte[16];
408 byte[] randDataSS = new byte[16];
409 rand.GetBytes(randDataS);
410 rand.GetBytes(randDataSS);
411
412 agent.secureSessionID = new LLUUID(randDataSS, 0);
413 agent.sessionID = new LLUUID(randDataS, 0);
414
415 // Profile UUID
416 agent.UUID = profile.UUID;
417
418 // Current position (from Home)
419 agent.currentHandle = profile.homeRegion;
420 agent.currentPos = profile.homeLocation;
421
422 // What time did the user login?
423 agent.loginTime = Util.UnixTimeSinceEpoch();
424 agent.logoutTime = 0;
425
426 // Current location
427 agent.regionID = LLUUID.Zero; // Fill in later
428 agent.currentRegion = LLUUID.Zero; // Fill in later
429
430 profile.currentAgent = agent;
431 }
432
397 /// <summary> 433 /// <summary>
398 /// Saves a target agent to the database 434 /// Saves a target agent to the database
399 /// </summary> 435 /// </summary>
@@ -445,4 +481,4 @@ namespace OpenSim.Framework.UserManagement
445 public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); 481 public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password);
446 public abstract UserProfileData SetupMasterUser(LLUUID uuid); 482 public abstract UserProfileData SetupMasterUser(LLUUID uuid);
447 } 483 }
448} \ No newline at end of file 484}