diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/UserAccountService/GridUserService.cs | 76 | ||||
-rw-r--r-- | OpenSim/Services/UserAccountService/GridUserServiceBase.cs | 82 | ||||
-rw-r--r-- | OpenSim/Services/UserAccountService/UserAccountService.cs | 373 | ||||
-rw-r--r-- | OpenSim/Services/UserAccountService/UserAccountServiceBase.cs (renamed from OpenSim/Services/UserService/UserServiceBase.cs) | 19 |
4 files changed, 545 insertions, 5 deletions
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs new file mode 100644 index 0000000..c6e33bb --- /dev/null +++ b/OpenSim/Services/UserAccountService/GridUserService.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using Nini.Config; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | |||
40 | namespace OpenSim.Services.UserAccountService | ||
41 | { | ||
42 | public class GridUserService : GridUserServiceBase, IGridUserService | ||
43 | { | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | public GridUserService(IConfigSource config) : base(config) | ||
47 | { | ||
48 | m_log.Debug("[USER GRID SERVICE]: Starting user grid service"); | ||
49 | } | ||
50 | |||
51 | public GridUserInfo GetGridUserInfo(string userID) | ||
52 | { | ||
53 | GridUserData d = m_Database.GetGridUserData(userID); | ||
54 | |||
55 | GridUserInfo info = new GridUserInfo(); | ||
56 | info.UserID = d.UserID; | ||
57 | info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); | ||
58 | info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); | ||
59 | info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); | ||
60 | |||
61 | return info; | ||
62 | } | ||
63 | |||
64 | public bool StoreGridUserInfo(GridUserInfo info) | ||
65 | { | ||
66 | GridUserData d = new GridUserData(); | ||
67 | |||
68 | d.Data["UserID"] = info.UserID; | ||
69 | d.Data["HomeRegionID"] = info.HomeRegionID.ToString(); | ||
70 | d.Data["HomePosition"] = info.HomePosition.ToString(); | ||
71 | d.Data["HomeLookAt"] = info.HomeLookAt.ToString(); | ||
72 | |||
73 | return m_Database.StoreGridUserData(d); | ||
74 | } | ||
75 | } | ||
76 | } \ No newline at end of file | ||
diff --git a/OpenSim/Services/UserAccountService/GridUserServiceBase.cs b/OpenSim/Services/UserAccountService/GridUserServiceBase.cs new file mode 100644 index 0000000..990cb63 --- /dev/null +++ b/OpenSim/Services/UserAccountService/GridUserServiceBase.cs | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Services.Base; | ||
35 | |||
36 | namespace OpenSim.Services.UserAccountService | ||
37 | { | ||
38 | public class GridUserServiceBase : ServiceBase | ||
39 | { | ||
40 | protected IGridUserData m_Database = null; | ||
41 | |||
42 | public GridUserServiceBase(IConfigSource config) : base(config) | ||
43 | { | ||
44 | string dllName = String.Empty; | ||
45 | string connString = String.Empty; | ||
46 | string realm = "GridUser"; | ||
47 | |||
48 | // | ||
49 | // Try reading the [DatabaseService] section, if it exists | ||
50 | // | ||
51 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
52 | if (dbConfig != null) | ||
53 | { | ||
54 | if (dllName == String.Empty) | ||
55 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
56 | if (connString == String.Empty) | ||
57 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
58 | } | ||
59 | |||
60 | // | ||
61 | // [GridUsetService] section overrides [DatabaseService], if it exists | ||
62 | // | ||
63 | IConfig presenceConfig = config.Configs["GridUserService"]; | ||
64 | if (presenceConfig != null) | ||
65 | { | ||
66 | dllName = presenceConfig.GetString("StorageProvider", dllName); | ||
67 | connString = presenceConfig.GetString("ConnectionString", connString); | ||
68 | realm = presenceConfig.GetString("Realm", realm); | ||
69 | } | ||
70 | |||
71 | // | ||
72 | // We tried, but this doesn't exist. We can't proceed. | ||
73 | // | ||
74 | if (dllName.Equals(String.Empty)) | ||
75 | throw new Exception("No StorageProvider configured"); | ||
76 | |||
77 | m_Database = LoadPlugin<IGridUserData>(dllName, new Object[] { connString, realm }); | ||
78 | if (m_Database == null) | ||
79 | throw new Exception("Could not find a storage interface in the given module " + dllName); | ||
80 | } | ||
81 | } | ||
82 | } \ No newline at end of file | ||
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs new file mode 100644 index 0000000..38caf74 --- /dev/null +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs | |||
@@ -0,0 +1,373 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using Nini.Config; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | |||
40 | namespace OpenSim.Services.UserAccountService | ||
41 | { | ||
42 | public class UserAccountService : UserAccountServiceBase, IUserAccountService | ||
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 | protected IInventoryService m_InventoryService; | ||
51 | |||
52 | public UserAccountService(IConfigSource config) | ||
53 | : base(config) | ||
54 | { | ||
55 | IConfig userConfig = config.Configs["UserAccountService"]; | ||
56 | if (userConfig == null) | ||
57 | throw new Exception("No UserAccountService configuration"); | ||
58 | |||
59 | // In case there are several instances of this class in the same process, | ||
60 | // the console commands are only registered for the root instance | ||
61 | if (m_RootInstance == null) | ||
62 | { | ||
63 | m_RootInstance = this; | ||
64 | string gridServiceDll = userConfig.GetString("GridService", string.Empty); | ||
65 | if (gridServiceDll != string.Empty) | ||
66 | m_GridService = LoadPlugin<IGridService>(gridServiceDll, new Object[] { config }); | ||
67 | |||
68 | string authServiceDll = userConfig.GetString("AuthenticationService", string.Empty); | ||
69 | if (authServiceDll != string.Empty) | ||
70 | m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config }); | ||
71 | |||
72 | string presenceServiceDll = userConfig.GetString("PresenceService", string.Empty); | ||
73 | if (presenceServiceDll != string.Empty) | ||
74 | m_PresenceService = LoadPlugin<IPresenceService>(presenceServiceDll, new Object[] { config }); | ||
75 | |||
76 | string invServiceDll = userConfig.GetString("InventoryService", string.Empty); | ||
77 | if (invServiceDll != string.Empty) | ||
78 | m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config }); | ||
79 | |||
80 | if (MainConsole.Instance != null) | ||
81 | { | ||
82 | MainConsole.Instance.Commands.AddCommand("UserService", false, | ||
83 | "create user", | ||
84 | "create user [<first> [<last> [<pass> [<email>]]]]", | ||
85 | "Create a new user", HandleCreateUser); | ||
86 | MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password", | ||
87 | "reset user password [<first> [<last> [<password>]]]", | ||
88 | "Reset a user password", HandleResetUserPassword); | ||
89 | } | ||
90 | |||
91 | } | ||
92 | |||
93 | } | ||
94 | |||
95 | #region IUserAccountService | ||
96 | |||
97 | public UserAccount GetUserAccount(UUID scopeID, string firstName, | ||
98 | string lastName) | ||
99 | { | ||
100 | UserAccountData[] d; | ||
101 | |||
102 | if (scopeID != UUID.Zero) | ||
103 | { | ||
104 | d = m_Database.Get( | ||
105 | new string[] { "ScopeID", "FirstName", "LastName" }, | ||
106 | new string[] { scopeID.ToString(), firstName, lastName }); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | d = m_Database.Get( | ||
111 | new string[] { "FirstName", "LastName" }, | ||
112 | new string[] { firstName, lastName }); | ||
113 | } | ||
114 | |||
115 | if (d.Length < 1) | ||
116 | return null; | ||
117 | |||
118 | return MakeUserAccount(d[0]); | ||
119 | } | ||
120 | |||
121 | private UserAccount MakeUserAccount(UserAccountData d) | ||
122 | { | ||
123 | UserAccount u = new UserAccount(); | ||
124 | u.FirstName = d.FirstName; | ||
125 | u.LastName = d.LastName; | ||
126 | u.PrincipalID = d.PrincipalID; | ||
127 | u.ScopeID = d.ScopeID; | ||
128 | if (d.Data.ContainsKey("Email") && d.Data["Email"] != null) | ||
129 | u.Email = d.Data["Email"].ToString(); | ||
130 | else | ||
131 | u.Email = string.Empty; | ||
132 | u.Created = Convert.ToInt32(d.Data["Created"].ToString()); | ||
133 | if (d.Data.ContainsKey("UserTitle") && d.Data["UserTitle"] != null) | ||
134 | u.UserTitle = d.Data["UserTitle"].ToString(); | ||
135 | else | ||
136 | u.UserTitle = string.Empty; | ||
137 | |||
138 | if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null) | ||
139 | { | ||
140 | string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' }); | ||
141 | u.ServiceURLs = new Dictionary<string, object>(); | ||
142 | |||
143 | foreach (string url in URLs) | ||
144 | { | ||
145 | string[] parts = url.Split(new char[] { '=' }); | ||
146 | |||
147 | if (parts.Length != 2) | ||
148 | continue; | ||
149 | |||
150 | string name = System.Web.HttpUtility.UrlDecode(parts[0]); | ||
151 | string val = System.Web.HttpUtility.UrlDecode(parts[1]); | ||
152 | |||
153 | u.ServiceURLs[name] = val; | ||
154 | } | ||
155 | } | ||
156 | else | ||
157 | u.ServiceURLs = new Dictionary<string, object>(); | ||
158 | |||
159 | return u; | ||
160 | } | ||
161 | |||
162 | public UserAccount GetUserAccount(UUID scopeID, string email) | ||
163 | { | ||
164 | UserAccountData[] d; | ||
165 | |||
166 | if (scopeID != UUID.Zero) | ||
167 | { | ||
168 | d = m_Database.Get( | ||
169 | new string[] { "ScopeID", "Email" }, | ||
170 | new string[] { scopeID.ToString(), email }); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | d = m_Database.Get( | ||
175 | new string[] { "Email" }, | ||
176 | new string[] { email }); | ||
177 | } | ||
178 | |||
179 | if (d.Length < 1) | ||
180 | return null; | ||
181 | |||
182 | return MakeUserAccount(d[0]); | ||
183 | } | ||
184 | |||
185 | public UserAccount GetUserAccount(UUID scopeID, UUID principalID) | ||
186 | { | ||
187 | UserAccountData[] d; | ||
188 | |||
189 | if (scopeID != UUID.Zero) | ||
190 | { | ||
191 | d = m_Database.Get( | ||
192 | new string[] { "ScopeID", "PrincipalID" }, | ||
193 | new string[] { scopeID.ToString(), principalID.ToString() }); | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | d = m_Database.Get( | ||
198 | new string[] { "PrincipalID" }, | ||
199 | new string[] { principalID.ToString() }); | ||
200 | } | ||
201 | |||
202 | if (d.Length < 1) | ||
203 | { | ||
204 | return null; | ||
205 | } | ||
206 | |||
207 | return MakeUserAccount(d[0]); | ||
208 | } | ||
209 | |||
210 | public bool StoreUserAccount(UserAccount data) | ||
211 | { | ||
212 | UserAccountData d = new UserAccountData(); | ||
213 | |||
214 | d.FirstName = data.FirstName; | ||
215 | d.LastName = data.LastName; | ||
216 | d.PrincipalID = data.PrincipalID; | ||
217 | d.ScopeID = data.ScopeID; | ||
218 | d.Data = new Dictionary<string, string>(); | ||
219 | d.Data["Email"] = data.Email; | ||
220 | d.Data["Created"] = data.Created.ToString(); | ||
221 | |||
222 | List<string> parts = new List<string>(); | ||
223 | |||
224 | foreach (KeyValuePair<string, object> kvp in data.ServiceURLs) | ||
225 | { | ||
226 | string key = System.Web.HttpUtility.UrlEncode(kvp.Key); | ||
227 | string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); | ||
228 | parts.Add(key + "=" + val); | ||
229 | } | ||
230 | |||
231 | d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray()); | ||
232 | |||
233 | return m_Database.Store(d); | ||
234 | } | ||
235 | |||
236 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
237 | { | ||
238 | UserAccountData[] d = m_Database.GetUsers(scopeID, query); | ||
239 | |||
240 | if (d == null) | ||
241 | return new List<UserAccount>(); | ||
242 | |||
243 | List<UserAccount> ret = new List<UserAccount>(); | ||
244 | |||
245 | foreach (UserAccountData data in d) | ||
246 | ret.Add(MakeUserAccount(data)); | ||
247 | |||
248 | return ret; | ||
249 | } | ||
250 | |||
251 | #endregion | ||
252 | |||
253 | #region Console commands | ||
254 | /// <summary> | ||
255 | /// Create a new user | ||
256 | /// </summary> | ||
257 | /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param> | ||
258 | protected void HandleCreateUser(string module, string[] cmdparams) | ||
259 | { | ||
260 | string firstName; | ||
261 | string lastName; | ||
262 | string password; | ||
263 | string email; | ||
264 | |||
265 | if (cmdparams.Length < 3) | ||
266 | firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); | ||
267 | else firstName = cmdparams[2]; | ||
268 | |||
269 | if (cmdparams.Length < 4) | ||
270 | lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); | ||
271 | else lastName = cmdparams[3]; | ||
272 | |||
273 | if (cmdparams.Length < 5) | ||
274 | password = MainConsole.Instance.PasswdPrompt("Password"); | ||
275 | else password = cmdparams[4]; | ||
276 | |||
277 | if (cmdparams.Length < 6) | ||
278 | email = MainConsole.Instance.CmdPrompt("Email", ""); | ||
279 | else email = cmdparams[5]; | ||
280 | |||
281 | UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); | ||
282 | if (null == account) | ||
283 | { | ||
284 | account = new UserAccount(UUID.Zero, firstName, lastName, email); | ||
285 | if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) | ||
286 | { | ||
287 | account.ServiceURLs = new Dictionary<string, object>(); | ||
288 | account.ServiceURLs["HomeURI"] = string.Empty; | ||
289 | account.ServiceURLs["GatekeeperURI"] = string.Empty; | ||
290 | account.ServiceURLs["InventoryServerURI"] = string.Empty; | ||
291 | account.ServiceURLs["AssetServerURI"] = string.Empty; | ||
292 | } | ||
293 | |||
294 | if (StoreUserAccount(account)) | ||
295 | { | ||
296 | bool success = false; | ||
297 | if (m_AuthenticationService != null) | ||
298 | success = m_AuthenticationService.SetPassword(account.PrincipalID, password); | ||
299 | if (!success) | ||
300 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", | ||
301 | firstName, lastName); | ||
302 | |||
303 | GridRegion home = null; | ||
304 | if (m_GridService != null) | ||
305 | { | ||
306 | List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero); | ||
307 | if (defaultRegions != null && defaultRegions.Count >= 1) | ||
308 | home = defaultRegions[0]; | ||
309 | |||
310 | if (m_PresenceService != null && home != null) | ||
311 | m_PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
312 | else | ||
313 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", | ||
314 | firstName, lastName); | ||
315 | |||
316 | } | ||
317 | else | ||
318 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", | ||
319 | firstName, lastName); | ||
320 | |||
321 | if (m_InventoryService != null) | ||
322 | success = m_InventoryService.CreateUserInventory(account.PrincipalID); | ||
323 | if (!success) | ||
324 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", | ||
325 | firstName, lastName); | ||
326 | |||
327 | |||
328 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); | ||
329 | } | ||
330 | } | ||
331 | else | ||
332 | { | ||
333 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); | ||
334 | } | ||
335 | |||
336 | } | ||
337 | |||
338 | protected void HandleResetUserPassword(string module, string[] cmdparams) | ||
339 | { | ||
340 | string firstName; | ||
341 | string lastName; | ||
342 | string newPassword; | ||
343 | |||
344 | if (cmdparams.Length < 4) | ||
345 | firstName = MainConsole.Instance.CmdPrompt("First name"); | ||
346 | else firstName = cmdparams[3]; | ||
347 | |||
348 | if (cmdparams.Length < 5) | ||
349 | lastName = MainConsole.Instance.CmdPrompt("Last name"); | ||
350 | else lastName = cmdparams[4]; | ||
351 | |||
352 | if (cmdparams.Length < 6) | ||
353 | newPassword = MainConsole.Instance.PasswdPrompt("New password"); | ||
354 | else newPassword = cmdparams[5]; | ||
355 | |||
356 | UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); | ||
357 | if (account == null) | ||
358 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: No such user"); | ||
359 | |||
360 | bool success = false; | ||
361 | if (m_AuthenticationService != null) | ||
362 | success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword); | ||
363 | if (!success) | ||
364 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Unable to reset password for account {0} {1}.", | ||
365 | firstName, lastName); | ||
366 | else | ||
367 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Password reset for user {0} {1}", firstName, lastName); | ||
368 | } | ||
369 | |||
370 | #endregion | ||
371 | |||
372 | } | ||
373 | } | ||
diff --git a/OpenSim/Services/UserService/UserServiceBase.cs b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs index fea8b01..c1a7b76 100644 --- a/OpenSim/Services/UserService/UserServiceBase.cs +++ b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs | |||
@@ -40,20 +40,29 @@ namespace OpenSim.Services.UserAccountService | |||
40 | 40 | ||
41 | public UserAccountServiceBase(IConfigSource config) : base(config) | 41 | public UserAccountServiceBase(IConfigSource config) : base(config) |
42 | { | 42 | { |
43 | string dllName = String.Empty; | ||
44 | string connString = String.Empty; | ||
45 | string realm = "UserAccounts"; | ||
46 | |||
47 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
48 | if (dbConfig != null) | ||
49 | { | ||
50 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
51 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
52 | } | ||
53 | |||
43 | IConfig userConfig = config.Configs["UserAccountService"]; | 54 | IConfig userConfig = config.Configs["UserAccountService"]; |
44 | if (userConfig == null) | 55 | if (userConfig == null) |
45 | throw new Exception("No UserAccountService configuration"); | 56 | throw new Exception("No UserAccountService configuration"); |
46 | 57 | ||
47 | string dllName = userConfig.GetString("StorageProvider", | 58 | dllName = userConfig.GetString("StorageProvider", dllName); |
48 | String.Empty); | ||
49 | 59 | ||
50 | if (dllName == String.Empty) | 60 | if (dllName == String.Empty) |
51 | throw new Exception("No StorageProvider configured"); | 61 | throw new Exception("No StorageProvider configured"); |
52 | 62 | ||
53 | string connString = userConfig.GetString("ConnectionString", | 63 | connString = userConfig.GetString("ConnectionString", connString); |
54 | String.Empty); | ||
55 | 64 | ||
56 | string realm = userConfig.GetString("Realm", "users"); | 65 | realm = userConfig.GetString("Realm", realm); |
57 | 66 | ||
58 | m_Database = LoadPlugin<IUserAccountData>(dllName, new Object[] {connString, realm}); | 67 | m_Database = LoadPlugin<IUserAccountData>(dllName, new Object[] {connString, realm}); |
59 | 68 | ||