From a9dde515ba7d35b6069a3b2cd8b66bb72b007801 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 22 Jun 2007 18:28:49 +0000 Subject: SandBox mode login now shares a base class with the grid mode user server. To allow people to login without creating accounts first in sandbox mode anytime a login request is received without a matching account already being in the database, a new account will be made. (also in sandbox mode, passwords aren't currently used). --- .../IUserServices.cs | 4 +- .../LoginResponse.cs | 656 +++++++++++++++++++++ .../OpenGrid.Framework.UserManagement.csproj | 3 + .../OpenGrid.Framework.UserManagement.dll.build | 1 + .../UserManagerBase.cs | 318 ++++------ .../OpenSim.Framework/Types/NetworkServersInfo.cs | 35 +- Common/OpenSim.Framework/Types/PrimData.cs | 1 - Common/OpenSim.Servers/LoginResponse.cs | 58 +- Common/OpenSim.Servers/LoginServer.cs | 31 +- 9 files changed, 837 insertions(+), 270 deletions(-) create mode 100644 Common/OpenGrid.Framework.UserManager/LoginResponse.cs (limited to 'Common') diff --git a/Common/OpenGrid.Framework.Communications/IUserServices.cs b/Common/OpenGrid.Framework.Communications/IUserServices.cs index 4cb66e7..3d8e791 100644 --- a/Common/OpenGrid.Framework.Communications/IUserServices.cs +++ b/Common/OpenGrid.Framework.Communications/IUserServices.cs @@ -36,9 +36,9 @@ namespace OpenGrid.Framework.Communications { public interface IUserServices { - UserProfileData GetUserProfile(string first_name, string last_name); + UserProfileData GetUserProfile(string firstName, string lastName); UserProfileData GetUserProfile(string name); - UserProfileData GetUserProfile(LLUUID avatar_id); + UserProfileData GetUserProfile(LLUUID avatarID); } } diff --git a/Common/OpenGrid.Framework.UserManager/LoginResponse.cs b/Common/OpenGrid.Framework.UserManager/LoginResponse.cs new file mode 100644 index 0000000..1c51aeb --- /dev/null +++ b/Common/OpenGrid.Framework.UserManager/LoginResponse.cs @@ -0,0 +1,656 @@ +using System; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Collections; +using System.Xml; +using libsecondlife; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Interfaces; +using Nwc.XmlRpc; + +namespace OpenGrid.Framework.UserManagement +{ + + /// + /// A temp class to handle login response. + /// Should make use of UserProfileManager where possible. + /// + + public class LoginResponse + { + private Hashtable loginFlagsHash; + private Hashtable globalTexturesHash; + private Hashtable loginError; + private Hashtable eventCategoriesHash; + private Hashtable uiConfigHash; + private Hashtable classifiedCategoriesHash; + + private ArrayList loginFlags; + private ArrayList globalTextures; + private ArrayList eventCategories; + private ArrayList uiConfig; + private ArrayList classifiedCategories; + private ArrayList inventoryRoot; + private ArrayList initialOutfit; + private ArrayList agentInventory; + + private UserInfo userProfile; + + private LLUUID agentID; + private LLUUID sessionID; + private LLUUID secureSessionID; + private LLUUID baseFolderID; + private LLUUID inventoryFolderID; + + // Login Flags + private string dst; + private string stipendSinceLogin; + private string gendered; + private string everLoggedIn; + private string login; + private int simPort; + private string simAddress; + private string agentAccess; + private Int32 circuitCode; + private uint regionX; + private uint regionY; + + // Login + private string firstname; + private string lastname; + + // Global Textures + private string sunTexture; + private string cloudTexture; + private string moonTexture; + + // Error Flags + private string errorReason; + private string errorMessage; + + // Response + private XmlRpcResponse xmlRpcResponse; + private XmlRpcResponse defaultXmlRpcResponse; + + private string welcomeMessage; + private string startLocation; + private string allowFirstLife; + private string home; + private string seedCapability; + private string lookAt; + + public LoginResponse() + { + this.loginFlags = new ArrayList(); + this.globalTextures = new ArrayList(); + this.eventCategories = new ArrayList(); + this.uiConfig = new ArrayList(); + this.classifiedCategories = new ArrayList(); + + this.loginError = new Hashtable(); + this.eventCategoriesHash = new Hashtable(); + this.classifiedCategoriesHash = new Hashtable(); + this.uiConfigHash = new Hashtable(); + + this.defaultXmlRpcResponse = new XmlRpcResponse(); + this.userProfile = new UserInfo(); + this.inventoryRoot = new ArrayList(); + this.initialOutfit = new ArrayList(); + this.agentInventory = new ArrayList(); + + this.xmlRpcResponse = new XmlRpcResponse(); + this.defaultXmlRpcResponse = new XmlRpcResponse(); + + this.SetDefaultValues(); + } // LoginServer + + public void SetDefaultValues() + { + try + { + this.DST = "N"; + this.StipendSinceLogin = "N"; + this.Gendered = "Y"; + this.EverLoggedIn = "Y"; + this.login = "false"; + this.firstname = "Test"; + this.lastname = "User"; + this.agentAccess = "M"; + this.startLocation = "last"; + this.allowFirstLife = "Y"; + + this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; + this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + + this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; + this.ErrorReason = "key"; + this.welcomeMessage = "Welcome to OpenSim!"; + this.seedCapability = ""; + this.home = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}"; + this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; + this.RegionX = (uint)255232; + this.RegionY = (uint)254976; + + // Classifieds; + this.AddClassifiedCategory((Int32)1, "Shopping"); + this.AddClassifiedCategory((Int32)2, "Land Rental"); + this.AddClassifiedCategory((Int32)3, "Property Rental"); + this.AddClassifiedCategory((Int32)4, "Special Attraction"); + this.AddClassifiedCategory((Int32)5, "New Products"); + this.AddClassifiedCategory((Int32)6, "Employment"); + this.AddClassifiedCategory((Int32)7, "Wanted"); + this.AddClassifiedCategory((Int32)8, "Service"); + this.AddClassifiedCategory((Int32)9, "Personal"); + + + this.SessionID = LLUUID.Random(); + this.SecureSessionID = LLUUID.Random(); + this.AgentID = LLUUID.Random(); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + this.initialOutfit.Add(InitialOutfitHash); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.WriteLine( + OpenSim.Framework.Console.LogPriority.LOW, + "LoginResponse: Unable to set default values: " + e.Message + ); + } + + } // SetDefaultValues + + #region Login Failure Methods + public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) + { + // Overwrite any default values; + this.xmlRpcResponse = new XmlRpcResponse(); + + // Ensure Login Failed message/reason; + this.ErrorMessage = message; + this.ErrorReason = reason; + + this.loginError["reason"] = this.ErrorReason; + this.loginError["message"] = this.ErrorMessage; + this.loginError["login"] = login; + this.xmlRpcResponse.Value = this.loginError; + return (this.xmlRpcResponse); + } // GenerateResponse + + public XmlRpcResponse CreateFailedResponse() + { + return (this.CreateLoginFailedResponse()); + } // CreateErrorConnectingToGridResponse() + + public XmlRpcResponse CreateLoginFailedResponse() + { + return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false")); + } // LoginFailedResponse + + public XmlRpcResponse CreateAlreadyLoggedInResponse() + { + return (this.GenerateFailureResponse("presence", "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", "false")); + } // CreateAlreadyLoggedInResponse() + + public XmlRpcResponse CreateDeadRegionResponse() + { + return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false")); + } + + public XmlRpcResponse CreateGridErrorResponse() + { + return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false")); + } + + #endregion + + public XmlRpcResponse ToXmlRpcResponse() + { + try + { + + Hashtable responseData = new Hashtable(); + + this.loginFlagsHash = new Hashtable(); + this.loginFlagsHash["daylight_savings"] = this.DST; + this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin; + this.loginFlagsHash["gendered"] = this.Gendered; + this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn; + this.loginFlags.Add(this.loginFlagsHash); + + responseData["first_name"] = this.Firstname; + responseData["last_name"] = this.Lastname; + responseData["agent_access"] = this.agentAccess; + + this.globalTexturesHash = new Hashtable(); + this.globalTexturesHash["sun_texture_id"] = this.SunTexture; + this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture; + this.globalTexturesHash["moon_texture_id"] = this.MoonTexture; + this.globalTextures.Add(this.globalTexturesHash); + this.eventCategories.Add(this.eventCategoriesHash); + + this.AddToUIConfig("allow_first_life", this.allowFirstLife); + this.uiConfig.Add(this.uiConfigHash); + + responseData["sim_port"] =(Int32) this.SimPort; + responseData["sim_ip"] = this.SimAddress; + responseData["agent_id"] = this.AgentID.ToStringHyphenated(); + responseData["session_id"] = this.SessionID.ToStringHyphenated(); + responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated(); + responseData["circuit_code"] = this.CircuitCode; + responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["login-flags"] = this.loginFlags; + responseData["global-textures"] = this.globalTextures; + responseData["seed_capability"] = this.seedCapability; + + responseData["event_categories"] = this.eventCategories; + responseData["event_notifications"] = new ArrayList(); // todo + responseData["classified_categories"] = this.classifiedCategories; + responseData["ui-config"] = this.uiConfig; + + responseData["inventory-skeleton"] = this.agentInventory; + responseData["inventory-skel-lib"] = new ArrayList(); // todo + responseData["inventory-root"] = this.inventoryRoot; + responseData["gestures"] = new ArrayList(); // todo + responseData["inventory-lib-owner"] = new ArrayList(); // todo + responseData["initial-outfit"] = this.initialOutfit; + responseData["start_location"] = this.startLocation; + responseData["seed_capability"] = this.seedCapability; + responseData["home"] = this.home; + responseData["look_at"] = this.lookAt; + responseData["message"] = this.welcomeMessage; + responseData["region_x"] = (Int32)this.RegionX * 256; + responseData["region_y"] = (Int32)this.RegionY * 256; + + //responseData["inventory-lib-root"] = new ArrayList(); // todo + //responseData["buddy-list"] = new ArrayList(); // todo + + responseData["login"] = "true"; + this.xmlRpcResponse.Value = responseData; + + return (this.xmlRpcResponse); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.WriteLine( + OpenSim.Framework.Console.LogPriority.LOW, + "LoginResponse: Error creating XML-RPC Response: " + e.Message + ); + return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); + + } + + } // ToXmlRpcResponse + + public void SetEventCategories(string category, string value) + { + this.eventCategoriesHash[category] = value; + } // SetEventCategories + + public void AddToUIConfig(string itemName, string item) + { + this.uiConfigHash[itemName] = item; + } // SetUIConfig + + public void AddClassifiedCategory(Int32 ID, string categoryName) + { + this.classifiedCategoriesHash["category_name"] = categoryName; + this.classifiedCategoriesHash["category_id"] = ID; + this.classifiedCategories.Add(this.classifiedCategoriesHash); + // this.classifiedCategoriesHash.Clear(); + } // SetClassifiedCategory + + #region Properties + public string Login + { + get + { + return this.login; + } + set + { + this.login = value; + } + } // Login + + public string DST + { + get + { + return this.dst; + } + set + { + this.dst = value; + } + } // DST + + public string StipendSinceLogin + { + get + { + return this.stipendSinceLogin; + } + set + { + this.stipendSinceLogin = value; + } + } // StipendSinceLogin + + public string Gendered + { + get + { + return this.gendered; + } + set + { + this.gendered = value; + } + } // Gendered + + public string EverLoggedIn + { + get + { + return this.everLoggedIn; + } + set + { + this.everLoggedIn = value; + } + } // EverLoggedIn + + public int SimPort + { + get + { + return this.simPort; + } + set + { + this.simPort = value; + } + } // SimPort + + public string SimAddress + { + get + { + return this.simAddress; + } + set + { + this.simAddress = value; + } + } // SimAddress + + public LLUUID AgentID + { + get + { + return this.agentID; + } + set + { + this.agentID = value; + } + } // AgentID + + public LLUUID SessionID + { + get + { + return this.sessionID; + } + set + { + this.sessionID = value; + } + } // SessionID + + public LLUUID SecureSessionID + { + get + { + return this.secureSessionID; + } + set + { + this.secureSessionID = value; + } + } // SecureSessionID + + public Int32 CircuitCode + { + get + { + return this.circuitCode; + } + set + { + this.circuitCode = value; + } + } // CircuitCode + + public uint RegionX + { + get + { + return this.regionX; + } + set + { + this.regionX = value; + } + } // RegionX + + public uint RegionY + { + get + { + return this.regionY; + } + set + { + this.regionY = value; + } + } // RegionY + + public string SunTexture + { + get + { + return this.sunTexture; + } + set + { + this.sunTexture = value; + } + } // SunTexture + + public string CloudTexture + { + get + { + return this.cloudTexture; + } + set + { + this.cloudTexture = value; + } + } // CloudTexture + + public string MoonTexture + { + get + { + return this.moonTexture; + } + set + { + this.moonTexture = value; + } + } // MoonTexture + + public string Firstname + { + get + { + return this.firstname; + } + set + { + this.firstname = value; + } + } // Firstname + + public string Lastname + { + get + { + return this.lastname; + } + set + { + this.lastname = value; + } + } // Lastname + + public string AgentAccess + { + get + { + return this.agentAccess; + } + set + { + this.agentAccess = value; + } + } + + public string StartLocation + { + get + { + return this.startLocation; + } + set + { + this.startLocation = value; + } + } // StartLocation + + public string LookAt + { + get + { + return this.lookAt; + } + set + { + this.lookAt = value; + } + } + + public string SeedCapability + { + get + { + return this.seedCapability; + } + set + { + this.seedCapability = value; + } + } // SeedCapability + + public string ErrorReason + { + get + { + return this.errorReason; + } + set + { + this.errorReason = value; + } + } // ErrorReason + + public string ErrorMessage + { + get + { + return this.errorMessage; + } + set + { + this.errorMessage = value; + } + } // ErrorMessage + + public ArrayList InventoryRoot + { + get + { + return this.inventoryRoot; + } + set + { + this.inventoryRoot = value; + } + } + + public ArrayList InventorySkeleton + { + get + { + return this.agentInventory; + } + set + { + this.agentInventory = value; + } + } + + public string Home + { + get + { + return this.home; + } + set + { + this.home = value; + } + } + + public string Message + { + get + { + return this.welcomeMessage; + } + set + { + this.welcomeMessage = value; + } + } + #endregion + + + public class UserInfo + { + public string firstname; + public string lastname; + public ulong homeregionhandle; + public LLVector3 homepos; + public LLVector3 homelookat; + } + } +} + diff --git a/Common/OpenGrid.Framework.UserManager/OpenGrid.Framework.UserManagement.csproj b/Common/OpenGrid.Framework.UserManager/OpenGrid.Framework.UserManagement.csproj index 232712b..9a3cdba 100644 --- a/Common/OpenGrid.Framework.UserManager/OpenGrid.Framework.UserManagement.csproj +++ b/Common/OpenGrid.Framework.UserManager/OpenGrid.Framework.UserManagement.csproj @@ -108,6 +108,9 @@ + + Code + Code diff --git a/Common/OpenGrid.Framework.UserManager/OpenGrid.Framework.UserManagement.dll.build b/Common/OpenGrid.Framework.UserManager/OpenGrid.Framework.UserManagement.dll.build index a2f5d13..9dc2383 100644 --- a/Common/OpenGrid.Framework.UserManager/OpenGrid.Framework.UserManagement.dll.build +++ b/Common/OpenGrid.Framework.UserManager/OpenGrid.Framework.UserManagement.dll.build @@ -11,6 +11,7 @@ + diff --git a/Common/OpenGrid.Framework.UserManager/UserManagerBase.cs b/Common/OpenGrid.Framework.UserManager/UserManagerBase.cs index eaa53dd..01fbf3a 100644 --- a/Common/OpenGrid.Framework.UserManager/UserManagerBase.cs +++ b/Common/OpenGrid.Framework.UserManager/UserManagerBase.cs @@ -79,37 +79,7 @@ namespace OpenGrid.Framework.UserManagement pluginAssembly = null; } - /// - /// - /// - /// - 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 find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - } - + #region Get UserProfile /// /// Loads a user profile from a database by UUID /// @@ -190,7 +160,9 @@ namespace OpenGrid.Framework.UserManagement return null; } + #endregion + #region Get UserAgent /// /// Loads a user agent by uuid (not called directly) /// @@ -258,94 +230,9 @@ namespace OpenGrid.Framework.UserManagement return null; } - /// - /// Creates a error response caused by invalid XML - /// - /// An XMLRPC response - private static XmlRpcResponse CreateErrorConnectingToGridResponse() - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable ErrorRespData = new Hashtable(); - ErrorRespData["reason"] = "key"; - ErrorRespData["message"] = "Error connecting to grid. Could not percieve credentials from login XML."; - ErrorRespData["login"] = "false"; - response.Value = ErrorRespData; - return response; - } - - /// - /// Creates an error response caused by bad login credentials - /// - /// An XMLRPC response - private static XmlRpcResponse CreateLoginErrorResponse() - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable ErrorRespData = new Hashtable(); - ErrorRespData["reason"] = "key"; - ErrorRespData["message"] = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; - ErrorRespData["login"] = "false"; - response.Value = ErrorRespData; - return response; - } - - /// - /// Creates an error response caused by being logged in already - /// - /// An XMLRPC Response - private static XmlRpcResponse CreateAlreadyLoggedInResponse() - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable PresenceErrorRespData = new Hashtable(); - PresenceErrorRespData["reason"] = "presence"; - PresenceErrorRespData["message"] = "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"; - PresenceErrorRespData["login"] = "false"; - response.Value = PresenceErrorRespData; - return response; - } - - /// - /// Creates an error response caused by target region being down - /// - /// An XMLRPC Response - private static XmlRpcResponse CreateDeadRegionResponse() - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable PresenceErrorRespData = new Hashtable(); - PresenceErrorRespData["reason"] = "key"; - PresenceErrorRespData["message"] = "The region you are attempting to log into is not responding. Please select another region and try again."; - PresenceErrorRespData["login"] = "false"; - response.Value = PresenceErrorRespData; - return response; - } - - /// - /// Customises the login response and fills in missing values. - /// - /// The existing response - /// The user profile - public virtual void CustomiseResponse(ref Hashtable response, ref UserProfileData theUser) - { - - } - - /// - /// Checks a user against it's password hash - /// - /// The users profile - /// The supplied password - /// Authenticated? - public 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); - } + #endregion + #region CreateAgent /// /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB /// @@ -390,7 +277,7 @@ namespace OpenGrid.Framework.UserManagement { 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); @@ -424,6 +311,58 @@ namespace OpenGrid.Framework.UserManagement 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 /// @@ -441,6 +380,7 @@ namespace OpenGrid.Framework.UserManagement string passwd = ""; UserProfileData TheUser; + LoginResponse logResponse = new LoginResponse(); if (GoodXML) { @@ -448,20 +388,20 @@ namespace OpenGrid.Framework.UserManagement lastname = (string)requestData["last"]; passwd = (string)requestData["passwd"]; - TheUser = getUserProfile(firstname, lastname); + TheUser = GetTheUser(firstname, lastname); if (TheUser == null) - return CreateLoginErrorResponse(); + return logResponse.CreateLoginFailedResponse(); GoodLogin = AuthenticateUser(ref TheUser, passwd); } else { - return CreateErrorConnectingToGridResponse(); + return logResponse.CreateGridErrorResponse(); } if (!GoodLogin) { - return CreateLoginErrorResponse(); + return logResponse.CreateLoginFailedResponse(); } else { @@ -469,7 +409,7 @@ namespace OpenGrid.Framework.UserManagement if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline) { // Reject the login - return CreateAlreadyLoggedInResponse(); + return logResponse.CreateAlreadyLoggedInResponse(); } // Otherwise... // Create a new agent session @@ -477,39 +417,8 @@ namespace OpenGrid.Framework.UserManagement try { - Hashtable responseData = new Hashtable(); LLUUID AgentID = TheUser.UUID; - - // Global Texture Section - Hashtable GlobalT = new Hashtable(); - GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; - GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - ArrayList GlobalTextures = new ArrayList(); - GlobalTextures.Add(GlobalT); - - // Login Flags Section - Hashtable LoginFlagsHash = new Hashtable(); - LoginFlagsHash["daylight_savings"] = "N"; - LoginFlagsHash["stipend_since_login"] = "N"; - LoginFlagsHash["gendered"] = "Y"; // Needs to be combined with below... - LoginFlagsHash["ever_logged_in"] = "Y"; // Should allow male/female av selection - ArrayList LoginFlags = new ArrayList(); - LoginFlags.Add(LoginFlagsHash); - - // UI Customisation Section - Hashtable uiconfig = new Hashtable(); - uiconfig["allow_first_life"] = "Y"; - ArrayList ui_config = new ArrayList(); - ui_config.Add(uiconfig); - - // Classified Categories Section - Hashtable ClassifiedCategoriesHash = new Hashtable(); - ClassifiedCategoriesHash["category_name"] = "Generic"; - ClassifiedCategoriesHash["category_id"] = (Int32)1; - ArrayList ClassifiedCategories = new ArrayList(); - ClassifiedCategories.Add(ClassifiedCategoriesHash); // Inventory Library Section ArrayList AgentInventoryArray = new ArrayList(); @@ -534,62 +443,37 @@ namespace OpenGrid.Framework.UserManagement ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); - Hashtable InitialOutfitHash = new Hashtable(); - InitialOutfitHash["folder_name"] = "Nightclub Female"; - InitialOutfitHash["gender"] = "female"; - ArrayList InitialOutfit = new ArrayList(); - InitialOutfit.Add(InitialOutfitHash); - // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); - // Generics - responseData["last_name"] = TheUser.surname; - responseData["ui-config"] = ui_config; - responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); - responseData["login-flags"] = LoginFlags; - responseData["global-textures"] = GlobalTextures; - responseData["classified_categories"] = ClassifiedCategories; - responseData["event_categories"] = new ArrayList(); - responseData["inventory-skeleton"] = AgentInventoryArray; - responseData["inventory-skel-lib"] = new ArrayList(); - responseData["inventory-root"] = InventoryRoot; - responseData["event_notifications"] = new ArrayList(); - responseData["gestures"] = new ArrayList(); - responseData["inventory-lib-owner"] = new ArrayList(); - responseData["initial-outfit"] = InitialOutfit; - responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - responseData["start_location"] = "last"; - responseData["home"] = "!!null temporary value {home}!!"; // Overwritten - responseData["message"] = _config.DefaultStartupMsg; - responseData["first_name"] = TheUser.username; - responseData["circuit_code"] = (Int32)circode; - responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port; - responseData["secure_session_id"] = TheUser.currentAgent.secureSessionID.ToStringHyphenated(); - responseData["look_at"] = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; - responseData["agent_id"] = AgentID.ToStringHyphenated(); - responseData["region_y"] = (Int32)0; // Overwritten - responseData["region_x"] = (Int32)0; // Overwritten - responseData["seed_capability"] = ""; - responseData["agent_access"] = "M"; - responseData["session_id"] = TheUser.currentAgent.sessionID.ToStringHyphenated(); - responseData["login"] = "true"; - + 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 responseData, ref TheUser); + this.CustomiseResponse(ref logResponse, ref TheUser); } catch (Exception e) { Console.WriteLine(e.ToString()); - return CreateDeadRegionResponse(); + return logResponse.CreateDeadRegionResponse(); } - CommitAgent(ref TheUser); - response.Value = responseData; - // TheUser.SendDataToSim(SimInfo); - return response; + return logResponse.ToXmlRpcResponse(); } catch (Exception E) @@ -602,6 +486,8 @@ namespace OpenGrid.Framework.UserManagement } + #endregion + /// /// Deletes an active agent session /// @@ -617,6 +503,37 @@ namespace OpenGrid.Framework.UserManagement } /// + /// + /// + /// + 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) @@ -693,6 +610,8 @@ namespace OpenGrid.Framework.UserManagement 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()); @@ -716,6 +635,7 @@ namespace OpenGrid.Framework.UserManagement return ProfileToXml(userProfile); } + #endregion } } diff --git a/Common/OpenSim.Framework/Types/NetworkServersInfo.cs b/Common/OpenSim.Framework/Types/NetworkServersInfo.cs index 0cf0ea6..709b7dd 100644 --- a/Common/OpenSim.Framework/Types/NetworkServersInfo.cs +++ b/Common/OpenSim.Framework/Types/NetworkServersInfo.cs @@ -45,16 +45,47 @@ namespace OpenSim.Framework.Types public string UserRecvKey = ""; public bool isSandbox; + public uint DefaultHomeLocX = 0; + public uint DefaultHomeLocY = 0; + public void InitConfig(bool sandboxMode, IGenericConfig configData) { this.isSandbox = sandboxMode; try { + string attri = ""; + // default home location X + attri = ""; + attri = configData.GetAttribute("DefaultLocationX"); + if (attri == "") + { + string location = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("Default Home Location X", "1000"); + configData.SetAttribute("DefaultLocationX", location); + this.DefaultHomeLocX = (uint)Convert.ToUInt32(location); + } + else + { + this.DefaultHomeLocX = (uint)Convert.ToUInt32(attri); + } + + // default home location Y + attri = ""; + attri = configData.GetAttribute("DefaultLocationY"); + if (attri == "") + { + string location = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("Default Home Location Y", "1000"); + configData.SetAttribute("DefaultLocationY", location); + this.DefaultHomeLocY = (uint)Convert.ToUInt32(location); + } + else + { + this.DefaultHomeLocY = (uint)Convert.ToUInt32(attri); + } + if (!isSandbox) { - string attri = ""; - //Grid Server URL + //Grid Server attri = ""; attri = configData.GetAttribute("GridServerURL"); if (attri == "") diff --git a/Common/OpenSim.Framework/Types/PrimData.cs b/Common/OpenSim.Framework/Types/PrimData.cs index 836b8fb..56d41b3 100644 --- a/Common/OpenSim.Framework/Types/PrimData.cs +++ b/Common/OpenSim.Framework/Types/PrimData.cs @@ -60,7 +60,6 @@ namespace OpenSim.Framework.Types public sbyte PathTwistBegin; public byte[] Texture; - public Int32 CreationDate; public uint OwnerMask = FULL_MASK_PERMISSIONS; public uint NextOwnerMask = FULL_MASK_PERMISSIONS; diff --git a/Common/OpenSim.Servers/LoginResponse.cs b/Common/OpenSim.Servers/LoginResponse.cs index debfe43..dc4732c 100644 --- a/Common/OpenSim.Servers/LoginResponse.cs +++ b/Common/OpenSim.Servers/LoginResponse.cs @@ -72,7 +72,7 @@ namespace OpenSim.UserServer private ArrayList initialOutfit; private ArrayList agentInventory; - private UserProfile userProfile; + private UserInfo userProfile; private LLUUID agentID; private LLUUID sessionID; @@ -131,7 +131,7 @@ namespace OpenSim.UserServer this.uiConfigHash = new Hashtable(); this.defaultXmlRpcResponse = new XmlRpcResponse(); - this.userProfile = new UserProfile(); + this.userProfile = new UserInfo(); this.inventoryRoot = new ArrayList(); this.initialOutfit = new ArrayList(); this.agentInventory = new ArrayList(); @@ -181,28 +181,9 @@ namespace OpenSim.UserServer this.AddClassifiedCategory((Int32)8, "Service"); this.AddClassifiedCategory((Int32)9, "Personal"); - int SessionRand = Util.RandomClass.Next(1, 999); - this.SessionID = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797"); + this.SessionID = LLUUID.Random(); this.SecureSessionID = LLUUID.Random(); - - this.userProfile.Inventory.CreateRootFolder(this.userProfile.UUID, true); - this.baseFolderID = this.userProfile.Inventory.GetFolderID("Textures"); - this.inventoryFolderID = this.userProfile.Inventory.GetFolderID("My Inventory-"); - Hashtable InventoryRootHash = new Hashtable(); - InventoryRootHash["folder_id"] = this.userProfile.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); - this.inventoryRoot.Add(InventoryRootHash); - - Hashtable TempHash; - foreach (InventoryFolder InvFolder in this.userProfile.Inventory.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(); - this.agentInventory.Add(TempHash); - } + this.AgentID = LLUUID.Random(); Hashtable InitialOutfitHash = new Hashtable(); InitialOutfitHash["folder_name"] = "Nightclub Female"; @@ -219,15 +200,6 @@ namespace OpenSim.UserServer } // SetDefaultValues - protected virtual LLUUID GetAgentId() - { - // todo - LLUUID Agent; - int AgentRand = Util.RandomClass.Next(1, 9999); - Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead"); - return Agent; - } // GetAgentId - private XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) { // Overwrite any default values; @@ -287,9 +259,6 @@ namespace OpenSim.UserServer this.AddToUIConfig("allow_first_life", this.allowFirstLife); this.uiConfig.Add(this.uiConfigHash); - // Create a agent and session LLUUID - this.agentID = this.GetAgentId(); - responseData["sim_port"] = this.SimPort; responseData["sim_ip"] = this.SimAddress; responseData["agent_id"] = this.AgentID.ToStringHyphenated(); @@ -320,6 +289,9 @@ namespace OpenSim.UserServer responseData["region_x"] = (Int32)this.RegionX * 256; responseData["region_y"] = (Int32)this.RegionY * 256; + //responseData["inventory-lib-root"] = new ArrayList(); // todo + //responseData["buddy-list"] = new ArrayList(); // todo + responseData["login"] = "true"; this.xmlRpcResponse.Value = responseData; @@ -355,6 +327,7 @@ namespace OpenSim.UserServer // this.classifiedCategoriesHash.Clear(); } // SetClassifiedCategory + #region Properties public string Login { get @@ -667,5 +640,16 @@ namespace OpenSim.UserServer } } // ErrorMessage - } // LoginResponse -} // namespace OpenSim.UserServer \ No newline at end of file + #endregion + + + public class UserInfo + { + public string firstname; + public string lastname; + public ulong homeregionhandle; + public LLVector3 homepos; + public LLVector3 homelookat; + } + } +} \ No newline at end of file diff --git a/Common/OpenSim.Servers/LoginServer.cs b/Common/OpenSim.Servers/LoginServer.cs index 1243147..e5373dd 100644 --- a/Common/OpenSim.Servers/LoginServer.cs +++ b/Common/OpenSim.Servers/LoginServer.cs @@ -148,36 +148,14 @@ namespace OpenSim.UserServer NumClients++; - // Create a agent and session LLUUID - // Agent = GetAgentId(first, last); - // int SessionRand = Util.RandomClass.Next(1, 999); - // Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797"); - // LLUUID secureSess = LLUUID.Random(); - loginResponse.SimPort = m_simPort.ToString(); loginResponse.SimAddress = m_simAddr.ToString(); - // loginResponse.AgentID = Agent.ToStringHyphenated(); - // loginResponse.SessionID = Session.ToStringHyphenated(); - // loginResponse.SecureSessionID = secureSess.ToStringHyphenated(); + loginResponse.CircuitCode = (Int32)(Util.RandomClass.Next()); XmlRpcResponse response = loginResponse.ToXmlRpcResponse(); Hashtable responseData = (Hashtable)response.Value; - //inventory - /* ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"]; - Hashtable Inventory1 = (Hashtable)InventoryList[0]; - Hashtable Inventory2 = (Hashtable)InventoryList[1]; - LLUUID BaseFolderID = LLUUID.Random(); - LLUUID InventoryFolderID = LLUUID.Random(); - Inventory2["name"] = "Textures"; - Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); - Inventory2["type_default"] = 0; - Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); - - ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"]; - Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; - Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); - */ + CustomiseLoginResponse(responseData, first, last); Login _login = new Login(); @@ -191,11 +169,6 @@ namespace OpenSim.UserServer _login.BaseFolder = loginResponse.BaseFolderID; _login.InventoryFolder = loginResponse.InventoryFolderID; - //working on local computer if so lets add to the gridserver's list of sessions? - /* if (m_gridServer.GetName() == "Local") - { - ((LocalGridBase)m_gridServer).AddNewSession(_login); - }*/ ulong reghand = Helpers.UIntsToLong((regionX * 256), (regionY * 256)); AddSession(reghand,_login); -- cgit v1.1