From 646bbbc84b8010e0dacbeed5342cdb045f46cc49 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 27 Jun 2007 15:28:52 +0000 Subject: Some work on restructuring the namespaces / project names. Note this doesn't compile yet as not all the code has been changed to use the new namespaces. Am committing it now for feedback on the namespaces. --- OpenSim/Framework/UserManager/UserManagerBase.cs | 641 +++++++++++++++++++++++ 1 file changed, 641 insertions(+) create mode 100644 OpenSim/Framework/UserManager/UserManagerBase.cs (limited to 'OpenSim/Framework/UserManager/UserManagerBase.cs') diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs new file mode 100644 index 0000000..eb46c14 --- /dev/null +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -0,0 +1,641 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Data; +using libsecondlife; +using System.Reflection; + +using System.Xml; +using Nwc.XmlRpc; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; + +using System.Security.Cryptography; + +namespace OpenSim.Framework.UserManagement +{ + public class UserManagerBase + { + public OpenSim.Framework.Interfaces.UserConfig _config; + Dictionary _plugins = new Dictionary(); + + /// + /// Adds a new user server plugin - user servers will be requested in the order they were loaded. + /// + /// The filename to the user server plugin DLL + public void AddPlugin(string FileName) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IUserData", true); + + if (typeInterface != null) + { + IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Initialise(); + this._plugins.Add(plug.getName(), plug); + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface"); + } + + typeInterface = null; + } + } + + pluginAssembly = null; + } + + #region Get UserProfile + /// + /// Loads a user profile from a database by UUID + /// + /// The target UUID + /// A user profile + public UserProfileData getUserProfile(LLUUID uuid) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + UserProfileData profile = plugin.Value.getUserByUUID(uuid); + profile.currentAgent = getUserAgent(profile.UUID); + return profile; + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + + /// + /// Loads a user profile by name + /// + /// The target name + /// A user profile + public UserProfileData getUserProfile(string name) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + UserProfileData profile = plugin.Value.getUserByName(name); + profile.currentAgent = getUserAgent(profile.UUID); + return profile; + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + /// + /// Loads a user profile by name + /// + /// First name + /// Last name + /// A user profile + public UserProfileData getUserProfile(string fname, string lname) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + UserProfileData profile = plugin.Value.getUserByName(fname,lname); + try + { + profile.currentAgent = getUserAgent(profile.UUID); + } + catch (Exception e) + { + // Ignore + } + return profile; + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + #endregion + + #region Get UserAgent + /// + /// Loads a user agent by uuid (not called directly) + /// + /// The agents UUID + /// Agent profiles + public UserAgentData getUserAgent(LLUUID uuid) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getAgentByUUID(uuid); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + /// + /// Loads a user agent by name (not called directly) + /// + /// The agents name + /// A user agent + public UserAgentData getUserAgent(string name) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getAgentByName(name); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + /// + /// Loads a user agent by name (not called directly) + /// + /// The agents firstname + /// The agents lastname + /// A user agent + public UserAgentData getUserAgent(string fname, string lname) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getAgentByName(fname,lname); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + #endregion + + #region CreateAgent + /// + /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB + /// + /// The users profile + /// The users loginrequest + public void CreateAgent(ref UserProfileData profile, XmlRpcRequest request) + { + Hashtable requestData = (Hashtable)request.Params[0]; + + UserAgentData agent = new UserAgentData(); + + // User connection + agent.agentIP = ""; + agent.agentOnline = true; + agent.agentPort = 0; + + // Generate sessions + RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); + byte[] randDataS = new byte[16]; + byte[] randDataSS = new byte[16]; + rand.GetBytes(randDataS); + rand.GetBytes(randDataSS); + + agent.secureSessionID = new LLUUID(randDataSS, 0); + agent.sessionID = new LLUUID(randDataS, 0); + + // Profile UUID + agent.UUID = profile.UUID; + + // Current position (from Home) + agent.currentHandle = profile.homeRegion; + agent.currentPos = profile.homeLocation; + + // If user specified additional start, use that + if (requestData.ContainsKey("start")) + { + string startLoc = ((string)requestData["start"]).Trim(); + if (!(startLoc == "last" || startLoc == "home")) + { + // Format: uri:Ahern&162&213&34 + try + { + string[] parts = startLoc.Remove(0, 4).Split('&'); + string region = parts[0]; + + //////////////////////////////////////////////////// + //SimProfile SimInfo = new SimProfile(); + //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); + } + catch (Exception e) + { + + } + } + } + + // What time did the user login? + agent.loginTime = Util.UnixTimeSinceEpoch(); + agent.logoutTime = 0; + + // Current location + agent.regionID = new LLUUID(); // Fill in later + agent.currentRegion = new LLUUID(); // Fill in later + + profile.currentAgent = agent; + } + + /// + /// Saves a target agent to the database + /// + /// The users profile + /// Successful? + public bool CommitAgent(ref UserProfileData profile) + { + // Saves the agent to database + return true; + } + + #endregion + + /// + /// Checks a user against it's password hash + /// + /// The users profile + /// The supplied password + /// Authenticated? + public virtual bool AuthenticateUser(ref UserProfileData profile, string password) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose( + "Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + + #region Xml Response + + /// + /// + /// + /// + /// + /// + public virtual UserProfileData GetTheUser(string firstname, string lastname) + { + return getUserProfile(firstname, lastname); + } + + /// + /// + /// + /// + public virtual string GetMessage() + { + return _config.DefaultStartupMsg; + } + + /// + /// Customises the login response and fills in missing values. + /// + /// The existing response + /// The user profile + public virtual void CustomiseResponse(ref LoginResponse response, ref UserProfileData theUser) + { + + } + + /// + /// Main user login function + /// + /// The XMLRPC request + /// The response to send + public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); + bool GoodLogin = false; + string firstname = ""; + string lastname = ""; + string passwd = ""; + + UserProfileData TheUser; + LoginResponse logResponse = new LoginResponse(); + + if (GoodXML) + { + firstname = (string)requestData["first"]; + lastname = (string)requestData["last"]; + passwd = (string)requestData["passwd"]; + + TheUser = GetTheUser(firstname, lastname); + if (TheUser == null) + return logResponse.CreateLoginFailedResponse(); + + GoodLogin = AuthenticateUser(ref TheUser, passwd); + } + else + { + return logResponse.CreateGridErrorResponse(); + } + + if (!GoodLogin) + { + return logResponse.CreateLoginFailedResponse(); + } + else + { + // If we already have a session... + if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline) + { + // Reject the login + return logResponse.CreateAlreadyLoggedInResponse(); + } + // Otherwise... + // Create a new agent session + CreateAgent(ref TheUser, request); + + try + { + + LLUUID AgentID = TheUser.UUID; + + // Inventory Library Section + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + + AgentInventory Library = new AgentInventory(); + Library.CreateRootFolder(AgentID, true); + + foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + Hashtable InventoryRootHash = new Hashtable(); + InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated(); + ArrayList InventoryRoot = new ArrayList(); + InventoryRoot.Add(InventoryRootHash); + + // Circuit Code + uint circode = (uint)(Util.RandomClass.Next()); + + logResponse.Lastname = TheUser.surname; + logResponse.Firstname = TheUser.username; + logResponse.AgentID = AgentID.ToStringHyphenated(); + logResponse.SessionID = TheUser.currentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = TheUser.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.InventoryRoot = InventoryRoot; + logResponse.InventorySkeleton = AgentInventoryArray; + logResponse.CircuitCode = (Int32)circode; + logResponse.RegionX = 0; //overwritten + logResponse.RegionY = 0; //overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; + logResponse.SimAddress = "127.0.0.1"; //overwritten + logResponse.SimPort = 0; //overwritten + logResponse.Message = this.GetMessage(); + + try + { + this.CustomiseResponse(ref logResponse, ref TheUser); + } + catch (Exception e) + { + System.Console.WriteLine(e.ToString()); + return logResponse.CreateDeadRegionResponse(); + } + CommitAgent(ref TheUser); + + return logResponse.ToXmlRpcResponse(); + + } + catch (Exception E) + { + System.Console.WriteLine(E.ToString()); + } + //} + } + return response; + + } + + #endregion + + /// + /// Deletes an active agent session + /// + /// The request + /// The path (eg /bork/narf/test) + /// Parameters sent + /// Success "OK" else error + public string RestDeleteUserSessionMethod(string request, string path, string param) + { + // TODO! Important! + + return "OK"; + } + + /// + /// + /// + /// + public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) + { + UserProfileData user = new UserProfileData(); + user.homeLocation = new LLVector3(128, 128, 100); + user.UUID = LLUUID.Random(); + user.username = firstName; + user.surname = lastName; + user.passwordHash = pass; + user.passwordSalt = ""; + user.created = Util.UnixTimeSinceEpoch(); + user.homeLookAt = new LLVector3(100, 100, 100); + user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256)); + + foreach (KeyValuePair plugin in _plugins) + { + try + { + plugin.Value.addNewUserProfile(user); + + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + } + + /// + /// Returns an error message that the user could not be found in the database + /// + /// XML string consisting of a error element containing individual error(s) + public string CreateUnknownUserErrorResponse() + { + System.IO.StringWriter sw = new System.IO.StringWriter(); + XmlTextWriter xw = new XmlTextWriter(sw); + + // Header + xw.Formatting = Formatting.Indented; + xw.WriteStartDocument(); + xw.WriteDocType("error", null, null, null); + xw.WriteComment("An error occured"); + xw.WriteStartElement("error"); + + // User + xw.WriteElementString("unknownuser", "Unable to find a user with that name"); + + // Footer + xw.WriteEndElement(); + xw.Flush(); + xw.Close(); + + return sw.ToString(); + } + + /// + /// Converts a user profile to an XML element which can be returned + /// + /// The user profile + /// A string containing an XML Document of the user profile + public string ProfileToXml(UserProfileData profile) + { + System.IO.StringWriter sw = new System.IO.StringWriter(); + XmlTextWriter xw = new XmlTextWriter(sw); + + // Header + xw.Formatting = Formatting.Indented; + xw.WriteStartDocument(); + xw.WriteDocType("userprofile", null, null, null); + xw.WriteComment("Found user profiles matching the request"); + xw.WriteStartElement("users"); + + // User + xw.WriteStartElement("user"); + // Account information + xw.WriteAttributeString("firstname", profile.username); + xw.WriteAttributeString("lastname", profile.surname); + xw.WriteAttributeString("uuid", profile.UUID.ToStringHyphenated()); + // Server Information + xw.WriteAttributeString("server_inventory", profile.userInventoryURI); + xw.WriteAttributeString("server_asset", profile.userAssetURI); + // Profile Information + xw.WriteAttributeString("profile_about", profile.profileAboutText); + xw.WriteAttributeString("profile_firstlife_about", profile.profileFirstText); + xw.WriteAttributeString("profile_firstlife_image", profile.profileFirstImage.ToStringHyphenated()); + xw.WriteAttributeString("profile_can_do", profile.profileCanDoMask.ToString()); + xw.WriteAttributeString("profile_want_do", profile.profileWantDoMask.ToString()); + xw.WriteAttributeString("profile_image", profile.profileImage.ToStringHyphenated()); + xw.WriteAttributeString("profile_created",profile.created.ToString()); + xw.WriteAttributeString("profile_lastlogin",profile.lastLogin.ToString()); + // Home region information + xw.WriteAttributeString("home_coordinates", profile.homeLocation.ToString()); + xw.WriteAttributeString("home_region", profile.homeRegion.ToString()); + xw.WriteAttributeString("home_look", profile.homeLookAt.ToString()); + + xw.WriteEndElement(); + + // Footer + xw.WriteEndElement(); + xw.Flush(); + xw.Close(); + + return sw.ToString(); + } + + #region REST Methods + //should most likely move out of here and into the grid's userserver sub class + public string RestGetUserMethodName(string request, string path, string param) + { + UserProfileData userProfile = getUserProfile(param.Trim()); + + if (userProfile == null) + { + return CreateUnknownUserErrorResponse(); + } + + return ProfileToXml(userProfile); + } + + public string RestGetUserMethodUUID(string request, string path, string param) + { + UserProfileData userProfile = getUserProfile(new LLUUID(param)); + + if (userProfile == null) + { + return CreateUnknownUserErrorResponse(); + } + + return ProfileToXml(userProfile); + } + #endregion + + } +} -- cgit v1.1 From bee543300fc812277e9a9478dc05b986e00ed44e Mon Sep 17 00:00:00 2001 From: mingchen Date: Thu, 28 Jun 2007 14:45:46 +0000 Subject: *User Profile requests on OGS UserServer now uses XMLRPC instead of REST *Added base support for setting up a master user --- OpenSim/Framework/UserManager/UserManagerBase.cs | 126 +++++++++++------------ 1 file changed, 60 insertions(+), 66 deletions(-) (limited to 'OpenSim/Framework/UserManager/UserManagerBase.cs') 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 /// Returns an error message that the user could not be found in the database /// /// XML string consisting of a error element containing individual error(s) - public string CreateUnknownUserErrorResponse() + public XmlRpcResponse CreateUnknownUserErrorResponse() { - System.IO.StringWriter sw = new System.IO.StringWriter(); - XmlTextWriter xw = new XmlTextWriter(sw); - - // Header - xw.Formatting = Formatting.Indented; - xw.WriteStartDocument(); - xw.WriteDocType("error", null, null, null); - xw.WriteComment("An error occured"); - xw.WriteStartElement("error"); - - // User - xw.WriteElementString("unknownuser", "Unable to find a user with that name"); - - // Footer - xw.WriteEndElement(); - xw.Flush(); - xw.Close(); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + responseData["error_type"] = "unknown_user"; + responseData["error_desc"] = "The user requested is not in the database"; - return sw.ToString(); + response.Value = responseData; + return response; } /// @@ -565,75 +553,81 @@ namespace OpenSim.Framework.UserManagement /// /// The user profile /// A string containing an XML Document of the user profile - public string ProfileToXml(UserProfileData profile) + public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) { - System.IO.StringWriter sw = new System.IO.StringWriter(); - XmlTextWriter xw = new XmlTextWriter(sw); - - // Header - xw.Formatting = Formatting.Indented; - xw.WriteStartDocument(); - xw.WriteDocType("userprofile", null, null, null); - xw.WriteComment("Found user profiles matching the request"); - xw.WriteStartElement("users"); - - // User - xw.WriteStartElement("user"); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + // Account information - xw.WriteAttributeString("firstname", profile.username); - xw.WriteAttributeString("lastname", profile.surname); - xw.WriteAttributeString("uuid", profile.UUID.ToStringHyphenated()); + responseData["firstname"] = profile.username; + responseData["lastname"] = profile.surname; + responseData["uuid"] = profile.UUID.ToStringHyphenated(); // Server Information - xw.WriteAttributeString("server_inventory", profile.userInventoryURI); - xw.WriteAttributeString("server_asset", profile.userAssetURI); + responseData["server_inventory"] = profile.userInventoryURI; + responseData["server_asset"] = profile.userAssetURI; // Profile Information - xw.WriteAttributeString("profile_about", profile.profileAboutText); - xw.WriteAttributeString("profile_firstlife_about", profile.profileFirstText); - xw.WriteAttributeString("profile_firstlife_image", profile.profileFirstImage.ToStringHyphenated()); - xw.WriteAttributeString("profile_can_do", profile.profileCanDoMask.ToString()); - xw.WriteAttributeString("profile_want_do", profile.profileWantDoMask.ToString()); - xw.WriteAttributeString("profile_image", profile.profileImage.ToStringHyphenated()); - xw.WriteAttributeString("profile_created",profile.created.ToString()); - xw.WriteAttributeString("profile_lastlogin",profile.lastLogin.ToString()); + responseData["profile_about"] = profile.profileAboutText; + responseData["profile_firstlife_about"] = profile.profileFirstText; + responseData["profile_firstlife_image"] = profile.profileFirstImage.ToStringHyphenated(); + responseData["profile_can_do"] = profile.profileCanDoMask.ToString(); + responseData["profile_want_do"] = profile.profileWantDoMask.ToString(); + responseData["profile_image"] = profile.profileImage.ToStringHyphenated(); + responseData["profile_created"] = profile.created.ToString(); + responseData["profile_lastlogin"] = profile.lastLogin.ToString(); // Home region information - xw.WriteAttributeString("home_coordinates", profile.homeLocation.ToString()); - xw.WriteAttributeString("home_region", profile.homeRegion.ToString()); - xw.WriteAttributeString("home_look", profile.homeLookAt.ToString()); + responseData["home_coordinates"] = profile.homeLocation.ToString(); + responseData["home_region"] = profile.homeRegion.ToString(); + responseData["home_look"] = profile.homeLookAt.ToString(); - xw.WriteEndElement(); - - // Footer - xw.WriteEndElement(); - xw.Flush(); - xw.Close(); - - return sw.ToString(); + response.Value = responseData; + return response; } - #region REST Methods + #region XMLRPC User Methods //should most likely move out of here and into the grid's userserver sub class - public string RestGetUserMethodName(string request, string path, string param) + public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) { - UserProfileData userProfile = getUserProfile(param.Trim()); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + UserProfileData userProfile; - if (userProfile == null) + if (requestData.Contains("avatar_name")) + { + userProfile = getUserProfile((string)requestData["avatar_name"]); + if (userProfile == null) + { + return CreateUnknownUserErrorResponse(); + } + } + else { return CreateUnknownUserErrorResponse(); } + - return ProfileToXml(userProfile); + return ProfileToXmlRPCResponse(userProfile); } - public string RestGetUserMethodUUID(string request, string path, string param) + public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) { - UserProfileData userProfile = getUserProfile(new LLUUID(param)); - - if (userProfile == null) + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + UserProfileData userProfile; + if (requestData.Contains("avatar_uuid")) + { + userProfile = getUserProfile((LLUUID)requestData["avatar_uuid"]); + if (userProfile == null) + { + return CreateUnknownUserErrorResponse(); + } + } + else { return CreateUnknownUserErrorResponse(); } - return ProfileToXml(userProfile); + + return ProfileToXmlRPCResponse(userProfile); } #endregion -- cgit v1.1 From 90b01ba80ccaa69bf7cf76be6ce0a6ca05717d6c Mon Sep 17 00:00:00 2001 From: mingchen Date: Fri, 29 Jun 2007 01:58:16 +0000 Subject: *Hopefully fixed the empty dialog box error on client when logging in on sandbox mode --- OpenSim/Framework/UserManager/UserManagerBase.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Framework/UserManager/UserManagerBase.cs') diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index bc35164..d06059e 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -472,7 +472,6 @@ namespace OpenSim.Framework.UserManagement return logResponse.CreateDeadRegionResponse(); } CommitAgent(ref TheUser); - return logResponse.ToXmlRpcResponse(); } -- cgit v1.1 From 5e805656db1215518a344d6d5364629a4997fd47 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sun, 1 Jul 2007 13:17:27 +0000 Subject: Fixed SimpleApp - aka thankgoditssundaycommit * Updated SimpleApp with various introduced dependencies * Extracted ScenePrescence creation in Scene * removed try-catchall from UserManagerBase (that actually hid a bug) * Refactored RegionInfo * handle is calculated * it will explode upon accessing x,y,ip,port,externalip if not explicitly initialized * Removed superfluous 'ref' keywords * Removed a shitload of 'catch Exception e' that causes build warnings * Lots of small refactorings, renames et c * Ignored some bins --- OpenSim/Framework/UserManager/UserManagerBase.cs | 60 ++++++++++-------------- 1 file changed, 25 insertions(+), 35 deletions(-) (limited to 'OpenSim/Framework/UserManager/UserManagerBase.cs') diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index d06059e..560752e 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -43,7 +43,7 @@ using System.Security.Cryptography; namespace OpenSim.Framework.UserManagement { - public class UserManagerBase + public abstract class UserManagerBase { public OpenSim.Framework.Interfaces.UserConfig _config; Dictionary _plugins = new Dictionary(); @@ -142,14 +142,9 @@ namespace OpenSim.Framework.UserManagement try { UserProfileData profile = plugin.Value.getUserByName(fname,lname); - try - { - profile.currentAgent = getUserAgent(profile.UUID); - } - catch (Exception e) - { - // Ignore - } + + profile.currentAgent = getUserAgent(profile.UUID); + return profile; } catch (Exception e) @@ -238,16 +233,14 @@ namespace OpenSim.Framework.UserManagement /// /// The users profile /// The users loginrequest - public void CreateAgent(ref UserProfileData profile, XmlRpcRequest request) + public void CreateAgent(UserProfileData profile, XmlRpcRequest request) { Hashtable requestData = (Hashtable)request.Params[0]; UserAgentData agent = new UserAgentData(); // User connection - agent.agentIP = ""; agent.agentOnline = true; - agent.agentPort = 0; // Generate sessions RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); @@ -282,7 +275,7 @@ namespace OpenSim.Framework.UserManagement //SimProfile SimInfo = new SimProfile(); //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); } - catch (Exception e) + catch (Exception) { } @@ -319,7 +312,7 @@ namespace OpenSim.Framework.UserManagement /// The users profile /// The supplied password /// Authenticated? - public virtual bool AuthenticateUser(ref UserProfileData profile, string password) + public virtual bool AuthenticateUser(UserProfileData profile, string password) { OpenSim.Framework.Console.MainLog.Instance.Verbose( "Authenticating " + profile.username + " " + profile.surname); @@ -358,10 +351,7 @@ namespace OpenSim.Framework.UserManagement /// /// The existing response /// The user profile - public virtual void CustomiseResponse(ref LoginResponse response, ref UserProfileData theUser) - { - - } + public abstract void CustomiseResponse( LoginResponse response, UserProfileData theUser); /// /// Main user login function @@ -379,7 +369,7 @@ namespace OpenSim.Framework.UserManagement string lastname = ""; string passwd = ""; - UserProfileData TheUser; + UserProfileData userProfile; LoginResponse logResponse = new LoginResponse(); if (GoodXML) @@ -388,11 +378,11 @@ namespace OpenSim.Framework.UserManagement lastname = (string)requestData["last"]; passwd = (string)requestData["passwd"]; - TheUser = GetTheUser(firstname, lastname); - if (TheUser == null) + userProfile = GetTheUser(firstname, lastname); + if (userProfile == null) return logResponse.CreateLoginFailedResponse(); - GoodLogin = AuthenticateUser(ref TheUser, passwd); + GoodLogin = AuthenticateUser(userProfile, passwd); } else { @@ -406,19 +396,19 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline) + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) { // Reject the login return logResponse.CreateAlreadyLoggedInResponse(); } // Otherwise... // Create a new agent session - CreateAgent(ref TheUser, request); + CreateAgent( userProfile, request); try { - LLUUID AgentID = TheUser.UUID; + LLUUID AgentID = userProfile.UUID; // Inventory Library Section ArrayList AgentInventoryArray = new ArrayList(); @@ -446,32 +436,32 @@ namespace OpenSim.Framework.UserManagement // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); - logResponse.Lastname = TheUser.surname; - logResponse.Firstname = TheUser.username; + logResponse.Lastname = userProfile.surname; + logResponse.Firstname = userProfile.username; logResponse.AgentID = AgentID.ToStringHyphenated(); - logResponse.SessionID = TheUser.currentAgent.sessionID.ToStringHyphenated(); - logResponse.SecureSessionID = TheUser.currentAgent.secureSessionID.ToStringHyphenated(); + logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); + logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.CircuitCode = (Int32)circode; - logResponse.RegionX = 0; //overwritten - logResponse.RegionY = 0; //overwritten + //logResponse.RegionX = 0; //overwritten + //logResponse.RegionY = 0; //overwritten logResponse.Home = "!!null temporary value {home}!!"; // Overwritten //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - logResponse.SimAddress = "127.0.0.1"; //overwritten - logResponse.SimPort = 0; //overwritten + //logResponse.SimAddress = "127.0.0.1"; //overwritten + //logResponse.SimPort = 0; //overwritten logResponse.Message = this.GetMessage(); try { - this.CustomiseResponse(ref logResponse, ref TheUser); + this.CustomiseResponse( logResponse, userProfile); } catch (Exception e) { System.Console.WriteLine(e.ToString()); return logResponse.CreateDeadRegionResponse(); } - CommitAgent(ref TheUser); + CommitAgent(ref userProfile); return logResponse.ToXmlRpcResponse(); } -- cgit v1.1 From 9b6b6d05d45cf0f754a0b26bf6240ef50be66563 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Jul 2007 14:37:29 +0000 Subject: * Optimized usings (the 'LL ate my scripts' commit) * added some licensing info --- OpenSim/Framework/UserManager/UserManagerBase.cs | 37 +++++++++++------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'OpenSim/Framework/UserManager/UserManagerBase.cs') diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index 560752e..f316cc7 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -28,24 +28,21 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Data; -using libsecondlife; using System.Reflection; - -using System.Xml; +using System.Security.Cryptography; +using libsecondlife; using Nwc.XmlRpc; -using OpenSim.Framework.Sims; +using OpenSim.Framework.Console; +using OpenSim.Framework.Data; +using OpenSim.Framework.Interfaces; using OpenSim.Framework.Inventory; using OpenSim.Framework.Utilities; -using System.Security.Cryptography; - namespace OpenSim.Framework.UserManagement { public abstract class UserManagerBase { - public OpenSim.Framework.Interfaces.UserConfig _config; + public UserConfig _config; Dictionary _plugins = new Dictionary(); /// @@ -54,10 +51,10 @@ namespace OpenSim.Framework.UserManagement /// The filename to the user server plugin DLL public void AddPlugin(string FileName) { - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Attempting to load " + FileName); + MainLog.Instance.Verbose( "Userstorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + MainLog.Instance.Verbose( "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { if (!pluginType.IsAbstract) @@ -69,7 +66,7 @@ namespace OpenSim.Framework.UserManagement IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); this._plugins.Add(plug.getName(), plug); - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface"); + MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface"); } typeInterface = null; @@ -97,7 +94,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -122,7 +119,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -149,7 +146,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -173,7 +170,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -195,7 +192,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -218,7 +215,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -314,7 +311,7 @@ namespace OpenSim.Framework.UserManagement /// Authenticated? public virtual bool AuthenticateUser(UserProfileData profile, string password) { - OpenSim.Framework.Console.MainLog.Instance.Verbose( + MainLog.Instance.Verbose( "Authenticating " + profile.username + " " + profile.surname); password = password.Remove(0, 3); //remove $1$ @@ -517,7 +514,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); } } } -- cgit v1.1 From 583f2a9de8e503773a427facd5f81a82b40bd585 Mon Sep 17 00:00:00 2001 From: mingchen Date: Thu, 5 Jul 2007 15:15:28 +0000 Subject: *Removed SimProfile.cs as it is no longer needed (in favor of SimProfileData) *Added simulator_data_request XMLRPC method to request data from the grid server about a sim instead of faking its login *Login is progressing, now just getting an XML error (http://pastebin.com/942515) -- if you can fix this, throw MingChen in IRC a Private Message --- OpenSim/Framework/UserManager/UserManagerBase.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/UserManager/UserManagerBase.cs') diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index f316cc7..af5feac 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -357,6 +357,8 @@ namespace OpenSim.Framework.UserManagement /// The response to send public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { + + System.Console.WriteLine("Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; @@ -457,11 +459,13 @@ namespace OpenSim.Framework.UserManagement { System.Console.WriteLine(e.ToString()); return logResponse.CreateDeadRegionResponse(); + //return logResponse.ToXmlRpcResponse(); } CommitAgent(ref userProfile); return logResponse.ToXmlRpcResponse(); } + catch (Exception E) { System.Console.WriteLine(E.ToString()); -- cgit v1.1 From bc02ddf5231d7731af33cc0aa5dc914cbdeb5ee7 Mon Sep 17 00:00:00 2001 From: mingchen Date: Fri, 6 Jul 2007 20:40:03 +0000 Subject: *Fixed several bugs that crashed the viewer and opensim server when logging in on grid mode *Note: Grid Mode now works in sugilite, but is still unstable **Known bug in which the grid server crashes after being relaunched from a previously create configuration **Crashing of the viewer crashes the OpenSim server which then crashes the grid server -- needs better handling of exceptions **Multiple sims is still untested, but should connect correctly. Moving between the sims may be a different story --- OpenSim/Framework/UserManager/UserManagerBase.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/UserManager/UserManagerBase.cs') diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index af5feac..df6fbb2 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -565,10 +565,15 @@ namespace OpenSim.Framework.UserManagement responseData["profile_created"] = profile.created.ToString(); responseData["profile_lastlogin"] = profile.lastLogin.ToString(); // Home region information - responseData["home_coordinates"] = profile.homeLocation.ToString(); + responseData["home_coordinates_x"] = profile.homeLocation.X.ToString(); + responseData["home_coordinates_y"] = profile.homeLocation.Y.ToString(); + responseData["home_coordinates_z"] = profile.homeLocation.Z.ToString(); + responseData["home_region"] = profile.homeRegion.ToString(); - responseData["home_look"] = profile.homeLookAt.ToString(); + responseData["home_look_x"] = profile.homeLookAt.X.ToString(); + responseData["home_look_y"] = profile.homeLookAt.Y.ToString(); + responseData["home_look_z"] = profile.homeLookAt.Z.ToString(); response.Value = responseData; return response; } -- cgit v1.1