diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/UserManagement')
3 files changed, 314 insertions, 47 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs index 7b89c2c..3e0a610 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
52 | 52 | ||
53 | #region ISharedRegionModule | 53 | #region ISharedRegionModule |
54 | 54 | ||
55 | public new void Initialise(IConfigSource config) | 55 | public override void Initialise(IConfigSource config) |
56 | { | 56 | { |
57 | string umanmod = config.Configs["Modules"].GetString("UserManagementModule", null); | 57 | string umanmod = config.Configs["Modules"].GetString("UserManagementModule", null); |
58 | if (umanmod == Name) | 58 | if (umanmod == Name) |
@@ -111,7 +111,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
111 | } | 111 | } |
112 | 112 | ||
113 | // This is it! Let's ask the other world | 113 | // This is it! Let's ask the other world |
114 | if (words[0].Contains(".")) | 114 | if (words[0].Contains(".")) |
115 | { | 115 | { |
116 | string[] names = words[0].Split(new char[] { '.' }); | 116 | string[] names = words[0].Split(new char[] { '.' }); |
117 | if (names.Length >= 2) | 117 | if (names.Length >= 2) |
@@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
130 | } | 130 | } |
131 | 131 | ||
132 | UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr); | 132 | UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr); |
133 | 133 | ||
134 | UUID userID = UUID.Zero; | 134 | UUID userID = UUID.Zero; |
135 | try | 135 | try |
136 | { | 136 | { |
@@ -140,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
140 | { | 140 | { |
141 | m_log.Debug("[USER MANAGEMENT MODULE]: GetUUID call failed ", e); | 141 | m_log.Debug("[USER MANAGEMENT MODULE]: GetUUID call failed ", e); |
142 | } | 142 | } |
143 | 143 | ||
144 | if (!userID.Equals(UUID.Zero)) | 144 | if (!userID.Equals(UUID.Zero)) |
145 | { | 145 | { |
146 | UserData ud = new UserData(); | 146 | UserData ud = new UserData(); |
@@ -163,8 +163,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
163 | //{ | 163 | //{ |
164 | // foreach (UserData d in m_UserCache.Values) | 164 | // foreach (UserData d in m_UserCache.Values) |
165 | // { | 165 | // { |
166 | // if (d.LastName.StartsWith("@") && | 166 | // if (d.LastName.StartsWith("@") && |
167 | // (d.FirstName.ToLower().StartsWith(query.ToLower()) || | 167 | // (d.FirstName.ToLower().StartsWith(query.ToLower()) || |
168 | // d.LastName.ToLower().StartsWith(query.ToLower()))) | 168 | // d.LastName.ToLower().StartsWith(query.ToLower()))) |
169 | // users.Add(d); | 169 | // users.Add(d); |
170 | // } | 170 | // } |
@@ -172,4 +172,4 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
172 | } | 172 | } |
173 | 173 | ||
174 | } | 174 | } |
175 | } \ No newline at end of file | 175 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/Tests/HGUserManagementModuleTests.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/Tests/HGUserManagementModuleTests.cs index 4e3b7e5..9d91aa3 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/Tests/HGUserManagementModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/Tests/HGUserManagementModuleTests.cs | |||
@@ -37,7 +37,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement.Tests | |||
37 | { | 37 | { |
38 | [TestFixture] | 38 | [TestFixture] |
39 | public class HGUserManagementModuleTests : OpenSimTestCase | 39 | public class HGUserManagementModuleTests : OpenSimTestCase |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Test that a new HG agent (i.e. one without a user account) has their name cached in the UMM upon creation. | 42 | /// Test that a new HG agent (i.e. one without a user account) has their name cached in the UMM upon creation. |
43 | /// </summary> | 43 | /// </summary> |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 7ecbd26..2695464 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
66 | 66 | ||
67 | #region ISharedRegionModule | 67 | #region ISharedRegionModule |
68 | 68 | ||
69 | public void Initialise(IConfigSource config) | 69 | public virtual void Initialise(IConfigSource config) |
70 | { | 70 | { |
71 | string umanmod = config.Configs["Modules"].GetString("UserManagementModule", Name); | 71 | string umanmod = config.Configs["Modules"].GetString("UserManagementModule", Name); |
72 | if (umanmod == Name) | 72 | if (umanmod == Name) |
@@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
88 | m_DisplayChangingHomeURI = userManagementConfig.GetBoolean("DisplayChangingHomeURI", false); | 88 | m_DisplayChangingHomeURI = userManagementConfig.GetBoolean("DisplayChangingHomeURI", false); |
89 | } | 89 | } |
90 | 90 | ||
91 | public bool IsSharedModule | 91 | public virtual bool IsSharedModule |
92 | { | 92 | { |
93 | get { return true; } | 93 | get { return true; } |
94 | } | 94 | } |
@@ -98,12 +98,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
98 | get { return "BasicUserManagementModule"; } | 98 | get { return "BasicUserManagementModule"; } |
99 | } | 99 | } |
100 | 100 | ||
101 | public Type ReplaceableInterface | 101 | public virtual Type ReplaceableInterface |
102 | { | 102 | { |
103 | get { return null; } | 103 | get { return null; } |
104 | } | 104 | } |
105 | 105 | ||
106 | public void AddRegion(Scene scene) | 106 | public virtual void AddRegion(Scene scene) |
107 | { | 107 | { |
108 | if (m_Enabled) | 108 | if (m_Enabled) |
109 | { | 109 | { |
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | public void RemoveRegion(Scene scene) | 122 | public virtual void RemoveRegion(Scene scene) |
123 | { | 123 | { |
124 | if (m_Enabled) | 124 | if (m_Enabled) |
125 | { | 125 | { |
@@ -131,17 +131,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | public void RegionLoaded(Scene s) | 134 | public virtual void RegionLoaded(Scene s) |
135 | { | 135 | { |
136 | if (m_Enabled && m_ServiceThrottle == null) | 136 | if (m_Enabled && m_ServiceThrottle == null) |
137 | m_ServiceThrottle = s.RequestModuleInterface<IServiceThrottleModule>(); | 137 | m_ServiceThrottle = s.RequestModuleInterface<IServiceThrottleModule>(); |
138 | } | 138 | } |
139 | 139 | ||
140 | public void PostInitialise() | 140 | public virtual void PostInitialise() |
141 | { | 141 | { |
142 | } | 142 | } |
143 | 143 | ||
144 | public void Close() | 144 | public virtual void Close() |
145 | { | 145 | { |
146 | lock (m_Scenes) | 146 | lock (m_Scenes) |
147 | { | 147 | { |
@@ -157,31 +157,34 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
157 | 157 | ||
158 | #region Event Handlers | 158 | #region Event Handlers |
159 | 159 | ||
160 | void EventManager_OnPrimsLoaded(Scene s) | 160 | protected virtual void EventManager_OnPrimsLoaded(Scene s) |
161 | { | 161 | { |
162 | // let's sniff all the user names referenced by objects in the scene | 162 | // let's sniff all the user names referenced by objects in the scene |
163 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Caching creators' data from {0} ({1} objects)...", s.RegionInfo.RegionName, s.GetEntities().Length); | 163 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Caching creators' data from {0} ({1} objects)...", s.RegionInfo.RegionName, s.GetEntities().Length); |
164 | s.ForEachSOG(delegate(SceneObjectGroup sog) { CacheCreators(sog); }); | 164 | s.ForEachSOG(delegate(SceneObjectGroup sog) { CacheCreators(sog); }); |
165 | } | 165 | } |
166 | 166 | ||
167 | void EventManager_OnNewClient(IClientAPI client) | 167 | protected virtual void EventManager_OnNewClient(IClientAPI client) |
168 | { | 168 | { |
169 | client.OnConnectionClosed += new Action<IClientAPI>(HandleConnectionClosed); | 169 | client.OnConnectionClosed += new Action<IClientAPI>(HandleConnectionClosed); |
170 | client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); | 170 | client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); |
171 | client.OnAvatarPickerRequest += new AvatarPickerRequest(HandleAvatarPickerRequest); | 171 | client.OnAvatarPickerRequest += new AvatarPickerRequest(HandleAvatarPickerRequest); |
172 | } | 172 | } |
173 | 173 | ||
174 | void HandleConnectionClosed(IClientAPI client) | 174 | protected virtual void HandleConnectionClosed(IClientAPI client) |
175 | { | 175 | { |
176 | client.OnNameFromUUIDRequest -= new UUIDNameRequest(HandleUUIDNameRequest); | 176 | client.OnNameFromUUIDRequest -= new UUIDNameRequest(HandleUUIDNameRequest); |
177 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); | 177 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); |
178 | client.OnConnectionClosed -= new Action<IClientAPI>(HandleConnectionClosed); | ||
178 | } | 179 | } |
179 | 180 | ||
180 | void HandleUUIDNameRequest(UUID uuid, IClientAPI client) | 181 | protected virtual void HandleUUIDNameRequest(UUID uuid, IClientAPI client) |
181 | { | 182 | { |
182 | // m_log.DebugFormat( | 183 | // m_log.DebugFormat( |
183 | // "[USER MANAGEMENT MODULE]: Handling request for name binding of UUID {0} from {1}", | 184 | // "[USER MANAGEMENT MODULE]: Handling request for name binding of UUID {0} from {1}", |
184 | // uuid, remote_client.Name); | 185 | // uuid, remote_client.Name); |
186 | if(m_Scenes.Count <= 0) | ||
187 | return; | ||
185 | 188 | ||
186 | if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid)) | 189 | if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid)) |
187 | { | 190 | { |
@@ -204,7 +207,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
204 | } | 207 | } |
205 | 208 | ||
206 | // Not found in cache, queue continuation | 209 | // Not found in cache, queue continuation |
207 | m_ServiceThrottle.Enqueue("name", uuid.ToString(), delegate | 210 | m_ServiceThrottle.Enqueue("uuidname", uuid.ToString(), delegate |
208 | { | 211 | { |
209 | //m_log.DebugFormat("[YYY]: Name request {0}", uuid); | 212 | //m_log.DebugFormat("[YYY]: Name request {0}", uuid); |
210 | 213 | ||
@@ -214,9 +217,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
214 | // So to avoid clients | 217 | // So to avoid clients |
215 | // (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will | 218 | // (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will |
216 | // instead drop the request entirely. | 219 | // instead drop the request entirely. |
220 | if(!client.IsActive) | ||
221 | return; | ||
217 | if (GetUser(uuid, out user)) | 222 | if (GetUser(uuid, out user)) |
218 | { | 223 | { |
219 | client.SendNameReply(uuid, user.FirstName, user.LastName); | 224 | if(client.IsActive) |
225 | client.SendNameReply(uuid, user.FirstName, user.LastName); | ||
220 | } | 226 | } |
221 | // else | 227 | // else |
222 | // m_log.DebugFormat( | 228 | // m_log.DebugFormat( |
@@ -226,7 +232,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
226 | } | 232 | } |
227 | } | 233 | } |
228 | 234 | ||
229 | public void HandleAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query) | 235 | public virtual void HandleAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query) |
230 | { | 236 | { |
231 | //EventManager.TriggerAvatarPickerRequest(); | 237 | //EventManager.TriggerAvatarPickerRequest(); |
232 | 238 | ||
@@ -286,8 +292,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
286 | 292 | ||
287 | #region IPeople | 293 | #region IPeople |
288 | 294 | ||
289 | public List<UserData> GetUserData(string query, int page_size, int page_number) | 295 | public virtual List<UserData> GetUserData(string query, int page_size, int page_number) |
290 | { | 296 | { |
297 | if(m_Scenes.Count <= 0) | ||
298 | return new List<UserData>();; | ||
299 | |||
291 | // search the user accounts service | 300 | // search the user accounts service |
292 | List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); | 301 | List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); |
293 | 302 | ||
@@ -323,7 +332,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
323 | 332 | ||
324 | #endregion IPeople | 333 | #endregion IPeople |
325 | 334 | ||
326 | private void CacheCreators(SceneObjectGroup sog) | 335 | protected virtual void CacheCreators(SceneObjectGroup sog) |
327 | { | 336 | { |
328 | //m_log.DebugFormat("[USER MANAGEMENT MODULE]: processing {0} {1}; {2}", sog.RootPart.Name, sog.RootPart.CreatorData, sog.RootPart.CreatorIdentification); | 337 | //m_log.DebugFormat("[USER MANAGEMENT MODULE]: processing {0} {1}; {2}", sog.RootPart.Name, sog.RootPart.CreatorData, sog.RootPart.CreatorIdentification); |
329 | AddUser(sog.RootPart.CreatorID, sog.RootPart.CreatorData); | 338 | AddUser(sog.RootPart.CreatorID, sog.RootPart.CreatorData); |
@@ -336,9 +345,108 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
336 | } | 345 | } |
337 | } | 346 | } |
338 | 347 | ||
348 | /// <summary> | ||
349 | /// | ||
350 | /// </summary> | ||
351 | /// <param name="uuid"></param> | ||
352 | /// <param name="names">Caller please provide a properly instantiated array for names, string[2]</param> | ||
353 | /// <returns></returns> | ||
354 | protected virtual bool TryGetUserNames(UUID uuid, string[] names) | ||
355 | { | ||
356 | if (names == null) | ||
357 | names = new string[2]; | ||
358 | |||
359 | if (TryGetUserNamesFromCache(uuid, names)) | ||
360 | return true; | ||
361 | |||
362 | if (TryGetUserNamesFromServices(uuid, names)) | ||
363 | return true; | ||
364 | |||
365 | return false; | ||
366 | } | ||
367 | |||
368 | protected virtual bool TryGetUserNamesFromCache(UUID uuid, string[] names) | ||
369 | { | ||
370 | lock (m_UserCache) | ||
371 | { | ||
372 | if (m_UserCache.ContainsKey(uuid)) | ||
373 | { | ||
374 | names[0] = m_UserCache[uuid].FirstName; | ||
375 | names[1] = m_UserCache[uuid].LastName; | ||
376 | |||
377 | return true; | ||
378 | } | ||
379 | } | ||
380 | |||
381 | return false; | ||
382 | } | ||
383 | |||
384 | /// <summary> | ||
385 | /// Try to get the names bound to the given uuid, from the services. | ||
386 | /// </summary> | ||
387 | /// <returns>True if the name was found, false if not.</returns> | ||
388 | /// <param name='uuid'></param> | ||
389 | /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param> | ||
390 | protected virtual bool TryGetUserNamesFromServices(UUID uuid, string[] names) | ||
391 | { | ||
392 | if(m_Scenes.Count <= 0) | ||
393 | return false; | ||
394 | |||
395 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid); | ||
396 | |||
397 | if (account != null) | ||
398 | { | ||
399 | names[0] = account.FirstName; | ||
400 | names[1] = account.LastName; | ||
401 | |||
402 | UserData user = new UserData(); | ||
403 | user.FirstName = account.FirstName; | ||
404 | user.LastName = account.LastName; | ||
405 | |||
406 | lock (m_UserCache) | ||
407 | m_UserCache[uuid] = user; | ||
408 | |||
409 | return true; | ||
410 | } | ||
411 | else | ||
412 | { | ||
413 | // Let's try the GridUser service | ||
414 | GridUserInfo uInfo = m_Scenes[0].GridUserService.GetGridUserInfo(uuid.ToString()); | ||
415 | if (uInfo != null) | ||
416 | { | ||
417 | string url, first, last, tmp; | ||
418 | UUID u; | ||
419 | if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out u, out url, out first, out last, out tmp)) | ||
420 | { | ||
421 | AddUser(uuid, first, last, url); | ||
422 | |||
423 | if (m_UserCache.ContainsKey(uuid)) | ||
424 | { | ||
425 | names[0] = m_UserCache[uuid].FirstName; | ||
426 | names[1] = m_UserCache[uuid].LastName; | ||
427 | |||
428 | return true; | ||
429 | } | ||
430 | } | ||
431 | else | ||
432 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Unable to parse UUI {0}", uInfo.UserID); | ||
433 | } | ||
434 | // else | ||
435 | // { | ||
436 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: No grid user found for {0}", uuid); | ||
437 | // } | ||
438 | |||
439 | names[0] = "Unknown"; | ||
440 | names[1] = "UserUMMTGUN9"; | ||
441 | |||
442 | return false; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | |||
339 | #region IUserManagement | 447 | #region IUserManagement |
340 | 448 | ||
341 | public UUID GetUserIdByName(string name) | 449 | public virtual UUID GetUserIdByName(string name) |
342 | { | 450 | { |
343 | string[] parts = name.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); | 451 | string[] parts = name.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); |
344 | if (parts.Length < 2) | 452 | if (parts.Length < 2) |
@@ -347,8 +455,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
347 | return GetUserIdByName(parts[0], parts[1]); | 455 | return GetUserIdByName(parts[0], parts[1]); |
348 | } | 456 | } |
349 | 457 | ||
350 | public UUID GetUserIdByName(string firstName, string lastName) | 458 | public virtual UUID GetUserIdByName(string firstName, string lastName) |
351 | { | 459 | { |
460 | if(m_Scenes.Count <= 0) | ||
461 | return UUID.Zero; | ||
462 | |||
352 | // TODO: Optimize for reverse lookup if this gets used by non-console commands. | 463 | // TODO: Optimize for reverse lookup if this gets used by non-console commands. |
353 | lock (m_UserCache) | 464 | lock (m_UserCache) |
354 | { | 465 | { |
@@ -367,14 +478,159 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
367 | return UUID.Zero; | 478 | return UUID.Zero; |
368 | } | 479 | } |
369 | 480 | ||
370 | public string GetUserName(UUID uuid) | 481 | public virtual string GetUserName(UUID uuid) |
371 | { | 482 | { |
372 | UserData user; | 483 | UserData user; |
373 | GetUser(uuid, out user); | 484 | GetUser(uuid, out user); |
374 | return user.FirstName + " " + user.LastName; | 485 | return user.FirstName + " " + user.LastName; |
375 | } | 486 | } |
376 | 487 | ||
377 | public string GetUserHomeURL(UUID userID) | 488 | public virtual Dictionary<UUID,string> GetUsersNames(string[] ids) |
489 | { | ||
490 | Dictionary<UUID,string> ret = new Dictionary<UUID,string>(); | ||
491 | if(m_Scenes.Count <= 0) | ||
492 | return ret; | ||
493 | |||
494 | List<string> missing = new List<string>(); | ||
495 | Dictionary<UUID,string> untried = new Dictionary<UUID, string>(); | ||
496 | |||
497 | // look in cache | ||
498 | UserData userdata = new UserData(); | ||
499 | |||
500 | UUID uuid = UUID.Zero; | ||
501 | foreach(string id in ids) | ||
502 | { | ||
503 | if(UUID.TryParse(id, out uuid)) | ||
504 | { | ||
505 | lock (m_UserCache) | ||
506 | { | ||
507 | if (m_UserCache.TryGetValue(uuid, out userdata) && | ||
508 | userdata.FirstName != "Unknown" && userdata.FirstName != string.Empty) | ||
509 | { | ||
510 | string name = userdata.FirstName + " " + userdata.LastName; | ||
511 | |||
512 | if(userdata.HasGridUserTried) | ||
513 | ret[uuid] = name; | ||
514 | else | ||
515 | { | ||
516 | untried[uuid] = name; | ||
517 | missing.Add(id); | ||
518 | } | ||
519 | } | ||
520 | else | ||
521 | missing.Add(id); | ||
522 | } | ||
523 | } | ||
524 | } | ||
525 | |||
526 | if(missing.Count == 0) | ||
527 | return ret; | ||
528 | |||
529 | // try user account service | ||
530 | List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts( | ||
531 | m_Scenes[0].RegionInfo.ScopeID, missing); | ||
532 | |||
533 | if(accounts.Count != 0) | ||
534 | { | ||
535 | foreach(UserAccount uac in accounts) | ||
536 | { | ||
537 | if(uac != null) | ||
538 | { | ||
539 | string name = uac.FirstName + " " + uac.LastName; | ||
540 | ret[uac.PrincipalID] = name; | ||
541 | missing.Remove(uac.PrincipalID.ToString()); // slowww | ||
542 | untried.Remove(uac.PrincipalID); | ||
543 | |||
544 | userdata = new UserData(); | ||
545 | userdata.Id = uac.PrincipalID; | ||
546 | userdata.FirstName = uac.FirstName; | ||
547 | userdata.LastName = uac.LastName; | ||
548 | userdata.HomeURL = string.Empty; | ||
549 | userdata.IsUnknownUser = false; | ||
550 | userdata.HasGridUserTried = true; | ||
551 | lock (m_UserCache) | ||
552 | m_UserCache[uac.PrincipalID] = userdata; | ||
553 | } | ||
554 | } | ||
555 | } | ||
556 | |||
557 | if (missing.Count == 0 || m_Scenes[0].GridUserService == null) | ||
558 | return ret; | ||
559 | |||
560 | // try grid user service | ||
561 | |||
562 | GridUserInfo[] pinfos = m_Scenes[0].GridUserService.GetGridUserInfo(missing.ToArray()); | ||
563 | if(pinfos.Length > 0) | ||
564 | { | ||
565 | foreach(GridUserInfo uInfo in pinfos) | ||
566 | { | ||
567 | if (uInfo != null) | ||
568 | { | ||
569 | string url, first, last, tmp; | ||
570 | |||
571 | if(uInfo.UserID.Length <= 36) | ||
572 | continue; | ||
573 | |||
574 | if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out uuid, out url, out first, out last, out tmp)) | ||
575 | { | ||
576 | if (url != string.Empty) | ||
577 | { | ||
578 | try | ||
579 | { | ||
580 | userdata = new UserData(); | ||
581 | userdata.FirstName = first.Replace(" ", ".") + "." + last.Replace(" ", "."); | ||
582 | userdata.LastName = "@" + new Uri(url).Authority; | ||
583 | userdata.Id = uuid; | ||
584 | userdata.HomeURL = url; | ||
585 | userdata.IsUnknownUser = false; | ||
586 | userdata.HasGridUserTried = true; | ||
587 | lock (m_UserCache) | ||
588 | m_UserCache[uuid] = userdata; | ||
589 | |||
590 | string name = userdata.FirstName + " " + userdata.LastName; | ||
591 | ret[uuid] = name; | ||
592 | missing.Remove(uuid.ToString()); | ||
593 | untried.Remove(uuid); | ||
594 | } | ||
595 | catch | ||
596 | { | ||
597 | } | ||
598 | } | ||
599 | } | ||
600 | } | ||
601 | } | ||
602 | } | ||
603 | |||
604 | // add the untried in cache that still failed | ||
605 | if(untried.Count > 0) | ||
606 | { | ||
607 | foreach(KeyValuePair<UUID, string> kvp in untried) | ||
608 | { | ||
609 | ret[kvp.Key] = kvp.Value; | ||
610 | missing.Remove((kvp.Key).ToString()); | ||
611 | } | ||
612 | } | ||
613 | |||
614 | // add the UMMthings ( not sure we should) | ||
615 | if(missing.Count > 0) | ||
616 | { | ||
617 | foreach(string id in missing) | ||
618 | { | ||
619 | if(UUID.TryParse(id, out uuid) && uuid != UUID.Zero) | ||
620 | { | ||
621 | if (m_Scenes[0].LibraryService != null && | ||
622 | (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid)) | ||
623 | ret[uuid] = "Mr OpenSim"; | ||
624 | else | ||
625 | ret[uuid] = "Unknown UserUMMAU43"; | ||
626 | } | ||
627 | } | ||
628 | } | ||
629 | |||
630 | return ret; | ||
631 | } | ||
632 | |||
633 | public virtual string GetUserHomeURL(UUID userID) | ||
378 | { | 634 | { |
379 | UserData user; | 635 | UserData user; |
380 | if(GetUser(userID, out user)) | 636 | if(GetUser(userID, out user)) |
@@ -384,7 +640,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
384 | return string.Empty; | 640 | return string.Empty; |
385 | } | 641 | } |
386 | 642 | ||
387 | public string GetUserServerURL(UUID userID, string serverType) | 643 | public virtual string GetUserServerURL(UUID userID, string serverType) |
388 | { | 644 | { |
389 | UserData userdata; | 645 | UserData userdata; |
390 | if(!GetUser(userID, out userdata)) | 646 | if(!GetUser(userID, out userdata)) |
@@ -424,14 +680,14 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
424 | return string.Empty; | 680 | return string.Empty; |
425 | } | 681 | } |
426 | 682 | ||
427 | public string GetUserUUI(UUID userID) | 683 | public virtual string GetUserUUI(UUID userID) |
428 | { | 684 | { |
429 | string uui; | 685 | string uui; |
430 | GetUserUUI(userID, out uui); | 686 | GetUserUUI(userID, out uui); |
431 | return uui; | 687 | return uui; |
432 | } | 688 | } |
433 | 689 | ||
434 | public bool GetUserUUI(UUID userID, out string uui) | 690 | public virtual bool GetUserUUI(UUID userID, out string uui) |
435 | { | 691 | { |
436 | UserData ud; | 692 | UserData ud; |
437 | bool result = GetUser(userID, out ud); | 693 | bool result = GetUser(userID, out ud); |
@@ -449,6 +705,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
449 | last = parts[1]; | 705 | last = parts[1]; |
450 | } | 706 | } |
451 | uui = userID + ";" + homeURL + ";" + first + " " + last; | 707 | uui = userID + ";" + homeURL + ";" + first + " " + last; |
708 | return result; | ||
452 | } | 709 | } |
453 | } | 710 | } |
454 | 711 | ||
@@ -457,8 +714,14 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
457 | } | 714 | } |
458 | 715 | ||
459 | #region Cache Management | 716 | #region Cache Management |
460 | public bool GetUser(UUID uuid, out UserData userdata) | 717 | public virtual bool GetUser(UUID uuid, out UserData userdata) |
461 | { | 718 | { |
719 | if(m_Scenes.Count <= 0) | ||
720 | { | ||
721 | userdata = new UserData(); | ||
722 | return false; | ||
723 | } | ||
724 | |||
462 | lock (m_UserCache) | 725 | lock (m_UserCache) |
463 | { | 726 | { |
464 | if (m_UserCache.TryGetValue(uuid, out userdata)) | 727 | if (m_UserCache.TryGetValue(uuid, out userdata)) |
@@ -471,7 +734,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
471 | else | 734 | else |
472 | { | 735 | { |
473 | userdata = new UserData(); | 736 | userdata = new UserData(); |
474 | userdata.HasGridUserTried = false; | ||
475 | userdata.Id = uuid; | 737 | userdata.Id = uuid; |
476 | userdata.FirstName = "Unknown"; | 738 | userdata.FirstName = "Unknown"; |
477 | userdata.LastName = "UserUMMAU42"; | 739 | userdata.LastName = "UserUMMAU42"; |
@@ -544,7 +806,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
544 | return !userdata.IsUnknownUser; | 806 | return !userdata.IsUnknownUser; |
545 | } | 807 | } |
546 | 808 | ||
547 | public void AddUser(UUID uuid, string first, string last) | 809 | public virtual void AddUser(UUID uuid, string first, string last, bool isNPC = false) |
548 | { | 810 | { |
549 | lock(m_UserCache) | 811 | lock(m_UserCache) |
550 | { | 812 | { |
@@ -555,13 +817,13 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
555 | user.FirstName = first; | 817 | user.FirstName = first; |
556 | user.LastName = last; | 818 | user.LastName = last; |
557 | user.IsUnknownUser = false; | 819 | user.IsUnknownUser = false; |
558 | user.HasGridUserTried = false; | 820 | user.HasGridUserTried = isNPC; |
559 | m_UserCache.Add(uuid, user); | 821 | m_UserCache.Add(uuid, user); |
560 | } | 822 | } |
561 | } | 823 | } |
562 | } | 824 | } |
563 | 825 | ||
564 | public void AddUser(UUID uuid, string first, string last, string homeURL) | 826 | public virtual void AddUser(UUID uuid, string first, string last, string homeURL) |
565 | { | 827 | { |
566 | //m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, first {1}, last {2}, url {3}", uuid, first, last, homeURL); | 828 | //m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, first {1}, last {2}, url {3}", uuid, first, last, homeURL); |
567 | 829 | ||
@@ -611,7 +873,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
611 | } | 873 | } |
612 | } | 874 | } |
613 | 875 | ||
614 | public void AddUser(UUID id, string creatorData) | 876 | public virtual void AddUser(UUID id, string creatorData) |
615 | { | 877 | { |
616 | // m_log.InfoFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); | 878 | // m_log.InfoFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); |
617 | 879 | ||
@@ -694,24 +956,29 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
694 | } | 956 | } |
695 | #endregion | 957 | #endregion |
696 | 958 | ||
697 | public bool IsLocalGridUser(UUID uuid) | 959 | public virtual bool IsLocalGridUser(UUID uuid) |
698 | { | 960 | { |
699 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); | 961 | lock (m_Scenes) |
700 | if (account == null || (account != null && !account.LocalToGrid)) | 962 | { |
701 | return false; | 963 | if (m_Scenes.Count == 0) |
964 | return true; | ||
965 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); | ||
966 | if (account == null || (account != null && !account.LocalToGrid)) | ||
967 | return false; | ||
968 | } | ||
702 | 969 | ||
703 | return true; | 970 | return true; |
704 | } | 971 | } |
705 | 972 | ||
706 | #endregion IUserManagement | 973 | #endregion IUserManagement |
707 | 974 | ||
708 | protected void Init() | 975 | protected virtual void Init() |
709 | { | 976 | { |
710 | AddUser(UUID.Zero, "Unknown", "User"); | 977 | AddUser(UUID.Zero, "Unknown", "User"); |
711 | RegisterConsoleCmds(); | 978 | RegisterConsoleCmds(); |
712 | } | 979 | } |
713 | 980 | ||
714 | protected void RegisterConsoleCmds() | 981 | protected virtual void RegisterConsoleCmds() |
715 | { | 982 | { |
716 | MainConsole.Instance.Commands.AddCommand("Users", true, | 983 | MainConsole.Instance.Commands.AddCommand("Users", true, |
717 | "show name", | 984 | "show name", |
@@ -735,7 +1002,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
735 | HandleResetUserCache); | 1002 | HandleResetUserCache); |
736 | } | 1003 | } |
737 | 1004 | ||
738 | private void HandleResetUserCache(string module, string[] cmd) | 1005 | protected virtual void HandleResetUserCache(string module, string[] cmd) |
739 | { | 1006 | { |
740 | lock(m_UserCache) | 1007 | lock(m_UserCache) |
741 | { | 1008 | { |
@@ -743,7 +1010,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
743 | } | 1010 | } |
744 | } | 1011 | } |
745 | 1012 | ||
746 | private void HandleShowUser(string module, string[] cmd) | 1013 | protected virtual void HandleShowUser(string module, string[] cmd) |
747 | { | 1014 | { |
748 | if (cmd.Length < 3) | 1015 | if (cmd.Length < 3) |
749 | { | 1016 | { |
@@ -772,7 +1039,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
772 | MainConsole.Instance.Output(cdt.ToString()); | 1039 | MainConsole.Instance.Output(cdt.ToString()); |
773 | } | 1040 | } |
774 | 1041 | ||
775 | private void HandleShowUsers(string module, string[] cmd) | 1042 | protected virtual void HandleShowUsers(string module, string[] cmd) |
776 | { | 1043 | { |
777 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | 1044 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); |
778 | cdt.AddColumn("UUID", 36); | 1045 | cdt.AddColumn("UUID", 36); |