public string GetUserServerURL(UUID userID, string serverType) { UserData userdata; lock (m_UserCache) m_UserCache.TryGetValue(userID, out userdata); if (userdata != null) { // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID); if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) { return userdata.ServerURLs[serverType].ToString(); } if (!string.IsNullOrEmpty(userdata.HomeURL)) { //m_log.DebugFormat( // "[USER MANAGEMENT MODULE]: Did not find url type {0} so requesting urls from '{1}' for {2}", // serverType, userdata.HomeURL, userID); UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); try { userdata.ServerURLs = uConn.GetServerURLs(userID); } catch (Exception e) { m_log.Debug("[USER MANAGEMENT MODULE]: GetServerURLs call failed ", e); userdata.ServerURLs = new Dictionary<string, object>(); } if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) return userdata.ServerURLs[serverType].ToString(); } } return string.Empty; }
//protected override void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online) //{ // // Let's single out the UUIs // List<string> localFriends = new List<string>(); // List<string> foreignFriends = new List<string>(); // string tmp = string.Empty; // foreach (string s in friendList) // { // UUID id; // if (UUID.TryParse(s, out id)) // localFriends.Add(s); // else if (Util.ParseUniversalUserIdentifier(s, out id, out tmp, out tmp, out tmp, out tmp)) // { // foreignFriends.Add(s); // // add it here too, who knows maybe the foreign friends happens to be on this grid // localFriends.Add(id.ToString()); // } // } // // OK, see who's present on this grid // List<string> toBeRemoved = new List<string>(); // PresenceInfo[] presence = PresenceService.GetAgents(localFriends.ToArray()); // foreach (PresenceInfo pi in presence) // { // UUID presenceID; // if (UUID.TryParse(pi.UserID, out presenceID)) // { // online.Add(presenceID); // foreach (string s in foreignFriends) // if (s.StartsWith(pi.UserID)) // toBeRemoved.Add(s); // } // } // foreach (string s in toBeRemoved) // foreignFriends.Remove(s); // // OK, let's send this up the stack, and leave a closure here // // collecting online friends in other grids // Util.FireAndForget(delegate { CollectOnlineFriendsElsewhere(userID, foreignFriends); }); //} //private void CollectOnlineFriendsElsewhere(UUID userID, List<string> foreignFriends) //{ // // let's divide the friends on a per-domain basis // Dictionary<string, List<string>> friendsPerDomain = new Dictionary<string, List<string>>(); // foreach (string friend in foreignFriends) // { // UUID friendID; // if (!UUID.TryParse(friend, out friendID)) // { // // it's a foreign friend // string url = string.Empty, tmp = string.Empty; // if (Util.ParseUniversalUserIdentifier(friend, out friendID, out url, out tmp, out tmp, out tmp)) // { // if (!friendsPerDomain.ContainsKey(url)) // friendsPerDomain[url] = new List<string>(); // friendsPerDomain[url].Add(friend); // } // } // } // // Now, call those worlds // foreach (KeyValuePair<string, List<string>> kvp in friendsPerDomain) // { // List<string> ids = new List<string>(); // foreach (string f in kvp.Value) // ids.Add(f); // UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); // List<UUID> online = uConn.GetOnlineFriends(userID, ids); // // Finally send the notifications to the user // // this whole process may take a while, so let's check at every // // iteration that the user is still here // IClientAPI client = LocateClientObject(userID); // if (client != null) // client.SendAgentOnline(online.ToArray()); // else // break; // } //} protected override void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) { // m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID); // First, let's divide the friends on a per-domain basis Dictionary<string, List<FriendInfo>> friendsPerDomain = new Dictionary<string, List<FriendInfo>>(); foreach (FriendInfo friend in friendList) { UUID friendID; if (UUID.TryParse(friend.Friend, out friendID)) { if (!friendsPerDomain.ContainsKey("local")) friendsPerDomain["local"] = new List<FriendInfo>(); friendsPerDomain["local"].Add(friend); } else { // it's a foreign friend string url = string.Empty, tmp = string.Empty; if (Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out url, out tmp, out tmp, out tmp)) { // Let's try our luck in the local sim. Who knows, maybe it's here if (LocalStatusNotification(userID, friendID, online)) continue; if (!friendsPerDomain.ContainsKey(url)) friendsPerDomain[url] = new List<FriendInfo>(); friendsPerDomain[url].Add(friend); } } } // For the local friends, just call the base method // Let's do this first of all if (friendsPerDomain.ContainsKey("local")) base.StatusNotify(friendsPerDomain["local"], userID, online); foreach (KeyValuePair<string, List<FriendInfo>> kvp in friendsPerDomain) { if (kvp.Key != "local") { // For the others, call the user agent service List<string> ids = new List<string>(); foreach (FriendInfo f in kvp.Value) ids.Add(f.Friend); UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); List<UUID> friendsOnline = uConn.StatusNotification(ids, userID, online); if (online && friendsOnline.Count > 0) { IClientAPI client = LocateClientObject(userID); if (client != null) client.SendAgentOnline(friendsOnline.ToArray()); } } } // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting StatusNotify for {0}", userID); }
private void ProcessFriendshipOffered(UUID fromID, String fromName, UUID toID, String message) { // Great, it's a genuine request. Let's proceed. // But now we need to confirm that the requester is who he says he is // before we act on the friendship request. if (!fromName.Contains("@")) return; string[] parts = fromName.Split(new char[] {'@'}); if (parts.Length != 2) return; string uriStr = "http://" + parts[1]; try { new Uri(uriStr); } catch (UriFormatException) { return; } UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr); Dictionary<string, object> servers = uasConn.GetServerURLs(fromID); if (!servers.ContainsKey("FriendsServerURI")) return; HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(servers["FriendsServerURI"].ToString()); if (!friendsConn.ValidateFriendshipOffered(fromID, toID)) { m_log.WarnFormat("[HGFRIENDS SERVICE]: Friendship request from {0} to {1} is invalid. Impersonations?", fromID, toID); return; } string fromUUI = Util.UniversalIdentifier(fromID, parts[0], "@" + parts[1], uriStr); // OK, we're good! ForwardToSim("FriendshipOffered", fromID, fromName, fromUUI, toID, message); }
public bool VerifyClient(AgentCircuitData aCircuit, string token) { if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) { string url = aCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService security = new UserAgentServiceConnector(url); return security.VerifyClient(aCircuit.SessionID, token); } else { m_log.DebugFormat( "[HG ENTITY TRANSFER MODULE]: Agent {0} {1} does not have a HomeURI OH NO!", aCircuit.firstname, aCircuit.lastname); } return false; }
// // Get the UserAccountBits // private bool GetUserProfileData(UUID userID, out Dictionary<string, object> userInfo) { IUserManagement uManage = UserManagementModule; Dictionary<string,object> info = new Dictionary<string, object>(); if (!uManage.IsLocalGridUser(userID)) { // Is Foreign string home_url = uManage.GetUserServerURL(userID, "HomeURI"); if (String.IsNullOrEmpty(home_url)) { info["user_flags"] = 0; info["user_created"] = 0; info["user_title"] = "Unavailable"; userInfo = info; return true; } UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url); Dictionary<string, object> account = uConn.GetUserInfo(userID); if (account.Count > 0) { if (account.ContainsKey("user_flags")) info["user_flags"] = account["user_flags"]; else info["user_flags"] = ""; if (account.ContainsKey("user_created")) info["user_created"] = account["user_created"]; else info["user_created"] = ""; info["user_title"] = "HG Visitor"; } else { info["user_flags"] = 0; info["user_created"] = 0; info["user_title"] = "HG Visitor"; } userInfo = info; return true; } else { // Is local Scene scene = m_Scenes[0]; IUserAccountService uas = scene.UserAccountService; UserAccount account = uas.GetUserAccount(scene.RegionInfo.ScopeID, userID); info["user_flags"] = account.UserFlags; info["user_created"] = account.Created; if (!String.IsNullOrEmpty(account.UserTitle)) info["user_title"] = account.UserTitle; else info["user_title"] = ""; userInfo = info; return false; } }
void OnConnectionClosed(IClientAPI obj) { if (obj.IsLoggingOut) { object sp = null; if (obj.Scene.TryGetScenePresence(obj.AgentId, out sp)) { if (((ScenePresence)sp).IsChildAgent) return; } // Let's find out if this is a foreign user or a local user UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, obj.AgentId); if (account != null) { // local grid user return; } AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) { string url = aCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService security = new UserAgentServiceConnector(url); security.LogoutAgent(obj.AgentId, obj.SessionId); //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url); } else m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: HomeURI not found for agent {0} logout", obj.AgentId); } }
protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI); reason = string.Empty; logout = false; int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) { // this user is going to another grid // for local users, check if HyperGrid teleport is allowed, based on user level if (Scene.UserManagementModule.IsLocalGridUser(sp.UUID) && sp.UserLevel < m_levelHGTeleport) { m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); reason = "Hypergrid teleport not allowed"; return false; } if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) { string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService connector; if (userAgentDriver.Equals(m_ThisHomeURI) && m_UAS != null) connector = m_UAS; else connector = new UserAgentServiceConnector(userAgentDriver); bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, false, out reason); logout = success; // flag for later logout from this grid; this is an HG TP if (success) sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout); return success; } else { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent does not have a HomeURI address"); return false; } } return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout); }
private string TryGetRecipientUUI(UUID fromAgent, UUID toAgent) { // Let's call back the fromAgent's user agent service // Maybe that service knows about the toAgent IClientAPI client = LocateClientObject(fromAgent); if (client != null) { AgentCircuitData circuit = m_Scenes[0].AuthenticateHandler.GetAgentCircuitData(client.AgentId); if (circuit != null) { if (circuit.ServiceURLs.ContainsKey("HomeURI")) { string uasURL = circuit.ServiceURLs["HomeURI"].ToString(); m_log.DebugFormat("[HG MESSAGE TRANSFER]: getting UUI of user {0} from {1}", toAgent, uasURL); UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uasURL); string agentUUI = string.Empty; try { agentUUI = uasConn.GetUUI(fromAgent, toAgent); } catch (Exception e) { m_log.Debug("[HG MESSAGE TRANSFER]: GetUUI call failed ", e); } return agentUUI; } } } return string.Empty; }
public string GetUserServerURL(UUID userID, string serverType) { UserData userdata; if(!GetUser(userID, out userdata)) { return string.Empty; } if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) { return userdata.ServerURLs[serverType].ToString(); } if (!string.IsNullOrEmpty(userdata.HomeURL)) { // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID); UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); try { userdata.ServerURLs = uConn.GetServerURLs(userID); } catch(System.Net.WebException e) { m_log.DebugFormat("[USER MANAGEMENT MODULE]: GetServerURLs call failed {0}", e.Message); userdata.ServerURLs = new Dictionary<string, object>(); } catch (Exception e) { m_log.Debug("[USER MANAGEMENT MODULE]: GetServerURLs call failed ", e); userdata.ServerURLs = new Dictionary<string, object>(); } if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) return userdata.ServerURLs[serverType].ToString(); } return string.Empty; }
protected override void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users) { if (query.Contains("@")) // [email protected], maybe? { string[] words = query.Split(new char[] { '@' }); if (words.Length != 2) { m_log.DebugFormat("[USER MANAGEMENT MODULE]: Malformed address {0}", query); return; } words[0] = words[0].Trim(); // it has at least 1 words[1] = words[1].Trim(); if (words[0] == String.Empty) // query was @foo.com? { foreach (UserData d in m_UserCache.Values) { if (d.LastName.ToLower().StartsWith("@" + words[1].ToLower())) users.Add(d); } // We're done return; } // words.Length == 2 and words[0] != string.empty // [email protected] ? foreach (UserData d in m_UserCache.Values) { if (d.LastName.StartsWith("@") && d.FirstName.ToLower().Equals(words[0].ToLower()) && d.LastName.ToLower().Equals("@" + words[1].ToLower())) { users.Add(d); // It's cached. We're done return; } } // This is it! Let's ask the other world if (words[0].Contains(".")) { string[] names = words[0].Split(new char[] { '.' }); if (names.Length >= 2) { string uriStr = "http://" + words[1]; // Let's check that the last name is a valid address try { new Uri(uriStr); } catch (UriFormatException) { m_log.DebugFormat("[USER MANAGEMENT MODULE]: Malformed address {0}", uriStr); return; } UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr); UUID userID = uasConn.GetUUID(names[0], names[1]); if (!userID.Equals(UUID.Zero)) { UserData ud = new UserData(); ud.Id = userID; ud.FirstName = words[0]; ud.LastName = "@" + words[1]; users.Add(ud); AddUser(userID, names[0], names[1], uriStr); m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0}@{1} found", words[0], words[1]); } else m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0}@{1} not found", words[0], words[1]); } } } //else //{ // foreach (UserData d in m_UserCache.Values) // { // if (d.LastName.StartsWith("@") && // (d.FirstName.ToLower().StartsWith(query.ToLower()) || // d.LastName.ToLower().StartsWith(query.ToLower()))) // users.Add(d); // } //} }
protected bool Authenticate(AgentCircuitData aCircuit, out string message) { message = ""; if (!CheckAddress(aCircuit.ServiceSessionID)) { message = "Please use " + m_Uri.GetLeftPart(UriPartial.Authority) + " instead."; return false; } if (string.IsNullOrEmpty(aCircuit.IPAddress)) { m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide a client IP address."); return false; } string userURL = string.Empty; if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); if (userURL == string.Empty) { m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL"); message = "Agent did not provide an authentication server URL."; return false; } if (userURL == m_ExternalName) { return m_UserAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID); } else { IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); try { return userAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID); } catch { m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", userURL); message = string.Format("Unable to contact authentication service at {0}.", userURL); return false; } } }
public string GetUserServerURL(UUID userID, string serverType) { UserData userdata; lock (m_UserCache) m_UserCache.TryGetValue(userID, out userdata); if (userdata != null) { // m_log.DebugFormat("[UserManagementModule]: Requested url type {0} for {1}", serverType, userID); if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) { return userdata.ServerURLs[serverType].ToString(); } if (userdata.HomeURL != null && userdata.HomeURL != string.Empty) { //m_log.DebugFormat( // "[UserManagementModule]: Did not find url type {0} so requesting urls from '{1}' for {2}", // serverType, userdata.HomeURL, userID); UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); userdata.ServerURLs = uConn.GetServerURLs(userID); if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) return userdata.ServerURLs[serverType].ToString(); } } return string.Empty; }
public string GetUserServerURL(UUID userID, string serverType) { if (m_UserCache.ContainsKey(userID)) { UserData userdata = m_UserCache[userID]; if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) return userdata.ServerURLs[serverType].ToString(); if (userdata.HomeURL != string.Empty) { UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); userdata.ServerURLs = uConn.GetServerURLs(userID); if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null) return userdata.ServerURLs[serverType].ToString(); } } return string.Empty; }
void OnConnectionClosed(IClientAPI obj) { if (obj.IsLoggingOut) { AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) { string url = aCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService security = new UserAgentServiceConnector(url); security.LogoutAgent(obj.AgentId, obj.SessionId); //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url); } else m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: HomeURI not found for agent {0} logout", obj.AgentId); } }
protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI); reason = string.Empty; logout = false; int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { // this user is going to another grid if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) { string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver); bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason); logout = success; // flag for later logout from this grid; this is an HG TP return success; } else { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent does not have a HomeURI address"); return false; } } return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); }
/// <summary> /// Gets the user account data. /// </summary> /// <returns> /// The user profile data. /// </returns> /// <param name='userID'> /// If set to <c>true</c> user I. /// </param> /// <param name='userInfo'> /// If set to <c>true</c> user info. /// </param> bool GetUserAccountData(UUID userID, out Dictionary<string, object> userInfo) { Dictionary<string,object> info = new Dictionary<string, object>(); if (UserManagementModule.IsLocalGridUser(userID)) { // Is local IUserAccountService uas = Scene.UserAccountService; UserAccount account = uas.GetUserAccount(Scene.RegionInfo.ScopeID, userID); info["user_flags"] = account.UserFlags; info["user_created"] = account.Created; if (!String.IsNullOrEmpty(account.UserTitle)) info["user_title"] = account.UserTitle; else info["user_title"] = ""; userInfo = info; return false; } else { // Is Foreign string home_url = UserManagementModule.GetUserServerURL(userID, "HomeURI"); if (String.IsNullOrEmpty(home_url)) { info["user_flags"] = 0; info["user_created"] = 0; info["user_title"] = "Unavailable"; userInfo = info; return true; } UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url); Dictionary<string, object> account; try { account = uConn.GetUserInfo(userID); } catch (Exception e) { m_log.Debug("[PROFILES]: GetUserInfo call failed ", e); account = new Dictionary<string, object>(); } if (account.Count > 0) { if (account.ContainsKey("user_flags")) info["user_flags"] = account["user_flags"]; else info["user_flags"] = ""; if (account.ContainsKey("user_created")) info["user_created"] = account["user_created"]; else info["user_created"] = ""; info["user_title"] = "HG Visitor"; } else { info["user_flags"] = 0; info["user_created"] = 0; info["user_title"] = "HG Visitor"; } userInfo = info; return true; } }
public override void TeleportHome(UUID id, IClientAPI client) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); // Let's find out if this is a foreign user or a local user UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, id); if (account != null) { // local grid user m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); base.TeleportHome(id, client); return; } // Foreign user wants to go home // AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("HomeURI"))) { client.SendTeleportFailed("Your information has been lost"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); return; } IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; GridRegion finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt); if (finalDestination == null) { client.SendTeleportFailed("Your home region could not be found"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); return; } ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); if (sp == null) { client.SendTeleportFailed("Internal error"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); return; } IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); GridRegion homeGatekeeper = MakeRegion(aCircuit); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}", aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); }
public bool VerifyClient(AgentCircuitData aCircuit, string token) { if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) { string url = aCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService security = new UserAgentServiceConnector(url); return security.VerifyClient(aCircuit.SessionID, token); } return false; }
public string osAvatarName2Key(string firstname, string lastname) { CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); m_host.AddScriptLPS(1); IUserManagement userManager = World.RequestModuleInterface<IUserManagement>(); if (userManager == null) { OSSLShoutError("osAvatarName2Key: UserManagement module not available"); return string.Empty; } // Check if the user is already cached UUID userID = userManager.GetUserIdByName(firstname, lastname); if (userID != UUID.Zero) return userID.ToString(); // Query for the user String realFirstName; String realLastName; String serverURI; if (Util.ParseForeignAvatarName(firstname, lastname, out realFirstName, out realLastName, out serverURI)) { try { UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true); if (userConnection != null) { userID = userConnection.GetUUID(realFirstName, realLastName); if (userID != UUID.Zero) { userManager.AddUser(userID, realFirstName, realLastName, serverURI); return userID.ToString(); } } } catch (Exception /*e*/) { // m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid ", e); } } else { UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); if (account != null) return account.PrincipalID.ToString(); } return UUID.Zero.ToString(); }
public string osAvatarName2Key(string firstname, string lastname) { CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); m_host.AddScriptLPS(1); if (lastname.Contains("@")) { String realFirstName; String realLastName; String serverURI; realFirstName = firstname.Split('.')[0]; realLastName = firstname.Split('.')[1]; serverURI = new Uri("http://" + lastname.Replace("@", "")).ToString(); try { UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true); if (userConnection != null) { UUID ruserid = userConnection.GetUUID(realFirstName, realLastName); if (ruserid != null) { IUserManagement userManager = m_ScriptEngine.World.RequestModuleInterface<IUserManagement>(); if (userManager != null) { //Use the HomeURI from the script to get user infos and then ask the remote gridserver for the real HomeURI. userManager.AddUser(ruserid, realFirstName, realLastName, serverURI); serverURI = userManager.GetUserServerURL(ruserid, "HomeURI"); userManager.AddUser(ruserid, realFirstName, realLastName, serverURI); return ruserid.ToString(); } } } } catch (Exception osAvatarException) { //m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid\n" + osAvatarException.Message); } } else { UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); if (account != null) return account.PrincipalID.ToString(); } return UUID.Zero.ToString(); }
public override bool TeleportHome(UUID id, IClientAPI client) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); // Let's find out if this is a foreign user or a local user IUserManagement uMan = Scene.RequestModuleInterface<IUserManagement>(); if (uMan != null && uMan.IsLocalGridUser(id)) { // local grid user m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); return base.TeleportHome(id, client); } // Foreign user wants to go home // AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("HomeURI"))) { client.SendTeleportFailed("Your information has been lost"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); return false; } IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; GridRegion finalDestination = null; try { finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt); } catch (Exception e) { m_log.Debug("[HG ENTITY TRANSFER MODULE]: GetHomeRegion call failed ", e); } if (finalDestination == null) { client.SendTeleportFailed("Your home region could not be found"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); return false; } ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); if (sp == null) { client.SendTeleportFailed("Internal error"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); return false; } GridRegion homeGatekeeper = MakeRegion(aCircuit); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}", aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); DoTeleport( sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); return true; }
protected bool Authenticate(AgentCircuitData aCircuit) { if (!CheckAddress(aCircuit.ServiceSessionID)) return false; string userURL = string.Empty; if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); if (userURL == string.Empty) { m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL"); return false; } if (userURL == m_ExternalName) return m_UserAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID); else { Object[] args = new Object[] { userURL }; IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); if (userAgentService != null) { try { return userAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID); } catch { m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", userURL); return false; } } } return false; }
void OnConnectionClosed(IClientAPI obj) { if (obj.SceneAgent.IsChildAgent) return; // Let's find out if this is a foreign user or a local user IUserManagement uMan = Scene.RequestModuleInterface<IUserManagement>(); // UserAccount account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, obj.AgentId); if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) { // local grid user m_UAS.LogoutAgent(obj.AgentId, obj.SessionId); return; } AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("HomeURI")) { string url = aCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService security = new UserAgentServiceConnector(url); security.LogoutAgent(obj.AgentId, obj.SessionId); //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url); } else { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: HomeURI not found for agent {0} logout", obj.AgentId); } }
// This will cache the user data // Change this to return bool private bool GetUserInfo(UUID userID) { UserData userdata; lock (m_UserCache) m_UserCache.TryGetValue(userID, out userdata); if (userdata != null) { // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID); if (userdata.Flags >= 0) { // This is already populated return true; } if (userdata.HomeURL != null && userdata.HomeURL != string.Empty) { m_log.DebugFormat( "[USER MANAGEMENT MODULE]: Requesting user flags from '{0}' for {1}", userdata.HomeURL, userID); UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); Dictionary<string, object> info = uConn.GetUserInfo(userID); // Pull our data now if (info["result"].ToString() == "success") { userdata.Flags = (int)info["user_flags"]; userdata.Created = (int)info["user_created"]; userdata.Title = (string)info["user_title"]; return true; } } } return false; }