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; 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 (userdata.HomeURL != null && userdata.HomeURL != string.Empty) { 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); 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 override 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); } base.OnConnectionClosed(obj); }
protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) { 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)); }
protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, EntityTransferContext ctx, 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 bool isLocal = Scene.UserManagementModule.IsLocalGridUser(sp.UUID); if (isLocal && sp.GodController.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 (m_thisGridInfo.IsLocalHome(userAgentDriver) == 1 && m_UAS != null) { connector = m_UAS; } else { connector = new UserAgentServiceConnector(userAgentDriver); } GridRegion source = new GridRegion(Scene.RegionInfo) { RawServerURI = m_thisGridInfo.GateKeeperURL }; bool success = connector.LoginAgentToGrid(source, agentCircuit, reg, finalDestination, false, out reason); logout = success; // flag for later logout from this grid; this is an HG TP if (success) { 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, ctx, out reason, out logout)); }
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 = 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(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); }
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 GetUserServerURL(UUID userID, string serverType) { UserData userdata; m_UserCacheRwLock.AcquireReaderLock(-1); try { m_UserCache.TryGetValue(userID, out userdata); } finally { m_UserCacheRwLock.ReleaseReaderLock(); } 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 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); } } }
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); }
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) { object url; if (userdata.ServerURLs.TryGetValue(serverType, out url)) { return(url.ToString()); } } else 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>(); } object url; if (userdata.ServerURLs.TryGetValue(serverType, out url)) { return(url.ToString()); } } } return(string.Empty); }
protected bool Authenticate(AgentCircuitData aCircuit) { if (!CheckAddress(aCircuit.ServiceSessionID)) { 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(); } OSHHTPHost userHomeHost = new OSHHTPHost(userURL, true); if (!userHomeHost.IsResolvedHost) { m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL"); return(false); } if (m_gatekeeperHost.Equals(userHomeHost)) { 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); return(false); } } }
public string GetUserServerURL(UUID userID, string serverType) { // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID); 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]: 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 (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 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); }
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.Data.RegionFlags.Hyperlink) != 0) { // this user is going to another grid // check if HyperGrid teleport is allowed, based on user level if (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 = 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 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)); }
// 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); }
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); } } }
// // 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); } }
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); // WARNING! that uriStr is not quite right... it may be missing the / at the end, // which will cause trouble (duplicate entries on some tables). We should // get the UUI instead from the UAS. TO BE FIXED. 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); // } //} }
/// <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> private 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); } }
//protected override bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agentData, ScenePresence sp) //{ // int flags = Scene.GridService.GetRegionFlags(Scene.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 (m_RestrictAppearanceAbroad && Scene.UserManagementModule.IsLocalGridUser(agentData.AgentID)) // { // // We need to strip the agent off its appearance // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Sending generic appearance"); // // Delete existing npc attachments // Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); // // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments // AvatarAppearance newAppearance = new AvatarAppearance(ExportedAppearance, true); // sp.Appearance = newAppearance; // // Rez needed npc attachments // Scene.AttachmentsModule.RezAttachments(sp); // IAvatarFactoryModule module = Scene.RequestModuleInterface<IAvatarFactoryModule>(); // //module.SendAppearance(sp.UUID); // module.RequestRebake(sp, false); // Scene.AttachmentsModule.CopyAttachments(sp, agentData); // agentData.Appearance = sp.Appearance; // } // } // foreach (AvatarAttachment a in agentData.Appearance.GetAttachments()) // m_log.DebugFormat("[XXX]: {0}-{1}", a.ItemID, a.AssetID); // return base.UpdateAgent(reg, finalDestination, agentData, sp); //} public override bool TeleportHome(UUID id, IClientAPI client) { // 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 return(base.TeleportHome(id, client)); } bool notsame = false; if (client == null) { m_log.DebugFormat( "[HG ENTITY TRANSFER MODULE]: Request to teleport {0} home", id); } else { if (id == client.AgentId) { m_log.DebugFormat( "[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, id); } else { notsame = true; m_log.DebugFormat( "[HG ENTITY TRANSFER MODULE]: Request to teleport {0} home by {1} {2}", id, client.Name, client.AgentId); } } ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(id); if (sp == null || sp.IsDeleted || sp.IsChildAgent || sp.ControllingClient == null || !sp.ControllingClient.IsActive) { if (notsame) { client.SendAlertMessage("TeleportHome: Agent not found in the scene"); } m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene"); return(false); } IClientAPI targetClient = sp.ControllingClient; if (sp.IsInTransit) { if (notsame) { client.SendAlertMessage("TeleportHome: Agent already processing a teleport"); } targetClient.SendTeleportFailed("Already processing a teleport"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent still in teleport"); return(false); } // Foreign user wants to go home // AgentCircuitData aCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(targetClient.CircuitCode); if (aCircuit == null) { if (notsame) { client.SendAlertMessage("TeleportHome: Agent information not found"); } targetClient.SendTeleportFailed("Home information not found"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); return(false); } if (!aCircuit.ServiceURLs.ContainsKey("HomeURI")) { if (notsame) { client.SendAlertMessage("TeleportHome: Agent home not set"); } targetClient.SendTeleportFailed("Home not set"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent home not set"); return(false); } string homeURI = aCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService userAgentService = new UserAgentServiceConnector(homeURI); Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; GridRegion finalDestination = null; try { finalDestination = userAgentService.GetHomeRegion(id, out position, out lookAt); } catch (Exception e) { m_log.Debug("[HG ENTITY TRANSFER MODULE]: GetHomeRegion call failed ", e); } if (finalDestination == null) { if (notsame) { client.SendAlertMessage("TeleportHome: Agent Home region not found"); } targetClient.SendTeleportFailed("Home region not found"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); return(false); } GridRegion homeGatekeeper = MakeGateKeeperRegion(homeURI); 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 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); }
protected override void AddAdditionalUsers(string query, List <UserData> users, HashSet <UUID> found) { 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().ToLower(); string match1 = "@" + words[1]; if (String.IsNullOrWhiteSpace(words[0])) // query was @foo.com? { foreach (UserData d in m_userCacheByID.Values) { if (found.Contains(d.Id)) { continue; } if (d.LastName.ToLower().StartsWith(match1)) { users.Add(d); } } // We're done return; } string match0 = words[0].ToLower(); // words.Length == 2 and words[0] != string.empty // [email protected] ? foreach (UserData d in m_userCacheByID.Values) { if (found.Contains(d.Id)) { continue; } if (d.LastName.ToLower().Equals(match1) && d.FirstName.ToLower().Equals(match0)) { 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; } UUID userID = UUID.Zero; uriStr = uriStr.ToLower(); if (!WebUtil.GlobalExpiringBadURLs.ContainsKey(uriStr)) { UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr); try { userID = uasConn.GetUUID(names[0], names[1]); } catch (Exception e) { m_log.Debug("[USER MANAGEMENT MODULE]: GetUUID call failed ", e); } } 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]); } } } } }