diff options
author | Diva Canto | 2010-01-09 18:04:50 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-09 18:04:50 -0800 |
commit | 96ecdcf9c5ba35e589a599ad37cc6ce1a83f46f1 (patch) | |
tree | 330ddb23901e60acc9772b6df48a7795f51e3bbe /OpenSim/Services/UserAccountService/UserAccountService.cs | |
parent | Merge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensi... (diff) | |
download | opensim-SC-96ecdcf9c5ba35e589a599ad37cc6ce1a83f46f1.zip opensim-SC-96ecdcf9c5ba35e589a599ad37cc6ce1a83f46f1.tar.gz opensim-SC-96ecdcf9c5ba35e589a599ad37cc6ce1a83f46f1.tar.bz2 opensim-SC-96ecdcf9c5ba35e589a599ad37cc6ce1a83f46f1.tar.xz |
* Added SetPassword to IAuthenticationService.
* Added create user command to UserAccountService. Works.
* Deleted create user command from OpenSim.
Diffstat (limited to 'OpenSim/Services/UserAccountService/UserAccountService.cs')
-rw-r--r-- | OpenSim/Services/UserAccountService/UserAccountService.cs | 145 |
1 files changed, 95 insertions, 50 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index dacfa51..8f78813 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs | |||
@@ -26,25 +26,58 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using Nini.Config; | 31 | using Nini.Config; |
31 | using OpenSim.Data; | 32 | using OpenSim.Data; |
32 | using OpenSim.Framework.Console; | ||
33 | using OpenSim.Services.Interfaces; | 33 | using OpenSim.Services.Interfaces; |
34 | using System.Collections.Generic; | 34 | using OpenSim.Framework.Console; |
35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
36 | |||
35 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using log4net; | ||
36 | 39 | ||
37 | namespace OpenSim.Services.UserAccountService | 40 | namespace 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 | } | ||
80 | |||
48 | } | 81 | } |
49 | 82 | ||
50 | #region IUserAccountService | 83 | #region IUserAccountService |
@@ -202,52 +235,64 @@ namespace OpenSim.Services.UserAccountService | |||
202 | string lastName; | 235 | string lastName; |
203 | string password; | 236 | string password; |
204 | string email; | 237 | string email; |
205 | uint regX = 1000; | 238 | |
206 | uint regY = 1000; | 239 | if (cmdparams.Length < 3) |
207 | 240 | firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); | |
208 | // IConfig standalone; | 241 | else firstName = cmdparams[2]; |
209 | // if ((standalone = m_config.Source.Configs["StandAlone"]) != null) | 242 | |
210 | // { | 243 | if (cmdparams.Length < 4) |
211 | // regX = (uint)standalone.GetInt("default_location_x", (int)regX); | 244 | lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); |
212 | // regY = (uint)standalone.GetInt("default_location_y", (int)regY); | 245 | else lastName = cmdparams[3]; |
213 | // } | 246 | |
214 | 247 | if (cmdparams.Length < 5) | |
215 | 248 | password = MainConsole.Instance.PasswdPrompt("Password"); | |
216 | // if (cmdparams.Length < 3) | 249 | else password = cmdparams[4]; |
217 | // firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); | 250 | |
218 | // else firstName = cmdparams[2]; | 251 | if (cmdparams.Length < 6) |
219 | 252 | email = MainConsole.Instance.CmdPrompt("Email", ""); | |
220 | // if (cmdparams.Length < 4) | 253 | else email = cmdparams[5]; |
221 | // lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); | 254 | |
222 | // else lastName = cmdparams[3]; | 255 | UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); |
223 | 256 | if (null == account) | |
224 | // if (cmdparams.Length < 5) | 257 | { |
225 | // password = MainConsole.Instance.PasswdPrompt("Password"); | 258 | account = new UserAccount(UUID.Zero, firstName, lastName, email); |
226 | // else password = cmdparams[4]; | 259 | if (StoreUserAccount(account)) |
227 | 260 | { | |
228 | // if (cmdparams.Length < 6) | 261 | bool success = false; |
229 | // regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); | 262 | if (m_AuthenticationService != null) |
230 | // else regX = Convert.ToUInt32(cmdparams[5]); | 263 | success = m_AuthenticationService.SetPassword(account.PrincipalID, password); |
231 | 264 | if (!success) | |
232 | // if (cmdparams.Length < 7) | 265 | 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())); | 266 | firstName, lastName); |
234 | // else regY = Convert.ToUInt32(cmdparams[6]); | 267 | |
235 | 268 | GridRegion home = null; | |
236 | // if (cmdparams.Length < 8) | 269 | if (m_GridService != null) |
237 | // email = MainConsole.Instance.CmdPrompt("Email", ""); | 270 | { |
238 | // else email = cmdparams[7]; | 271 | List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero); |
239 | 272 | if (defaultRegions != null && defaultRegions.Count >= 1) | |
240 | // if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName)) | 273 | home = defaultRegions[0]; |
241 | // { | 274 | |
242 | // m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY); | 275 | if (m_PresenceService != null && home != null) |
243 | // } | 276 | m_PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); |
244 | // else | 277 | else |
245 | // { | 278 | 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); | 279 | firstName, lastName); |
247 | // } | 280 | |
248 | //} | 281 | } |
282 | else | ||
283 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", | ||
284 | firstName, lastName); | ||
285 | |||
286 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); | ||
287 | } | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); | ||
292 | } | ||
249 | 293 | ||
250 | } | 294 | } |
251 | #endregion | 295 | #endregion |
296 | |||
252 | } | 297 | } |
253 | } | 298 | } |