aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Hypergrid
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Hypergrid')
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs196
1 files changed, 0 insertions, 196 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs
deleted file mode 100644
index 4baefc4..0000000
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs
+++ /dev/null
@@ -1,196 +0,0 @@
1/**
2 * Copyright (c) 2008, Contributors. All rights reserved.
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the Organizations nor the names of Individual
14 * Contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25 * OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29using System.Reflection;
30using log4net;
31using Nini.Config;
32using OpenMetaverse;
33using OpenSim.Data;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.Interfaces;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41
42namespace OpenSim.Region.CoreModules.Hypergrid
43{
44 public class HGStandaloneAssetService : IRegionModule
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private static bool initialized = false;
48 private static bool enabled = false;
49
50 Scene m_scene;
51 //AssetService m_assetService;
52
53 #region IRegionModule interface
54
55 public void Initialise(Scene scene, IConfigSource config)
56 {
57 if (!initialized)
58 {
59 initialized = true;
60 m_scene = scene;
61
62 // This module is only on for standalones in hypergrid mode
63 enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false);
64 }
65 }
66
67 public void PostInitialise()
68 {
69 if (enabled)
70 {
71 m_log.Info("[HGStandaloneAssetService]: Starting...");
72
73 //m_assetService = new AssetService(m_scene);
74 new AssetService(m_scene);
75 }
76 }
77
78 public void Close()
79 {
80 }
81
82 public string Name
83 {
84 get { return "HGStandaloneAssetService"; }
85 }
86
87 public bool IsSharedModule
88 {
89 get { return true; }
90 }
91
92 #endregion
93
94 }
95
96 public class AssetService
97 {
98 private IUserService m_userService;
99 private bool m_doLookup = false;
100
101 public bool DoLookup
102 {
103 get { return m_doLookup; }
104 set { m_doLookup = value; }
105 }
106 private static readonly ILog m_log
107 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
108
109 public AssetService(Scene m_scene)
110 {
111 AddHttpHandlers(m_scene);
112 m_userService = m_scene.CommsManager.UserService;
113 }
114
115 protected void AddHttpHandlers(Scene m_scene)
116 {
117 IAssetDataPlugin m_assetProvider
118 = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin;
119
120 IHttpServer httpServer = m_scene.CommsManager.HttpServer;
121 httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider));
122 httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider));
123
124 }
125
126 ///// <summary>
127 ///// Check that the source of an inventory request is one that we trust.
128 ///// </summary>
129 ///// <param name="peer"></param>
130 ///// <returns></returns>
131 //public bool CheckTrustSource(IPEndPoint peer)
132 //{
133 // if (m_doLookup)
134 // {
135 // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer);
136 // UriBuilder ub = new UriBuilder(m_userserver_url);
137 // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host);
138 // foreach (IPAddress uaddr in uaddrs)
139 // {
140 // if (uaddr.Equals(peer.Address))
141 // {
142 // return true;
143 // }
144 // }
145
146 // m_log.WarnFormat(
147 // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources",
148 // peer);
149
150 // return false;
151 // }
152 // else
153 // {
154 // return true;
155 // }
156 //}
157
158 /// <summary>
159 /// Check that the source of an inventory request for a particular agent is a current session belonging to
160 /// that agent.
161 /// </summary>
162 /// <param name="session_id"></param>
163 /// <param name="avatar_id"></param>
164 /// <returns></returns>
165 public bool CheckAuthSession(string session_id, string avatar_id)
166 {
167 if (m_doLookup)
168 {
169 m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id);
170 UUID userID = UUID.Zero;
171 UUID sessionID = UUID.Zero;
172 UUID.TryParse(avatar_id, out userID);
173 UUID.TryParse(session_id, out sessionID);
174 if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero))
175 {
176 m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id);
177 return false;
178 }
179 UserProfileData userProfile = m_userService.GetUserProfile(userID);
180 if (userProfile != null && userProfile.CurrentAgent != null &&
181 userProfile.CurrentAgent.SessionID == sessionID)
182 {
183 m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access.");
184 return true;
185 }
186
187 m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected");
188 return false;
189 }
190 else
191 {
192 return true;
193 }
194 }
195 }
196}