aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGridServices.UserServer
diff options
context:
space:
mode:
authorMW2007-05-25 16:27:07 +0000
committerMW2007-05-25 16:27:07 +0000
commitb2d588ed1c9068324333ec3c5ab86efe6a36216d (patch)
tree950442d2af673e1df34e85ca5b8265ddd6c99906 /OpenGridServices/OpenGridServices.UserServer
parentOops (diff)
downloadopensim-SC_OLD-b2d588ed1c9068324333ec3c5ab86efe6a36216d.zip
opensim-SC_OLD-b2d588ed1c9068324333ec3c5ab86efe6a36216d.tar.gz
opensim-SC_OLD-b2d588ed1c9068324333ec3c5ab86efe6a36216d.tar.bz2
opensim-SC_OLD-b2d588ed1c9068324333ec3c5ab86efe6a36216d.tar.xz
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)
Diffstat (limited to 'OpenGridServices/OpenGridServices.UserServer')
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/Main.cs56
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj4
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build9
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/UserManager.cs31
4 files changed, 78 insertions, 22 deletions
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;
40using OpenSim.Framework.Interfaces; 40using OpenSim.Framework.Interfaces;
41using OpenSim.Framework.Console; 41using OpenSim.Framework.Console;
42using OpenSim.Servers; 42using OpenSim.Servers;
43using OpenSim.Framework.Utilities;
44using OpenSim.GenericConfig;
43 45
44namespace OpenGridServices.UserServer 46namespace OpenGridServices.UserServer
45{ 47{
@@ -48,8 +50,9 @@ namespace OpenGridServices.UserServer
48 public class OpenUser_Main : BaseServer, conscmd_callback 50 public class OpenUser_Main : BaseServer, conscmd_callback
49 { 51 {
50 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll"; 52 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll";
51 private string StorageDll = "OpenGrid.Framework.Data.MySQL.dll"; 53 private string StorageDll = "OpenGrid.Framework.Data.DB4o.dll";
52 private UserConfig Cfg; 54 private UserConfig Cfg;
55 protected IGenericConfig localXMLConfig;
53 56
54 public UserManager m_userManager; // Replaces below. 57 public UserManager m_userManager; // Replaces below.
55 58
@@ -88,6 +91,11 @@ namespace OpenGridServices.UserServer
88 91
89 public void Startup() 92 public void Startup()
90 { 93 {
94 this.localXMLConfig = new XmlConfig("UserServerConfig.xml");
95 this.localXMLConfig.LoadData();
96 this.ConfigDB(this.localXMLConfig);
97 this.localXMLConfig.Close();
98
91 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration"); 99 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration");
92 Cfg = this.LoadConfigDll(this.ConfigDll); 100 Cfg = this.LoadConfigDll(this.ConfigDll);
93 Cfg.InitConfig(); 101 Cfg.InitConfig();
@@ -112,33 +120,22 @@ namespace OpenGridServices.UserServer
112 switch (what) 120 switch (what)
113 { 121 {
114 case "user": 122 case "user":
115 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"Commandline user creation is currently disabled.");
116 break;
117 /*
118 string tempfirstname; 123 string tempfirstname;
119 string templastname; 124 string templastname;
120 string tempMD5Passwd; 125 string tempMD5Passwd;
126 uint regX = 997;
127 uint regY = 996;
121 128
122 tempfirstname = m_console.CmdPrompt("First name"); 129 tempfirstname = m_console.CmdPrompt("First name");
123 templastname = m_console.CmdPrompt("Last name"); 130 templastname = m_console.CmdPrompt("Last name");
124 tempMD5Passwd = m_console.PasswdPrompt("Password"); 131 tempMD5Passwd = m_console.PasswdPrompt("Password");
132 regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
133 regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
125 134
126 System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); 135 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
127 byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
128 bs = x.ComputeHash(bs);
129 System.Text.StringBuilder s = new System.Text.StringBuilder();
130 foreach (byte b in bs)
131 {
132 s.Append(b.ToString("x2").ToLower());
133 }
134 tempMD5Passwd = s.ToString();
135 136
136 UserProfile newuser = m_userProfileManager.CreateNewProfile(tempfirstname, templastname, tempMD5Passwd); 137 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
137 newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
138 newuser.homepos = new LLVector3(128f, 128f, 150f);
139 m_userProfileManager.SaveUserProfiles();
140 break; 138 break;
141 */
142 } 139 }
143 } 140 }
144 141
@@ -162,6 +159,29 @@ namespace OpenGridServices.UserServer
162 } 159 }
163 } 160 }
164 161
162 private void ConfigDB(IGenericConfig configData)
163 {
164 try
165 {
166 string attri = "";
167 attri = configData.GetAttribute("DataBaseProvider");
168 if (attri == "")
169 {
170 StorageDll = "OpenGrid.Framework.Data.DB4o.dll";
171 configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll");
172 }
173 else
174 {
175 StorageDll = attri;
176 }
177 configData.Commit();
178 }
179 catch (Exception e)
180 {
181
182 }
183 }
184
165 private UserConfig LoadConfigDll(string dllName) 185 private UserConfig LoadConfigDll(string dllName)
166 { 186 {
167 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 187 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 @@
78 <HintPath>OpenSim.Framework.Console.dll</HintPath> 78 <HintPath>OpenSim.Framework.Console.dll</HintPath>
79 <Private>False</Private> 79 <Private>False</Private>
80 </Reference> 80 </Reference>
81 <Reference Include="OpenSim.GenericConfig.Xml" >
82 <HintPath>OpenSim.GenericConfig.Xml.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
81 <Reference Include="OpenSim.Servers" > 85 <Reference Include="OpenSim.Servers" >
82 <HintPath>OpenSim.Servers.dll</HintPath> 86 <HintPath>OpenSim.Servers.dll</HintPath>
83 <Private>False</Private> 87 <Private>False</Private>
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 @@
23 <include name="System.dll" /> 23 <include name="System.dll" />
24 <include name="System.Data.dll" /> 24 <include name="System.Data.dll" />
25 <include name="System.Xml.dll" /> 25 <include name="System.Xml.dll" />
26 <include name="OpenSim.Framework.dll" /> 26 <include name="../../bin/OpenSim.Framework.dll" />
27 <include name="OpenSim.Framework.Console.dll" /> 27 <include name="../../bin/OpenSim.Framework.Console.dll" />
28 <include name="../../bin/OpenGrid.Framework.Data.dll" /> 28 <include name="../../bin/OpenGrid.Framework.Data.dll" />
29 <include name="OpenSim.Servers.dll" /> 29 <include name="../../bin/OpenSim.GenericConfig.Xml.dll" />
30 <include name="../../bin/OpenSim.Servers.dll" />
30 <include name="../../bin/libsecondlife.dll" /> 31 <include name="../../bin/libsecondlife.dll" />
31 <include name="../../bin/Db4objects.Db4o.dll" /> 32 <include name="../../bin/Db4objects.Db4o.dll" />
32 <include name="XMLRPC.dll" /> 33 <include name="../../bin/XMLRPC.dll" />
33 </references> 34 </references>
34 </csc> 35 </csc>
35 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> 36 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
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
53 } 53 }
54 54
55 /// <summary> 55 /// <summary>
56 ///
57 /// </summary>
58 /// <param name="user"></param>
59 public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
60 {
61 UserProfileData user = new UserProfileData();
62 user.homeLocation = new LLVector3(128, 128, 100);
63 user.UUID = LLUUID.Random();
64 user.username = firstName;
65 user.surname = lastName;
66 user.passwordHash = pass;
67 user.passwordSalt = "";
68 user.created = Util.UnixTimeSinceEpoch();
69 user.homeLookAt = new LLVector3(100, 100, 100);
70 user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256));
71
72 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
73 {
74 try
75 {
76 plugin.Value.addNewUserProfile(user);
77
78 }
79 catch (Exception e)
80 {
81 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
82 }
83 }
84 }
85
86 /// <summary>
56 /// Loads a user profile from a database by UUID 87 /// Loads a user profile from a database by UUID
57 /// </summary> 88 /// </summary>
58 /// <param name="uuid">The target UUID</param> 89 /// <param name="uuid">The target UUID</param>