From ae4b02e1152b775dc1cdccd1abfbff44ab1a8949 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 25 Nov 2010 11:14:16 -0800 Subject: WARNING: LOTS OF CONFIGURATION CHANGES AFFECTING PRIMARILY HG CONFIGS. Added capability to preserve creator information on HG asset transfers. Added a new HGAssetService that is intended to be the one outside the firewall. It processes and filters the assets that go out of the grid. Also fixed the normal AssetService to do special things for the main instance (console commands, etc). Moved HGInventoryService to OpenSim.Services.HypergridService. Changed the way the login service gets the ServiceURL configs. --- .../Services/HypergridService/HGAssetService.cs | 181 +++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 OpenSim/Services/HypergridService/HGAssetService.cs (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs new file mode 100644 index 0000000..6e0d4cd --- /dev/null +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -0,0 +1,181 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * 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 OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 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.IO; +using System.Reflection; +using System.Xml; + +using Nini.Config; +using log4net; +using OpenMetaverse; + +using OpenSim.Framework; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Services.AssetService; + +namespace OpenSim.Services.HypergridService +{ + public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private string m_ProfileServiceURL; + private IUserAccountService m_UserAccountService; + + private UserAccountCache m_Cache; + + public HGAssetService(IConfigSource config) : base(config) + { + m_log.Debug("[HGAsset Service]: Starting"); + IConfig assetConfig = config.Configs["HGAssetService"]; + if (assetConfig == null) + throw new Exception("No HGAssetService configuration"); + + string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty); + if (userAccountsDll == string.Empty) + throw new Exception("Please specify UserAccountsService in HGAssetService configuration"); + + Object[] args = new Object[] { config }; + m_UserAccountService = ServerUtils.LoadPlugin(userAccountsDll, args); + if (m_UserAccountService == null) + throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); + + m_ProfileServiceURL = assetConfig.GetString("ProfileServerURI", string.Empty); + + m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); + } + + #region IAssetService overrides + public override AssetBase Get(string id) + { + AssetBase asset = base.Get(id); + + if (asset == null) + return null; + + if (asset.Metadata.Type == (sbyte)AssetType.Object) + asset.Data = AdjustIdentifiers(asset.Data); ; + + AdjustIdentifiers(asset.Metadata); + + return asset; + } + + public override AssetMetadata GetMetadata(string id) + { + AssetMetadata meta = base.GetMetadata(id); + + if (meta == null) + return null; + + AdjustIdentifiers(meta); + + return meta; + } + + public override byte[] GetData(string id) + { + byte[] data = base.GetData(id); + + if (data == null) + return null; + + return AdjustIdentifiers(data); + } + + //public virtual bool Get(string id, Object sender, AssetRetrieved handler) + + public override bool Delete(string id) + { + // NOGO + return false; + } + + #endregion + + protected void AdjustIdentifiers(AssetMetadata meta) + { + UserAccount creator = m_Cache.GetUser(meta.CreatorID); + if (creator != null) + meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; + + } + + protected byte[] AdjustIdentifiers(byte[] data) + { + string xml = Utils.BytesToString(data); + return Utils.StringToBytes(RewriteSOP(xml)); + } + + protected string RewriteSOP(string xml) + { + XmlDocument doc = new XmlDocument(); + doc.LoadXml(xml); + XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); + + foreach (XmlNode sop in sops) + { + UserAccount creator = null; + bool hasCreatorData = false; + XmlNodeList nodes = sop.ChildNodes; + foreach (XmlNode node in nodes) + { + if (node.Name == "CreatorID") + creator = m_Cache.GetUser(node.InnerText); + if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty) + hasCreatorData = true; + + //if (node.Name == "OwnerID") + //{ + // UserAccount owner = GetUser(node.InnerText); + // if (owner != null) + // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName; + //} + } + if (!hasCreatorData && creator != null) + { + XmlElement creatorData = doc.CreateElement("CreatorData"); + creatorData.InnerText = m_ProfileServiceURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; + sop.AppendChild(creatorData); + } + } + + using (StringWriter wr = new StringWriter()) + { + doc.Save(wr); + return wr.ToString(); + } + + } + + } + +} -- cgit v1.1 From 3292a2255882018b7fed3e80f430dc26892b92ea Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Nov 2010 22:06:34 -0800 Subject: Creator information preserved upon HG transfers. --- OpenSim/Services/HypergridService/HGAssetService.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 6e0d4cd..9b098a0 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -126,7 +126,6 @@ namespace OpenSim.Services.HypergridService UserAccount creator = m_Cache.GetUser(meta.CreatorID); if (creator != null) meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; - } protected byte[] AdjustIdentifiers(byte[] data) -- cgit v1.1 From f86c438653fc3c8356a8f0c43a055b1928183f02 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 29 Nov 2010 08:43:33 -0800 Subject: Preservation of creator information now also working in IARs. Cleaned up usage help. Moved Osp around, deleted unnecessary OspInventoryWrapperPlugin, added manipulation of SOP's xml representation in a generic ExternalRepresentationUtils function. --- .../Services/HypergridService/HGAssetService.cs | 44 +--------------------- 1 file changed, 2 insertions(+), 42 deletions(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 9b098a0..584ab6f 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -35,6 +35,7 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Serialization.External; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Services.AssetService; @@ -131,48 +132,7 @@ namespace OpenSim.Services.HypergridService protected byte[] AdjustIdentifiers(byte[] data) { string xml = Utils.BytesToString(data); - return Utils.StringToBytes(RewriteSOP(xml)); - } - - protected string RewriteSOP(string xml) - { - XmlDocument doc = new XmlDocument(); - doc.LoadXml(xml); - XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); - - foreach (XmlNode sop in sops) - { - UserAccount creator = null; - bool hasCreatorData = false; - XmlNodeList nodes = sop.ChildNodes; - foreach (XmlNode node in nodes) - { - if (node.Name == "CreatorID") - creator = m_Cache.GetUser(node.InnerText); - if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty) - hasCreatorData = true; - - //if (node.Name == "OwnerID") - //{ - // UserAccount owner = GetUser(node.InnerText); - // if (owner != null) - // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName; - //} - } - if (!hasCreatorData && creator != null) - { - XmlElement creatorData = doc.CreateElement("CreatorData"); - creatorData.InnerText = m_ProfileServiceURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; - sop.AppendChild(creatorData); - } - } - - using (StringWriter wr = new StringWriter()) - { - doc.Save(wr); - return wr.ToString(); - } - + return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero)); } } -- cgit v1.1 From 7d24dbca3c85cafe182648139ab132563e3e1cdd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 1 Dec 2010 16:01:22 -0800 Subject: Added some comments. Better than listening to the boring speaker... --- OpenSim/Services/HypergridService/HGAssetService.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 584ab6f..a82d0d1 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -42,6 +42,11 @@ using OpenSim.Services.AssetService; namespace OpenSim.Services.HypergridService { + /// + /// Hypergrid asset service. It serves the IAssetService interface, + /// but implements it in ways that are appropriate for inter-grid + /// asset exchanges. + /// public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService { private static readonly ILog m_log = -- cgit v1.1 From bbd0e68c06b79acf0781d78e81fa292f549d676b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 15 Oct 2011 20:23:26 -0700 Subject: Guard HGAssetService against uninitialized variables and null arguments. --- OpenSim/Services/HypergridService/HGAssetService.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index a82d0d1..e518329 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -129,6 +129,9 @@ namespace OpenSim.Services.HypergridService protected void AdjustIdentifiers(AssetMetadata meta) { + if (meta == null || m_Cache == null) + return; + UserAccount creator = m_Cache.GetUser(meta.CreatorID); if (creator != null) meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; -- cgit v1.1 From 8bdd80abfa3830142b16615d97d555dad417e08d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 Jan 2012 09:56:35 -0800 Subject: HG: normalize all externalized user ULRs to be the Home URL, i.e. the location of the user's UAS. This corrects an earlier design which had some cases pointing to the profile server. WARNING: CONFIGURATION CHANGES in both the sims (*Common.ini) and the Robust configs (Robust.HG.ini). Please check diff of the example files, but basically all vars that were pointing to profile should point to the UAS instead and should be called HomeURI. --- OpenSim/Services/HypergridService/HGAssetService.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index e518329..22e233a 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -53,7 +53,7 @@ namespace OpenSim.Services.HypergridService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private string m_ProfileServiceURL; + private string m_HomeURL; private IUserAccountService m_UserAccountService; private UserAccountCache m_Cache; @@ -74,7 +74,10 @@ namespace OpenSim.Services.HypergridService if (m_UserAccountService == null) throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); - m_ProfileServiceURL = assetConfig.GetString("ProfileServerURI", string.Empty); + // legacy configuration [obsolete] + m_HomeURL = assetConfig.GetString("ProfileServerURI", string.Empty); + // Preferred + m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL); m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); } @@ -134,13 +137,13 @@ namespace OpenSim.Services.HypergridService UserAccount creator = m_Cache.GetUser(meta.CreatorID); if (creator != null) - meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; + meta.CreatorID = meta.CreatorID + ";" + m_HomeURL + "/" + creator.FirstName + " " + creator.LastName; } protected byte[] AdjustIdentifiers(byte[] data) { string xml = Utils.BytesToString(data); - return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero)); + return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_HomeURL, m_Cache, UUID.Zero)); } } -- cgit v1.1 From 8131a24cde3f3877b3b8dd850871c57c17b2b216 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 27 Mar 2012 10:08:13 -0700 Subject: Send the config section name up to the service classes themselves (XInventory and Assets). --- OpenSim/Services/HypergridService/HGAssetService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 22e233a..db98166 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -58,10 +58,10 @@ namespace OpenSim.Services.HypergridService private UserAccountCache m_Cache; - public HGAssetService(IConfigSource config) : base(config) + public HGAssetService(IConfigSource config, string configName) : base(config, configName) { m_log.Debug("[HGAsset Service]: Starting"); - IConfig assetConfig = config.Configs["HGAssetService"]; + IConfig assetConfig = config.Configs[configName]; if (assetConfig == null) throw new Exception("No HGAssetService configuration"); -- cgit v1.1 From 3089b6d824f1d4eb25ba12c5fd037153fdc92e1e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 20 Sep 2012 15:49:22 -0700 Subject: More HG2.0: Added permission policies in HGAsset Service based on asset types. The policies are given in the config. This is only half of the story. The other half, pertaining to exports/imports made by the sim, will be done next. --- .../Services/HypergridService/HGAssetService.cs | 79 +++++++++++++++++++++- 1 file changed, 76 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index db98166..d6541c4 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -58,6 +58,9 @@ namespace OpenSim.Services.HypergridService private UserAccountCache m_Cache; + private bool[] m_DisallowGET, m_DisallowPOST; + private string[] m_AssetTypeNames; + public HGAssetService(IConfigSource config, string configName) : base(config, configName) { m_log.Debug("[HGAsset Service]: Starting"); @@ -80,6 +83,34 @@ namespace OpenSim.Services.HypergridService m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL); m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); + + // Permissions + Type enumType = typeof(AssetType); + m_AssetTypeNames = Enum.GetNames(enumType); + for (int i = 0; i < m_AssetTypeNames.Length; i++) + m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower(); + int n = Enum.GetValues(enumType).Length; + m_DisallowGET = new bool[n]; + m_DisallowPOST = new bool[n]; + + LoadPermsFromConfig(assetConfig, "DisallowGET", m_DisallowGET); + LoadPermsFromConfig(assetConfig, "DisallowPOST", m_DisallowPOST); + + } + + private void LoadPermsFromConfig(IConfig assetConfig, string variable, bool[] bitArray) + { + string perms = assetConfig.GetString(variable, String.Empty); + string[] parts = perms.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries); + foreach (string s in parts) + { + int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower()); + if (index >= 0) + bitArray[index] = true; + else + m_log.WarnFormat("[HGAsset Service]: Invalid AssetType {0}", s); + } + } #region IAssetService overrides @@ -90,6 +121,9 @@ namespace OpenSim.Services.HypergridService if (asset == null) return null; + if (!AllowedGet(asset.Type)) + return null; + if (asset.Metadata.Type == (sbyte)AssetType.Object) asset.Data = AdjustIdentifiers(asset.Data); ; @@ -112,16 +146,27 @@ namespace OpenSim.Services.HypergridService public override byte[] GetData(string id) { - byte[] data = base.GetData(id); + AssetBase asset = Get(id); - if (data == null) + if (asset == null) return null; - return AdjustIdentifiers(data); + if (!AllowedGet(asset.Type)) + return null; + + return asset.Data; } //public virtual bool Get(string id, Object sender, AssetRetrieved handler) + public override string Store(AssetBase asset) + { + if (!AllowedPost(asset.Type)) + return UUID.Zero.ToString(); + + return base.Store(asset); + } + public override bool Delete(string id) { // NOGO @@ -130,6 +175,34 @@ namespace OpenSim.Services.HypergridService #endregion + protected bool AllowedGet(sbyte type) + { + string assetTypeName = ((AssetType)type).ToString(); + + int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower()); + if (index >= 0 && m_DisallowGET[index]) + { + m_log.DebugFormat("[HGAsset Service]: GET denied: service does not allow export of AssetType {0}", assetTypeName); + return false; + } + + return true; + } + + protected bool AllowedPost(sbyte type) + { + string assetTypeName = ((AssetType)type).ToString(); + + int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower()); + if (index >= 0 && m_DisallowPOST[index]) + { + m_log.DebugFormat("[HGAsset Service]: POST denied: service does not allow import of AssetType {0}", assetTypeName); + return false; + } + + return true; + } + protected void AdjustIdentifiers(AssetMetadata meta) { if (meta == null || m_Cache == null) -- cgit v1.1 From e379566e6e3bed0d7001f099a5ea8dfd648d76cf Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 20 Sep 2012 19:50:57 -0700 Subject: Improvement over last commit: refactor the asset permissions code, so that it can be used by both the HG Asset Service and the simulator. Also renamed the config vars to something more intuitive --- .../Services/HypergridService/HGAssetService.cs | 63 ++-------------------- 1 file changed, 5 insertions(+), 58 deletions(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index d6541c4..f1275a0 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -58,8 +58,7 @@ namespace OpenSim.Services.HypergridService private UserAccountCache m_Cache; - private bool[] m_DisallowGET, m_DisallowPOST; - private string[] m_AssetTypeNames; + private AssetPermissions m_AssetPerms; public HGAssetService(IConfigSource config, string configName) : base(config, configName) { @@ -85,31 +84,7 @@ namespace OpenSim.Services.HypergridService m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); // Permissions - Type enumType = typeof(AssetType); - m_AssetTypeNames = Enum.GetNames(enumType); - for (int i = 0; i < m_AssetTypeNames.Length; i++) - m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower(); - int n = Enum.GetValues(enumType).Length; - m_DisallowGET = new bool[n]; - m_DisallowPOST = new bool[n]; - - LoadPermsFromConfig(assetConfig, "DisallowGET", m_DisallowGET); - LoadPermsFromConfig(assetConfig, "DisallowPOST", m_DisallowPOST); - - } - - private void LoadPermsFromConfig(IConfig assetConfig, string variable, bool[] bitArray) - { - string perms = assetConfig.GetString(variable, String.Empty); - string[] parts = perms.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries); - foreach (string s in parts) - { - int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower()); - if (index >= 0) - bitArray[index] = true; - else - m_log.WarnFormat("[HGAsset Service]: Invalid AssetType {0}", s); - } + m_AssetPerms = new AssetPermissions(assetConfig); } @@ -121,7 +96,7 @@ namespace OpenSim.Services.HypergridService if (asset == null) return null; - if (!AllowedGet(asset.Type)) + if (!m_AssetPerms.AllowedExport(asset.Type)) return null; if (asset.Metadata.Type == (sbyte)AssetType.Object) @@ -151,7 +126,7 @@ namespace OpenSim.Services.HypergridService if (asset == null) return null; - if (!AllowedGet(asset.Type)) + if (!m_AssetPerms.AllowedExport(asset.Type)) return null; return asset.Data; @@ -161,7 +136,7 @@ namespace OpenSim.Services.HypergridService public override string Store(AssetBase asset) { - if (!AllowedPost(asset.Type)) + if (!m_AssetPerms.AllowedImport(asset.Type)) return UUID.Zero.ToString(); return base.Store(asset); @@ -175,34 +150,6 @@ namespace OpenSim.Services.HypergridService #endregion - protected bool AllowedGet(sbyte type) - { - string assetTypeName = ((AssetType)type).ToString(); - - int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower()); - if (index >= 0 && m_DisallowGET[index]) - { - m_log.DebugFormat("[HGAsset Service]: GET denied: service does not allow export of AssetType {0}", assetTypeName); - return false; - } - - return true; - } - - protected bool AllowedPost(sbyte type) - { - string assetTypeName = ((AssetType)type).ToString(); - - int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower()); - if (index >= 0 && m_DisallowPOST[index]) - { - m_log.DebugFormat("[HGAsset Service]: POST denied: service does not allow import of AssetType {0}", assetTypeName); - return false; - } - - return true; - } - protected void AdjustIdentifiers(AssetMetadata meta) { if (meta == null || m_Cache == null) -- cgit v1.1 From 5f97b3e1d9775a88c1d952f1d599254969a262d2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 21 Sep 2012 06:41:32 -0700 Subject: Minor: change the return value of unsuccessful posts to string.Empty. --- OpenSim/Services/HypergridService/HGAssetService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index f1275a0..84dec8d 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -137,7 +137,7 @@ namespace OpenSim.Services.HypergridService public override string Store(AssetBase asset) { if (!m_AssetPerms.AllowedImport(asset.Type)) - return UUID.Zero.ToString(); + return string.Empty; return base.Store(asset); } -- cgit v1.1 From 0ff61341e479423125daa180eb7ee83bd643939b Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 31 Oct 2013 11:17:28 +0200 Subject: HGAssetService searches for the "HomeURI" setting in several sections: Startup, Hypergrid, HGAssetService Resolves http://opensimulator.org/mantis/view.php?id=6940 --- OpenSim/Services/HypergridService/HGAssetService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 84dec8d..5c804d4 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -76,10 +76,10 @@ namespace OpenSim.Services.HypergridService if (m_UserAccountService == null) throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); - // legacy configuration [obsolete] - m_HomeURL = assetConfig.GetString("ProfileServerURI", string.Empty); - // Preferred - m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL); + m_HomeURL = Util.GetConfigVarFromSections(config, "HomeURI", + new string[] { "Startup", "Hypergrid", configName }, string.Empty); + if (m_HomeURL == string.Empty) + throw new Exception("[HGAssetService] No HomeURI specified"); m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); -- cgit v1.1 From aeae34505f5f306bbf4d9f3db19db8a26ac5e63d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 6 Nov 2014 01:15:22 +0000 Subject: When processing incoming attachments via HG, if a request for uuid gathering or final asset import takes too long remove remaining requests from same user to prevent hold up of other user's incoming attachments. This improves upon the earlier naive simply queueing immplementation. Threshold is 30 seconds. If this happens to a user they can relog and fetch will be reattempted. --- OpenSim/Services/HypergridService/HGAssetService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 5c804d4..b57f8d8 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -100,7 +100,7 @@ namespace OpenSim.Services.HypergridService return null; if (asset.Metadata.Type == (sbyte)AssetType.Object) - asset.Data = AdjustIdentifiers(asset.Data); ; + asset.Data = AdjustIdentifiers(asset.Data); AdjustIdentifiers(asset.Metadata); -- cgit v1.1 From 1abbad71b4603245e5481c11e3ce55f57b64935f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 5 May 2015 20:59:09 -0700 Subject: Refactored some code that is used in two different dlls related to SOP rewriting. Also added some unit tests that relate to mantis #7514 --- OpenSim/Services/HypergridService/HGAssetService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index b57f8d8..a829932 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -163,7 +163,7 @@ namespace OpenSim.Services.HypergridService protected byte[] AdjustIdentifiers(byte[] data) { string xml = Utils.BytesToString(data); - return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_HomeURL, m_Cache, UUID.Zero)); + return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero)); } } -- cgit v1.1 From e5a1243abc04c3f6f62e94425fea25b2ad84b577 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 1 Aug 2015 18:58:05 -0700 Subject: Mantis #7657 and #7514. This should alleviate the problem of bad object assets being passed around via HG and archives. No guarantees that all the leaks have been found, but at least it detects and fixes these bad assets upon: (1) storing and getting assets over HG -- assuming the core HG asset service is being used (not the case with OSGrid!) (2) importing assets via OAR and IAR Instantiation of bad assets now should also work, instead of producing an exception, but the bad assets themselves aren't being fixed in the DB. That should be done with a cleaning tool -- see Perl script in Mantis #7657. Virus! --- .../Services/HypergridService/HGAssetService.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'OpenSim/Services/HypergridService/HGAssetService.cs') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index a829932..b83fb1e 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -129,6 +129,14 @@ namespace OpenSim.Services.HypergridService if (!m_AssetPerms.AllowedExport(asset.Type)) return null; + // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) + // Fix bad assets before sending them elsewhere + if (asset.Type == (int)AssetType.Object && asset.Data != null) + { + string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data)); + asset.Data = Utils.StringToBytes(xml); + } + return asset.Data; } @@ -139,6 +147,14 @@ namespace OpenSim.Services.HypergridService if (!m_AssetPerms.AllowedImport(asset.Type)) return string.Empty; + // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) + // Fix bad assets before storing on this server + if (asset.Type == (int)AssetType.Object && asset.Data != null) + { + string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data)); + asset.Data = Utils.StringToBytes(xml); + } + return base.Store(asset); } @@ -160,9 +176,15 @@ namespace OpenSim.Services.HypergridService meta.CreatorID = meta.CreatorID + ";" + m_HomeURL + "/" + creator.FirstName + " " + creator.LastName; } + // Only for Object protected byte[] AdjustIdentifiers(byte[] data) { string xml = Utils.BytesToString(data); + + // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) + // Fix bad assets before sending them elsewhere + xml = ExternalRepresentationUtils.SanitizeXml(xml); + return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero)); } -- cgit v1.1