protected virtual string GenerateLandmark(ScenePresence presence, out string prefix, out string suffix) { if (m_ThisGatekeeper != String.Empty) { if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(presence.UUID)) { prefix = "HG "; } else { prefix = string.Empty; } suffix = " @ " + m_ThisGatekeeper; Vector3 pos = presence.AbsolutePosition; return(String.Format("Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\ngatekeeper {5}\n", presence.Scene.RegionInfo.RegionID, pos.X, pos.Y, pos.Z, presence.RegionHandle, m_ThisGatekeeper)); } else { prefix = string.Empty; suffix = string.Empty; Vector3 pos = presence.AbsolutePosition; return(String.Format("Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\n", presence.Scene.RegionInfo.RegionID, pos.X, pos.Y, pos.Z, presence.RegionHandle)); } }
protected override void OnInstantMessage(IClientAPI client, GridInstantMessage im) { if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) { // we got a friendship offer UUID principalID = new UUID(im.fromAgentID); UUID friendID = new UUID(im.toAgentID); // Check if friendID is foreigner and if principalID has the permission // to request friendships with foreigners. If not, return immediately. if (!UserManagementModule.IsLocalGridUser(friendID)) { ScenePresence avatar = null; ((Scene)client.Scene).TryGetScenePresence(principalID, out avatar); if (avatar == null) { return; } if (avatar.GodController.UserLevel < m_levelHGFriends) { client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false); return; } } } base.OnInstantMessage(client, im); }
public override bool IsForeignUser(UUID userID, out string assetServerURL) { assetServerURL = string.Empty; if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) { // foreign ScenePresence sp = null; if (m_Scene.TryGetScenePresence(userID, out sp)) { AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); assetServerURL = assetServerURL.Trim(new char[] { '/' }); } } else { assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); assetServerURL = assetServerURL.Trim(new char[] { '/' }); } return(true); } return(false); }
protected override void StoreBackwards(UUID friendID, UUID agentID) { bool agentIsLocal = true; // bool friendIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); // friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); } // Is the requester a local user? if (agentIsLocal) { // local grid users m_log.DebugFormat("[HGFRIENDS MODULE]: Friendship requester is local. Storing backwards."); base.StoreBackwards(friendID, agentID); return; } // no provision for this temporary friendship state when user is not local //FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), 0); }
protected override FriendInfo[] GetFriendsFromService(IClientAPI client) { // m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name); Boolean agentIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(client.AgentId); } if (agentIsLocal) { return(base.GetFriendsFromService(client)); } FriendInfo[] finfos = new FriendInfo[0]; // Foreigner AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); if (agentClientCircuit != null) { string agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); finfos = FriendsService.GetFriends(agentUUI); m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, agentUUI); } // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name); return(finfos); }
public override FriendInfo[] GetFriendsFromService(IClientAPI client) { // m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name); Boolean agentIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(client.AgentId); } if (agentIsLocal) { return(base.GetFriendsFromService(client)); } FriendInfo[] finfos = new FriendInfo[0]; // Foreigner AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); if (agentClientCircuit != null) { // Note that this is calling a different interface than base; this one calls with a string param! finfos = FriendsService.GetFriends(client.AgentId.ToString()); m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, client.AgentId.ToString()); } // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name); return(finfos); }
/// <summary> /// Gets the user's inventory URL from its serviceURLs, if the user is foreign, /// and sticks it in the cache /// </summary> /// <param name="userID"></param> private void CacheInventoryServiceURL(UUID userID) { if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) { // The user is not local; let's cache its service URL string inventoryURL = string.Empty; ScenePresence sp = null; try { m_Scenes.ForEach(delegate(Scene scene) { scene.TryGetScenePresence(userID, out sp); if (sp != null) { AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); if (aCircuit == null) { throw new ThreadedClasses.ReturnValueException <ScenePresence>(null); } if (aCircuit.ServiceURLs == null) { throw new ThreadedClasses.ReturnValueException <ScenePresence>(null); } if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) { inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); if (inventoryURL != null && inventoryURL != string.Empty) { inventoryURL = inventoryURL.Trim(new char[] { '/' }); m_InventoryURLs[userID] = inventoryURL; m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); throw new ThreadedClasses.ReturnValueException <ScenePresence>(sp); } } } }); } catch (ThreadedClasses.ReturnValueException <ScenePresence> e) { sp = e.Value; } if (sp == null) { inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI"); if (!string.IsNullOrEmpty(inventoryURL)) { inventoryURL = inventoryURL.Trim(new char[] { '/' }); m_InventoryURLs[userID] = inventoryURL; m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); } } } }
/// <summary> /// Gets the user's inventory URL from its serviceURLs, if the user is foreign, /// and sticks it in the cache /// </summary> /// <param name="userID"></param> private void CacheInventoryServiceURL(UUID userID) { if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) { // The user is not local; let's cache its service URL string inventoryURL = string.Empty; ScenePresence sp = null; foreach (Scene scene in m_Scenes) { scene.TryGetScenePresence(userID, out sp); if (sp != null) { AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); if (aCircuit == null) { return; } if (aCircuit.ServiceURLs == null) { return; } if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) { inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); if (inventoryURL != null && inventoryURL != string.Empty) { inventoryURL = inventoryURL.Trim(new char[] { '/' }); lock (m_InventoryURLs) m_InventoryURLs[userID] = inventoryURL; m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); return; } } // else // { // m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID); // return; // } } } if (sp == null) { inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI"); if (!string.IsNullOrEmpty(inventoryURL)) { inventoryURL = inventoryURL.Trim(new char[] { '/' }); lock (m_InventoryURLs) m_InventoryURLs[userID] = inventoryURL; m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); } } } }
private bool OnTransferUserInventory(UUID itemID, UUID userID, UUID recipientID) { if (m_bypassPermissions) { return(true); } if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(recipientID)) { return(false); } return(true); }
public override bool IsForeignUser(UUID userID, out string assetServerURL) { assetServerURL = string.Empty; if (UserManagementModule != null) { if (!m_CheckSeparateAssets) { if (!UserManagementModule.IsLocalGridUser(userID)) { // foreign ScenePresence sp = null; if (m_Scene.TryGetScenePresence(userID, out sp)) { AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); assetServerURL = assetServerURL.Trim(new char[] { '/' }); } } else { assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); assetServerURL = assetServerURL.Trim(new char[] { '/' }); } return(true); } } else { if (IsLocalInventoryAssetsUser(userID, out assetServerURL)) { m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL); return(false); } else { m_log.DebugFormat("[HGScene]: user {0} has foreign assets {1}", userID, assetServerURL); return(true); } } } return(false); }
/// <summary> /// Gets the user gatekeeper server URI. /// </summary> /// <returns> /// The user gatekeeper server URI. /// </returns> /// <param name='userID'> /// If set to <c>true</c> user URI. /// </param> /// <param name='serverURI'> /// If set to <c>true</c> server URI. /// </param> bool GetUserGatekeeperURI(UUID userID, out string serverURI) { bool local; local = UserManagementModule.IsLocalGridUser(userID); if (!local) { serverURI = UserManagementModule.GetUserServerURL(userID, "GatekeeperURI"); // Is Foreign return(true); } else { serverURI = MyGatekeeper; // Is local return(false); } }
/// <summary> /// Gets the user profile server UR. /// </summary> /// <returns> /// The user profile server UR. /// </returns> /// <param name='userID'> /// If set to <c>true</c> user I. /// </param> /// <param name='serverURI'> /// If set to <c>true</c> server UR. /// </param> private bool GetUserProfileServerURI(UUID userID, out string serverURI) { bool local; local = UserManagementModule.IsLocalGridUser(userID); if (!local) { serverURI = UserManagementModule.GetUserServerURL(userID, "ProfileServerURI"); // Is Foreign return(true); } else { serverURI = ProfileServerUri; // Is local return(false); } }
protected override string GenerateLandmark(ScenePresence presence, out string prefix, out string suffix) { if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(presence.UUID)) { prefix = "HG "; } else { prefix = string.Empty; } suffix = " @ " + m_thisGridInfo.GateKeeperURLNoEndSlash; Vector3 pos = presence.AbsolutePosition; return(String.Format(Culture.FormatProvider, "Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\ngatekeeper {5}\n", presence.Scene.RegionInfo.RegionID, pos.X, pos.Y, pos.Z, presence.RegionHandle, m_thisGridInfo.GateKeeperURLNoEndSlash)); }
private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) { if (m_bypassPermissions) { return(true); } if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer)) { SceneObjectGroup sog = null; if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer) { return(true); } return(false); } return(true); }
protected override bool StoreRights(UUID agentID, UUID friendID, int rights) { Boolean agentIsLocal = true; Boolean friendIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); } // Are they both local users? if (agentIsLocal && friendIsLocal) { // local grid users return(base.StoreRights(agentID, friendID, rights)); } if (agentIsLocal) // agent is local, friend is foreigner { FriendInfo[] finfos = GetFriends(agentID); FriendInfo finfo = GetFriend(finfos, friendID); if (finfo != null) { FriendsService.StoreFriend(agentID.ToString(), finfo.Friend, rights); return(true); } } if (friendIsLocal) // agent is foreigner, friend is local { string agentUUI = GetUUI(friendID, agentID); if (agentUUI != string.Empty) { FriendsService.StoreFriend(agentUUI, friendID.ToString(), rights); return(true); } } return(false); }
protected override void StoreBackwards(UUID friendID, UUID agentID) { Boolean agentIsLocal = true; Boolean friendIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); } // Are they both local users? if (agentIsLocal && friendIsLocal) { // local grid users m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); base.StoreBackwards(friendID, agentID); return; } // no provision for this temporary friendship state //FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), 0); }
private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp) { if (m_bypassPermissions) { return(true); } if (sp == null || sog == null) { return(false); } if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(sp.UUID)) { if (sog.OwnerID == sp.UUID) { return(true); } return(false); } return(true); }
public void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) { UUID toAgentID = new UUID(im.toAgentID); // Try root avatar only first foreach (Scene scene in m_Scenes) { // m_log.DebugFormat( // "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", // toAgentID.ToString(), scene.RegionInfo.RegionName); ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null && !sp.IsChildAgent) { // Local message // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); return; } } // try child avatar second foreach (Scene scene in m_Scenes) { // m_log.DebugFormat( // "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", // toAgentID, scene.RegionInfo.RegionName); ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null) { // Local message // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); return; } } // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); // Is the user a local user? string url = string.Empty; bool foreigner = false; if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(toAgentID)) // foreign user { url = UserManagementModule.GetUserServerURL(toAgentID, "IMServerURI"); foreigner = true; } Util.FireAndForget(delegate { bool success = false; if (foreigner && url == string.Empty) // we don't know about this user { string recipientUUI = TryGetRecipientUUI(new UUID(im.fromAgentID), toAgentID); m_log.DebugFormat("[HG MESSAGE TRANSFER]: Got UUI {0}", recipientUUI); if (recipientUUI != string.Empty) { UUID id; string u = string.Empty, first = string.Empty, last = string.Empty, secret = string.Empty; if (Util.ParseUniversalUserIdentifier(recipientUUI, out id, out u, out first, out last, out secret)) { success = m_IMService.OutgoingInstantMessage(im, u, true); if (success) { UserManagementModule.AddUser(toAgentID, u + ";" + first + " " + last); } } } } else { success = m_IMService.OutgoingInstantMessage(im, url, foreigner); } if (!success && !foreigner) { HandleUndeliveredMessage(im, result); } else { result(success); } }); return; }
protected override bool DeleteFriendship(UUID agentID, UUID exfriendID) { Boolean agentIsLocal = true; Boolean friendIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); friendIsLocal = UserManagementModule.IsLocalGridUser(exfriendID); } // Are they both local users? if (agentIsLocal && friendIsLocal) { // local grid users return(base.DeleteFriendship(agentID, exfriendID)); } // ok, at least one of them is foreigner, let's get their data string agentUUI = string.Empty; string friendUUI = string.Empty; if (agentIsLocal) // agent is local, 'friend' is foreigner { // We need to look for its information in the friends list itself FriendInfo[] finfos = GetFriends(agentID); FriendInfo finfo = GetFriend(finfos, exfriendID); if (finfo != null) { friendUUI = finfo.Friend; // delete in the local friends service the reference to the foreign friend FriendsService.Delete(agentID, friendUUI); // and also the converse FriendsService.Delete(friendUUI, agentID.ToString()); // notify the exfriend's service Util.FireAndForget(delegate { Delete(exfriendID, agentID, friendUUI); }); m_log.DebugFormat("[HGFRIENDS MODULE]: {0} terminated {1}", agentID, friendUUI); return(true); } } else if (friendIsLocal) // agent is foreigner, 'friend' is local { agentUUI = GetUUI(exfriendID, agentID); if (agentUUI != string.Empty) { // delete in the local friends service the reference to the foreign agent FriendsService.Delete(exfriendID, agentUUI); // and also the converse FriendsService.Delete(agentUUI, exfriendID.ToString()); // notify the agent's service? Util.FireAndForget(delegate { Delete(agentID, exfriendID, agentUUI); }); m_log.DebugFormat("[HGFRIENDS MODULE]: {0} terminated {1}", agentUUI, exfriendID); return(true); } } //else They're both foreigners! Can't handle this return(false); }
protected override void StoreFriendships(UUID agentID, UUID friendID) { Boolean agentIsLocal = true; Boolean friendIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); } // Are they both local users? if (agentIsLocal && friendIsLocal) { // local grid users m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); base.StoreFriendships(agentID, friendID); return; } // ok, at least one of them is foreigner, let's get their data IClientAPI agentClient = LocateClientObject(agentID); IClientAPI friendClient = LocateClientObject(friendID); AgentCircuitData agentClientCircuit = null; AgentCircuitData friendClientCircuit = null; string agentUUI = string.Empty; string friendUUI = string.Empty; string agentFriendService = string.Empty; string friendFriendService = string.Empty; if (agentClient != null) { agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); } if (friendClient != null) { friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); } m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", agentUUI, friendUUI, agentFriendService, friendFriendService); // Generate a random 8-character hex number that will sign this friendship string secret = UUID.Random().ToString().Substring(0, 8); if (agentIsLocal) // agent is local, 'friend' is foreigner { // This may happen when the agent returned home, in which case the friend is not there // We need to look for its information in the friends list itself bool confirming = false; if (friendUUI == string.Empty) { FriendInfo[] finfos = GetFriends(agentID); foreach (FriendInfo finfo in finfos) { if (finfo.TheirFlags == -1) { if (finfo.Friend.StartsWith(friendID.ToString())) { friendUUI = finfo.Friend; confirming = true; } } } } // If it's confirming the friendship, we already have the full friendUUI with the secret string theFriendUUID = confirming ? friendUUI : friendUUI + ";" + secret; // store in the local friends service a reference to the foreign friend FriendsService.StoreFriend(agentID.ToString(), theFriendUUID, 1); // and also the converse FriendsService.StoreFriend(theFriendUUID, agentID.ToString(), 1); if (!confirming && friendClientCircuit != null) { // store in the foreign friends service a reference to the local agent HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(friendFriendService, friendClientCircuit.SessionID, friendClientCircuit.ServiceSessionID); friendsConn.NewFriendship(friendID, agentUUI + ";" + secret); } } else if (friendIsLocal) // 'friend' is local, agent is foreigner { // store in the local friends service a reference to the foreign agent FriendsService.StoreFriend(friendID.ToString(), agentUUI + ";" + secret, 1); // and also the converse FriendsService.StoreFriend(agentUUI + ";" + secret, friendID.ToString(), 1); if (agentClientCircuit != null) { // store in the foreign friends service a reference to the local agent HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(agentFriendService, agentClientCircuit.SessionID, agentClientCircuit.ServiceSessionID); friendsConn.NewFriendship(agentID, friendUUI + ";" + secret); } } else // They're both foreigners! { HGFriendsServicesConnector friendsConn; if (agentClientCircuit != null) { friendsConn = new HGFriendsServicesConnector(agentFriendService, agentClientCircuit.SessionID, agentClientCircuit.ServiceSessionID); friendsConn.NewFriendship(agentID, friendUUI + ";" + secret); } if (friendClientCircuit != null) { friendsConn = new HGFriendsServicesConnector(friendFriendService, friendClientCircuit.SessionID, friendClientCircuit.ServiceSessionID); friendsConn.NewFriendship(friendID, agentUUI + ";" + secret); } } // my brain hurts now }
protected override void StoreFriendships(UUID agentID, UUID friendID) { Boolean agentIsLocal = true; Boolean friendIsLocal = true; if (UserManagementModule != null) { agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); } // Are they both local users? if (agentIsLocal && friendIsLocal) { // local grid users m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); DeletePreviousHGRelations(agentID, friendID); base.StoreFriendships(agentID, friendID); return; } // ok, at least one of them is foreigner, let's get their data IClientAPI agentClient = LocateClientObject(agentID); IClientAPI friendClient = LocateClientObject(friendID); AgentCircuitData agentClientCircuit = null; AgentCircuitData friendClientCircuit = null; string agentUUI = string.Empty; string friendUUI = string.Empty; string agentFriendService = string.Empty; string friendFriendService = string.Empty; if (agentClient != null) { agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); RecacheFriends(agentClient); } if (friendClient != null) { friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); RecacheFriends(friendClient); } m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", agentUUI, friendUUI, agentFriendService, friendFriendService); // Generate a random 8-character hex number that will sign this friendship string secret = UUID.Random().ToString().Substring(0, 8); string theFriendUUID = friendUUI + ";" + secret; string agentUUID = agentUUI + ";" + secret; if (agentIsLocal) // agent is local, 'friend' is foreigner { // This may happen when the agent returned home, in which case the friend is not there // We need to look for its information in the friends list itself FriendInfo[] finfos = null; bool confirming = false; if (friendUUI == string.Empty) { finfos = GetFriendsFromCache(agentID); foreach (FriendInfo finfo in finfos) { if (finfo.TheirFlags == -1) { if (finfo.Friend.StartsWith(friendID.ToString())) { friendUUI = finfo.Friend; theFriendUUID = friendUUI; UUID utmp = UUID.Zero; string url = String.Empty; string first = String.Empty; string last = String.Empty; // If it's confirming the friendship, we already have the full UUI with the secret if (Util.ParseUniversalUserIdentifier(theFriendUUID, out utmp, out url, out first, out last, out secret)) { agentUUID = agentUUI + ";" + secret; m_uMan.AddUser(utmp, first, last, url); } confirming = true; break; } } } if (!confirming) { friendUUI = m_uMan.GetUserUUI(friendID); theFriendUUID = friendUUI + ";" + secret; } friendFriendService = m_uMan.GetUserServerURL(friendID, "FriendsServerURI"); // m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", // agentUUI, friendUUI, agentFriendService, friendFriendService); } // Delete any previous friendship relations DeletePreviousRelations(agentID, friendID); // store in the local friends service a reference to the foreign friend FriendsService.StoreFriend(agentID.ToString(), theFriendUUID, 1); // and also the converse FriendsService.StoreFriend(theFriendUUID, agentID.ToString(), 1); //if (!confirming) //{ // store in the foreign friends service a reference to the local agent HGFriendsServicesConnector friendsConn = null; if (friendClientCircuit != null) // the friend is here, validate session { friendsConn = new HGFriendsServicesConnector(friendFriendService, friendClientCircuit.SessionID, friendClientCircuit.ServiceSessionID); } else // the friend is not here, he initiated the request in his home world { friendsConn = new HGFriendsServicesConnector(friendFriendService); } friendsConn.NewFriendship(friendID, agentUUID); //} } else if (friendIsLocal) // 'friend' is local, agent is foreigner { // Delete any previous friendship relations DeletePreviousRelations(agentID, friendID); // store in the local friends service a reference to the foreign agent FriendsService.StoreFriend(friendID.ToString(), agentUUI + ";" + secret, 1); // and also the converse FriendsService.StoreFriend(agentUUI + ";" + secret, friendID.ToString(), 1); if (agentClientCircuit != null) { // store in the foreign friends service a reference to the local agent HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(agentFriendService, agentClientCircuit.SessionID, agentClientCircuit.ServiceSessionID); friendsConn.NewFriendship(agentID, friendUUI + ";" + secret); } } else // They're both foreigners! { HGFriendsServicesConnector friendsConn; if (agentClientCircuit != null) { friendsConn = new HGFriendsServicesConnector(agentFriendService, agentClientCircuit.SessionID, agentClientCircuit.ServiceSessionID); friendsConn.NewFriendship(agentID, friendUUI + ";" + secret); } if (friendClientCircuit != null) { friendsConn = new HGFriendsServicesConnector(friendFriendService, friendClientCircuit.SessionID, friendClientCircuit.ServiceSessionID); friendsConn.NewFriendship(friendID, agentUUI + ";" + secret); } } // my brain hurts now }
/// <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); } }