diff options
Diffstat (limited to 'OpenSim/Grid')
-rw-r--r-- | OpenSim/Grid/AssetServer/Main.cs | 146 | ||||
-rw-r--r-- | OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs | 63 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/AuthedSessionCache.cs | 133 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/GridInventoryService.cs | 256 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/InventoryServiceBase.cs | 519 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/Main.cs | 182 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs | 2 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs | 2 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/UserLoginService.cs | 70 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/UserManager.cs | 56 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/Main.cs | 8 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/UserServerCommsManager.cs | 4 |
12 files changed, 95 insertions, 1346 deletions
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs deleted file mode 100644 index ac8f888..0000000 --- a/OpenSim/Grid/AssetServer/Main.cs +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
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 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using log4net.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Data; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.AssetLoader.Filesystem; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Framework.Statistics; | ||
41 | |||
42 | namespace OpenSim.Grid.AssetServer | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// An asset server | ||
46 | /// </summary> | ||
47 | public class OpenAsset_Main : BaseOpenSimServer | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | public static OpenAsset_Main assetserver; | ||
52 | |||
53 | // Temporarily hardcoded - should be a plugin | ||
54 | protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); | ||
55 | |||
56 | private IAssetDataPlugin m_assetProvider; | ||
57 | |||
58 | public static void Main(string[] args) | ||
59 | { | ||
60 | XmlConfigurator.Configure(); | ||
61 | |||
62 | assetserver = new OpenAsset_Main(); | ||
63 | assetserver.Startup(); | ||
64 | |||
65 | assetserver.Work(); | ||
66 | } | ||
67 | |||
68 | private void Work() | ||
69 | { | ||
70 | m_console.Output("Enter help for a list of commands"); | ||
71 | |||
72 | while (true) | ||
73 | { | ||
74 | m_console.Prompt(); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public OpenAsset_Main() | ||
79 | { | ||
80 | m_console = new LocalConsole("Asset"); | ||
81 | |||
82 | MainConsole.Instance = m_console; | ||
83 | } | ||
84 | |||
85 | protected override void StartupSpecific() | ||
86 | { | ||
87 | AssetConfig config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml"))); | ||
88 | |||
89 | m_log.Info("[ASSET]: Setting up asset DB"); | ||
90 | setupDB(config); | ||
91 | |||
92 | m_log.Info("[ASSET]: Loading default asset set from '" + config.AssetSetsLocation + "'"); | ||
93 | LoadDefaultAssets(config.AssetSetsLocation); | ||
94 | |||
95 | m_log.Info("[ASSET]: Starting HTTP process"); | ||
96 | m_httpServer = new BaseHttpServer(config.HttpPort); | ||
97 | |||
98 | m_stats = StatsManager.StartCollectingAssetStats(); | ||
99 | |||
100 | AddHttpHandlers(); | ||
101 | |||
102 | m_httpServer.Start(); | ||
103 | |||
104 | base.StartupSpecific(); | ||
105 | } | ||
106 | |||
107 | protected void AddHttpHandlers() | ||
108 | { | ||
109 | m_httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); | ||
110 | m_httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); | ||
111 | } | ||
112 | |||
113 | public byte[] GetAssetData(UUID assetID, bool isTexture) | ||
114 | { | ||
115 | return null; | ||
116 | } | ||
117 | |||
118 | public void setupDB(AssetConfig config) | ||
119 | { | ||
120 | try | ||
121 | { | ||
122 | m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(config.DatabaseProvider, config.DatabaseConnect); | ||
123 | if (m_assetProvider == null) | ||
124 | { | ||
125 | m_log.Error("[ASSET]: Failed to load a database plugin, server halting"); | ||
126 | Environment.Exit(-1); | ||
127 | } | ||
128 | } | ||
129 | catch (Exception e) | ||
130 | { | ||
131 | m_log.Warn("[ASSET]: setupDB() - Exception occured"); | ||
132 | m_log.Warn("[ASSET]: " + e.ToString()); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | public void LoadDefaultAssets(string pAssetSetsLocation) | ||
137 | { | ||
138 | assetLoader.ForEachDefaultXmlAsset(pAssetSetsLocation, StoreAsset); | ||
139 | } | ||
140 | |||
141 | protected void StoreAsset(AssetBase asset) | ||
142 | { | ||
143 | m_assetProvider.StoreAsset(asset); | ||
144 | } | ||
145 | } | ||
146 | } | ||
diff --git a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs deleted file mode 100644 index 5d67e3f..0000000 --- a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
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 | */ | ||
27 | |||
28 | using System.Reflection; | ||
29 | using System.Runtime.InteropServices; | ||
30 | |||
31 | // General information about an assembly is controlled through the following | ||
32 | // set of attributes. Change these attribute values to modify the information | ||
33 | // associated with an assembly. | ||
34 | |||
35 | [assembly : AssemblyTitle("OGS-AssetServer")] | ||
36 | [assembly : AssemblyDescription("")] | ||
37 | [assembly : AssemblyConfiguration("")] | ||
38 | [assembly : AssemblyCompany("http://opensimulator.org")] | ||
39 | [assembly : AssemblyProduct("OGS-AssetServer")] | ||
40 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] | ||
41 | [assembly : AssemblyTrademark("")] | ||
42 | [assembly : AssemblyCulture("")] | ||
43 | |||
44 | // Setting ComVisible to false makes the types in this assembly not visible | ||
45 | // to COM components. If you need to access a type in this assembly from | ||
46 | // COM, set the ComVisible attribute to true on that type. | ||
47 | |||
48 | [assembly : ComVisible(false)] | ||
49 | |||
50 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
51 | |||
52 | [assembly : Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] | ||
53 | |||
54 | // Version information for an assembly consists of the following four values: | ||
55 | // | ||
56 | // Major Version | ||
57 | // Minor Version | ||
58 | // Build Number | ||
59 | // Revision | ||
60 | // | ||
61 | |||
62 | [assembly : AssemblyVersion("0.6.5.*")] | ||
63 | [assembly : AssemblyFileVersion("0.6.5.0")] | ||
diff --git a/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs b/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs deleted file mode 100644 index dadf34a..0000000 --- a/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs +++ /dev/null | |||
@@ -1,133 +0,0 @@ | |||
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 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace OpenSim.Grid.InventoryServer | ||
32 | { | ||
33 | public class AuthedSessionCache | ||
34 | { | ||
35 | public class CacheData | ||
36 | { | ||
37 | private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1); | ||
38 | private string m_session_id; | ||
39 | private string m_agent_id; | ||
40 | private int m_expire; | ||
41 | |||
42 | private int get_current_unix_time() | ||
43 | { | ||
44 | return (int)(DateTime.UtcNow - UNIX_EPOCH).TotalSeconds; | ||
45 | } | ||
46 | |||
47 | public CacheData(string sid, string aid) | ||
48 | { | ||
49 | m_session_id = sid; | ||
50 | m_agent_id = aid; | ||
51 | m_expire = get_current_unix_time() + DEFAULT_LIFETIME; | ||
52 | } | ||
53 | |||
54 | public CacheData(string sid, string aid, int time_now) | ||
55 | { | ||
56 | m_session_id = sid; | ||
57 | m_agent_id = aid; | ||
58 | m_expire = time_now + DEFAULT_LIFETIME; | ||
59 | } | ||
60 | |||
61 | public string SessionID | ||
62 | { | ||
63 | get { return m_session_id; } | ||
64 | set { m_session_id = value; } | ||
65 | } | ||
66 | |||
67 | public string AgentID | ||
68 | { | ||
69 | get { return m_agent_id; } | ||
70 | set { m_agent_id = value; } | ||
71 | } | ||
72 | |||
73 | public bool isExpired | ||
74 | { | ||
75 | get { return m_expire < get_current_unix_time(); } | ||
76 | } | ||
77 | |||
78 | public void Renew() | ||
79 | { | ||
80 | m_expire = get_current_unix_time() + DEFAULT_LIFETIME; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | private static readonly int DEFAULT_LIFETIME = 30; | ||
85 | private Dictionary<string, CacheData> m_authed_sessions = new Dictionary<string,CacheData>(); | ||
86 | // private int m_session_lifetime = DEFAULT_LIFETIME; | ||
87 | |||
88 | public AuthedSessionCache() | ||
89 | { | ||
90 | // m_session_lifetime = DEFAULT_LIFETIME; | ||
91 | } | ||
92 | |||
93 | public AuthedSessionCache(int timeout) | ||
94 | { | ||
95 | // m_session_lifetime = timeout; | ||
96 | } | ||
97 | |||
98 | public CacheData getCachedSession(string session_id, string agent_id) | ||
99 | { | ||
100 | CacheData ret = null; | ||
101 | lock (m_authed_sessions) | ||
102 | { | ||
103 | if (m_authed_sessions.ContainsKey(session_id)) | ||
104 | { | ||
105 | CacheData cached_session = m_authed_sessions[session_id]; | ||
106 | if (!cached_session.isExpired && cached_session.AgentID == agent_id) | ||
107 | { | ||
108 | ret = m_authed_sessions[session_id]; | ||
109 | // auto renew | ||
110 | m_authed_sessions[session_id].Renew(); | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | public void Add(string session_id, string agent_id) | ||
118 | { | ||
119 | CacheData data = new CacheData(session_id, agent_id); | ||
120 | lock (m_authed_sessions) | ||
121 | { | ||
122 | if (m_authed_sessions.ContainsKey(session_id)) | ||
123 | { | ||
124 | m_authed_sessions[session_id] = data; | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | m_authed_sessions.Add(session_id, data); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs deleted file mode 100644 index 0704faa..0000000 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
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 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | |||
40 | namespace OpenSim.Grid.InventoryServer | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Used on a grid server to satisfy external inventory requests | ||
44 | /// </summary> | ||
45 | public class GridInventoryService : InventoryServiceBase | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private bool m_doLookup = false; | ||
50 | |||
51 | public bool DoLookup | ||
52 | { | ||
53 | get { return m_doLookup; } | ||
54 | set { m_doLookup = value; } | ||
55 | } | ||
56 | |||
57 | private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs | ||
58 | |||
59 | private string m_userserver_url; | ||
60 | private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); | ||
61 | |||
62 | public GridInventoryService(string userserver_url) | ||
63 | { | ||
64 | m_userserver_url = userserver_url; | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Check that the source of an inventory request is one that we trust. | ||
69 | /// </summary> | ||
70 | /// <param name="peer"></param> | ||
71 | /// <returns></returns> | ||
72 | public bool CheckTrustSource(IPEndPoint peer) | ||
73 | { | ||
74 | if (m_doLookup) | ||
75 | { | ||
76 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); | ||
77 | UriBuilder ub = new UriBuilder(m_userserver_url); | ||
78 | IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); | ||
79 | foreach (IPAddress uaddr in uaddrs) | ||
80 | { | ||
81 | if (uaddr.Equals(peer.Address)) | ||
82 | { | ||
83 | return true; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | m_log.WarnFormat( | ||
88 | "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", | ||
89 | peer); | ||
90 | |||
91 | return false; | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | return true; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | ||
101 | /// that agent. | ||
102 | /// </summary> | ||
103 | /// <param name="session_id"></param> | ||
104 | /// <param name="avatar_id"></param> | ||
105 | /// <returns></returns> | ||
106 | public bool CheckAuthSession(string session_id, string avatar_id) | ||
107 | { | ||
108 | if (m_doLookup) | ||
109 | { | ||
110 | m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id); | ||
111 | |||
112 | if (m_session_cache.getCachedSession(session_id, avatar_id) == null) | ||
113 | { | ||
114 | // cache miss, ask userserver | ||
115 | Hashtable requestData = new Hashtable(); | ||
116 | requestData["avatar_uuid"] = avatar_id; | ||
117 | requestData["session_id"] = session_id; | ||
118 | ArrayList SendParams = new ArrayList(); | ||
119 | SendParams.Add(requestData); | ||
120 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); | ||
121 | XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); | ||
122 | |||
123 | Hashtable responseData = (Hashtable)UserResp.Value; | ||
124 | if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") | ||
125 | { | ||
126 | m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver"); | ||
127 | // add to cache; the session time will be automatically renewed | ||
128 | m_session_cache.Add(session_id, avatar_id); | ||
129 | return true; | ||
130 | } | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | // cache hits | ||
135 | m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache"); | ||
136 | return true; | ||
137 | } | ||
138 | |||
139 | m_log.Warn("[GRID AGENT INVENTORY]: unknown session_id, request rejected"); | ||
140 | return false; | ||
141 | } | ||
142 | else | ||
143 | { | ||
144 | return true; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Return a user's entire inventory | ||
150 | /// </summary> | ||
151 | /// <param name="rawUserID"></param> | ||
152 | /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> | ||
153 | public InventoryCollection GetUserInventory(Guid rawUserID) | ||
154 | { | ||
155 | UUID userID = new UUID(rawUserID); | ||
156 | |||
157 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); | ||
158 | |||
159 | // Uncomment me to simulate a slow responding inventory server | ||
160 | //Thread.Sleep(16000); | ||
161 | |||
162 | InventoryCollection invCollection = new InventoryCollection(); | ||
163 | |||
164 | List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID); | ||
165 | |||
166 | if (null == allFolders) | ||
167 | { | ||
168 | m_log.WarnFormat("[GRID AGENT INVENTORY]: No inventory found for user {0}", rawUserID); | ||
169 | |||
170 | return invCollection; | ||
171 | } | ||
172 | |||
173 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | ||
174 | |||
175 | foreach (InventoryFolderBase folder in allFolders) | ||
176 | { | ||
177 | List<InventoryItemBase> items = RequestFolderItems(folder.ID); | ||
178 | |||
179 | if (items != null) | ||
180 | { | ||
181 | allItems.InsertRange(0, items); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | invCollection.UserID = userID; | ||
186 | invCollection.Folders = allFolders; | ||
187 | invCollection.Items = allItems; | ||
188 | |||
189 | // foreach (InventoryFolderBase folder in invCollection.Folders) | ||
190 | // { | ||
191 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); | ||
192 | // } | ||
193 | // | ||
194 | // foreach (InventoryItemBase item in invCollection.Items) | ||
195 | // { | ||
196 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); | ||
197 | // } | ||
198 | |||
199 | m_log.InfoFormat( | ||
200 | "[GRID AGENT INVENTORY]: Sending back inventory response to user {0} containing {1} folders and {2} items", | ||
201 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); | ||
202 | |||
203 | return invCollection; | ||
204 | } | ||
205 | |||
206 | public List<InventoryItemBase> GetFolderItems(Guid folderID) | ||
207 | { | ||
208 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | ||
209 | |||
210 | |||
211 | List<InventoryItemBase> items = RequestFolderItems(new UUID(folderID)); | ||
212 | |||
213 | if (items != null) | ||
214 | { | ||
215 | allItems.InsertRange(0, items); | ||
216 | } | ||
217 | m_log.InfoFormat( | ||
218 | "[GRID AGENT INVENTORY]: Sending back inventory response containing {0} items", allItems.Count.ToString()); | ||
219 | return allItems; | ||
220 | } | ||
221 | |||
222 | /// <summary> | ||
223 | /// Guid to UUID wrapper for same name IInventoryServices method | ||
224 | /// </summary> | ||
225 | /// <param name="rawUserID"></param> | ||
226 | /// <returns></returns> | ||
227 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) | ||
228 | { | ||
229 | UUID userID = new UUID(rawUserID); | ||
230 | return GetInventorySkeleton(userID); | ||
231 | } | ||
232 | |||
233 | /// <summary> | ||
234 | /// Create an inventory for the given user. | ||
235 | /// </summary> | ||
236 | /// <param name="rawUserID"></param> | ||
237 | /// <returns></returns> | ||
238 | public bool CreateUsersInventory(Guid rawUserID) | ||
239 | { | ||
240 | UUID userID = new UUID(rawUserID); | ||
241 | |||
242 | m_log.InfoFormat("[GRID AGENT INVENTORY]: Creating new set of inventory folders for user {0}", userID); | ||
243 | |||
244 | return CreateNewUserInventory(userID); | ||
245 | } | ||
246 | |||
247 | public List<InventoryItemBase> GetActiveGestures(Guid rawUserID) | ||
248 | { | ||
249 | UUID userID = new UUID(rawUserID); | ||
250 | |||
251 | m_log.InfoFormat("[GRID AGENT INVENTORY]: fetching active gestures for user {0}", userID); | ||
252 | |||
253 | return GetActiveGestures(userID); | ||
254 | } | ||
255 | } | ||
256 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs b/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs deleted file mode 100644 index f8b4949..0000000 --- a/OpenSim/Grid/InventoryServer/InventoryServiceBase.cs +++ /dev/null | |||
@@ -1,519 +0,0 @@ | |||
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 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | |||
36 | namespace OpenSim.Grid.InventoryServer | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Abstract base class used by local and grid implementations of an inventory service. | ||
40 | /// </summary> | ||
41 | public abstract class InventoryServiceBase : IInterServiceInventoryServices | ||
42 | { | ||
43 | |||
44 | private static readonly ILog m_log | ||
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected List<IInventoryDataPlugin> m_plugins = new List<IInventoryDataPlugin>(); | ||
48 | |||
49 | #region Plugin methods | ||
50 | |||
51 | /// <summary> | ||
52 | /// Add a new inventory data plugin - plugins will be requested in the order they were added. | ||
53 | /// </summary> | ||
54 | /// <param name="plugin">The plugin that will provide data</param> | ||
55 | public void AddPlugin(IInventoryDataPlugin plugin) | ||
56 | { | ||
57 | m_plugins.Add(plugin); | ||
58 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// Adds a list of inventory data plugins, as described by `provider' | ||
62 | /// and `connect', to `m_plugins'. | ||
63 | /// </summary> | ||
64 | /// <param name="provider"> | ||
65 | /// The filename of the inventory server plugin DLL. | ||
66 | /// </param> | ||
67 | /// <param name="connect"> | ||
68 | /// The connection string for the storage backend. | ||
69 | /// </param> | ||
70 | public void AddPlugin(string provider, string connect) | ||
71 | { | ||
72 | m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IInventoryDataPlugin>(provider, connect)); | ||
73 | } | ||
74 | |||
75 | #endregion | ||
76 | |||
77 | #region IInventoryServices methods | ||
78 | |||
79 | public string Host | ||
80 | { | ||
81 | get { return "default"; } | ||
82 | } | ||
83 | |||
84 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | ||
85 | { | ||
86 | // m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); | ||
87 | |||
88 | InventoryFolderBase rootFolder = RequestRootFolder(userId); | ||
89 | |||
90 | // Agent has no inventory structure yet. | ||
91 | if (null == rootFolder) | ||
92 | { | ||
93 | return null; | ||
94 | } | ||
95 | |||
96 | List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>(); | ||
97 | |||
98 | userFolders.Add(rootFolder); | ||
99 | |||
100 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
101 | { | ||
102 | IList<InventoryFolderBase> folders = plugin.getFolderHierarchy(rootFolder.ID); | ||
103 | userFolders.AddRange(folders); | ||
104 | } | ||
105 | |||
106 | // foreach (InventoryFolderBase folder in userFolders) | ||
107 | // { | ||
108 | // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); | ||
109 | // } | ||
110 | |||
111 | return userFolders; | ||
112 | } | ||
113 | |||
114 | // See IInventoryServices | ||
115 | public virtual bool HasInventoryForUser(UUID userID) | ||
116 | { | ||
117 | return false; | ||
118 | } | ||
119 | |||
120 | // See IInventoryServices | ||
121 | public virtual InventoryFolderBase RequestRootFolder(UUID userID) | ||
122 | { | ||
123 | // Retrieve the first root folder we get from the list of plugins. | ||
124 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
125 | { | ||
126 | InventoryFolderBase rootFolder = plugin.getUserRootFolder(userID); | ||
127 | if (rootFolder != null) | ||
128 | return rootFolder; | ||
129 | } | ||
130 | |||
131 | // Return nothing if no plugin was able to supply a root folder | ||
132 | return null; | ||
133 | } | ||
134 | |||
135 | // See IInventoryServices | ||
136 | public bool CreateNewUserInventory(UUID user) | ||
137 | { | ||
138 | InventoryFolderBase existingRootFolder = RequestRootFolder(user); | ||
139 | |||
140 | if (null != existingRootFolder) | ||
141 | { | ||
142 | m_log.WarnFormat( | ||
143 | "[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have " | ||
144 | + "a root inventory folder with id {1}", | ||
145 | user, existingRootFolder.ID); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | UsersInventory inven = new UsersInventory(); | ||
150 | inven.CreateNewInventorySet(user); | ||
151 | AddNewInventorySet(inven); | ||
152 | |||
153 | return true; | ||
154 | } | ||
155 | |||
156 | return false; | ||
157 | } | ||
158 | |||
159 | public List<InventoryItemBase> GetActiveGestures(UUID userId) | ||
160 | { | ||
161 | List<InventoryItemBase> activeGestures = new List<InventoryItemBase>(); | ||
162 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
163 | { | ||
164 | activeGestures.AddRange(plugin.fetchActiveGestures(userId)); | ||
165 | } | ||
166 | |||
167 | return activeGestures; | ||
168 | } | ||
169 | |||
170 | #endregion | ||
171 | |||
172 | #region Methods used by GridInventoryService | ||
173 | |||
174 | public List<InventoryFolderBase> RequestSubFolders(UUID parentFolderID) | ||
175 | { | ||
176 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); | ||
177 | |||
178 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
179 | { | ||
180 | inventoryList.AddRange(plugin.getInventoryFolders(parentFolderID)); | ||
181 | } | ||
182 | |||
183 | return inventoryList; | ||
184 | } | ||
185 | |||
186 | public List<InventoryItemBase> RequestFolderItems(UUID folderID) | ||
187 | { | ||
188 | List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); | ||
189 | |||
190 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
191 | { | ||
192 | itemsList.AddRange(plugin.getInventoryInFolder(folderID)); | ||
193 | } | ||
194 | |||
195 | return itemsList; | ||
196 | } | ||
197 | |||
198 | #endregion | ||
199 | |||
200 | // See IInventoryServices | ||
201 | public virtual bool AddFolder(InventoryFolderBase folder) | ||
202 | { | ||
203 | m_log.DebugFormat( | ||
204 | "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
205 | |||
206 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
207 | { | ||
208 | plugin.addInventoryFolder(folder); | ||
209 | } | ||
210 | |||
211 | // FIXME: Should return false on failure | ||
212 | return true; | ||
213 | } | ||
214 | |||
215 | // See IInventoryServices | ||
216 | public virtual bool UpdateFolder(InventoryFolderBase folder) | ||
217 | { | ||
218 | m_log.DebugFormat( | ||
219 | "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
220 | |||
221 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
222 | { | ||
223 | plugin.updateInventoryFolder(folder); | ||
224 | } | ||
225 | |||
226 | // FIXME: Should return false on failure | ||
227 | return true; | ||
228 | } | ||
229 | |||
230 | // See IInventoryServices | ||
231 | public virtual bool MoveFolder(InventoryFolderBase folder) | ||
232 | { | ||
233 | m_log.DebugFormat( | ||
234 | "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | ||
235 | |||
236 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
237 | { | ||
238 | plugin.moveInventoryFolder(folder); | ||
239 | } | ||
240 | |||
241 | // FIXME: Should return false on failure | ||
242 | return true; | ||
243 | } | ||
244 | |||
245 | // See IInventoryServices | ||
246 | public virtual bool AddItem(InventoryItemBase item) | ||
247 | { | ||
248 | m_log.DebugFormat( | ||
249 | "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); | ||
250 | |||
251 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
252 | { | ||
253 | plugin.addInventoryItem(item); | ||
254 | } | ||
255 | |||
256 | // FIXME: Should return false on failure | ||
257 | return true; | ||
258 | } | ||
259 | |||
260 | // See IInventoryServices | ||
261 | public virtual bool UpdateItem(InventoryItemBase item) | ||
262 | { | ||
263 | m_log.InfoFormat( | ||
264 | "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); | ||
265 | |||
266 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
267 | { | ||
268 | plugin.updateInventoryItem(item); | ||
269 | } | ||
270 | |||
271 | // FIXME: Should return false on failure | ||
272 | return true; | ||
273 | } | ||
274 | |||
275 | // See IInventoryServices | ||
276 | public virtual bool DeleteItem(InventoryItemBase item) | ||
277 | { | ||
278 | m_log.InfoFormat( | ||
279 | "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); | ||
280 | |||
281 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
282 | { | ||
283 | plugin.deleteInventoryItem(item.ID); | ||
284 | } | ||
285 | |||
286 | // FIXME: Should return false on failure | ||
287 | return true; | ||
288 | } | ||
289 | |||
290 | public virtual InventoryItemBase QueryItem(InventoryItemBase item) | ||
291 | { | ||
292 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
293 | { | ||
294 | InventoryItemBase result = plugin.queryInventoryItem(item.ID); | ||
295 | if (result != null) | ||
296 | return result; | ||
297 | } | ||
298 | |||
299 | return null; | ||
300 | } | ||
301 | |||
302 | public virtual InventoryFolderBase QueryFolder(InventoryFolderBase item) | ||
303 | { | ||
304 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
305 | { | ||
306 | InventoryFolderBase result = plugin.queryInventoryFolder(item.ID); | ||
307 | if (result != null) | ||
308 | return result; | ||
309 | } | ||
310 | |||
311 | return null; | ||
312 | } | ||
313 | |||
314 | /// <summary> | ||
315 | /// Purge a folder of all items items and subfolders. | ||
316 | /// | ||
317 | /// FIXME: Really nasty in a sense, because we have to query the database to get information we may | ||
318 | /// already know... Needs heavy refactoring. | ||
319 | /// </summary> | ||
320 | /// <param name="folder"></param> | ||
321 | public virtual bool PurgeFolder(InventoryFolderBase folder) | ||
322 | { | ||
323 | m_log.DebugFormat( | ||
324 | "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); | ||
325 | |||
326 | List<InventoryFolderBase> subFolders = RequestSubFolders(folder.ID); | ||
327 | |||
328 | foreach (InventoryFolderBase subFolder in subFolders) | ||
329 | { | ||
330 | // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); | ||
331 | |||
332 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
333 | { | ||
334 | plugin.deleteInventoryFolder(subFolder.ID); | ||
335 | } | ||
336 | } | ||
337 | |||
338 | List<InventoryItemBase> items = RequestFolderItems(folder.ID); | ||
339 | |||
340 | foreach (InventoryItemBase item in items) | ||
341 | { | ||
342 | DeleteItem(item); | ||
343 | } | ||
344 | |||
345 | // FIXME: Should return false on failure | ||
346 | return true; | ||
347 | } | ||
348 | |||
349 | private void AddNewInventorySet(UsersInventory inventory) | ||
350 | { | ||
351 | foreach (InventoryFolderBase folder in inventory.Folders.Values) | ||
352 | { | ||
353 | AddFolder(folder); | ||
354 | } | ||
355 | } | ||
356 | |||
357 | public InventoryItemBase GetInventoryItem(UUID itemID) | ||
358 | { | ||
359 | foreach (IInventoryDataPlugin plugin in m_plugins) | ||
360 | { | ||
361 | InventoryItemBase item = plugin.getInventoryItem(itemID); | ||
362 | if (item != null) | ||
363 | return item; | ||
364 | } | ||
365 | |||
366 | return null; | ||
367 | } | ||
368 | |||
369 | /// <summary> | ||
370 | /// Used to create a new user inventory. | ||
371 | /// </summary> | ||
372 | private class UsersInventory | ||
373 | { | ||
374 | public Dictionary<UUID, InventoryFolderBase> Folders = new Dictionary<UUID, InventoryFolderBase>(); | ||
375 | public Dictionary<UUID, InventoryItemBase> Items = new Dictionary<UUID, InventoryItemBase>(); | ||
376 | |||
377 | public virtual void CreateNewInventorySet(UUID user) | ||
378 | { | ||
379 | InventoryFolderBase folder = new InventoryFolderBase(); | ||
380 | |||
381 | folder.ParentID = UUID.Zero; | ||
382 | folder.Owner = user; | ||
383 | folder.ID = UUID.Random(); | ||
384 | folder.Name = "My Inventory"; | ||
385 | folder.Type = (short)AssetType.Folder; | ||
386 | folder.Version = 1; | ||
387 | Folders.Add(folder.ID, folder); | ||
388 | |||
389 | UUID rootFolder = folder.ID; | ||
390 | |||
391 | folder = new InventoryFolderBase(); | ||
392 | folder.ParentID = rootFolder; | ||
393 | folder.Owner = user; | ||
394 | folder.ID = UUID.Random(); | ||
395 | folder.Name = "Animations"; | ||
396 | folder.Type = (short)AssetType.Animation; | ||
397 | folder.Version = 1; | ||
398 | Folders.Add(folder.ID, folder); | ||
399 | |||
400 | folder = new InventoryFolderBase(); | ||
401 | folder.ParentID = rootFolder; | ||
402 | folder.Owner = user; | ||
403 | folder.ID = UUID.Random(); | ||
404 | folder.Name = "Body Parts"; | ||
405 | folder.Type = (short)AssetType.Bodypart; | ||
406 | folder.Version = 1; | ||
407 | Folders.Add(folder.ID, folder); | ||
408 | |||
409 | folder = new InventoryFolderBase(); | ||
410 | folder.ParentID = rootFolder; | ||
411 | folder.Owner = user; | ||
412 | folder.ID = UUID.Random(); | ||
413 | folder.Name = "Calling Cards"; | ||
414 | folder.Type = (short)AssetType.CallingCard; | ||
415 | folder.Version = 1; | ||
416 | Folders.Add(folder.ID, folder); | ||
417 | |||
418 | folder = new InventoryFolderBase(); | ||
419 | folder.ParentID = rootFolder; | ||
420 | folder.Owner = user; | ||
421 | folder.ID = UUID.Random(); | ||
422 | folder.Name = "Clothing"; | ||
423 | folder.Type = (short)AssetType.Clothing; | ||
424 | folder.Version = 1; | ||
425 | Folders.Add(folder.ID, folder); | ||
426 | |||
427 | folder = new InventoryFolderBase(); | ||
428 | folder.ParentID = rootFolder; | ||
429 | folder.Owner = user; | ||
430 | folder.ID = UUID.Random(); | ||
431 | folder.Name = "Gestures"; | ||
432 | folder.Type = (short)AssetType.Gesture; | ||
433 | folder.Version = 1; | ||
434 | Folders.Add(folder.ID, folder); | ||
435 | |||
436 | folder = new InventoryFolderBase(); | ||
437 | folder.ParentID = rootFolder; | ||
438 | folder.Owner = user; | ||
439 | folder.ID = UUID.Random(); | ||
440 | folder.Name = "Landmarks"; | ||
441 | folder.Type = (short)AssetType.Landmark; | ||
442 | folder.Version = 1; | ||
443 | Folders.Add(folder.ID, folder); | ||
444 | |||
445 | folder = new InventoryFolderBase(); | ||
446 | folder.ParentID = rootFolder; | ||
447 | folder.Owner = user; | ||
448 | folder.ID = UUID.Random(); | ||
449 | folder.Name = "Lost And Found"; | ||
450 | folder.Type = (short)AssetType.LostAndFoundFolder; | ||
451 | folder.Version = 1; | ||
452 | Folders.Add(folder.ID, folder); | ||
453 | |||
454 | folder = new InventoryFolderBase(); | ||
455 | folder.ParentID = rootFolder; | ||
456 | folder.Owner = user; | ||
457 | folder.ID = UUID.Random(); | ||
458 | folder.Name = "Notecards"; | ||
459 | folder.Type = (short)AssetType.Notecard; | ||
460 | folder.Version = 1; | ||
461 | Folders.Add(folder.ID, folder); | ||
462 | |||
463 | folder = new InventoryFolderBase(); | ||
464 | folder.ParentID = rootFolder; | ||
465 | folder.Owner = user; | ||
466 | folder.ID = UUID.Random(); | ||
467 | folder.Name = "Objects"; | ||
468 | folder.Type = (short)AssetType.Object; | ||
469 | folder.Version = 1; | ||
470 | Folders.Add(folder.ID, folder); | ||
471 | |||
472 | folder = new InventoryFolderBase(); | ||
473 | folder.ParentID = rootFolder; | ||
474 | folder.Owner = user; | ||
475 | folder.ID = UUID.Random(); | ||
476 | folder.Name = "Photo Album"; | ||
477 | folder.Type = (short)AssetType.SnapshotFolder; | ||
478 | folder.Version = 1; | ||
479 | Folders.Add(folder.ID, folder); | ||
480 | |||
481 | folder = new InventoryFolderBase(); | ||
482 | folder.ParentID = rootFolder; | ||
483 | folder.Owner = user; | ||
484 | folder.ID = UUID.Random(); | ||
485 | folder.Name = "Scripts"; | ||
486 | folder.Type = (short)AssetType.LSLText; | ||
487 | folder.Version = 1; | ||
488 | Folders.Add(folder.ID, folder); | ||
489 | |||
490 | folder = new InventoryFolderBase(); | ||
491 | folder.ParentID = rootFolder; | ||
492 | folder.Owner = user; | ||
493 | folder.ID = UUID.Random(); | ||
494 | folder.Name = "Sounds"; | ||
495 | folder.Type = (short)AssetType.Sound; | ||
496 | folder.Version = 1; | ||
497 | Folders.Add(folder.ID, folder); | ||
498 | |||
499 | folder = new InventoryFolderBase(); | ||
500 | folder.ParentID = rootFolder; | ||
501 | folder.Owner = user; | ||
502 | folder.ID = UUID.Random(); | ||
503 | folder.Name = "Textures"; | ||
504 | folder.Type = (short)AssetType.Texture; | ||
505 | folder.Version = 1; | ||
506 | Folders.Add(folder.ID, folder); | ||
507 | |||
508 | folder = new InventoryFolderBase(); | ||
509 | folder.ParentID = rootFolder; | ||
510 | folder.Owner = user; | ||
511 | folder.ID = UUID.Random(); | ||
512 | folder.Name = "Trash"; | ||
513 | folder.Type = (short)AssetType.TrashFolder; | ||
514 | folder.Version = 1; | ||
515 | Folders.Add(folder.ID, folder); | ||
516 | } | ||
517 | } | ||
518 | } | ||
519 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs deleted file mode 100644 index 6106d93..0000000 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ /dev/null | |||
@@ -1,182 +0,0 @@ | |||
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 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using log4net.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Communications.Services; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | |||
41 | namespace OpenSim.Grid.InventoryServer | ||
42 | { | ||
43 | public class OpenInventory_Main : BaseOpenSimServer | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private GridInventoryService m_inventoryService; | ||
48 | //private HGInventoryService m_directInventoryService; | ||
49 | |||
50 | public const string LogName = "INVENTORY"; | ||
51 | |||
52 | public static void Main(string[] args) | ||
53 | { | ||
54 | XmlConfigurator.Configure(); | ||
55 | |||
56 | OpenInventory_Main theServer = new OpenInventory_Main(); | ||
57 | theServer.Startup(); | ||
58 | |||
59 | theServer.Work(); | ||
60 | } | ||
61 | |||
62 | public OpenInventory_Main() | ||
63 | { | ||
64 | m_console = new LocalConsole("Inventory"); | ||
65 | MainConsole.Instance = m_console; | ||
66 | } | ||
67 | |||
68 | protected override void StartupSpecific() | ||
69 | { | ||
70 | InventoryConfig config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); | ||
71 | |||
72 | m_inventoryService = new GridInventoryService(config.UserServerURL); | ||
73 | m_inventoryService.DoLookup = config.SessionLookUp; | ||
74 | m_inventoryService.AddPlugin(config.DatabaseProvider, config.DatabaseConnect); | ||
75 | |||
76 | |||
77 | m_log.Info("[" + LogName + "]: Starting HTTP server ..."); | ||
78 | |||
79 | m_httpServer = new BaseHttpServer(config.HttpPort); | ||
80 | |||
81 | AddHttpHandlers(config.RegionAccessToAgentsInventory); | ||
82 | |||
83 | m_httpServer.Start(); | ||
84 | |||
85 | m_log.Info("[" + LogName + "]: Started HTTP server"); | ||
86 | |||
87 | base.StartupSpecific(); | ||
88 | |||
89 | m_console.Commands.AddCommand("inventoryserver", false, "add user", | ||
90 | "add user", | ||
91 | "Add a random user inventory", HandleAddUser); | ||
92 | } | ||
93 | |||
94 | protected void AddHttpHandlers(bool regionAccess) | ||
95 | { | ||
96 | if (regionAccess) | ||
97 | { | ||
98 | m_httpServer.AddStreamHandler( | ||
99 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | ||
100 | "POST", "/GetInventory/", m_inventoryService.GetUserInventory, m_inventoryService.CheckAuthSession)); | ||
101 | |||
102 | m_httpServer.AddStreamHandler( | ||
103 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
104 | "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, m_inventoryService.CheckAuthSession)); | ||
105 | |||
106 | m_httpServer.AddStreamHandler( | ||
107 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
108 | "POST", "/MoveFolder/", m_inventoryService.MoveFolder, m_inventoryService.CheckAuthSession)); | ||
109 | |||
110 | m_httpServer.AddStreamHandler( | ||
111 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
112 | "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, m_inventoryService.CheckAuthSession)); | ||
113 | |||
114 | m_httpServer.AddStreamHandler( | ||
115 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
116 | "POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession)); | ||
117 | |||
118 | m_httpServer.AddStreamHandler( | ||
119 | new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | ||
120 | "POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession)); | ||
121 | |||
122 | m_httpServer.AddStreamHandler( | ||
123 | new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryFolderBase>( | ||
124 | "POST", "/QueryFolder/", m_inventoryService.QueryFolder, m_inventoryService.CheckAuthSession)); | ||
125 | |||
126 | } | ||
127 | |||
128 | m_httpServer.AddStreamHandler( | ||
129 | new RestDeserialiseTrustedHandler<Guid, bool>( | ||
130 | "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory, m_inventoryService.CheckTrustSource)); | ||
131 | |||
132 | m_httpServer.AddStreamHandler( | ||
133 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
134 | "POST", "/NewFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckAuthSession)); | ||
135 | |||
136 | m_httpServer.AddStreamHandler( | ||
137 | new RestDeserialiseTrustedHandler<InventoryFolderBase, bool>( | ||
138 | "POST", "/CreateFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckTrustSource)); | ||
139 | |||
140 | m_httpServer.AddStreamHandler( | ||
141 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
142 | "POST", "/NewItem/", m_inventoryService.AddItem, m_inventoryService.CheckAuthSession)); | ||
143 | |||
144 | m_httpServer.AddStreamHandler( | ||
145 | new RestDeserialiseTrustedHandler<InventoryItemBase, bool>( | ||
146 | "POST", "/AddNewItem/", m_inventoryService.AddItem, m_inventoryService.CheckTrustSource)); | ||
147 | |||
148 | m_httpServer.AddStreamHandler( | ||
149 | new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>( | ||
150 | "POST", "/GetItems/", m_inventoryService.GetFolderItems, m_inventoryService.CheckTrustSource)); | ||
151 | |||
152 | // for persistent active gestures | ||
153 | m_httpServer.AddStreamHandler( | ||
154 | new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>> | ||
155 | ("POST", "/ActiveGestures/", m_inventoryService.GetActiveGestures, m_inventoryService.CheckTrustSource)); | ||
156 | |||
157 | // WARNING: Root folders no longer just delivers the root and immediate child folders (e.g | ||
158 | // system folders such as Objects, Textures), but it now returns the entire inventory skeleton. | ||
159 | // It would have been better to rename this request, but complexities in the BaseHttpServer | ||
160 | // (e.g. any http request not found is automatically treated as an xmlrpc request) make it easier | ||
161 | // to do this for now. | ||
162 | m_httpServer.AddStreamHandler( | ||
163 | new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>> | ||
164 | ("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton, m_inventoryService.CheckTrustSource)); | ||
165 | } | ||
166 | |||
167 | private void Work() | ||
168 | { | ||
169 | m_console.Output("Enter help for a list of commands\n"); | ||
170 | |||
171 | while (true) | ||
172 | { | ||
173 | m_console.Prompt(); | ||
174 | } | ||
175 | } | ||
176 | |||
177 | private void HandleAddUser(string module, string[] args) | ||
178 | { | ||
179 | m_inventoryService.CreateUsersInventory(UUID.Random().Guid); | ||
180 | } | ||
181 | } | ||
182 | } | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs b/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs index 8006119..76c4899 100644 --- a/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs +++ b/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs | |||
@@ -70,6 +70,6 @@ namespace OpenSim.Grid.MessagingServer.Modules | |||
70 | { | 70 | { |
71 | //throw new Exception("The method or operation is not implemented."); | 71 | //throw new Exception("The method or operation is not implemented."); |
72 | return null; | 72 | return null; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | } | 75 | } |
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs index 9d31d81..77caf47 100644 --- a/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs +++ b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Grid.UserServer.Modules | |||
47 | 47 | ||
48 | /// <summary> | 48 | /// <summary> |
49 | /// Hypergrid login service used in grid mode. | 49 | /// Hypergrid login service used in grid mode. |
50 | /// </summary> | 50 | /// </summary> |
51 | public class UserLoginAuthService : HGLoginAuthService | 51 | public class UserLoginAuthService : HGLoginAuthService |
52 | { | 52 | { |
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs index 01d5537..7d0e0de 100644 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs | |||
@@ -34,6 +34,7 @@ using System.Text.RegularExpressions; | |||
34 | using log4net; | 34 | using log4net; |
35 | using Nwc.XmlRpc; | 35 | using Nwc.XmlRpc; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using Nini.Config; | ||
37 | using OpenSim.Data; | 38 | using OpenSim.Data; |
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
@@ -42,6 +43,9 @@ using OpenSim.Framework.Communications.Cache; | |||
42 | using OpenSim.Framework.Capabilities; | 43 | using OpenSim.Framework.Capabilities; |
43 | using OpenSim.Framework.Servers; | 44 | using OpenSim.Framework.Servers; |
44 | using OpenSim.Framework.Servers.HttpServer; | 45 | using OpenSim.Framework.Servers.HttpServer; |
46 | using OpenSim.Services.Interfaces; | ||
47 | using OpenSim.Services.Connectors; | ||
48 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
45 | 49 | ||
46 | namespace OpenSim.Grid.UserServer.Modules | 50 | namespace OpenSim.Grid.UserServer.Modules |
47 | { | 51 | { |
@@ -51,7 +55,7 @@ namespace OpenSim.Grid.UserServer.Modules | |||
51 | 55 | ||
52 | /// <summary> | 56 | /// <summary> |
53 | /// Login service used in grid mode. | 57 | /// Login service used in grid mode. |
54 | /// </summary> | 58 | /// </summary> |
55 | public class UserLoginService : LoginService | 59 | public class UserLoginService : LoginService |
56 | { | 60 | { |
57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -63,6 +67,8 @@ namespace OpenSim.Grid.UserServer.Modules | |||
63 | public UserConfig m_config; | 67 | public UserConfig m_config; |
64 | private readonly IRegionProfileRouter m_regionProfileService; | 68 | private readonly IRegionProfileRouter m_regionProfileService; |
65 | 69 | ||
70 | private IGridService m_GridService; | ||
71 | |||
66 | protected BaseHttpServer m_httpServer; | 72 | protected BaseHttpServer m_httpServer; |
67 | 73 | ||
68 | public UserLoginService( | 74 | public UserLoginService( |
@@ -76,6 +82,8 @@ namespace OpenSim.Grid.UserServer.Modules | |||
76 | m_defaultHomeY = m_config.DefaultY; | 82 | m_defaultHomeY = m_config.DefaultY; |
77 | m_interInventoryService = inventoryService; | 83 | m_interInventoryService = inventoryService; |
78 | m_regionProfileService = regionProfileService; | 84 | m_regionProfileService = regionProfileService; |
85 | |||
86 | m_GridService = new GridServicesConnector(config.GridServerURL.ToString()); | ||
79 | } | 87 | } |
80 | 88 | ||
81 | public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers) | 89 | public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers) |
@@ -203,47 +211,38 @@ namespace OpenSim.Grid.UserServer.Modules | |||
203 | 211 | ||
204 | protected override RegionInfo RequestClosestRegion(string region) | 212 | protected override RegionInfo RequestClosestRegion(string region) |
205 | { | 213 | { |
206 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region, | 214 | return GridRegionToRegionInfo(m_GridService.GetRegionByName(UUID.Zero, region)); |
207 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | ||
208 | |||
209 | if (profileData != null) | ||
210 | { | ||
211 | return profileData.ToRegionInfo(); | ||
212 | } | ||
213 | else | ||
214 | { | ||
215 | return null; | ||
216 | } | ||
217 | } | 215 | } |
218 | 216 | ||
219 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) | 217 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) |
220 | { | 218 | { |
221 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle, | 219 | uint x = 0, y = 0; |
222 | m_config.GridServerURL, m_config.GridSendKey, | 220 | Utils.LongToUInts(homeRegionHandle, out x, out y); |
223 | m_config.GridRecvKey); | 221 | return GridRegionToRegionInfo(m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y)); |
224 | if (profileData != null) | ||
225 | { | ||
226 | return profileData.ToRegionInfo(); | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | return null; | ||
231 | } | ||
232 | } | 222 | } |
233 | 223 | ||
234 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) | 224 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) |
235 | { | 225 | { |
236 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId, | 226 | return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId)); |
237 | m_config.GridServerURL, m_config.GridSendKey, | 227 | } |
238 | m_config.GridRecvKey); | 228 | |
239 | if (profileData != null) | 229 | private RegionInfo GridRegionToRegionInfo(GridRegion gregion) |
240 | { | 230 | { |
241 | return profileData.ToRegionInfo(); | 231 | if (gregion == null) |
242 | } | ||
243 | else | ||
244 | { | ||
245 | return null; | 232 | return null; |
246 | } | 233 | |
234 | RegionInfo rinfo = new RegionInfo(); | ||
235 | rinfo.ExternalHostName = gregion.ExternalHostName; | ||
236 | rinfo.HttpPort = gregion.HttpPort; | ||
237 | rinfo.InternalEndPoint = gregion.InternalEndPoint; | ||
238 | rinfo.RegionID = gregion.RegionID; | ||
239 | rinfo.RegionLocX = (uint)(gregion.RegionLocX / Constants.RegionSize); | ||
240 | rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize); | ||
241 | rinfo.RegionName = gregion.RegionName; | ||
242 | rinfo.ScopeID = gregion.ScopeID; | ||
243 | rinfo.ServerURI = gregion.ServerURI; | ||
244 | |||
245 | return rinfo; | ||
247 | } | 246 | } |
248 | 247 | ||
249 | protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) | 248 | protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) |
@@ -280,9 +279,8 @@ namespace OpenSim.Grid.UserServer.Modules | |||
280 | //response.SeedCapability = serverURI + CapsUtil.GetCapsSeedPath(capsPath); | 279 | //response.SeedCapability = serverURI + CapsUtil.GetCapsSeedPath(capsPath); |
281 | 280 | ||
282 | // Take off trailing / so that the caps path isn't //CAPS/someUUID | 281 | // Take off trailing / so that the caps path isn't //CAPS/someUUID |
283 | if (regionInfo.httpServerURI.EndsWith("/")) | 282 | string uri = regionInfo.httpServerURI.Trim(new char[] { '/' }); |
284 | regionInfo.httpServerURI = regionInfo.httpServerURI.Substring(0, regionInfo.httpServerURI.Length - 1); | 283 | response.SeedCapability = uri + CapsUtil.GetCapsSeedPath(capsPath); |
285 | response.SeedCapability = regionInfo.httpServerURI + CapsUtil.GetCapsSeedPath(capsPath); | ||
286 | 284 | ||
287 | 285 | ||
288 | // Notify the target of an incoming user | 286 | // Notify the target of an incoming user |
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs index 002f232..36c6297 100644 --- a/OpenSim/Grid/UserServer.Modules/UserManager.cs +++ b/OpenSim/Grid/UserServer.Modules/UserManager.cs | |||
@@ -108,6 +108,9 @@ namespace OpenSim.Grid.UserServer.Modules | |||
108 | m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); | 108 | m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); |
109 | m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); | 109 | m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); |
110 | 110 | ||
111 | // Used by IAR module to do password checks | ||
112 | m_httpServer.AddXmlRPCHandler("authenticate_user_by_password", XmlRPCAuthenticateUserMethodPassword); | ||
113 | |||
111 | m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); | 114 | m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); |
112 | m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); | 115 | m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); |
113 | m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); | 116 | m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); |
@@ -203,6 +206,57 @@ namespace OpenSim.Grid.UserServer.Modules | |||
203 | 206 | ||
204 | #region XMLRPC User Methods | 207 | #region XMLRPC User Methods |
205 | 208 | ||
209 | /// <summary> | ||
210 | /// Authenticate a user using their password | ||
211 | /// </summary> | ||
212 | /// <param name="request">Must contain values for "user_uuid" and "password" keys</param> | ||
213 | /// <param name="remoteClient"></param> | ||
214 | /// <returns></returns> | ||
215 | public XmlRpcResponse XmlRPCAuthenticateUserMethodPassword(XmlRpcRequest request, IPEndPoint remoteClient) | ||
216 | { | ||
217 | // m_log.DebugFormat("[USER MANAGER]: Received authenticated user by password request from {0}", remoteClient); | ||
218 | |||
219 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
220 | string userUuidRaw = (string)requestData["user_uuid"]; | ||
221 | string password = (string)requestData["password"]; | ||
222 | |||
223 | if (null == userUuidRaw) | ||
224 | return Util.CreateUnknownUserErrorResponse(); | ||
225 | |||
226 | UUID userUuid; | ||
227 | if (!UUID.TryParse(userUuidRaw, out userUuid)) | ||
228 | return Util.CreateUnknownUserErrorResponse(); | ||
229 | |||
230 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(userUuid); | ||
231 | if (null == userProfile) | ||
232 | return Util.CreateUnknownUserErrorResponse(); | ||
233 | |||
234 | string authed; | ||
235 | |||
236 | if (null == password) | ||
237 | { | ||
238 | authed = "FALSE"; | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | if (m_userDataBaseService.AuthenticateUserByPassword(userUuid, password)) | ||
243 | authed = "TRUE"; | ||
244 | else | ||
245 | authed = "FALSE"; | ||
246 | } | ||
247 | |||
248 | // m_log.DebugFormat( | ||
249 | // "[USER MANAGER]: Authentication by password result from {0} for {1} is {2}", | ||
250 | // remoteClient, userUuid, authed); | ||
251 | |||
252 | XmlRpcResponse response = new XmlRpcResponse(); | ||
253 | Hashtable responseData = new Hashtable(); | ||
254 | responseData["auth_user"] = authed; | ||
255 | response.Value = responseData; | ||
256 | |||
257 | return response; | ||
258 | } | ||
259 | |||
206 | public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request, IPEndPoint remoteClient) | 260 | public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request, IPEndPoint remoteClient) |
207 | { | 261 | { |
208 | // XmlRpcResponse response = new XmlRpcResponse(); | 262 | // XmlRpcResponse response = new XmlRpcResponse(); |
@@ -246,10 +300,10 @@ namespace OpenSim.Grid.UserServer.Modules | |||
246 | m_userDataBaseService.CommitAgent(ref userProfile); | 300 | m_userDataBaseService.CommitAgent(ref userProfile); |
247 | //setUserProfile(userProfile); | 301 | //setUserProfile(userProfile); |
248 | 302 | ||
249 | |||
250 | returnstring = "TRUE"; | 303 | returnstring = "TRUE"; |
251 | } | 304 | } |
252 | } | 305 | } |
306 | |||
253 | responseData.Add("returnString", returnstring); | 307 | responseData.Add("returnString", returnstring); |
254 | response.Value = responseData; | 308 | response.Value = responseData; |
255 | return response; | 309 | return response; |
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index baf0fd3..286076d7 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs | |||
@@ -187,13 +187,13 @@ namespace OpenSim.Grid.UserServer | |||
187 | /// <param name="inventoryService"></param> | 187 | /// <param name="inventoryService"></param> |
188 | protected virtual void StartupUserServerModules() | 188 | protected virtual void StartupUserServerModules() |
189 | { | 189 | { |
190 | m_log.Info("[STARTUP]: Establishing data connection"); | 190 | m_log.Info("[STARTUP]: Establishing data connection"); |
191 | 191 | ||
192 | //we only need core components so we can request them from here | 192 | //we only need core components so we can request them from here |
193 | IInterServiceInventoryServices inventoryService; | 193 | IInterServiceInventoryServices inventoryService; |
194 | TryGet<IInterServiceInventoryServices>(out inventoryService); | 194 | TryGet<IInterServiceInventoryServices>(out inventoryService); |
195 | 195 | ||
196 | CommunicationsManager commsManager = new UserServerCommsManager(inventoryService); | 196 | CommunicationsManager commsManager = new UserServerCommsManager(inventoryService); |
197 | 197 | ||
198 | //setup database access service, for now this has to be created before the other modules. | 198 | //setup database access service, for now this has to be created before the other modules. |
199 | m_userDataBaseService = new UserDataBaseService(commsManager); | 199 | m_userDataBaseService = new UserDataBaseService(commsManager); |
@@ -260,8 +260,6 @@ namespace OpenSim.Grid.UserServer | |||
260 | m_userManager.PostInitialise(); | 260 | m_userManager.PostInitialise(); |
261 | m_avatarAppearanceModule.PostInitialise(); | 261 | m_avatarAppearanceModule.PostInitialise(); |
262 | m_friendsModule.PostInitialise(); | 262 | m_friendsModule.PostInitialise(); |
263 | |||
264 | m_avatarAppearanceModule.PostInitialise(); | ||
265 | } | 263 | } |
266 | 264 | ||
267 | protected virtual void RegisterHttpHandlers() | 265 | protected virtual void RegisterHttpHandlers() |
@@ -276,8 +274,6 @@ namespace OpenSim.Grid.UserServer | |||
276 | m_avatarAppearanceModule.RegisterHandlers(m_httpServer); | 274 | m_avatarAppearanceModule.RegisterHandlers(m_httpServer); |
277 | m_messagesService.RegisterHandlers(m_httpServer); | 275 | m_messagesService.RegisterHandlers(m_httpServer); |
278 | m_gridInfoService.RegisterHandlers(m_httpServer); | 276 | m_gridInfoService.RegisterHandlers(m_httpServer); |
279 | |||
280 | m_avatarAppearanceModule.RegisterHandlers(m_httpServer); | ||
281 | } | 277 | } |
282 | 278 | ||
283 | public override void ShutdownSpecific() | 279 | public override void ShutdownSpecific() |
diff --git a/OpenSim/Grid/UserServer/UserServerCommsManager.cs b/OpenSim/Grid/UserServer/UserServerCommsManager.cs index 7200836..8ef693b 100644 --- a/OpenSim/Grid/UserServer/UserServerCommsManager.cs +++ b/OpenSim/Grid/UserServer/UserServerCommsManager.cs | |||
@@ -28,9 +28,9 @@ | |||
28 | using OpenSim.Framework.Communications; | 28 | using OpenSim.Framework.Communications; |
29 | 29 | ||
30 | namespace OpenSim.Grid.UserServer | 30 | namespace OpenSim.Grid.UserServer |
31 | { | 31 | { |
32 | public class UserServerCommsManager : CommunicationsManager | 32 | public class UserServerCommsManager : CommunicationsManager |
33 | { | 33 | { |
34 | public UserServerCommsManager(IInterServiceInventoryServices interServiceInventoryService) | 34 | public UserServerCommsManager(IInterServiceInventoryServices interServiceInventoryService) |
35 | : base(null, null) | 35 | : base(null, null) |
36 | { | 36 | { |