aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs224
1 files changed, 60 insertions, 164 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 37292d6..b4f6b5a 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -50,9 +50,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
50 public string LastName { get; set; } 50 public string LastName { get; set; }
51 public string HomeURL { get; set; } 51 public string HomeURL { get; set; }
52 public Dictionary<string, object> ServerURLs { get; set; } 52 public Dictionary<string, object> ServerURLs { get; set; }
53 public string Title { get; set; }
54 public int Flags { get; set; }
55 public int Created { get; set; }
56 } 53 }
57 54
58 public class UserManagementModule : ISharedRegionModule, IUserManagement 55 public class UserManagementModule : ISharedRegionModule, IUserManagement
@@ -284,94 +281,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
284 return string.Empty; 281 return string.Empty;
285 } 282 }
286 283
287 public int GetUserFlags(UUID userID)
288 {
289 UserData userdata;
290 lock (m_UserCache)
291 m_UserCache.TryGetValue(userID, out userdata);
292
293 if (userdata.Flags == -1)
294 GetUserInfo(userID);
295
296 if (userdata.Flags != -1)
297 return userdata.Flags;
298
299 return 0;
300 }
301
302 public int GetUserCreated(UUID userID)
303 {
304 UserData userdata;
305 lock (m_UserCache)
306 m_UserCache.TryGetValue(userID, out userdata);
307
308 if (userdata.Flags == -1)
309 GetUserInfo(userID);
310
311 if (userdata.Created != -1)
312 return userdata.Created;
313
314 return 0;
315 }
316
317 public string GetUserTitle(UUID userID)
318 {
319 UserData userdata;
320 lock (m_UserCache)
321 m_UserCache.TryGetValue(userID, out userdata);
322
323 if (userdata.Flags == -1)
324 GetUserInfo(userID);
325
326 if (userdata.Created != -1)
327 return userdata.Title;
328
329 return string.Empty;
330 }
331
332 // This will cache the user data
333 // Change this to return bool
334 private bool GetUserInfo(UUID userID)
335 {
336 UserData userdata;
337 lock (m_UserCache)
338 m_UserCache.TryGetValue(userID, out userdata);
339
340 if (userdata != null)
341 {
342// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID);
343
344 if (userdata.Flags >= 0)
345 {
346 // This is already populated
347 return true;
348 }
349
350 if (userdata.HomeURL != null && userdata.HomeURL != string.Empty)
351 {
352 m_log.DebugFormat(
353 "[USER MANAGEMENT MODULE]: Requesting user flags from '{0}' for {1}",
354 userdata.HomeURL, userID);
355
356 UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
357 Dictionary<string, object> info = uConn.GetUserInfo(userID);
358
359 // Pull our data now
360 if (info["result"].ToString() == "success")
361 {
362 userdata.Flags = (int)info["user_flags"];
363 userdata.Created = (int)info["user_created"];
364 userdata.Title = (string)info["user_title"];
365
366 return true;
367 }
368 }
369 }
370
371 return false;
372 }
373
374
375 public string GetUserUUI(UUID userID) 284 public string GetUserUUI(UUID userID)
376 { 285 {
377 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, userID); 286 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, userID);
@@ -413,68 +322,85 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
413 user.Id = uuid; 322 user.Id = uuid;
414 user.FirstName = first; 323 user.FirstName = first;
415 user.LastName = last; 324 user.LastName = last;
416 // user.ProfileURL = we should initialize this to the default
417 325
418 AddUserInternal(user); 326 AddUserInternal(user);
419 } 327 }
420 328
421 public void AddUser(UUID uuid, string first, string last, string profileURL) 329 public void AddUser(UUID uuid, string first, string last, string homeURL)
422 { 330 {
423 AddUser(uuid, profileURL + ";" + first + " " + last); 331 AddUser(uuid, homeURL + ";" + first + " " + last);
424 } 332 }
425 333
426 public void AddUser(UUID id, string creatorData) 334 public void AddUser (UUID id, string creatorData)
427 { 335 {
336 UserData oldUser;
337 //lock the whole block - prevent concurrent update
428 lock (m_UserCache) 338 lock (m_UserCache)
429 { 339 {
430 if (m_UserCache.ContainsKey(id)) 340 m_UserCache.TryGetValue (id, out oldUser);
431 return; 341 if (oldUser != null)
432 } 342 {
433 343 if (creatorData == null || creatorData == String.Empty)
434// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); 344 {
435 345 //ignore updates without creator data
436 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); 346 return;
347 }
348 //try update unknown users
349 //and creator's home URL's
350 if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL)))
351 {
352 m_UserCache.Remove (id);
353// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL);
354 }
355 else
356 {
357 //we have already a valid user within the cache
358 return;
359 }
360 }
361// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData);
437 362
438 if (account != null) 363 UserAccount account = m_Scenes [0].UserAccountService.GetUserAccount (m_Scenes [0].RegionInfo.ScopeID, id);
439 {
440 AddUser(id, account.FirstName, account.LastName);
441 }
442 else
443 {
444 UserData user = new UserData();
445 user.Id = id;
446 user.Flags = -1;
447 user.Created = -1;
448 364
449 if (creatorData != null && creatorData != string.Empty) 365 if (account != null)
450 { 366 {
451 //creatorData = <endpoint>;<name> 367 AddUser (id, account.FirstName, account.LastName);
368 }
369 else
370 {
371 UserData user = new UserData ();
372 user.Id = id;
452 373
453 string[] parts = creatorData.Split(';'); 374 if (creatorData != null && creatorData != string.Empty)
454 if (parts.Length >= 1)
455 { 375 {
456 user.HomeURL = parts[0]; 376 //creatorData = <endpoint>;<name>
457 try 377
458 { 378 string[] parts = creatorData.Split (';');
459 Uri uri = new Uri(parts[0]); 379 if (parts.Length >= 1)
460 user.LastName = "@" + uri.Authority;
461 }
462 catch (UriFormatException)
463 { 380 {
464 m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]); 381 user.HomeURL = parts [0];
465 user.LastName = "@unknown"; 382 try
383 {
384 Uri uri = new Uri (parts [0]);
385 user.LastName = "@" + uri.Authority;
386 }
387 catch (UriFormatException)
388 {
389 m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts [0]);
390 user.LastName = "@unknown";
391 }
466 } 392 }
393 if (parts.Length >= 2)
394 user.FirstName = parts [1].Replace (' ', '.');
395 }
396 else
397 {
398 user.FirstName = "Unknown";
399 user.LastName = "User";
467 } 400 }
468 if (parts.Length >= 2)
469 user.FirstName = parts[1].Replace(' ', '.');
470 }
471 else
472 {
473 user.FirstName = "Unknown";
474 user.LastName = "User";
475 }
476 401
477 AddUserInternal(user); 402 AddUserInternal (user);
403 }
478 } 404 }
479 } 405 }
480 406
@@ -488,36 +414,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
488// user.Id, user.FirstName, user.LastName, user.HomeURL); 414// user.Id, user.FirstName, user.LastName, user.HomeURL);
489 } 415 }
490 416
491 //public void AddUser(UUID uuid, string userData)
492 //{
493 // if (m_UserCache.ContainsKey(uuid))
494 // return;
495
496 // UserData user = new UserData();
497 // user.Id = uuid;
498
499 // // userData = <profile url>;<name>
500 // string[] parts = userData.Split(';');
501 // if (parts.Length >= 1)
502 // user.ProfileURL = parts[0].Trim();
503 // if (parts.Length >= 2)
504 // {
505 // string[] name = parts[1].Trim().Split(' ');
506 // if (name.Length >= 1)
507 // user.FirstName = name[0];
508 // if (name.Length >= 2)
509 // user.LastName = name[1];
510 // else
511 // user.LastName = "?";
512 // }
513
514 // lock (m_UserCache)
515 // m_UserCache.Add(uuid, user);
516
517 // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL);
518
519 //}
520
521 public bool IsLocalGridUser(UUID uuid) 417 public bool IsLocalGridUser(UUID uuid)
522 { 418 {
523 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); 419 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid);