From 518a8b9f2ac09a5060e2e59c913dfbe7faf397ef Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 25 Nov 2008 16:00:55 +0000 Subject: Update svn properties. --- .../Modules/Hypergrid/HGStandaloneAssetService.cs | 398 ++++++------- .../Hypergrid/HGStandaloneInventoryService.cs | 630 ++++++++++----------- .../Modules/Hypergrid/HGWorldMapModule.cs | 356 ++++++------ 3 files changed, 692 insertions(+), 692 deletions(-) (limited to 'OpenSim/Region/Environment/Modules') diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs index 192904c..d090052 100644 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneAssetService.cs @@ -1,200 +1,200 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -using System; -using System.Collections.Generic; -using System.Net; -using System.Reflection; - -using log4net; -using Nini.Config; - -using OpenMetaverse; - -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Grid.AssetServer; - -namespace OpenSim.Region.Environment.Modules.Hypergrid -{ - public class HGStandaloneAssetService : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool initialized = false; - private static bool enabled = false; - - Scene m_scene; - //AssetService m_assetService; - - #region IRegionModule interface - - public void Initialise(Scene scene, IConfigSource config) - { - if (!initialized) - { - initialized = true; - m_scene = scene; - - // This module is only on for standalones in hypergrid mode - enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); - } - } - - public void PostInitialise() - { - if (enabled) - { - m_log.Info("[HGStandaloneAssetService]: Starting..."); - +/** + * Copyright (c) 2008, Contributors. All rights reserved. + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Reflection; + +using log4net; +using Nini.Config; + +using OpenMetaverse; + +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Servers; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Grid.AssetServer; + +namespace OpenSim.Region.Environment.Modules.Hypergrid +{ + public class HGStandaloneAssetService : IRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool initialized = false; + private static bool enabled = false; + + Scene m_scene; + //AssetService m_assetService; + + #region IRegionModule interface + + public void Initialise(Scene scene, IConfigSource config) + { + if (!initialized) + { + initialized = true; + m_scene = scene; + + // This module is only on for standalones in hypergrid mode + enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); + } + } + + public void PostInitialise() + { + if (enabled) + { + m_log.Info("[HGStandaloneAssetService]: Starting..."); + //m_assetService = new AssetService(m_scene); - new AssetService(m_scene); - } - } - - public void Close() - { - } - - public string Name - { - get { return "HGStandaloneAssetService"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - } - - public class AssetService - { - private IUserService m_userService; - private bool m_doLookup = false; - - public bool DoLookup - { - get { return m_doLookup; } - set { m_doLookup = value; } - } - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public AssetService(Scene m_scene) - { - AddHttpHandlers(m_scene); - m_userService = m_scene.CommsManager.UserService; - } - - protected void AddHttpHandlers(Scene m_scene) - { - IAssetProviderPlugin m_assetProvider = ((AssetServerBase)m_scene.AssetCache.AssetServer).AssetProviderPlugin; - - m_scene.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); - m_scene.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); - - } - - - ///// - ///// Check that the source of an inventory request is one that we trust. - ///// - ///// - ///// - //public bool CheckTrustSource(IPEndPoint peer) - //{ - // if (m_doLookup) - // { - // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); - // UriBuilder ub = new UriBuilder(m_userserver_url); - // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); - // foreach (IPAddress uaddr in uaddrs) - // { - // if (uaddr.Equals(peer.Address)) - // { - // return true; - // } - // } - - // m_log.WarnFormat( - // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", - // peer); - - // return false; - // } - // else - // { - // return true; - // } - //} - - /// - /// Check that the source of an inventory request for a particular agent is a current session belonging to - /// that agent. - /// - /// - /// - /// - public bool CheckAuthSession(string session_id, string avatar_id) - { - if (m_doLookup) - { - m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); - UUID userID = UUID.Zero; - UUID sessionID = UUID.Zero; - UUID.TryParse(avatar_id, out userID); - UUID.TryParse(session_id, out sessionID); - if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) - { - m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); - return false; - } - UserProfileData userProfile = m_userService.GetUserProfile(userID); - if (userProfile != null && userProfile.CurrentAgent != null && - userProfile.CurrentAgent.SessionID == sessionID) - { - m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); - return true; - } - - m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); - return false; - } - else - { - return true; - } - } - } -} + new AssetService(m_scene); + } + } + + public void Close() + { + } + + public string Name + { + get { return "HGStandaloneAssetService"; } + } + + public bool IsSharedModule + { + get { return true; } + } + + #endregion + + } + + public class AssetService + { + private IUserService m_userService; + private bool m_doLookup = false; + + public bool DoLookup + { + get { return m_doLookup; } + set { m_doLookup = value; } + } + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public AssetService(Scene m_scene) + { + AddHttpHandlers(m_scene); + m_userService = m_scene.CommsManager.UserService; + } + + protected void AddHttpHandlers(Scene m_scene) + { + IAssetProviderPlugin m_assetProvider = ((AssetServerBase)m_scene.AssetCache.AssetServer).AssetProviderPlugin; + + m_scene.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); + m_scene.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); + + } + + + ///// + ///// Check that the source of an inventory request is one that we trust. + ///// + ///// + ///// + //public bool CheckTrustSource(IPEndPoint peer) + //{ + // if (m_doLookup) + // { + // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); + // UriBuilder ub = new UriBuilder(m_userserver_url); + // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); + // foreach (IPAddress uaddr in uaddrs) + // { + // if (uaddr.Equals(peer.Address)) + // { + // return true; + // } + // } + + // m_log.WarnFormat( + // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", + // peer); + + // return false; + // } + // else + // { + // return true; + // } + //} + + /// + /// Check that the source of an inventory request for a particular agent is a current session belonging to + /// that agent. + /// + /// + /// + /// + public bool CheckAuthSession(string session_id, string avatar_id) + { + if (m_doLookup) + { + m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); + UUID userID = UUID.Zero; + UUID sessionID = UUID.Zero; + UUID.TryParse(avatar_id, out userID); + UUID.TryParse(session_id, out sessionID); + if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) + { + m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); + return false; + } + UserProfileData userProfile = m_userService.GetUserProfile(userID); + if (userProfile != null && userProfile.CurrentAgent != null && + userProfile.CurrentAgent.SessionID == sessionID) + { + m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); + return true; + } + + m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); + return false; + } + else + { + return true; + } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs index 7eeece9..bfdbcfc 100644 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGStandaloneInventoryService.cs @@ -1,316 +1,316 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -using System; -using System.Collections.Generic; -using System.Net; -using System.Reflection; - -using log4net; -using Nini.Config; - -using OpenMetaverse; - -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Servers; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules.Hypergrid -{ - public class HGStandaloneInventoryService : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool initialized = false; - private static bool enabled = false; - - Scene m_scene; - //InventoryService m_inventoryService; - - #region IRegionModule interface - - public void Initialise(Scene scene, IConfigSource config) - { - if (!initialized) - { - initialized = true; - m_scene = scene; - - // This module is only on for standalones - enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); - } - } - - public void PostInitialise() - { - if (enabled) - { - m_log.Info("[HGStandaloneInvService]: Starting..."); +/** + * Copyright (c) 2008, Contributors. All rights reserved. + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Reflection; + +using log4net; +using Nini.Config; + +using OpenMetaverse; + +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Servers; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.Environment.Modules.Hypergrid +{ + public class HGStandaloneInventoryService : IRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool initialized = false; + private static bool enabled = false; + + Scene m_scene; + //InventoryService m_inventoryService; + + #region IRegionModule interface + + public void Initialise(Scene scene, IConfigSource config) + { + if (!initialized) + { + initialized = true; + m_scene = scene; + + // This module is only on for standalones + enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); + } + } + + public void PostInitialise() + { + if (enabled) + { + m_log.Info("[HGStandaloneInvService]: Starting..."); //m_inventoryService = new InventoryService(m_scene); - new InventoryService(m_scene); - } - } - - public void Close() - { - } - - public string Name - { - get { return "HGStandaloneInventoryService"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - } - - public class InventoryService - { - private InventoryServiceBase m_inventoryService; - private IUserService m_userService; - private bool m_doLookup = false; - - public bool DoLookup - { - get { return m_doLookup; } - set { m_doLookup = value; } - } - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public InventoryService(Scene m_scene) - { - m_inventoryService = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; - m_userService = m_scene.CommsManager.UserService; - AddHttpHandlers(m_scene); - - } - - protected void AddHttpHandlers(Scene m_scene) - { - m_scene.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); - - m_scene.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/NewFolder/", m_inventoryService.AddFolder, CheckAuthSession)); - - m_scene.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, CheckAuthSession)); - - m_scene.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/MoveFolder/", m_inventoryService.MoveFolder, CheckAuthSession)); - - m_scene.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, CheckAuthSession)); - - m_scene.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/NewItem/", m_inventoryService.AddItem, CheckAuthSession)); - - m_scene.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/DeleteItem/", m_inventoryService.DeleteItem, CheckAuthSession)); - - //// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g - //// system folders such as Objects, Textures), but it now returns the entire inventory skeleton. - //// It would have been better to rename this request, but complexities in the BaseHttpServer - //// (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier - //// to do this for now. - //m_scene.AddStreamHandler( - // new RestDeserialiseTrustedHandler> - // ("POST", "/RootFolders/", GetInventorySkeleton, CheckTrustSource)); - - //// for persistent active gestures - //m_scene.AddStreamHandler( - // new RestDeserialiseTrustedHandler> - // ("POST", "/ActiveGestures/", GetActiveGestures, CheckTrustSource)); - } - - - ///// - ///// Check that the source of an inventory request is one that we trust. - ///// - ///// - ///// - //public bool CheckTrustSource(IPEndPoint peer) - //{ - // if (m_doLookup) - // { - // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); - // UriBuilder ub = new UriBuilder(m_userserver_url); - // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); - // foreach (IPAddress uaddr in uaddrs) - // { - // if (uaddr.Equals(peer.Address)) - // { - // return true; - // } - // } - - // m_log.WarnFormat( - // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", - // peer); - - // return false; - // } - // else - // { - // return true; - // } - //} - - /// - /// Check that the source of an inventory request for a particular agent is a current session belonging to - /// that agent. - /// - /// - /// - /// - public bool CheckAuthSession(string session_id, string avatar_id) - { - if (m_doLookup) - { - m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); - UUID userID = UUID.Zero; - UUID sessionID = UUID.Zero; - UUID.TryParse(avatar_id, out userID); - UUID.TryParse(session_id, out sessionID); - if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) - { - m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); - return false; - } - UserProfileData userProfile = m_userService.GetUserProfile(userID); - if (userProfile != null && userProfile.CurrentAgent != null && - userProfile.CurrentAgent.SessionID == sessionID) - { - m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); - return true; - } - - m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); - return false; - } - else - { - return true; - } - } - - - /// - /// Return a user's entire inventory - /// - /// - /// The user's inventory. If an inventory cannot be found then an empty collection is returned. - public InventoryCollection GetUserInventory(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - - m_log.Info("[HGStandaloneInvService]: Processing request for inventory of " + userID); - - // Uncomment me to simulate a slow responding inventory server - //Thread.Sleep(16000); - - InventoryCollection invCollection = new InventoryCollection(); - - List allFolders = ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); - - if (null == allFolders) - { - m_log.WarnFormat("[HGStandaloneInvService]: No inventory found for user {0}", rawUserID); - - return invCollection; - } - - List allItems = new List(); - - foreach (InventoryFolderBase folder in allFolders) - { - List items = ((InventoryServiceBase)m_inventoryService).RequestFolderItems(folder.ID); - - if (items != null) - { - allItems.InsertRange(0, items); - } - } - - invCollection.UserID = userID; - invCollection.Folders = allFolders; - invCollection.Items = allItems; - - // foreach (InventoryFolderBase folder in invCollection.Folders) - // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); - // } - // - // foreach (InventoryItemBase item in invCollection.Items) - // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); - // } - - m_log.InfoFormat( - "[HGStandaloneInvService]: Sending back inventory response to user {0} containing {1} folders and {2} items", - invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); - - return invCollection; - } - - /// - /// Guid to UUID wrapper for same name IInventoryServices method - /// - /// - /// - public List GetInventorySkeleton(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - return ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); - } - - public List GetActiveGestures(Guid rawUserID) - { - UUID userID = new UUID(rawUserID); - - m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); - - return ((InventoryServiceBase)m_inventoryService).GetActiveGestures(userID); - } - } -} + new InventoryService(m_scene); + } + } + + public void Close() + { + } + + public string Name + { + get { return "HGStandaloneInventoryService"; } + } + + public bool IsSharedModule + { + get { return true; } + } + + #endregion + + } + + public class InventoryService + { + private InventoryServiceBase m_inventoryService; + private IUserService m_userService; + private bool m_doLookup = false; + + public bool DoLookup + { + get { return m_doLookup; } + set { m_doLookup = value; } + } + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public InventoryService(Scene m_scene) + { + m_inventoryService = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; + m_userService = m_scene.CommsManager.UserService; + AddHttpHandlers(m_scene); + + } + + protected void AddHttpHandlers(Scene m_scene) + { + m_scene.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); + + m_scene.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/NewFolder/", m_inventoryService.AddFolder, CheckAuthSession)); + + m_scene.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, CheckAuthSession)); + + m_scene.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/MoveFolder/", m_inventoryService.MoveFolder, CheckAuthSession)); + + m_scene.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, CheckAuthSession)); + + m_scene.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/NewItem/", m_inventoryService.AddItem, CheckAuthSession)); + + m_scene.AddStreamHandler( + new RestDeserialiseSecureHandler( + "POST", "/DeleteItem/", m_inventoryService.DeleteItem, CheckAuthSession)); + + //// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g + //// system folders such as Objects, Textures), but it now returns the entire inventory skeleton. + //// It would have been better to rename this request, but complexities in the BaseHttpServer + //// (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier + //// to do this for now. + //m_scene.AddStreamHandler( + // new RestDeserialiseTrustedHandler> + // ("POST", "/RootFolders/", GetInventorySkeleton, CheckTrustSource)); + + //// for persistent active gestures + //m_scene.AddStreamHandler( + // new RestDeserialiseTrustedHandler> + // ("POST", "/ActiveGestures/", GetActiveGestures, CheckTrustSource)); + } + + + ///// + ///// Check that the source of an inventory request is one that we trust. + ///// + ///// + ///// + //public bool CheckTrustSource(IPEndPoint peer) + //{ + // if (m_doLookup) + // { + // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); + // UriBuilder ub = new UriBuilder(m_userserver_url); + // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); + // foreach (IPAddress uaddr in uaddrs) + // { + // if (uaddr.Equals(peer.Address)) + // { + // return true; + // } + // } + + // m_log.WarnFormat( + // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", + // peer); + + // return false; + // } + // else + // { + // return true; + // } + //} + + /// + /// Check that the source of an inventory request for a particular agent is a current session belonging to + /// that agent. + /// + /// + /// + /// + public bool CheckAuthSession(string session_id, string avatar_id) + { + if (m_doLookup) + { + m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); + UUID userID = UUID.Zero; + UUID sessionID = UUID.Zero; + UUID.TryParse(avatar_id, out userID); + UUID.TryParse(session_id, out sessionID); + if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) + { + m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); + return false; + } + UserProfileData userProfile = m_userService.GetUserProfile(userID); + if (userProfile != null && userProfile.CurrentAgent != null && + userProfile.CurrentAgent.SessionID == sessionID) + { + m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); + return true; + } + + m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); + return false; + } + else + { + return true; + } + } + + + /// + /// Return a user's entire inventory + /// + /// + /// The user's inventory. If an inventory cannot be found then an empty collection is returned. + public InventoryCollection GetUserInventory(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + + m_log.Info("[HGStandaloneInvService]: Processing request for inventory of " + userID); + + // Uncomment me to simulate a slow responding inventory server + //Thread.Sleep(16000); + + InventoryCollection invCollection = new InventoryCollection(); + + List allFolders = ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); + + if (null == allFolders) + { + m_log.WarnFormat("[HGStandaloneInvService]: No inventory found for user {0}", rawUserID); + + return invCollection; + } + + List allItems = new List(); + + foreach (InventoryFolderBase folder in allFolders) + { + List items = ((InventoryServiceBase)m_inventoryService).RequestFolderItems(folder.ID); + + if (items != null) + { + allItems.InsertRange(0, items); + } + } + + invCollection.UserID = userID; + invCollection.Folders = allFolders; + invCollection.Items = allItems; + + // foreach (InventoryFolderBase folder in invCollection.Folders) + // { + // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); + // } + // + // foreach (InventoryItemBase item in invCollection.Items) + // { + // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); + // } + + m_log.InfoFormat( + "[HGStandaloneInvService]: Sending back inventory response to user {0} containing {1} folders and {2} items", + invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); + + return invCollection; + } + + /// + /// Guid to UUID wrapper for same name IInventoryServices method + /// + /// + /// + public List GetInventorySkeleton(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + return ((InventoryServiceBase)m_inventoryService).GetInventorySkeleton(userID); + } + + public List GetActiveGestures(Guid rawUserID) + { + UUID userID = new UUID(rawUserID); + + m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); + + return ((InventoryServiceBase)m_inventoryService).GetActiveGestures(userID); + } + } +} diff --git a/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs index 7f8f285..e642b7f 100644 --- a/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/Environment/Modules/Hypergrid/HGWorldMapModule.cs @@ -1,178 +1,178 @@ -/** - * Copyright (c) 2008, Contributors. All rights reserved. - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the Organizations nor the names of Individual - * Contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using System.Net; -using System.Reflection; -using System.Threading; -using OpenMetaverse; -using OpenMetaverse.Imaging; -using OpenMetaverse.StructuredData; -using log4net; -using Nini.Config; -using Nwc.XmlRpc; - -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; -using OpenSim.Framework.Servers; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules.World.WorldMap; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Types; -using Caps = OpenSim.Framework.Communications.Capabilities.Caps; - -using OSD = OpenMetaverse.StructuredData.OSD; -using OSDMap = OpenMetaverse.StructuredData.OSDMap; -using OSDArray = OpenMetaverse.StructuredData.OSDArray; - -namespace OpenSim.Region.Environment.Modules.Hypergrid -{ - public class HGWorldMapModule : WorldMapModule, IRegionModule - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - #region IRegionModule Members - - public override void Initialise(Scene scene, IConfigSource config) - { - IConfig startupConfig = config.Configs["Startup"]; - if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") - m_Enabled = true; - - if (!m_Enabled) - return; - m_log.Info("[HGMap] Initializing..."); - m_scene = scene; - } - - - public override string Name - { - get { return "HGWorldMap"; } - } - - - #endregion - - /// - /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates - /// - /// - /// - /// - /// - public override void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) - { - // - // WARNING!!! COPY & PASTE FROM SUPERCLASS - // The only difference is at the very end - // - - m_log.Info("[HGMap]: Request map blocks " + minX + "-" + maxX + " " + minY + "-" + maxY); - - //m_scene.ForEachScenePresence(delegate (ScenePresence sp) { - // if (!sp.IsChildAgent && sp.UUID == remoteClient.AgentId) - // { - // Console.WriteLine("XXX Root agent"); - // DoRequestMapBlocks(remoteClient, minX, minY, maxX, maxY, flag); - // } - //}; - - List mapBlocks; - if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible - { - List response = new List(); - - // this should return one mapblock at most. But make sure: Look whether the one we requested is in there - mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); - if (mapBlocks != null) - { - foreach (MapBlockData block in mapBlocks) - { - if (block.X == minX && block.Y == minY) - { - // found it => add it to response - response.Add(block); - break; - } - } - } - response = mapBlocks; - if (response.Count == 0) - { - // response still empty => couldn't find the map-tile the user clicked on => tell the client - MapBlockData block = new MapBlockData(); - block.X = (ushort)minX; - block.Y = (ushort)minY; - block.Access = 254; // == not there - response.Add(block); - } - remoteClient.SendMapBlock(response, 0); - } - else - { - // normal mapblock request. Use the provided values - mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); - - // Different from super - FillInMap(mapBlocks, minX, minY, maxX, maxY); - // - - remoteClient.SendMapBlock(mapBlocks, flag); - } - } - - - private void FillInMap(List mapBlocks, int minX, int minY, int maxX, int maxY) - { - for (int x = minX; x <= maxX; x++) - for (int y = minY; y <= maxY; y++) - { - MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); }); - if (mblock == null) - { - mblock = new MapBlockData(); - mblock.X = (ushort)x; - mblock.Y = (ushort)y; - mblock.Name = ""; - mblock.Access = 254; // not here??? - mblock.MapImageId = UUID.Zero; - mapBlocks.Add(mblock); - } - } - } - } -} +/** + * Copyright (c) 2008, Contributors. All rights reserved. + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the Organizations nor the names of Individual + * Contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Net; +using System.Reflection; +using System.Threading; +using OpenMetaverse; +using OpenMetaverse.Imaging; +using OpenMetaverse.StructuredData; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; + +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Servers; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules.World.WorldMap; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Types; +using Caps = OpenSim.Framework.Communications.Capabilities.Caps; + +using OSD = OpenMetaverse.StructuredData.OSD; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; +using OSDArray = OpenMetaverse.StructuredData.OSDArray; + +namespace OpenSim.Region.Environment.Modules.Hypergrid +{ + public class HGWorldMapModule : WorldMapModule, IRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + #region IRegionModule Members + + public override void Initialise(Scene scene, IConfigSource config) + { + IConfig startupConfig = config.Configs["Startup"]; + if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") + m_Enabled = true; + + if (!m_Enabled) + return; + m_log.Info("[HGMap] Initializing..."); + m_scene = scene; + } + + + public override string Name + { + get { return "HGWorldMap"; } + } + + + #endregion + + /// + /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates + /// + /// + /// + /// + /// + public override void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) + { + // + // WARNING!!! COPY & PASTE FROM SUPERCLASS + // The only difference is at the very end + // + + m_log.Info("[HGMap]: Request map blocks " + minX + "-" + maxX + " " + minY + "-" + maxY); + + //m_scene.ForEachScenePresence(delegate (ScenePresence sp) { + // if (!sp.IsChildAgent && sp.UUID == remoteClient.AgentId) + // { + // Console.WriteLine("XXX Root agent"); + // DoRequestMapBlocks(remoteClient, minX, minY, maxX, maxY, flag); + // } + //}; + + List mapBlocks; + if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible + { + List response = new List(); + + // this should return one mapblock at most. But make sure: Look whether the one we requested is in there + mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); + if (mapBlocks != null) + { + foreach (MapBlockData block in mapBlocks) + { + if (block.X == minX && block.Y == minY) + { + // found it => add it to response + response.Add(block); + break; + } + } + } + response = mapBlocks; + if (response.Count == 0) + { + // response still empty => couldn't find the map-tile the user clicked on => tell the client + MapBlockData block = new MapBlockData(); + block.X = (ushort)minX; + block.Y = (ushort)minY; + block.Access = 254; // == not there + response.Add(block); + } + remoteClient.SendMapBlock(response, 0); + } + else + { + // normal mapblock request. Use the provided values + mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); + + // Different from super + FillInMap(mapBlocks, minX, minY, maxX, maxY); + // + + remoteClient.SendMapBlock(mapBlocks, flag); + } + } + + + private void FillInMap(List mapBlocks, int minX, int minY, int maxX, int maxY) + { + for (int x = minX; x <= maxX; x++) + for (int y = minY; y <= maxY; y++) + { + MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); }); + if (mblock == null) + { + mblock = new MapBlockData(); + mblock.X = (ushort)x; + mblock.Y = (ushort)y; + mblock.Name = ""; + mblock.Access = 254; // not here??? + mblock.MapImageId = UUID.Zero; + mapBlocks.Add(mblock); + } + } + } + } +} -- cgit v1.1