From b2d588ed1c9068324333ec3c5ab86efe6a36216d Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 25 May 2007 16:27:07 +0000 Subject: Possible my last ever OpenSim/OGS contribution (if I continue to feel like this): Re-added a CLI "create user" command to the userserver, only currently works if using DB4o as the database provider. Added Xml config files to both the UserServer and Gridserver (UserServerConfig.xml and GridServerConfig.xml), so that the database provider can be set in it. (both currently default to DB4o , so maybe Adam will want to change it back to defaulting to MySQL) --- .../OpenGridServices.UserServer/Main.cs | 56 +++++++++++++++------- .../OpenGridServices.UserServer.csproj | 4 ++ .../OpenGridServices.UserServer.exe.build | 9 ++-- .../OpenGridServices.UserServer/UserManager.cs | 31 ++++++++++++ 4 files changed, 78 insertions(+), 22 deletions(-) (limited to 'OpenGridServices/OpenGridServices.UserServer') diff --git a/OpenGridServices/OpenGridServices.UserServer/Main.cs b/OpenGridServices/OpenGridServices.UserServer/Main.cs index 0eb314b..aec80dc 100644 --- a/OpenGridServices/OpenGridServices.UserServer/Main.cs +++ b/OpenGridServices/OpenGridServices.UserServer/Main.cs @@ -40,6 +40,8 @@ using OpenSim.Framework.Inventory; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Console; using OpenSim.Servers; +using OpenSim.Framework.Utilities; +using OpenSim.GenericConfig; namespace OpenGridServices.UserServer { @@ -48,8 +50,9 @@ namespace OpenGridServices.UserServer public class OpenUser_Main : BaseServer, conscmd_callback { private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll"; - private string StorageDll = "OpenGrid.Framework.Data.MySQL.dll"; + private string StorageDll = "OpenGrid.Framework.Data.DB4o.dll"; private UserConfig Cfg; + protected IGenericConfig localXMLConfig; public UserManager m_userManager; // Replaces below. @@ -88,6 +91,11 @@ namespace OpenGridServices.UserServer public void Startup() { + this.localXMLConfig = new XmlConfig("UserServerConfig.xml"); + this.localXMLConfig.LoadData(); + this.ConfigDB(this.localXMLConfig); + this.localXMLConfig.Close(); + MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration"); Cfg = this.LoadConfigDll(this.ConfigDll); Cfg.InitConfig(); @@ -112,33 +120,22 @@ namespace OpenGridServices.UserServer switch (what) { case "user": - m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"Commandline user creation is currently disabled."); - break; - /* string tempfirstname; string templastname; string tempMD5Passwd; + uint regX = 997; + uint regY = 996; tempfirstname = m_console.CmdPrompt("First name"); templastname = m_console.CmdPrompt("Last name"); tempMD5Passwd = m_console.PasswdPrompt("Password"); + regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); + regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); - System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); - byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd); - bs = x.ComputeHash(bs); - System.Text.StringBuilder s = new System.Text.StringBuilder(); - foreach (byte b in bs) - { - s.Append(b.ToString("x2").ToLower()); - } - tempMD5Passwd = s.ToString(); + tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); - UserProfile newuser = m_userProfileManager.CreateNewProfile(tempfirstname, templastname, tempMD5Passwd); - newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f); - newuser.homepos = new LLVector3(128f, 128f, 150f); - m_userProfileManager.SaveUserProfiles(); + m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); break; - */ } } @@ -162,6 +159,29 @@ namespace OpenGridServices.UserServer } } + private void ConfigDB(IGenericConfig configData) + { + try + { + string attri = ""; + attri = configData.GetAttribute("DataBaseProvider"); + if (attri == "") + { + StorageDll = "OpenGrid.Framework.Data.DB4o.dll"; + configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll"); + } + else + { + StorageDll = attri; + } + configData.Commit(); + } + catch (Exception e) + { + + } + } + private UserConfig LoadConfigDll(string dllName) { Assembly pluginAssembly = Assembly.LoadFrom(dllName); diff --git a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj index 16a713b..1bd07fb 100644 --- a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj +++ b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj @@ -78,6 +78,10 @@ OpenSim.Framework.Console.dll False + + OpenSim.GenericConfig.Xml.dll + False + OpenSim.Servers.dll False diff --git a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build index 7c5f7e7..5275ef4 100644 --- a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build +++ b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build @@ -23,13 +23,14 @@ - - + + - + + - + diff --git a/OpenGridServices/OpenGridServices.UserServer/UserManager.cs b/OpenGridServices/OpenGridServices.UserServer/UserManager.cs index a312445..fdda63b 100644 --- a/OpenGridServices/OpenGridServices.UserServer/UserManager.cs +++ b/OpenGridServices/OpenGridServices.UserServer/UserManager.cs @@ -53,6 +53,37 @@ namespace OpenGridServices.UserServer } /// + /// + /// + /// + 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.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + } + + /// /// Loads a user profile from a database by UUID /// /// The target UUID -- cgit v1.1