aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authormingchen2007-06-28 14:45:46 +0000
committermingchen2007-06-28 14:45:46 +0000
commitbee543300fc812277e9a9478dc05b986e00ed44e (patch)
tree06282ee383d09a271cc8c7bbeed5dd41b5abee8c /OpenSim
parentFinished removing the old scripting code, Scene.Scripting.cs and OpenSim.Fram... (diff)
downloadopensim-SC_OLD-bee543300fc812277e9a9478dc05b986e00ed44e.zip
opensim-SC_OLD-bee543300fc812277e9a9478dc05b986e00ed44e.tar.gz
opensim-SC_OLD-bee543300fc812277e9a9478dc05b986e00ed44e.tar.bz2
opensim-SC_OLD-bee543300fc812277e9a9478dc05b986e00ed44e.tar.xz
*User Profile requests on OGS UserServer now uses XMLRPC instead of REST
*Added base support for setting up a master user
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Communications/IUserServices.cs5
-rw-r--r--OpenSim/Framework/UserManager/UserManagerBase.cs126
-rw-r--r--OpenSim/Grid/UserServer/Main.cs4
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs25
-rw-r--r--OpenSim/Region/Communications/OGS1/OGSUserServices.cs17
5 files changed, 107 insertions, 70 deletions
diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs
index 6790651..37f4942 100644
--- a/OpenSim/Framework/Communications/IUserServices.cs
+++ b/OpenSim/Framework/Communications/IUserServices.cs
@@ -39,6 +39,9 @@ namespace OpenSim.Framework.Communications
39 UserProfileData GetUserProfile(string firstName, string lastName); 39 UserProfileData GetUserProfile(string firstName, string lastName);
40 UserProfileData GetUserProfile(string name); 40 UserProfileData GetUserProfile(string name);
41 UserProfileData GetUserProfile(LLUUID avatarID); 41 UserProfileData GetUserProfile(LLUUID avatarID);
42 42
43 UserProfileData SetupMasterUser(string firstName, string lastName);
44 UserProfileData SetupMasterUser(string firstName, string lastName, string password);
45
43 } 46 }
44} 47}
diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs
index eb46c14..bc35164 100644
--- a/OpenSim/Framework/UserManager/UserManagerBase.cs
+++ b/OpenSim/Framework/UserManager/UserManagerBase.cs
@@ -537,27 +537,15 @@ namespace OpenSim.Framework.UserManagement
537 /// Returns an error message that the user could not be found in the database 537 /// Returns an error message that the user could not be found in the database
538 /// </summary> 538 /// </summary>
539 /// <returns>XML string consisting of a error element containing individual error(s)</returns> 539 /// <returns>XML string consisting of a error element containing individual error(s)</returns>
540 public string CreateUnknownUserErrorResponse() 540 public XmlRpcResponse CreateUnknownUserErrorResponse()
541 { 541 {
542 System.IO.StringWriter sw = new System.IO.StringWriter(); 542 XmlRpcResponse response = new XmlRpcResponse();
543 XmlTextWriter xw = new XmlTextWriter(sw); 543 Hashtable responseData = new Hashtable();
544 544 responseData["error_type"] = "unknown_user";
545 // Header 545 responseData["error_desc"] = "The user requested is not in the database";
546 xw.Formatting = Formatting.Indented;
547 xw.WriteStartDocument();
548 xw.WriteDocType("error", null, null, null);
549 xw.WriteComment("An error occured");
550 xw.WriteStartElement("error");
551
552 // User
553 xw.WriteElementString("unknownuser", "Unable to find a user with that name");
554
555 // Footer
556 xw.WriteEndElement();
557 xw.Flush();
558 xw.Close();
559 546
560 return sw.ToString(); 547 response.Value = responseData;
548 return response;
561 } 549 }
562 550
563 /// <summary> 551 /// <summary>
@@ -565,75 +553,81 @@ namespace OpenSim.Framework.UserManagement
565 /// </summary> 553 /// </summary>
566 /// <param name="profile">The user profile</param> 554 /// <param name="profile">The user profile</param>
567 /// <returns>A string containing an XML Document of the user profile</returns> 555 /// <returns>A string containing an XML Document of the user profile</returns>
568 public string ProfileToXml(UserProfileData profile) 556 public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile)
569 { 557 {
570 System.IO.StringWriter sw = new System.IO.StringWriter(); 558 XmlRpcResponse response = new XmlRpcResponse();
571 XmlTextWriter xw = new XmlTextWriter(sw); 559 Hashtable responseData = new Hashtable();
572 560
573 // Header
574 xw.Formatting = Formatting.Indented;
575 xw.WriteStartDocument();
576 xw.WriteDocType("userprofile", null, null, null);
577 xw.WriteComment("Found user profiles matching the request");
578 xw.WriteStartElement("users");
579
580 // User
581 xw.WriteStartElement("user");
582 // Account information 561 // Account information
583 xw.WriteAttributeString("firstname", profile.username); 562 responseData["firstname"] = profile.username;
584 xw.WriteAttributeString("lastname", profile.surname); 563 responseData["lastname"] = profile.surname;
585 xw.WriteAttributeString("uuid", profile.UUID.ToStringHyphenated()); 564 responseData["uuid"] = profile.UUID.ToStringHyphenated();
586 // Server Information 565 // Server Information
587 xw.WriteAttributeString("server_inventory", profile.userInventoryURI); 566 responseData["server_inventory"] = profile.userInventoryURI;
588 xw.WriteAttributeString("server_asset", profile.userAssetURI); 567 responseData["server_asset"] = profile.userAssetURI;
589 // Profile Information 568 // Profile Information
590 xw.WriteAttributeString("profile_about", profile.profileAboutText); 569 responseData["profile_about"] = profile.profileAboutText;
591 xw.WriteAttributeString("profile_firstlife_about", profile.profileFirstText); 570 responseData["profile_firstlife_about"] = profile.profileFirstText;
592 xw.WriteAttributeString("profile_firstlife_image", profile.profileFirstImage.ToStringHyphenated()); 571 responseData["profile_firstlife_image"] = profile.profileFirstImage.ToStringHyphenated();
593 xw.WriteAttributeString("profile_can_do", profile.profileCanDoMask.ToString()); 572 responseData["profile_can_do"] = profile.profileCanDoMask.ToString();
594 xw.WriteAttributeString("profile_want_do", profile.profileWantDoMask.ToString()); 573 responseData["profile_want_do"] = profile.profileWantDoMask.ToString();
595 xw.WriteAttributeString("profile_image", profile.profileImage.ToStringHyphenated()); 574 responseData["profile_image"] = profile.profileImage.ToStringHyphenated();
596 xw.WriteAttributeString("profile_created",profile.created.ToString()); 575 responseData["profile_created"] = profile.created.ToString();
597 xw.WriteAttributeString("profile_lastlogin",profile.lastLogin.ToString()); 576 responseData["profile_lastlogin"] = profile.lastLogin.ToString();
598 // Home region information 577 // Home region information
599 xw.WriteAttributeString("home_coordinates", profile.homeLocation.ToString()); 578 responseData["home_coordinates"] = profile.homeLocation.ToString();
600 xw.WriteAttributeString("home_region", profile.homeRegion.ToString()); 579 responseData["home_region"] = profile.homeRegion.ToString();
601 xw.WriteAttributeString("home_look", profile.homeLookAt.ToString()); 580 responseData["home_look"] = profile.homeLookAt.ToString();
602 581
603 xw.WriteEndElement(); 582 response.Value = responseData;
604 583 return response;
605 // Footer
606 xw.WriteEndElement();
607 xw.Flush();
608 xw.Close();
609
610 return sw.ToString();
611 } 584 }
612 585
613 #region REST Methods 586 #region XMLRPC User Methods
614 //should most likely move out of here and into the grid's userserver sub class 587 //should most likely move out of here and into the grid's userserver sub class
615 public string RestGetUserMethodName(string request, string path, string param) 588 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
616 { 589 {
617 UserProfileData userProfile = getUserProfile(param.Trim()); 590 XmlRpcResponse response = new XmlRpcResponse();
591 Hashtable requestData = (Hashtable)request.Params[0];
592 UserProfileData userProfile;
618 593
619 if (userProfile == null) 594 if (requestData.Contains("avatar_name"))
595 {
596 userProfile = getUserProfile((string)requestData["avatar_name"]);
597 if (userProfile == null)
598 {
599 return CreateUnknownUserErrorResponse();
600 }
601 }
602 else
620 { 603 {
621 return CreateUnknownUserErrorResponse(); 604 return CreateUnknownUserErrorResponse();
622 } 605 }
606
623 607
624 return ProfileToXml(userProfile); 608 return ProfileToXmlRPCResponse(userProfile);
625 } 609 }
626 610
627 public string RestGetUserMethodUUID(string request, string path, string param) 611 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request)
628 { 612 {
629 UserProfileData userProfile = getUserProfile(new LLUUID(param)); 613 XmlRpcResponse response = new XmlRpcResponse();
630 614 Hashtable requestData = (Hashtable)request.Params[0];
631 if (userProfile == null) 615 UserProfileData userProfile;
616 if (requestData.Contains("avatar_uuid"))
617 {
618 userProfile = getUserProfile((LLUUID)requestData["avatar_uuid"]);
619 if (userProfile == null)
620 {
621 return CreateUnknownUserErrorResponse();
622 }
623 }
624 else
632 { 625 {
633 return CreateUnknownUserErrorResponse(); 626 return CreateUnknownUserErrorResponse();
634 } 627 }
635 628
636 return ProfileToXml(userProfile); 629
630 return ProfileToXmlRPCResponse(userProfile);
637 } 631 }
638 #endregion 632 #endregion
639 633
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 8ae4dbf..640f91a 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -107,8 +107,8 @@ namespace OpenSim.Grid.UserServer
107 107
108 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod); 108 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
109 109
110 httpServer.AddRestHandler("GET", "/user/name/", m_userManager.RestGetUserMethodName); 110 httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
111 httpServer.AddRestHandler("GET", "/user/uuid/", m_userManager.RestGetUserMethodUUID); 111 httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID);
112 112
113 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod); 113 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
114 114
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
index 1eb574c..2097870 100644
--- a/OpenSim/Region/Communications/Local/LocalUserServices.cs
+++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs
@@ -114,5 +114,30 @@ namespace OpenSim.Region.Communications.Local
114 114
115 } 115 }
116 116
117 public UserProfileData SetupMasterUser(string firstName, string lastName)
118 {
119 return SetupMasterUser(firstName, lastName, "");
120 }
121 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
122 {
123 UserProfileData profile = getUserProfile(firstName, lastName);
124 if (profile != null)
125 {
126
127 return profile;
128 }
129
130 Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account");
131 this.AddUserProfile(firstName, lastName, password, defaultHomeX, defaultHomeY);
132
133 profile = getUserProfile(firstName, lastName);
134
135 if (profile == null)
136 {
137 Console.WriteLine("Unknown Master User after creation attempt. No clue what to do here.");
138 }
139
140 return profile;
141 }
117 } 142 }
118} 143}
diff --git a/OpenSim/Region/Communications/OGS1/OGSUserServices.cs b/OpenSim/Region/Communications/OGS1/OGSUserServices.cs
index 012774d..48d3018 100644
--- a/OpenSim/Region/Communications/OGS1/OGSUserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGSUserServices.cs
@@ -11,7 +11,7 @@ namespace OpenSim.Region.Communications.OGS1
11 { 11 {
12 public UserProfileData GetUserProfile(string firstName, string lastName) 12 public UserProfileData GetUserProfile(string firstName, string lastName)
13 { 13 {
14 return null; 14 return GetUserProfile(firstName + " " + lastName);
15 } 15 }
16 public UserProfileData GetUserProfile(string name) 16 public UserProfileData GetUserProfile(string name)
17 { 17 {
@@ -21,5 +21,20 @@ namespace OpenSim.Region.Communications.OGS1
21 { 21 {
22 return null; 22 return null;
23 } 23 }
24
25 public UserProfileData SetupMasterUser(string firstName, string lastName)
26 {
27 return SetupMasterUser(firstName, lastName, "");
28 }
29
30 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
31 {
32 UserProfileData profile = GetUserProfile(firstName, lastName);
33 if (profile == null)
34 {
35 Console.WriteLine("Unknown Master User. Grid Mode: No clue what I should do. Probably would choose the grid owner UUID when that is implemented");
36 }
37 return null;
38 }
24 } 39 }
25} 40}