aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2010-01-10 01:46:56 +0000
committerMelanie2010-01-10 01:46:56 +0000
commit7403f2fd366cc96cd65ba95d7fba68dce1846982 (patch)
treed96022c04cb73cd8da0a57fe6c96589ada2819a0
parentFinally the region service config stuff is in. (diff)
parent* Moved command reset password from OpenSim to UserAccountService. (diff)
downloadopensim-SC_OLD-7403f2fd366cc96cd65ba95d7fba68dce1846982.zip
opensim-SC_OLD-7403f2fd366cc96cd65ba95d7fba68dce1846982.tar.gz
opensim-SC_OLD-7403f2fd366cc96cd65ba95d7fba68dce1846982.tar.bz2
opensim-SC_OLD-7403f2fd366cc96cd65ba95d7fba68dce1846982.tar.xz
Merge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensim into presence-refactor
-rw-r--r--OpenSim/Region/Application/OpenSim.cs121
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs5
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs29
-rw-r--r--OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs6
-rw-r--r--OpenSim/Services/Interfaces/IAuthenticationService.cs11
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs182
-rw-r--r--bin/config-include/StandaloneHypergrid.ini6
7 files changed, 185 insertions, 175 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 82b2fd4..31cc610 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -347,16 +347,6 @@ namespace OpenSim
347 "kill uuid <UUID>", 347 "kill uuid <UUID>",
348 "Kill an object by UUID", KillUUID); 348 "Kill an object by UUID", KillUUID);
349 349
350 if (ConfigurationSettings.Standalone)
351 {
352 m_console.Commands.AddCommand("region", false, "create user",
353 "create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
354 "Create a new user", HandleCreateUser);
355
356 m_console.Commands.AddCommand("region", false, "reset user password",
357 "reset user password [<first> [<last> [<password>]]]",
358 "Reset a user password", HandleResetUserPassword);
359 }
360 350
361 m_console.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>", 351 m_console.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
362 "Set local coordinate to map HG regions to", RunCommand); 352 "Set local coordinate to map HG regions to", RunCommand);
@@ -812,37 +802,6 @@ namespace OpenSim
812 m_console.ConsoleScene = m_sceneManager.CurrentScene; 802 m_console.ConsoleScene = m_sceneManager.CurrentScene;
813 } 803 }
814 804
815 /// <summary>
816 /// Execute switch for some of the create commands
817 /// </summary>
818 /// <param name="args"></param>
819 private void HandleCreateUser(string module, string[] cmd)
820 {
821 if (ConfigurationSettings.Standalone)
822 {
823 CreateUser(cmd);
824 }
825 else
826 {
827 m_log.Info("Create user is not available in grid mode, use the user server.");
828 }
829 }
830
831 /// <summary>
832 /// Execute switch for some of the reset commands
833 /// </summary>
834 /// <param name="args"></param>
835 protected void HandleResetUserPassword(string module, string[] cmd)
836 {
837 if (ConfigurationSettings.Standalone)
838 {
839 ResetUserPassword(cmd);
840 }
841 else
842 {
843 m_log.Info("Reset user password is not available in grid mode, use the user-server.");
844 }
845 }
846 805
847 /// <summary> 806 /// <summary>
848 /// Turn on some debugging values for OpenSim. 807 /// Turn on some debugging values for OpenSim.
@@ -1076,86 +1035,6 @@ namespace OpenSim
1076 } 1035 }
1077 1036
1078 /// <summary> 1037 /// <summary>
1079 /// Create a new user
1080 /// </summary>
1081 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
1082 protected void CreateUser(string[] cmdparams)
1083 {
1084 string firstName;
1085 string lastName;
1086 string password;
1087 string email;
1088 uint regX = 1000;
1089 uint regY = 1000;
1090
1091 IConfig standalone;
1092 if ((standalone = m_config.Source.Configs["StandAlone"]) != null)
1093 {
1094 regX = (uint)standalone.GetInt("default_location_x", (int)regX);
1095 regY = (uint)standalone.GetInt("default_location_y", (int)regY);
1096 }
1097
1098
1099 if (cmdparams.Length < 3)
1100 firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
1101 else firstName = cmdparams[2];
1102
1103 if (cmdparams.Length < 4)
1104 lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
1105 else lastName = cmdparams[3];
1106
1107 if (cmdparams.Length < 5)
1108 password = MainConsole.Instance.PasswdPrompt("Password");
1109 else password = cmdparams[4];
1110
1111 if (cmdparams.Length < 6)
1112 regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
1113 else regX = Convert.ToUInt32(cmdparams[5]);
1114
1115 if (cmdparams.Length < 7)
1116 regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
1117 else regY = Convert.ToUInt32(cmdparams[6]);
1118
1119 if (cmdparams.Length < 8)
1120 email = MainConsole.Instance.CmdPrompt("Email", "");
1121 else email = cmdparams[7];
1122
1123 if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName))
1124 {
1125 m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY);
1126 }
1127 else
1128 {
1129 m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName);
1130 }
1131 }
1132
1133 /// <summary>
1134 /// Reset a user password.
1135 /// </summary>
1136 /// <param name="cmdparams"></param>
1137 private void ResetUserPassword(string[] cmdparams)
1138 {
1139 string firstName;
1140 string lastName;
1141 string newPassword;
1142
1143 if (cmdparams.Length < 4)
1144 firstName = MainConsole.Instance.CmdPrompt("First name");
1145 else firstName = cmdparams[3];
1146
1147 if (cmdparams.Length < 5)
1148 lastName = MainConsole.Instance.CmdPrompt("Last name");
1149 else lastName = cmdparams[4];
1150
1151 if (cmdparams.Length < 6)
1152 newPassword = MainConsole.Instance.PasswdPrompt("New password");
1153 else newPassword = cmdparams[5];
1154
1155 m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword);
1156 }
1157
1158 /// <summary>
1159 /// Use XML2 format to serialize data to a file 1038 /// Use XML2 format to serialize data to a file
1160 /// </summary> 1039 /// </summary>
1161 /// <param name="module"></param> 1040 /// <param name="module"></param>
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs
index 4c65722..acc362b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs
@@ -153,6 +153,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication
153 return m_AuthenticationService.Release(principalID, token); 153 return m_AuthenticationService.Release(principalID, token);
154 } 154 }
155 155
156 public bool SetPassword(UUID principalID, string passwd)
157 {
158 return m_AuthenticationService.SetPassword(principalID, passwd);
159 }
160
156 #endregion 161 #endregion
157 162
158 } 163 }
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index dcf090e..f6dd085 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -32,6 +32,7 @@ using Nini.Config;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Services.Base; 33using OpenSim.Services.Base;
34using OpenSim.Data; 34using OpenSim.Data;
35using OpenSim.Framework;
35 36
36namespace OpenSim.Services.AuthenticationService 37namespace OpenSim.Services.AuthenticationService
37{ 38{
@@ -43,9 +44,9 @@ namespace OpenSim.Services.AuthenticationService
43 // 44 //
44 public class AuthenticationServiceBase : ServiceBase 45 public class AuthenticationServiceBase : ServiceBase
45 { 46 {
46// private static readonly ILog m_log = 47 private static readonly ILog m_log =
47// LogManager.GetLogger( 48 LogManager.GetLogger(
48// MethodBase.GetCurrentMethod().DeclaringType); 49 MethodBase.GetCurrentMethod().DeclaringType);
49 50
50 protected IAuthenticationData m_Database; 51 protected IAuthenticationData m_Database;
51 52
@@ -100,6 +101,27 @@ namespace OpenSim.Services.AuthenticationService
100 return m_Database.CheckToken(principalID, token, 0); 101 return m_Database.CheckToken(principalID, token, 0);
101 } 102 }
102 103
104 public virtual bool SetPassword(UUID principalID, string password)
105 {
106 string passwordSalt = Util.Md5Hash(UUID.Random().ToString());
107 string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt);
108
109 AuthenticationData auth = new AuthenticationData();
110 auth.PrincipalID = principalID;
111 auth.Data = new System.Collections.Generic.Dictionary<string, object>();
112 auth.Data["passwordHash"] = md5PasswdHash;
113 auth.Data["passwordSalt"] = passwordSalt;
114 auth.Data["webLoginKey"] = UUID.Zero.ToString();
115 if (!m_Database.Store(auth))
116 {
117 m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
118 return false;
119 }
120
121 m_log.InfoFormat("[AUTHENTICATION DB]: Set password for principalID {0}", principalID);
122 return true;
123 }
124
103 protected string GetToken(UUID principalID, int lifetime) 125 protected string GetToken(UUID principalID, int lifetime)
104 { 126 {
105 UUID token = UUID.Random(); 127 UUID token = UUID.Random();
@@ -109,5 +131,6 @@ namespace OpenSim.Services.AuthenticationService
109 131
110 return String.Empty; 132 return String.Empty;
111 } 133 }
134
112 } 135 }
113} 136}
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
index 1250658..f36fe5b 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
@@ -146,5 +146,11 @@ namespace OpenSim.Services.Connectors
146 146
147 return true; 147 return true;
148 } 148 }
149
150 public bool SetPassword(UUID principalID, string passwd)
151 {
152 // nope, we don't do this
153 return false;
154 }
149 } 155 }
150} 156}
diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs
index 9225773..9de261b 100644
--- a/OpenSim/Services/Interfaces/IAuthenticationService.cs
+++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs
@@ -66,6 +66,17 @@ namespace OpenSim.Services.Interfaces
66 bool Release(UUID principalID, string token); 66 bool Release(UUID principalID, string token);
67 67
68 ////////////////////////////////////////////////////// 68 //////////////////////////////////////////////////////
69 // SetPassword for a principal
70 //
71 // This method exists for the service, but may or may not
72 // be served remotely. That is, the authentication
73 // handlers may not include one handler for this,
74 // because it's a bit risky. Such handlers require
75 // authentication/authorization.
76 //
77 bool SetPassword(UUID principalID, string passwd);
78
79 //////////////////////////////////////////////////////
69 // Grid 80 // Grid
70 // 81 //
71 // We no longer need a shared secret between grid 82 // We no longer need a shared secret between grid
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index dacfa51..90077d8 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -26,25 +26,62 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using Nini.Config; 31using Nini.Config;
31using OpenSim.Data; 32using OpenSim.Data;
32using OpenSim.Framework.Console;
33using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
34using System.Collections.Generic; 34using OpenSim.Framework.Console;
35using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36
35using OpenMetaverse; 37using OpenMetaverse;
38using log4net;
36 39
37namespace OpenSim.Services.UserAccountService 40namespace OpenSim.Services.UserAccountService
38{ 41{
39 public class UserAccountService : UserAccountServiceBase, IUserAccountService 42 public class UserAccountService : UserAccountServiceBase, IUserAccountService
40 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private static UserAccountService m_RootInstance;
46
47 protected IGridService m_GridService;
48 protected IAuthenticationService m_AuthenticationService;
49 protected IPresenceService m_PresenceService;
50
41 public UserAccountService(IConfigSource config) 51 public UserAccountService(IConfigSource config)
42 : base(config) 52 : base(config)
43 { 53 {
44 MainConsole.Instance.Commands.AddCommand("UserService", false, 54 IConfig userConfig = config.Configs["UserAccountService"];
45 "create user", 55 if (userConfig == null)
46 "create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]", 56 throw new Exception("No UserAccountService configuration");
47 "Create a new user", HandleCreateUser); 57
58 // In case there are several instances of this class in the same process,
59 // the console commands are only registered for the root instance
60 if (m_RootInstance == null)
61 {
62 m_RootInstance = this;
63 string gridServiceDll = userConfig.GetString("GridService", string.Empty);
64 if (gridServiceDll != string.Empty)
65 m_GridService = LoadPlugin<IGridService>(gridServiceDll, new Object[] { config });
66
67 string authServiceDll = userConfig.GetString("AuthenticationService", string.Empty);
68 if (authServiceDll != string.Empty)
69 m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config });
70
71 string presenceServiceDll = userConfig.GetString("PresenceService", string.Empty);
72 if (presenceServiceDll != string.Empty)
73 m_PresenceService = LoadPlugin<IPresenceService>(presenceServiceDll, new Object[] { config });
74
75 MainConsole.Instance.Commands.AddCommand("UserService", false,
76 "create user",
77 "create user [<first> [<last> [<pass> [<email>]]]]",
78 "Create a new user", HandleCreateUser);
79 MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password",
80 "reset user password [<first> [<last> [<password>]]]",
81 "Reset a user password", HandleResetUserPassword);
82
83 }
84
48 } 85 }
49 86
50 #region IUserAccountService 87 #region IUserAccountService
@@ -202,52 +239,97 @@ namespace OpenSim.Services.UserAccountService
202 string lastName; 239 string lastName;
203 string password; 240 string password;
204 string email; 241 string email;
205 uint regX = 1000; 242
206 uint regY = 1000; 243 if (cmdparams.Length < 3)
207 244 firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
208 // IConfig standalone; 245 else firstName = cmdparams[2];
209 // if ((standalone = m_config.Source.Configs["StandAlone"]) != null) 246
210 // { 247 if (cmdparams.Length < 4)
211 // regX = (uint)standalone.GetInt("default_location_x", (int)regX); 248 lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
212 // regY = (uint)standalone.GetInt("default_location_y", (int)regY); 249 else lastName = cmdparams[3];
213 // } 250
214 251 if (cmdparams.Length < 5)
215 252 password = MainConsole.Instance.PasswdPrompt("Password");
216 // if (cmdparams.Length < 3) 253 else password = cmdparams[4];
217 // firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); 254
218 // else firstName = cmdparams[2]; 255 if (cmdparams.Length < 6)
219 256 email = MainConsole.Instance.CmdPrompt("Email", "");
220 // if (cmdparams.Length < 4) 257 else email = cmdparams[5];
221 // lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); 258
222 // else lastName = cmdparams[3]; 259 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
223 260 if (null == account)
224 // if (cmdparams.Length < 5) 261 {
225 // password = MainConsole.Instance.PasswdPrompt("Password"); 262 account = new UserAccount(UUID.Zero, firstName, lastName, email);
226 // else password = cmdparams[4]; 263 if (StoreUserAccount(account))
227 264 {
228 // if (cmdparams.Length < 6) 265 bool success = false;
229 // regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); 266 if (m_AuthenticationService != null)
230 // else regX = Convert.ToUInt32(cmdparams[5]); 267 success = m_AuthenticationService.SetPassword(account.PrincipalID, password);
231 268 if (!success)
232 // if (cmdparams.Length < 7) 269 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
233 // regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); 270 firstName, lastName);
234 // else regY = Convert.ToUInt32(cmdparams[6]); 271
235 272 GridRegion home = null;
236 // if (cmdparams.Length < 8) 273 if (m_GridService != null)
237 // email = MainConsole.Instance.CmdPrompt("Email", ""); 274 {
238 // else email = cmdparams[7]; 275 List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero);
239 276 if (defaultRegions != null && defaultRegions.Count >= 1)
240 // if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName)) 277 home = defaultRegions[0];
241 // { 278
242 // m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY); 279 if (m_PresenceService != null && home != null)
243 // } 280 m_PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
244 // else 281 else
245 // { 282 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
246 // m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName); 283 firstName, lastName);
247 // } 284
248 //} 285 }
286 else
287 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
288 firstName, lastName);
289
290 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName);
291 }
292 }
293 else
294 {
295 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName);
296 }
249 297
250 } 298 }
299
300 protected void HandleResetUserPassword(string module, string[] cmdparams)
301 {
302 string firstName;
303 string lastName;
304 string newPassword;
305
306 if (cmdparams.Length < 4)
307 firstName = MainConsole.Instance.CmdPrompt("First name");
308 else firstName = cmdparams[3];
309
310 if (cmdparams.Length < 5)
311 lastName = MainConsole.Instance.CmdPrompt("Last name");
312 else lastName = cmdparams[4];
313
314 if (cmdparams.Length < 6)
315 newPassword = MainConsole.Instance.PasswdPrompt("New password");
316 else newPassword = cmdparams[5];
317
318 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
319 if (account == null)
320 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: No such user");
321
322 bool success = false;
323 if (m_AuthenticationService != null)
324 success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword);
325 if (!success)
326 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Unable to reset password for account {0} {1}.",
327 firstName, lastName);
328 else
329 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Password reset for user {0} {1}", firstName, lastName);
330 }
331
251 #endregion 332 #endregion
333
252 } 334 }
253} 335}
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini
index 5e54cde..feca115 100644
--- a/bin/config-include/StandaloneHypergrid.ini
+++ b/bin/config-include/StandaloneHypergrid.ini
@@ -67,7 +67,11 @@
67 67
68[UserAccountService] 68[UserAccountService]
69 LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" 69 LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
70 70 ;; These are for creating new accounts
71 AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
72 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
73 GridService = "OpenSim.Services.GridService.dll:GridService"
74
71[LoginService] 75[LoginService]
72 LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" 76 LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService"
73 UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" 77 UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService"