From e93b782f9d86e4049a28d7f90c691dc5d242f234 Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Wed, 8 Apr 2009 19:59:37 +0000
Subject: * Introduced some experimental code with regards to asset data
substitution
---
.../Framework/Communications/Cache/AssetCache.cs | 43 ++++++++++++++++++++++
OpenSim/Framework/Communications/IUserService.cs | 3 ++
.../Communications/Tests/Cache/AssetCacheTests.cs | 17 +++++++--
.../Framework/Communications/UserManagerBase.cs | 5 +++
4 files changed, 65 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Framework/Communications')
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index e0d0bd7..b571c0b 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
+using System.Text.RegularExpressions;
using System.Threading;
using GlynnTucker.Cache;
using log4net;
@@ -547,9 +548,49 @@ namespace OpenSim.Framework.Communications.Cache
req.RequestUser.SendAsset(req2);
}
+ }
+
+ public byte[] ProcessAssetData(byte[] assetData)
+ {
+ string data = Encoding.ASCII.GetString(assetData);
+
+ data = ProcessAssetDataString(data);
+
+ return Encoding.ASCII.GetBytes( data );
+ }
+
+ public string ProcessAssetDataString(string data)
+ {
+ Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)");
+
+ data = regex.Replace(data, delegate(Match m)
+ {
+ string result = String.Empty;
+ string key = m.Groups[1].Captures[0].Value;
+
+ string value = m.Groups[2].Captures[0].Value;
+
+ Guid id = Util.GetHashGuid(value, AssetInfo.Secret);
+
+ switch (key)
+ {
+ case "creator_url":
+ result = "creator_id " + id;
+ break;
+
+ case "owner_url":
+ result = "owner_id " + id;
+ break;
+ }
+
+ return result;
+ });
+
+ return data;
}
+
public class AssetRequest
{
public IClientAPI RequestUser;
@@ -578,6 +619,8 @@ namespace OpenSim.Framework.Communications.Cache
Name = aBase.Name;
Description = aBase.Description;
}
+
+ public const string Secret = "secret";
}
public class TextureImage : AssetBase
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs
index 0846024..38c360a 100644
--- a/OpenSim/Framework/Communications/IUserService.cs
+++ b/OpenSim/Framework/Communications/IUserService.cs
@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using System.Collections.Generic;
using OpenMetaverse;
@@ -46,6 +47,8 @@ namespace OpenSim.Framework.Communications
/// The target UUID
/// A user profile. Returns null if no user profile is found.
UserProfileData GetUserProfile(UUID userId);
+
+ UserProfileData GetUserProfile(Uri uri);
UserAgentData GetAgentByUUID(UUID userId);
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
index 18ae9a7..70a398e 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
@@ -73,16 +73,27 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(
assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received");
}
-
+
private void AssetRequestCallback(UUID assetId, AssetBase asset)
{
m_assetIdReceived = assetId;
m_assetReceived = asset;
-
+
lock (this)
{
Monitor.PulseAll(this);
- }
+ }
+ }
+
+ [Test]
+ public void ProcessAssetDataTest()
+ {
+ string url = "http://host/dir/";
+ string data = " creator_url " + url + " ";
+
+ AssetCache assetCache = new AssetCache();
+
+ Assert.AreEqual(" creator_id "+Util.GetHashGuid( url, AssetCache.AssetInfo.Secret )+" ", assetCache.ProcessAssetDataString( data ));
}
}
}
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index c177d4f..b7280d3 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -122,6 +122,11 @@ namespace OpenSim.Framework.Communications
}
}
+ public UserProfileData GetUserProfile(Uri uri)
+ {
+ throw new System.NotImplementedException();
+ }
+
public UserAgentData GetAgentByUUID(UUID userId)
{
foreach (IUserDataPlugin plugin in _plugins)
--
cgit v1.1