From decd51f0811639169d63cb80fcc7dec931ea9530 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Dec 2009 08:11:26 -0800 Subject: [PATCH 1/6] Attempt at fixing mantis #4411. --- .../Cache/UserProfileCacheService.cs | 16 +++++++++++++++- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 9e12d94849..cebd571cdc 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -139,9 +139,16 @@ namespace OpenSim.Framework.Communications.Cache else { UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); - + if (userProfile != null) + { + if (userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") + userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; + if (userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") + userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; + return AddToCaches(userProfile); + } else return null; } @@ -169,7 +176,14 @@ namespace OpenSim.Framework.Communications.Cache { UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); if (userProfile != null) + { + if (userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") + userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; + if (userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") + userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; + return AddToCaches(userProfile); + } else return null; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index f2d8579c83..4d347cdfbc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -155,7 +155,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); // Yikes!! Remove this as soon as user services get refactored - LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.UserURL; + LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.AssetURL; LocalInventoryServerURI = scene.CommsManager.NetworkServersInfo.InventoryURL; LocalUserServerURI = scene.CommsManager.NetworkServersInfo.UserURL; HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI); From 5f0478c4c445cf049f8668bb82468fa30d783baf Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Dec 2009 08:28:24 -0800 Subject: [PATCH 2/6] Fix to make [bad] tests happy. --- .../Communications/Cache/UserProfileCacheService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index cebd571cdc..29a9e149de 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -142,9 +142,9 @@ namespace OpenSim.Framework.Communications.Cache if (userProfile != null) { - if (userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") + if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; - if (userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") + if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; return AddToCaches(userProfile); @@ -177,9 +177,9 @@ namespace OpenSim.Framework.Communications.Cache UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); if (userProfile != null) { - if (userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") + if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; - if (userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") + if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; return AddToCaches(userProfile); From 4bbe9a51ac8c4412b41c4e271a0d2652ca52e118 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Dec 2009 09:09:36 -0800 Subject: [PATCH 3/6] Added an image uuid to objects marked "Show in search". Only works for boxes. --- OpenSim/Region/DataSnapshot/ObjectSnapshot.cs | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs index 963909545d..76dac6107e 100644 --- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs @@ -45,6 +45,10 @@ namespace OpenSim.Region.DataSnapshot.Providers private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_stale = true; + private static UUID m_DefaultImage = new UUID("89556747-24cb-43ed-920b-47caed15465f"); + private static UUID m_BlankImage = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); + + public void Initialize(Scene scene, DataSnapshotManager parent) { m_scene = scene; @@ -142,6 +146,19 @@ namespace OpenSim.Region.DataSnapshot.Providers node.InnerText = land.LandData.GlobalID.ToString(); xmlobject.AppendChild(node); + node = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); + Vector3 loc = obj.AbsolutePosition; + node.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); + xmlobject.AppendChild(node); + + string bestImage = GuessImage(obj); + if (bestImage != string.Empty) + { + node = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); + node.InnerText = bestImage; + xmlobject.AppendChild(node); + } + parent.AppendChild(xmlobject); } } @@ -173,5 +190,58 @@ namespace OpenSim.Region.DataSnapshot.Providers } public event ProviderStale OnStale; + + /// + /// Guesses the best image, based on a simple heuristic. It guesses only for boxes. + /// We're optimizing for boxes, because those are the most common objects + /// marked "Show in search" -- boxes with content inside.For other shapes, + /// it's really hard to tell which texture should be grabbed. + /// + /// + /// + private string GuessImage(SceneObjectGroup sog) + { + string bestguess = string.Empty; + Dictionary counts = new Dictionary(); + if (sog.RootPart.Shape != null && sog.RootPart.Shape.ProfileShape == ProfileShape.Square && + sog.RootPart.Shape.Textures != null && sog.RootPart.Shape.Textures.FaceTextures != null) + { + if (sog.RootPart.Shape.Textures.DefaultTexture.TextureID != UUID.Zero && + sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage && + sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage && + sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50) + { + counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8; + } + + foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures) + { + if (tentry != null) + { + if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) + { + int c = 0; + counts.TryGetValue(tentry.TextureID, out c); + counts[tentry.TextureID] = c + 1; + // decrease the default texture count + if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID)) + counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1; + } + } + } + + // Let's pick the most unique texture + int min = 9999; + foreach (KeyValuePair kv in counts) + { + if (kv.Value < min && kv.Value >= 1) + { + bestguess = kv.Key.ToString(); + min = kv.Value; + } + } + } + return bestguess; + } } } From d20fe7bfdd41e3526e03a384b14b84a0fd92a1c2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Dec 2009 20:06:42 -0800 Subject: [PATCH 4/6] A couple of more sanity guards, but this won't fix things when user profile fetching is borked. --- OpenSim/Framework/Communications/Clients/AuthClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index 6b4bfec83f..adae637c0d 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -136,7 +136,7 @@ namespace OpenSim.Framework.Communications.Clients } Hashtable responseData = (Hashtable)UserResp.Value; - if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") + if (responseData != null && responseData.ContainsKey("auth_session") && responseData["auth_session"] != null && responseData["auth_session"].ToString() == "TRUE") { //System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); return true; From 62ec60ca76e2331b6dd91b4ab68420fd859ea76c Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 6 Dec 2009 17:56:29 -0600 Subject: [PATCH 5/6] Getting rid of a bunch of old classes, that are likely left over from the ROBUST change. Signed-off-by: Melanie --- OpenSim/Framework/AssetConfig.cs | 87 ----- OpenSim/Framework/AssetRequest.cs | 37 --- OpenSim/Framework/AssetStorage.cs | 48 --- OpenSim/Framework/IAssetCache.cs | 114 ------- OpenSim/Framework/InventoryConfig.cs | 113 ------- OpenSim/Framework/NeighbourInfo.cs | 42 --- OpenSim/Framework/Parallel.cs | 211 ------------ OpenSim/Framework/ProxyCodec.cs | 68 ---- OpenSim/Framework/RegionUpData.cs | 68 ---- OpenSim/Framework/Remoting.cs | 134 -------- OpenSim/Framework/SerializableInventory.cs | 58 ---- OpenSim/Framework/WearableItem.cs | 355 --------------------- 12 files changed, 1335 deletions(-) delete mode 100644 OpenSim/Framework/AssetConfig.cs delete mode 100644 OpenSim/Framework/AssetRequest.cs delete mode 100644 OpenSim/Framework/AssetStorage.cs delete mode 100644 OpenSim/Framework/IAssetCache.cs delete mode 100644 OpenSim/Framework/InventoryConfig.cs delete mode 100644 OpenSim/Framework/NeighbourInfo.cs delete mode 100644 OpenSim/Framework/Parallel.cs delete mode 100644 OpenSim/Framework/ProxyCodec.cs delete mode 100644 OpenSim/Framework/RegionUpData.cs delete mode 100644 OpenSim/Framework/Remoting.cs delete mode 100644 OpenSim/Framework/SerializableInventory.cs delete mode 100644 OpenSim/Framework/WearableItem.cs diff --git a/OpenSim/Framework/AssetConfig.cs b/OpenSim/Framework/AssetConfig.cs deleted file mode 100644 index 9ee41a14f1..0000000000 --- a/OpenSim/Framework/AssetConfig.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.IO; - -namespace OpenSim.Framework -{ - /// - /// AssetConfig -- For Asset Server Configuration - /// - public class AssetConfig:ConfigBase - { - public string DatabaseConnect = String.Empty; - public string DatabaseProvider = String.Empty; - public uint HttpPort = ConfigSettings.DefaultAssetServerHttpPort; - public string AssetSetsLocation = string.Empty; - - public AssetConfig(string description, string filename) - { - m_configMember = - new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true); - m_configMember.performConfigurationRetrieve(); - } - - public void loadConfigurationOptions() - { - m_configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "DLL for database provider", "OpenSim.Data.MySQL.dll", false); - - m_configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "Database connection string", "", false); - - m_configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - "Http Listener port", ConfigSettings.DefaultAssetServerHttpPort.ToString(), false); - - m_configMember.addConfigurationOption("assetset_location", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "Location of 'AssetSets.xml'", - string.Format(".{0}assets{0}AssetSets.xml", Path.DirectorySeparatorChar), false); - } - - public bool handleIncomingConfiguration(string configuration_key, object configuration_result) - { - switch (configuration_key) - { - case "database_provider": - DatabaseProvider = (string) configuration_result; - break; - case "database_connect": - DatabaseConnect = (string) configuration_result; - break; - case "assetset_location": - AssetSetsLocation = (string) configuration_result; - break; - case "http_port": - HttpPort = (uint) configuration_result; - break; - } - - return true; - } - } -} diff --git a/OpenSim/Framework/AssetRequest.cs b/OpenSim/Framework/AssetRequest.cs deleted file mode 100644 index fa4e2f9bfe..0000000000 --- a/OpenSim/Framework/AssetRequest.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 OpenMetaverse; - -namespace OpenSim.Framework -{ - public struct AssetRequest - { - public UUID AssetID; - public bool IsTexture; - } -} diff --git a/OpenSim/Framework/AssetStorage.cs b/OpenSim/Framework/AssetStorage.cs deleted file mode 100644 index 7dab2f2fcf..0000000000 --- a/OpenSim/Framework/AssetStorage.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 OpenMetaverse; - -namespace OpenSim.Framework -{ - public class AssetStorage - { - public byte[] Data; - public string Name; - public sbyte Type; - public UUID UUID; - - public AssetStorage() - { - } - - public AssetStorage(UUID assetUUID) - { - UUID = assetUUID; - } - } -} diff --git a/OpenSim/Framework/IAssetCache.cs b/OpenSim/Framework/IAssetCache.cs deleted file mode 100644 index 654180d42b..0000000000 --- a/OpenSim/Framework/IAssetCache.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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 OpenMetaverse; -using OpenMetaverse.Packets; - -namespace OpenSim.Framework -{ - public delegate void AssetRequestCallback(UUID assetId, AssetBase asset); - - /// - /// Interface to the local asset cache. This is the mechanism through which assets can be added and requested. - /// - public interface IAssetCache : IPlugin - { - /// - /// The 'server' from which assets can be requested and to which assets are persisted. - /// - - void Initialise(ConfigSettings cs); - - /// - /// Report statistical data to the log. - /// - void ShowState(); - - /// - /// Clear the asset cache. - /// - void Clear(); - - /// - /// Get an asset only if it's already in the cache. - /// - /// - /// - /// true if the asset was in the cache, false if it was not - bool TryGetCachedAsset(UUID assetID, out AssetBase asset); - - /// - /// Asynchronously retrieve an asset. - /// - /// - /// - /// - /// A callback invoked when the asset has either been found or not found. - /// If the asset was found this is called with the asset UUID and the asset data - /// If the asset was not found this is still called with the asset UUID but with a null asset data reference - void GetAsset(UUID assetID, AssetRequestCallback callback, bool isTexture); - - /// - /// Synchronously retreive an asset. If the asset isn't in the cache, a request will be made to the persistent store to - /// load it into the cache. - /// - /// - /// XXX We'll keep polling the cache until we get the asset or we exceed - /// the allowed number of polls. This isn't a very good way of doing things since a single thread - /// is processing inbound packets, so if the asset server is slow, we could block this for up to - /// the timeout period. Whereever possible we want to use the asynchronous callback GetAsset() - /// - /// - /// - /// null if the asset could not be retrieved - AssetBase GetAsset(UUID assetID, bool isTexture); - - /// - /// Add an asset to both the persistent store and the cache. - /// - /// - void AddAsset(AssetBase asset); - - /// - /// Expire an asset from the cache - /// - /// Allows you to clear a specific asset by uuid out - /// of the asset cache. This is needed because the osdynamic - /// texture code grows the asset cache without bounds. The - /// real solution here is a much better cache archicture, but - /// this is a stop gap measure until we have such a thing. - void ExpireAsset(UUID assetID); - - /// - /// Handle an asset request from the client. The result will be sent back asynchronously. - /// - /// - /// - void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest); - } - -} diff --git a/OpenSim/Framework/InventoryConfig.cs b/OpenSim/Framework/InventoryConfig.cs deleted file mode 100644 index f539d556d7..0000000000 --- a/OpenSim/Framework/InventoryConfig.cs +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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; - -namespace OpenSim.Framework -{ - /// - /// Defines and handles inventory grid server configuration - /// - public class InventoryConfig:ConfigBase - { - public string DatabaseConnect = String.Empty; - public string DatabaseProvider = String.Empty; - public string DefaultStartupMsg = String.Empty; - public uint HttpPort = ConfigSettings.DefaultInventoryServerHttpPort; - public string InventoryServerURL = String.Empty; - public string UserServerURL = String.Empty; - public string AssetServerURL = String.Empty; - public bool SessionLookUp = true; - public bool RegionAccessToAgentsInventory = true; - - public InventoryConfig(string description, string filename) - { - m_configMember = - new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, true); - m_configMember.performConfigurationRetrieve(); - } - - public void loadConfigurationOptions() - { - m_configMember.addConfigurationOption("default_inventory_server", - ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, - "Default Inventory Server URI (this server's external name)", - "http://127.0.0.1:8004", false); - m_configMember.addConfigurationOption("default_user_server", - ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, - "Default User Server URI", - "http://127.0.0.1:8002", false); - m_configMember.addConfigurationOption("default_asset_server", - ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, - "Default Asset Server URI", - "http://127.0.0.1:8003", false); - m_configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "DLL for database provider", "OpenSim.Data.MySQL.dll", false); - m_configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "Database Connect String", "", false); - m_configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - "Http Listener port", ConfigSettings.DefaultInventoryServerHttpPort.ToString(), false); - m_configMember.addConfigurationOption("session_lookup", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, - "Enable session lookup security", "False", false); - m_configMember.addConfigurationOption("region_access", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, - "Allow direct region access to users inventories? (Keep True if you don't know what this is about)", "True", false); - } - - public bool handleIncomingConfiguration(string configuration_key, object configuration_result) - { - switch (configuration_key) - { - case "default_inventory_server": - InventoryServerURL = (string)configuration_result; - break; - case "default_user_server": - UserServerURL = (string) configuration_result; - break; - case "default_asset_server": - AssetServerURL = (string)configuration_result; - break; - case "database_provider": - DatabaseProvider = (string) configuration_result; - break; - case "database_connect": - DatabaseConnect = (string) configuration_result; - break; - case "http_port": - HttpPort = (uint) configuration_result; - break; - case "session_lookup": - SessionLookUp = (bool)configuration_result; - break; - case "region_access": - RegionAccessToAgentsInventory = (bool)configuration_result; - break; - } - - return true; - } - } -} diff --git a/OpenSim/Framework/NeighbourInfo.cs b/OpenSim/Framework/NeighbourInfo.cs deleted file mode 100644 index 3a46fbb1b2..0000000000 --- a/OpenSim/Framework/NeighbourInfo.cs +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -namespace OpenSim.Framework -{ - public class NeighbourInfo - { - public ulong regionhandle; - public uint RegionLocX; - public uint RegionLocY; - public string sim_ip; - public uint sim_port; - - public NeighbourInfo() - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Parallel.cs b/OpenSim/Framework/Parallel.cs deleted file mode 100644 index a0394f2c25..0000000000 --- a/OpenSim/Framework/Parallel.cs +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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.Threading; - -namespace OpenSim.Framework -{ - /// - /// Provides helper methods for parallelizing loops - /// - public static class Parallel - { - public static readonly int ProcessorCount = System.Environment.ProcessorCount; - - /// - /// Executes a for loop in which iterations may run in parallel - /// - /// The loop will be started at this index - /// The loop will be terminated before this index is reached - /// Method body to run for each iteration of the loop - public static void For(int fromInclusive, int toExclusive, Action body) - { - For(ProcessorCount, fromInclusive, toExclusive, body); - } - - /// - /// Executes a for loop in which iterations may run in parallel - /// - /// The number of concurrent execution threads to run - /// The loop will be started at this index - /// The loop will be terminated before this index is reached - /// Method body to run for each iteration of the loop - public static void For(int threadCount, int fromInclusive, int toExclusive, Action body) - { - int counter = threadCount; - AutoResetEvent threadFinishEvent = new AutoResetEvent(false); - Exception exception = null; - - --fromInclusive; - - for (int i = 0; i < threadCount; i++) - { - Util.FireAndForget( - delegate(object o) - { -// int threadIndex = (int)o; - - while (exception == null) - { - int currentIndex = Interlocked.Increment(ref fromInclusive); - - if (currentIndex >= toExclusive) - break; - - try { body(currentIndex); } - catch (Exception ex) { exception = ex; break; } - } - - if (Interlocked.Decrement(ref counter) == 0) - threadFinishEvent.Set(); - }, i - ); - } - - threadFinishEvent.WaitOne(); - threadFinishEvent.Close(); - - if (exception != null) - throw new Exception(exception.Message, exception); - } - - /// - /// Executes a foreach loop in which iterations may run in parallel - /// - /// Object type that the collection wraps - /// An enumerable collection to iterate over - /// Method body to run for each object in the collection - public static void ForEach(IEnumerable enumerable, Action body) - { - ForEach(ProcessorCount, enumerable, body); - } - - /// - /// Executes a foreach loop in which iterations may run in parallel - /// - /// Object type that the collection wraps - /// The number of concurrent execution threads to run - /// An enumerable collection to iterate over - /// Method body to run for each object in the collection - public static void ForEach(int threadCount, IEnumerable enumerable, Action body) - { - int counter = threadCount; - AutoResetEvent threadFinishEvent = new AutoResetEvent(false); - IEnumerator enumerator = enumerable.GetEnumerator(); - object syncRoot = new object(); - Exception exception = null; - - for (int i = 0; i < threadCount; i++) - { - Util.FireAndForget( - delegate(object o) - { -// int threadIndex = (int)o; - - while (exception == null) - { - T entry; - - lock (syncRoot) - { - if (!enumerator.MoveNext()) - break; - entry = (T)enumerator.Current; // Explicit typecast for Mono's sake - } - - try { body(entry); } - catch (Exception ex) { exception = ex; break; } - } - - if (Interlocked.Decrement(ref counter) == 0) - threadFinishEvent.Set(); - }, i - ); - } - - threadFinishEvent.WaitOne(); - threadFinishEvent.Close(); - - if (exception != null) - throw new Exception(exception.Message, exception); - } - - /// - /// Executes a series of tasks in parallel - /// - /// A series of method bodies to execute - public static void Invoke(params Action[] actions) - { - Invoke(ProcessorCount, actions); - } - - /// - /// Executes a series of tasks in parallel - /// - /// The number of concurrent execution threads to run - /// A series of method bodies to execute - public static void Invoke(int threadCount, params Action[] actions) - { - int counter = threadCount; - AutoResetEvent threadFinishEvent = new AutoResetEvent(false); - int index = -1; - Exception exception = null; - - for (int i = 0; i < threadCount; i++) - { - Util.FireAndForget( - delegate(object o) - { -// int threadIndex = (int)o; - - while (exception == null) - { - int currentIndex = Interlocked.Increment(ref index); - - if (currentIndex >= actions.Length) - break; - - try { actions[currentIndex](); } - catch (Exception ex) { exception = ex; break; } - } - - if (Interlocked.Decrement(ref counter) == 0) - threadFinishEvent.Set(); - }, i - ); - } - - threadFinishEvent.WaitOne(); - threadFinishEvent.Close(); - - if (exception != null) - throw new Exception(exception.Message, exception); - } - } -} diff --git a/OpenSim/Framework/ProxyCodec.cs b/OpenSim/Framework/ProxyCodec.cs deleted file mode 100644 index 130581aac8..0000000000 --- a/OpenSim/Framework/ProxyCodec.cs +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.Net; - -namespace OpenSim.Framework -{ - public sealed class ProxyCodec - { - public static void EncodeProxyMessage(byte[] bytes, ref int numBytes, EndPoint trueEP) - { - if (numBytes > 4090) // max UPD size = 4096 - { - throw new Exception("ERROR: No space to encode the proxy EP"); - } - - ushort port = (ushort) ((IPEndPoint) trueEP).Port; - bytes[numBytes++] = (byte) (port % 256); - bytes[numBytes++] = (byte) (port / 256); - - foreach (byte b in ((IPEndPoint) trueEP).Address.GetAddressBytes()) - { - bytes[numBytes++] = b; - } - } - - public static IPEndPoint DecodeProxyMessage(byte[] bytes, ref int numBytes) - { - // IPv4 Only - byte[] addr = new byte[4]; - - addr[3] = bytes[--numBytes]; - addr[2] = bytes[--numBytes]; - addr[1] = bytes[--numBytes]; - addr[0] = bytes[--numBytes]; - - ushort port = (ushort) (bytes[--numBytes] * 256); - port += (ushort) bytes[--numBytes]; - - return new IPEndPoint(new IPAddress(addr), (int) port); - } - } -} diff --git a/OpenSim/Framework/RegionUpData.cs b/OpenSim/Framework/RegionUpData.cs deleted file mode 100644 index 12e444215b..0000000000 --- a/OpenSim/Framework/RegionUpData.cs +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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; - -namespace OpenSim.Framework -{ - [Serializable] - public class RegionUpData - { - private string m_ipaddr = ""; - private int m_port = 0; - private uint m_X = 0; - private uint m_Y = 0; - - public RegionUpData(uint X, uint Y, string ipaddr, int port) - { - m_X = X; - m_Y = Y; - m_ipaddr = ipaddr; - m_port = port; - } - - public uint X - { - get { return m_X; } - } - - public uint Y - { - get { return m_Y; } - } - - public string IPADDR - { - get { return m_ipaddr; } - } - - public int PORT - { - get { return m_port; } - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Remoting.cs b/OpenSim/Framework/Remoting.cs deleted file mode 100644 index 75024ef34c..0000000000 --- a/OpenSim/Framework/Remoting.cs +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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.Security.Cryptography; -using System.Text; - -namespace OpenSim.Framework -{ - /// - /// NEEDS AUDIT. - /// - /// - /// Suggested implementation - /// Store two digests for each foreign host. A local copy of the local hash using the local challenge (when issued), and a local copy of the remote hash using the remote challenge. - /// When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message. - /// When receiving data from the foreign host - run 'Authenticate' against the data and the attached byte[]. - /// Both hosts should be performing these operations for this to be effective. - /// - internal class RemoteDigest - { - private byte[] currentHash; - private byte[] secret; - - private SHA512Managed SHA512; - - /// - /// Initialises a new RemoteDigest authentication mechanism - /// - /// Needs an audit by a cryptographic professional - was not "roll your own"'d by choice but rather a serious lack of decent authentication mechanisms in .NET remoting - /// The shared secret between systems (for inter-sim, this is provided in encrypted form during connection, for grid this is input manually in setup) - /// Binary salt - some common value - to be decided what - /// The challenge key provided by the third party - public RemoteDigest(string sharedSecret, byte[] salt, string challenge) - { - SHA512 = new SHA512Managed(); - Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret, salt); - secret = RFC2898.GetBytes(512); - ASCIIEncoding ASCII = new ASCIIEncoding(); - - currentHash = SHA512.ComputeHash(AppendArrays(secret, ASCII.GetBytes(challenge))); - } - - /// - /// Authenticates a piece of incoming data against the local digest. Upon successful authentication, digest string is incremented. - /// - /// The incoming data - /// The remote digest - /// - public bool Authenticate(byte[] data, byte[] digest) - { - byte[] newHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data)); - if (digest == newHash) - { - currentHash = newHash; - return true; - } - else - { - throw new Exception("Hash comparison failed. Key resync required."); - } - } - - /// - /// Signs a new bit of data with the current hash. Returns a byte array which should be affixed to the message. - /// Signing a piece of data will automatically increment the hash - if you sign data and do not send it, the - /// hashes will get out of sync and throw an exception when validation is attempted. - /// - /// The outgoing data - /// The local digest - public byte[] Sign(byte[] data) - { - currentHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data)); - return currentHash; - } - - /// - /// Generates a new challenge string to be issued to a foreign host. Challenges are 1024-bit (effective strength of less than 512-bits) messages generated using the Crytographic Random Number Generator. - /// - /// A 128-character hexadecimal string containing the challenge. - public static string GenerateChallenge() - { - RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider(); - byte[] bytes = new byte[64]; - RNG.GetBytes(bytes); - - StringBuilder sb = new StringBuilder(bytes.Length * 2); - foreach (byte b in bytes) - { - sb.AppendFormat("{0:x2}", b); - } - return sb.ToString(); - } - - /// - /// Helper function, merges two byte arrays - /// - /// Sourced from MSDN Forum - /// A - /// B - /// C - private static byte[] AppendArrays(byte[] a, byte[] b) - { - byte[] c = new byte[a.Length + b.Length]; - Buffer.BlockCopy(a, 0, c, 0, a.Length); - Buffer.BlockCopy(b, 0, c, a.Length, b.Length); - return c; - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/SerializableInventory.cs b/OpenSim/Framework/SerializableInventory.cs deleted file mode 100644 index 6c7f3ff677..0000000000 --- a/OpenSim/Framework/SerializableInventory.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.Collections; -using System.Xml.Serialization; - -namespace OpenSim.Framework -{ - /* - * .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder - * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize - * into this simpler class, and then use that. - */ - - [XmlRoot(ElementName = "inventory", IsNullable = true)] - public class SerializableInventory - { - [XmlElement(ElementName = "folder", IsNullable = true)] public SerializableFolder root; - - #region Nested type: SerializableFolder - - [XmlRoot(ElementName = "folder", IsNullable = true)] - public class SerializableFolder : InventoryFolderBase - { - [XmlArray(ElementName = "items", IsNullable = true)] [XmlArrayItem(ElementName = "item", IsNullable = true, Type = typeof (InventoryItemBase))] public ArrayList - Items; - - [XmlArray(ElementName = "folders", IsNullable = true)] [XmlArrayItem(ElementName = "folder", IsNullable = true, Type = typeof (SerializableFolder))] public - ArrayList SubFolders; - } - - #endregion - } -} \ No newline at end of file diff --git a/OpenSim/Framework/WearableItem.cs b/OpenSim/Framework/WearableItem.cs deleted file mode 100644 index 159306acc0..0000000000 --- a/OpenSim/Framework/WearableItem.cs +++ /dev/null @@ -1,355 +0,0 @@ -/* - * 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.Globalization; -using System.IO; -using System.Text.RegularExpressions; -using OpenMetaverse; - -namespace OpenSim.Framework -{ - public class WearableItem - { - public string WearableName = ""; - public WearableType WearType = WearableType.Invalid; - - public string ItemInfo = "Created Wearable"; - - public SortedList VisualSettings = new SortedList(); - // public LLObject.TextureEntry TextureEntry = null; - //public byte[] TextureEntry = null; - - public List TextureStrings = new List(); - - //permissions - public uint BaseMask = 0; - public uint OwnerMask = 0; - public uint GroupMask = 0; - public uint EveryoneMask = 0; - public uint NextOwnerMask = 0; - - public UUID CreatorID = UUID.Zero; - public UUID OwnerID = UUID.Zero; - public UUID LastOwnerID = UUID.Zero; - public UUID GroupID = UUID.Zero; - - //sale - public string SaleType = "not"; - public int SalePrice = 10; - - private string BuildString = ""; - - - public WearableItem(string wearableName, WearableType type) - { - WearableName = wearableName; - WearType = type; - } - - public WearableItem(string wearableName) - { - WearableName = wearableName; - WearType = ConvertNameToType(WearableName); - } - - public WearableItem(WearableType type) - { - WearType = type; - WearableName = Enum.GetName(typeof(WearableType), type).ToLower(); - } - - public WearableItem() - { - } - - public void AddVisualSetting(VisualSetting setting) - { - if (!VisualSettings.ContainsKey(setting.VisualParam.ParamID)) - { - VisualSettings.Add(setting.VisualParam.ParamID, setting); - } - } - - public bool TryGetSetting(string paramName, out VisualSetting paramSetting) - { - foreach (VisualSetting setting in VisualSettings.Values) - { - if (setting.VisualParam.Name == paramName) - { - paramSetting = setting; - return true; - } - } - - paramSetting = null; - return false; - } - - public bool SetParamValue(string paramName, float value) - { - VisualSetting paramSetting; - if (TryGetSetting(paramName, out paramSetting)) - { - if ((value >= paramSetting.VisualParam.MinValue) && (value <= paramSetting.VisualParam.MaxValue)) - { - paramSetting.Value = value; - return true; - } - } - return false; - } - - public void RandomiseValues() - { - foreach (VisualSetting setting in VisualSettings.Values) - { - //int randNum = Util.RandomClass.Next(0, 1000); - float range = setting.VisualParam.MaxValue - setting.VisualParam.MinValue; - // float val = ((float) randNum) / ((float)(1000.0f / range)); - float val = (float)Util.RandomClass.NextDouble() * range * 0.2f; - setting.Value = setting.VisualParam.MinValue + (range / 2) + val; - } - } - - public WearableType ConvertNameToType(string name) - { - return (WearableType)Enum.Parse(typeof(WearableType), name, true); - } - - public string ToAssetFormat() - { - BuildString = "LLWearable version 22\n"; - BuildString += "New Item \n"; - BuildString += ItemInfo + "\n"; - - - AddSectionStart("permissions"); - AddTabbedNameValueLine("base_mask", BaseMask.ToString("00000000")); - AddTabbedNameValueLine("owner_mask", OwnerMask.ToString("00000000")); - AddTabbedNameValueLine("group_mask", GroupMask.ToString("00000000")); - AddTabbedNameValueLine("everyone_mask", EveryoneMask.ToString("00000000")); - AddTabbedNameValueLine("next_owner_mask", NextOwnerMask.ToString("00000000")); - AddTabbedNameValueLine("creator_id", CreatorID.ToString()); - AddTabbedNameValueLine("owner_id", OwnerID.ToString()); - AddTabbedNameValueLine("last_owner_id", LastOwnerID.ToString()); - AddTabbedNameValueLine("group_id", GroupID.ToString()); - AddSectionEnd(); - - AddSectionStart("sale_info"); - AddTabbedNameValueLine("sale_type", SaleType.ToString()); - AddTabbedNameValueLine("sale_price", SalePrice.ToString()); - AddSectionEnd(); - - AddNameValueLine("type", ((byte)WearType).ToString()); - AddNameValueLine("parameters", VisualSettings.Count.ToString()); - - foreach (KeyValuePair kp in VisualSettings) - { - AddNameValueLine(kp.Key.ToString(), kp.Value.Value.ToString(CultureInfo.InvariantCulture)); - } - if (TextureStrings.Count == 0) - { - AddNameValueLine("textures", "0"); //todo output texture entry - } - else - { - AddNameValueLine("textures", TextureStrings.Count.ToString()); - for (int i = 0; i < TextureStrings.Count; i++) - { - BuildString += TextureStrings[i] + "\n"; - } - BuildString += "\n"; - - } - - return BuildString; - } - - public void SaveToFile(string fileName) - { - File.WriteAllText(fileName, this.ToAssetFormat()); - } - - public void AddSectionStart(string sectionName) - { - BuildString += "\t" + sectionName + " 0\n"; - BuildString += "\t{\n"; - } - - public void AddSectionEnd() - { - BuildString += "\t}\n"; - } - - private void AddTabbedNameValueLine(string name, string value) - { - BuildString += "\t\t"; - BuildString += name + "\t"; - BuildString += value + "\n"; - } - - private void AddNameValueLine(string name, string value) - { - // BuildString += "\t\t"; - BuildString += name + " "; - BuildString += value + "\n"; - } - - #region Static Methods - public static List FindParamsForWearable(string wearableName) - { - List wearableParams = new List(); - foreach (VisualParam param in VisualParams.Params.Values) - { - if (param.Wearable == wearableName) - { - wearableParams.Add(param); - } - } - - return wearableParams; - } - - public static WearableItem Create(string wearableTypeName) - { - WearableItem wearableItem = new WearableItem(wearableTypeName); - List typeParams = FindParamsForWearable(wearableTypeName); - foreach (VisualParam param in typeParams) - { - wearableItem.AddVisualSetting(new VisualSetting(param)); - } - return wearableItem; - } - - public static WearableItem CreateFromAsset(string assetData) - { - UUID creatorID = UUID.Zero; - UUID ownerID = UUID.Zero; - UUID lastOwnerID = UUID.Zero; - UUID groupID = UUID.Zero; - - char[] newlineDelimiter = { '\n' }; - string[] lines = assetData.Split(newlineDelimiter); - - WearableItem wearableObject = null; - Regex r = new Regex("[\t ]+"); - bool reachedParams = false; - bool reachedTextures = false; - foreach (string line in lines) - { - string trimLine = line.Trim(); - // m_log.Debug("line : " + trimLine); - - string[] splitLine = r.Split(trimLine); - if (splitLine.Length > 1) - { - switch (splitLine[0]) - { - case "textures": - reachedParams = false; - reachedTextures = true; - break; - - case "type": - string wearableTypeName = Enum.GetName(typeof(WearableType), (WearableType)Convert.ToInt32(splitLine[1])); - wearableObject = Create(wearableTypeName.ToLower()); - break; - - case "parameters": - reachedParams = true; - break; - - case "creator_id": - creatorID = new UUID(splitLine[1]); - break; - - case "owner_id": - ownerID = new UUID(splitLine[1]); - break; - - case "last_owner_id": - lastOwnerID = new UUID(splitLine[1]); - break; - - case "group_id": - groupID = new UUID(splitLine[1]); - break; - - default: - if ((wearableObject != null) && (reachedParams)) - { - int id = Convert.ToInt32(splitLine[0]); - if (wearableObject.VisualSettings.ContainsKey(id)) - { - - wearableObject.VisualSettings[id].Value = Convert.ToSingle(splitLine[1], CultureInfo.InvariantCulture); - } - } - else if ((wearableObject != null) && (reachedTextures)) - { - wearableObject.TextureStrings.Add(line); - } - break; - } - } - } - - if (wearableObject != null) - { - wearableObject.CreatorID = creatorID; - wearableObject.OwnerID = ownerID; - wearableObject.LastOwnerID = lastOwnerID; - wearableObject.GroupID = groupID; - } - - return wearableObject; - } - #endregion - - #region Nested Class - public class VisualSetting - { - public VisualParam VisualParam; - public float Value = 0; - - public VisualSetting(VisualParam param, float value) - { - VisualParam = param; - Value = value; - } - - public VisualSetting(VisualParam param) - { - VisualParam = param; - Value = param.DefaultValue; - } - } - #endregion - } -} From 81debdfebe21bf7bd28a62dc3468151729d2e6c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 11 Dec 2009 20:20:18 -0800 Subject: [PATCH 6/6] A few more guards along the path to user server. --- OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs index 2f9a45f3d8..776d5d14ce 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs @@ -655,9 +655,12 @@ namespace OpenSim.Region.Communications.OGS1 userData.Email = (string)data["email"]; userData.ID = new UUID((string)data["uuid"]); userData.Created = Convert.ToInt32(data["profile_created"]); - userData.UserInventoryURI = (string)data["server_inventory"]; - userData.UserAssetURI = (string)data["server_asset"]; - userData.FirstLifeAboutText = (string)data["profile_firstlife_about"]; + if (data.Contains("server_inventory") && data["server_inventory"] != null) + userData.UserInventoryURI = (string)data["server_inventory"]; + if (data.Contains("server_asset") && data["server_asset"] != null) + userData.UserAssetURI = (string)data["server_asset"]; + if (data.Contains("profile_firstlife_about") && data["profile_firstlife_about"] != null) + userData.FirstLifeAboutText = (string)data["profile_firstlife_about"]; userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]); userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]); userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]);