aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorJonathan Freedman2010-12-05 11:49:15 -0800
committerJonathan Freedman2010-12-05 11:49:15 -0800
commit45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a (patch)
tree0351fb2c756a46d522fe41798c3969e020a3258d /OpenSim/Services
parentMerge branch 'master-core' into mantis5110 (diff)
parentMerge branch 'master' of /var/git/opensim/ (diff)
downloadopensim-SC-45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a.zip
opensim-SC-45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a.tar.gz
opensim-SC-45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a.tar.bz2
opensim-SC-45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a.tar.xz
Merge branch 'master-core' into mantis5110
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs73
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs3
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs145
-rw-r--r--OpenSim/Services/HypergridService/HGInventoryService.cs (renamed from OpenSim/Services/InventoryService/HGInventoryService.cs)54
-rw-r--r--OpenSim/Services/HypergridService/UserAccountCache.cs105
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs16
6 files changed, 354 insertions, 42 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 470a4dd..3fd2fcf 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -43,44 +43,51 @@ namespace OpenSim.Services.AssetService
43 LogManager.GetLogger( 43 LogManager.GetLogger(
44 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 protected static AssetService m_RootInstance;
47
46 public AssetService(IConfigSource config) : base(config) 48 public AssetService(IConfigSource config) : base(config)
47 { 49 {
48 MainConsole.Instance.Commands.AddCommand("kfs", false, 50 if (m_RootInstance == null)
49 "show digest",
50 "show digest <ID>",
51 "Show asset digest", HandleShowDigest);
52
53 MainConsole.Instance.Commands.AddCommand("kfs", false,
54 "delete asset",
55 "delete asset <ID>",
56 "Delete asset from database", HandleDeleteAsset);
57
58 if (m_AssetLoader != null)
59 { 51 {
60 IConfig assetConfig = config.Configs["AssetService"]; 52 m_RootInstance = this;
61 if (assetConfig == null)
62 throw new Exception("No AssetService configuration");
63 53
64 string loaderArgs = assetConfig.GetString("AssetLoaderArgs", 54 MainConsole.Instance.Commands.AddCommand("kfs", false,
65 String.Empty); 55 "show digest",
56 "show digest <ID>",
57 "Show asset digest", HandleShowDigest);
66 58
67 bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); 59 MainConsole.Instance.Commands.AddCommand("kfs", false,
60 "delete asset",
61 "delete asset <ID>",
62 "Delete asset from database", HandleDeleteAsset);
68 63
69 if (assetLoaderEnabled) 64 if (m_AssetLoader != null)
70 { 65 {
71 m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); 66 IConfig assetConfig = config.Configs["AssetService"];
72 m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, 67 if (assetConfig == null)
73 delegate(AssetBase a) 68 throw new Exception("No AssetService configuration");
74 { 69
75 Store(a); 70 string loaderArgs = assetConfig.GetString("AssetLoaderArgs",
76 }); 71 String.Empty);
72
73 bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
74
75 if (assetLoaderEnabled)
76 {
77 m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs);
78 m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs,
79 delegate(AssetBase a)
80 {
81 Store(a);
82 });
83 }
84
85 m_log.Info("[ASSET SERVICE]: Local asset service enabled");
77 } 86 }
78
79 m_log.Info("[ASSET SERVICE]: Local asset service enabled");
80 } 87 }
81 } 88 }
82 89
83 public AssetBase Get(string id) 90 public virtual AssetBase Get(string id)
84 { 91 {
85 UUID assetID; 92 UUID assetID;
86 93
@@ -93,12 +100,12 @@ namespace OpenSim.Services.AssetService
93 return m_Database.GetAsset(assetID); 100 return m_Database.GetAsset(assetID);
94 } 101 }
95 102
96 public AssetBase GetCached(string id) 103 public virtual AssetBase GetCached(string id)
97 { 104 {
98 return Get(id); 105 return Get(id);
99 } 106 }
100 107
101 public AssetMetadata GetMetadata(string id) 108 public virtual AssetMetadata GetMetadata(string id)
102 { 109 {
103 UUID assetID; 110 UUID assetID;
104 111
@@ -112,7 +119,7 @@ namespace OpenSim.Services.AssetService
112 return null; 119 return null;
113 } 120 }
114 121
115 public byte[] GetData(string id) 122 public virtual byte[] GetData(string id)
116 { 123 {
117 UUID assetID; 124 UUID assetID;
118 125
@@ -123,7 +130,7 @@ namespace OpenSim.Services.AssetService
123 return asset.Data; 130 return asset.Data;
124 } 131 }
125 132
126 public bool Get(string id, Object sender, AssetRetrieved handler) 133 public virtual bool Get(string id, Object sender, AssetRetrieved handler)
127 { 134 {
128 //m_log.DebugFormat("[AssetService]: Get asset async {0}", id); 135 //m_log.DebugFormat("[AssetService]: Get asset async {0}", id);
129 136
@@ -141,7 +148,7 @@ namespace OpenSim.Services.AssetService
141 return true; 148 return true;
142 } 149 }
143 150
144 public string Store(AssetBase asset) 151 public virtual string Store(AssetBase asset)
145 { 152 {
146 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID); 153 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
147 m_Database.StoreAsset(asset); 154 m_Database.StoreAsset(asset);
@@ -154,7 +161,7 @@ namespace OpenSim.Services.AssetService
154 return false; 161 return false;
155 } 162 }
156 163
157 public bool Delete(string id) 164 public virtual bool Delete(string id)
158 { 165 {
159 m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id); 166 m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id);
160 UUID assetID; 167 UUID assetID;
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 9e96163..10e3aee 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -333,7 +333,8 @@ namespace OpenSim.Services.HypergridService
333 333
334 string addressee = parts[0]; 334 string addressee = parts[0];
335 m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, m_ExternalName); 335 m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, m_ExternalName);
336 return (addressee == m_ExternalName); 336
337 return string.Equals(addressee, m_ExternalName, StringComparison.OrdinalIgnoreCase);
337 } 338 }
338 339
339 #endregion 340 #endregion
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
new file mode 100644
index 0000000..a82d0d1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -0,0 +1,145 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Reflection;
31using System.Xml;
32
33using Nini.Config;
34using log4net;
35using OpenMetaverse;
36
37using OpenSim.Framework;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using OpenSim.Services.AssetService;
42
43namespace OpenSim.Services.HypergridService
44{
45 /// <summary>
46 /// Hypergrid asset service. It serves the IAssetService interface,
47 /// but implements it in ways that are appropriate for inter-grid
48 /// asset exchanges.
49 /// </summary>
50 public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService
51 {
52 private static readonly ILog m_log =
53 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType);
55
56 private string m_ProfileServiceURL;
57 private IUserAccountService m_UserAccountService;
58
59 private UserAccountCache m_Cache;
60
61 public HGAssetService(IConfigSource config) : base(config)
62 {
63 m_log.Debug("[HGAsset Service]: Starting");
64 IConfig assetConfig = config.Configs["HGAssetService"];
65 if (assetConfig == null)
66 throw new Exception("No HGAssetService configuration");
67
68 string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty);
69 if (userAccountsDll == string.Empty)
70 throw new Exception("Please specify UserAccountsService in HGAssetService configuration");
71
72 Object[] args = new Object[] { config };
73 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
74 if (m_UserAccountService == null)
75 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
76
77 m_ProfileServiceURL = assetConfig.GetString("ProfileServerURI", string.Empty);
78
79 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
80 }
81
82 #region IAssetService overrides
83 public override AssetBase Get(string id)
84 {
85 AssetBase asset = base.Get(id);
86
87 if (asset == null)
88 return null;
89
90 if (asset.Metadata.Type == (sbyte)AssetType.Object)
91 asset.Data = AdjustIdentifiers(asset.Data); ;
92
93 AdjustIdentifiers(asset.Metadata);
94
95 return asset;
96 }
97
98 public override AssetMetadata GetMetadata(string id)
99 {
100 AssetMetadata meta = base.GetMetadata(id);
101
102 if (meta == null)
103 return null;
104
105 AdjustIdentifiers(meta);
106
107 return meta;
108 }
109
110 public override byte[] GetData(string id)
111 {
112 byte[] data = base.GetData(id);
113
114 if (data == null)
115 return null;
116
117 return AdjustIdentifiers(data);
118 }
119
120 //public virtual bool Get(string id, Object sender, AssetRetrieved handler)
121
122 public override bool Delete(string id)
123 {
124 // NOGO
125 return false;
126 }
127
128 #endregion
129
130 protected void AdjustIdentifiers(AssetMetadata meta)
131 {
132 UserAccount creator = m_Cache.GetUser(meta.CreatorID);
133 if (creator != null)
134 meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
135 }
136
137 protected byte[] AdjustIdentifiers(byte[] data)
138 {
139 string xml = Utils.BytesToString(data);
140 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero));
141 }
142
143 }
144
145}
diff --git a/OpenSim/Services/InventoryService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index d62c008..9ee1ae4 100644
--- a/OpenSim/Services/InventoryService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -33,11 +33,20 @@ using Nini.Config;
33using System.Reflection; 33using System.Reflection;
34using OpenSim.Services.Base; 34using OpenSim.Services.Base;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36using OpenSim.Services.InventoryService;
36using OpenSim.Data; 37using OpenSim.Data;
37using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Server.Base;
38 40
39namespace OpenSim.Services.InventoryService 41namespace OpenSim.Services.HypergridService
40{ 42{
43 /// <summary>
44 /// Hypergrid inventory service. It serves the IInventoryService interface,
45 /// but implements it in ways that are appropriate for inter-grid
46 /// inventory exchanges. Specifically, it does not performs deletions
47 /// and it responds to GetRootFolder requests with the ID of the
48 /// Suitcase folder, not the actual "My Inventory" folder.
49 /// </summary>
41 public class HGInventoryService : XInventoryService, IInventoryService 50 public class HGInventoryService : XInventoryService, IInventoryService
42 { 51 {
43 private static readonly ILog m_log = 52 private static readonly ILog m_log =
@@ -46,9 +55,16 @@ namespace OpenSim.Services.InventoryService
46 55
47 protected new IXInventoryData m_Database; 56 protected new IXInventoryData m_Database;
48 57
58 private string m_ProfileServiceURL;
59 private IUserAccountService m_UserAccountService;
60
61 private UserAccountCache m_Cache;
62
49 public HGInventoryService(IConfigSource config) 63 public HGInventoryService(IConfigSource config)
50 : base(config) 64 : base(config)
51 { 65 {
66 m_log.Debug("[HGInventory Service]: Starting");
67
52 string dllName = String.Empty; 68 string dllName = String.Empty;
53 string connString = String.Empty; 69 string connString = String.Empty;
54 //string realm = "Inventory"; // OSG version doesn't use this 70 //string realm = "Inventory"; // OSG version doesn't use this
@@ -68,12 +84,25 @@ namespace OpenSim.Services.InventoryService
68 // 84 //
69 // Try reading the [InventoryService] section, if it exists 85 // Try reading the [InventoryService] section, if it exists
70 // 86 //
71 IConfig authConfig = config.Configs["InventoryService"]; 87 IConfig invConfig = config.Configs["HGInventoryService"];
72 if (authConfig != null) 88 if (invConfig != null)
73 { 89 {
74 dllName = authConfig.GetString("StorageProvider", dllName); 90 dllName = invConfig.GetString("StorageProvider", dllName);
75 connString = authConfig.GetString("ConnectionString", connString); 91 connString = invConfig.GetString("ConnectionString", connString);
92
76 // realm = authConfig.GetString("Realm", realm); 93 // realm = authConfig.GetString("Realm", realm);
94 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
95 if (userAccountsDll == string.Empty)
96 throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
97
98 Object[] args = new Object[] { config };
99 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
100 if (m_UserAccountService == null)
101 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
102
103 m_ProfileServiceURL = invConfig.GetString("ProfileServerURI", string.Empty);
104
105 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
77 } 106 }
78 107
79 // 108 //
@@ -282,9 +311,18 @@ namespace OpenSim.Services.InventoryService
282 //{ 311 //{
283 //} 312 //}
284 313
285 //public InventoryItemBase GetItem(InventoryItemBase item) 314 public override InventoryItemBase GetItem(InventoryItemBase item)
286 //{ 315 {
287 //} 316 InventoryItemBase it = base.GetItem(item);
317
318 UserAccount user = m_Cache.GetUser(it.CreatorId);
319
320 // Adjust the creator data
321 if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty))
322 it.CreatorData = m_ProfileServiceURL + "/" + it.CreatorId + ";" + user.FirstName + " " + user.LastName;
323
324 return it;
325 }
288 326
289 //public InventoryFolderBase GetFolder(InventoryFolderBase folder) 327 //public InventoryFolderBase GetFolder(InventoryFolderBase folder)
290 //{ 328 //{
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs
new file mode 100644
index 0000000..3e9aea1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/UserAccountCache.cs
@@ -0,0 +1,105 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using log4net;
6using OpenMetaverse;
7
8using OpenSim.Services.Interfaces;
9
10namespace OpenSim.Services.HypergridService
11{
12 public class UserAccountCache : IUserAccountService
13 {
14 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
15
16 private static readonly ILog m_log =
17 LogManager.GetLogger(
18 MethodBase.GetCurrentMethod().DeclaringType);
19 private ExpiringCache<UUID, UserAccount> m_UUIDCache;
20
21 private IUserAccountService m_UserAccountService;
22
23 private static UserAccountCache m_Singleton;
24
25 public static UserAccountCache CreateUserAccountCache(IUserAccountService u)
26 {
27 if (m_Singleton == null)
28 m_Singleton = new UserAccountCache(u);
29
30 return m_Singleton;
31 }
32
33 private UserAccountCache(IUserAccountService u)
34 {
35 m_UUIDCache = new ExpiringCache<UUID, UserAccount>();
36 m_UserAccountService = u;
37 }
38
39 public void Cache(UUID userID, UserAccount account)
40 {
41 // Cache even null accounts
42 m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS);
43
44 //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
45 }
46
47 public UserAccount Get(UUID userID, out bool inCache)
48 {
49 UserAccount account = null;
50 inCache = false;
51 if (m_UUIDCache.TryGetValue(userID, out account))
52 {
53 //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
54 inCache = true;
55 return account;
56 }
57
58 return null;
59 }
60
61 public UserAccount GetUser(string id)
62 {
63 UUID uuid = UUID.Zero;
64 UUID.TryParse(id, out uuid);
65 bool inCache = false;
66 UserAccount account = Get(uuid, out inCache);
67 if (!inCache)
68 {
69 account = m_UserAccountService.GetUserAccount(UUID.Zero, uuid);
70 Cache(uuid, account);
71 }
72
73 return account;
74 }
75
76 #region IUserAccountService
77 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
78 {
79 return GetUser(userID.ToString());
80 }
81
82 public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName)
83 {
84 return null;
85 }
86
87 public UserAccount GetUserAccount(UUID scopeID, string Email)
88 {
89 return null;
90 }
91
92 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
93 {
94 return null;
95 }
96
97 public bool StoreUserAccount(UserAccount data)
98 {
99 return false;
100 }
101 #endregion
102
103 }
104
105}
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index e2d1f04..efc0568 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -761,6 +761,7 @@ namespace OpenSim.Services.LLLoginService
761 if (account.ServiceURLs == null) 761 if (account.ServiceURLs == null)
762 return; 762 return;
763 763
764 // Old style: get the service keys from the DB
764 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) 765 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
765 { 766 {
766 if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty)) 767 if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty))
@@ -772,6 +773,21 @@ namespace OpenSim.Services.LLLoginService
772 aCircuit.ServiceURLs[kvp.Key] = kvp.Value; 773 aCircuit.ServiceURLs[kvp.Key] = kvp.Value;
773 } 774 }
774 } 775 }
776
777 // New style: service keys start with SRV_; override the previous
778 string[] keys = m_LoginServerConfig.GetKeys();
779
780 if (keys.Length > 0)
781 {
782 IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("SRV_"));
783 foreach (string serviceKey in serviceKeys)
784 {
785 string keyName = serviceKey.Replace("SRV_", "");
786 aCircuit.ServiceURLs[keyName] = m_LoginServerConfig.GetString(serviceKey, string.Empty);
787 m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
788 }
789 }
790
775 } 791 }
776 792
777 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason) 793 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason)