aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/UserManager/UserManagerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/UserManager/UserManagerBase.cs')
-rw-r--r--OpenSim/Framework/UserManager/UserManagerBase.cs258
1 files changed, 16 insertions, 242 deletions
diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs
index 64c3be1..c1084e9 100644
--- a/OpenSim/Framework/UserManager/UserManagerBase.cs
+++ b/OpenSim/Framework/UserManager/UserManagerBase.cs
@@ -339,248 +339,6 @@ namespace OpenSim.Framework.UserManagement
339 #endregion 339 #endregion
340 340
341 /// <summary> 341 /// <summary>
342 /// Checks a user against it's password hash
343 /// </summary>
344 /// <param name="profile">The users profile</param>
345 /// <param name="password">The supplied password</param>
346 /// <returns>Authenticated?</returns>
347 public virtual bool AuthenticateUser(UserProfileData profile, string password)
348 {
349 MainLog.Instance.Verbose(
350 "Authenticating " + profile.username + " " + profile.surname);
351
352 password = password.Remove(0, 3); //remove $1$
353
354 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
355
356 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
357 }
358
359 #region Xml Response
360
361 /// <summary>
362 ///
363 /// </summary>
364 /// <param name="firstname"></param>
365 /// <param name="lastname"></param>
366 /// <returns></returns>
367 public virtual UserProfileData GetTheUser(string firstname, string lastname)
368 {
369 return getUserProfile(firstname, lastname);
370 }
371
372 /// <summary>
373 ///
374 /// </summary>
375 /// <returns></returns>
376 public virtual string GetMessage()
377 {
378 return _config.DefaultStartupMsg;
379 }
380
381 /// <summary>
382 ///
383 /// </summary>
384 /// <returns></returns>
385 protected virtual ArrayList GetInventoryLibrary()
386 {
387 //return new ArrayList();
388 Hashtable TempHash = new Hashtable();
389 TempHash["name"] = "OpenSim Library";
390 TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated();
391 TempHash["version"] = "1";
392 TempHash["type_default"] = "-1";
393 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
394 ArrayList temp = new ArrayList();
395 temp.Add(TempHash);
396
397 TempHash = new Hashtable();
398 TempHash["name"] = "Texture Library";
399 TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000";
400 TempHash["version"] = "1";
401 TempHash["type_default"] = "-1";
402 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001";
403 temp.Add(TempHash);
404 return temp;
405 }
406
407 /// <summary>
408 ///
409 /// </summary>
410 /// <returns></returns>
411 protected virtual ArrayList GetLibraryOwner()
412 {
413 //for now create random inventory library owner
414 Hashtable TempHash = new Hashtable();
415 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000";
416 ArrayList inventoryLibOwner = new ArrayList();
417 inventoryLibOwner.Add(TempHash);
418 return inventoryLibOwner;
419 }
420
421 protected virtual AgentInventory GetUsersInventory(LLUUID agentID)
422 {
423 AgentInventory userInventory = new AgentInventory();
424 userInventory.CreateRootFolder(agentID, false);
425
426 return userInventory;
427 }
428
429 protected virtual ArrayList CreateInventoryArray(AgentInventory userInventory)
430 {
431 ArrayList AgentInventoryArray = new ArrayList();
432 Hashtable TempHash;
433 foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
434 {
435 TempHash = new Hashtable();
436 TempHash["name"] = InvFolder.FolderName;
437 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
438 TempHash["version"] = (Int32)InvFolder.Version;
439 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
440 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
441 AgentInventoryArray.Add(TempHash);
442 }
443 return AgentInventoryArray;
444 }
445
446 /// <summary>
447 /// Customises the login response and fills in missing values.
448 /// </summary>
449 /// <param name="response">The existing response</param>
450 /// <param name="theUser">The user profile</param>
451 public abstract void CustomiseResponse( LoginResponse response, UserProfileData theUser);
452
453 /// <summary>
454 /// Main user login function
455 /// </summary>
456 /// <param name="request">The XMLRPC request</param>
457 /// <returns>The response to send</returns>
458 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
459 {
460
461 System.Console.WriteLine("Attempting login now...");
462 XmlRpcResponse response = new XmlRpcResponse();
463 Hashtable requestData = (Hashtable)request.Params[0];
464
465 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
466 bool GoodLogin = false;
467 string firstname = "";
468 string lastname = "";
469 string passwd = "";
470
471 UserProfileData userProfile;
472 LoginResponse logResponse = new LoginResponse();
473
474 if (GoodXML)
475 {
476 firstname = (string)requestData["first"];
477 lastname = (string)requestData["last"];
478 passwd = (string)requestData["passwd"];
479
480 userProfile = GetTheUser(firstname, lastname);
481 if (userProfile == null)
482 return logResponse.CreateLoginFailedResponse();
483
484 GoodLogin = AuthenticateUser(userProfile, passwd);
485 }
486 else
487 {
488 return logResponse.CreateGridErrorResponse();
489 }
490
491 if (!GoodLogin)
492 {
493 return logResponse.CreateLoginFailedResponse();
494 }
495 else
496 {
497 // If we already have a session...
498 if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline)
499 {
500 // Reject the login
501 return logResponse.CreateAlreadyLoggedInResponse();
502 }
503 // Otherwise...
504 // Create a new agent session
505 CreateAgent( userProfile, request);
506
507 try
508 {
509 LLUUID agentID = userProfile.UUID;
510
511 // Inventory Library Section
512 AgentInventory userInventory = this.GetUsersInventory(agentID);
513 ArrayList AgentInventoryArray = this.CreateInventoryArray(userInventory);
514
515 Hashtable InventoryRootHash = new Hashtable();
516 InventoryRootHash["folder_id"] = userInventory.InventoryRoot.FolderID.ToStringHyphenated();
517 ArrayList InventoryRoot = new ArrayList();
518 InventoryRoot.Add(InventoryRootHash);
519 userProfile.rootInventoryFolderID = userInventory.InventoryRoot.FolderID;
520
521 // Circuit Code
522 uint circode = (uint)(Util.RandomClass.Next());
523
524 logResponse.Lastname = userProfile.surname;
525 logResponse.Firstname = userProfile.username;
526 logResponse.AgentID = agentID.ToStringHyphenated();
527 logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated();
528 logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated();
529 logResponse.InventoryRoot = InventoryRoot;
530 logResponse.InventorySkeleton = AgentInventoryArray;
531 logResponse.InventoryLibrary = this.GetInventoryLibrary();
532 logResponse.InventoryLibraryOwner = this.GetLibraryOwner();
533 logResponse.CircuitCode = (Int32)circode;
534 //logResponse.RegionX = 0; //overwritten
535 //logResponse.RegionY = 0; //overwritten
536 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
537 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
538 //logResponse.SimAddress = "127.0.0.1"; //overwritten
539 //logResponse.SimPort = 0; //overwritten
540 logResponse.Message = this.GetMessage();
541
542 try
543 {
544 this.CustomiseResponse( logResponse, userProfile);
545 }
546 catch (Exception e)
547 {
548 System.Console.WriteLine(e.ToString());
549 return logResponse.CreateDeadRegionResponse();
550 //return logResponse.ToXmlRpcResponse();
551 }
552 CommitAgent(ref userProfile);
553 return logResponse.ToXmlRpcResponse();
554
555 }
556
557 catch (Exception E)
558 {
559 System.Console.WriteLine(E.ToString());
560 }
561 //}
562 }
563 return response;
564
565 }
566
567 #endregion
568
569 /// <summary>
570 /// Deletes an active agent session
571 /// </summary>
572 /// <param name="request">The request</param>
573 /// <param name="path">The path (eg /bork/narf/test)</param>
574 /// <param name="param">Parameters sent</param>
575 /// <returns>Success "OK" else error</returns>
576 public string RestDeleteUserSessionMethod(string request, string path, string param)
577 {
578 // TODO! Important!
579
580 return "OK";
581 }
582
583 /// <summary>
584 /// 342 ///
585 /// </summary> 343 /// </summary>
586 /// <param name="user"></param> 344 /// <param name="user"></param>
@@ -611,6 +369,22 @@ namespace OpenSim.Framework.UserManagement
611 } 369 }
612 } 370 }
613 371
372 // Rest and XML-RPC methods. (could move them to a sub class in the user server?)
373
374 /// <summary>
375 /// Deletes an active agent session
376 /// </summary>
377 /// <param name="request">The request</param>
378 /// <param name="path">The path (eg /bork/narf/test)</param>
379 /// <param name="param">Parameters sent</param>
380 /// <returns>Success "OK" else error</returns>
381 public string RestDeleteUserSessionMethod(string request, string path, string param)
382 {
383 // TODO! Important!
384
385 return "OK";
386 }
387
614 /// <summary> 388 /// <summary>
615 /// Returns an error message that the user could not be found in the database 389 /// Returns an error message that the user could not be found in the database
616 /// </summary> 390 /// </summary>