Пример #1
0
        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);
        }
        /// <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);
                    }
                }
            }
        }
Пример #3
0
        bool GetImageAssets(UUID avatarId)
        {
            string profileServerURI = string.Empty;
            string assetServerURI   = string.Empty;

            bool foreign = GetUserProfileServerURI(avatarId, out profileServerURI);

            if (!foreign)
            {
                return(true);
            }

            assetServerURI = UserManagementModule.GetUserServerURL(avatarId, "AssetServerURI");

            if (string.IsNullOrEmpty(profileServerURI) || string.IsNullOrEmpty(assetServerURI))
            {
                return(false);
            }

            OSDMap parameters = new OSDMap();

            parameters.Add("avatarId", OSD.FromUUID(avatarId));
            OSD Params = (OSD)parameters;

            try
            {
                if (!rpc.JsonRpcRequest(ref Params, "image_assets_request", profileServerURI, UUID.Random().ToString()))
                {
                    return(false);
                }

                parameters = (OSDMap)Params;

                if (parameters.ContainsKey("result"))
                {
                    OSDArray list = (OSDArray)parameters["result"];

                    foreach (OSD asset in list)
                    {
                        OSDString assetId = (OSDString)asset;

                        Scene.AssetService.Get(string.Format("{0}/{1}", assetServerURI, assetId.AsString()));
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Пример #4
0
        /// <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 IsLocalInventoryAssetsUser(UUID uuid, out string assetsURL)
 {
     assetsURL = UserManagementModule.GetUserServerURL(uuid, "AssetServerURI");
     if (assetsURL == string.Empty)
     {
         AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid);
         if (agent != null)
         {
             assetsURL = agent.ServiceURLs["AssetServerURI"].ToString();
             assetsURL = assetsURL.Trim(new char[] { '/' });
         }
     }
     return(m_LocalAssetsURL.Equals(assetsURL));
 }
        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 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);
            }
        }
Пример #8
0
        /// <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);
            }
        }
Пример #9
0
        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;
        }
        /// <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);
            }
        }