aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client
diff options
context:
space:
mode:
authorDiva Canto2010-01-08 20:31:29 -0800
committerDiva Canto2010-01-08 20:31:29 -0800
commit6b60f3cce5b9dc8c005c9fdb53731dc4e3e45ee8 (patch)
tree4608042e707df452c7e59363927f5bd87249d34b /OpenSim/Client
parentAdd migrations to add fields to user and auth tables (diff)
downloadopensim-SC-6b60f3cce5b9dc8c005c9fdb53731dc4e3e45ee8.zip
opensim-SC-6b60f3cce5b9dc8c005c9fdb53731dc4e3e45ee8.tar.gz
opensim-SC-6b60f3cce5b9dc8c005c9fdb53731dc4e3e45ee8.tar.bz2
opensim-SC-6b60f3cce5b9dc8c005c9fdb53731dc4e3e45ee8.tar.xz
A few more inches... Old friends things removed. Less references to UserProfileService.
Diffstat (limited to '')
-rw-r--r--OpenSim/Client/Linden/LLProxyLoginModule.cs364
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginModule.cs305
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginService.cs245
-rw-r--r--OpenSim/Client/Linden/Resources/LindenModules.addin.xml4
4 files changed, 0 insertions, 918 deletions
diff --git a/OpenSim/Client/Linden/LLProxyLoginModule.cs b/OpenSim/Client/Linden/LLProxyLoginModule.cs
deleted file mode 100644
index 9075f15..0000000
--- a/OpenSim/Client/Linden/LLProxyLoginModule.cs
+++ /dev/null
@@ -1,364 +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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using Nwc.XmlRpc;
33using System.Net;
34using System.Net.Sockets;
35using System.Reflection;
36using System.Security.Authentication;
37using log4net;
38using Nini.Config;
39using OpenMetaverse;
40using OpenSim.Framework;
41using OpenSim.Framework.Communications;
42using OpenSim.Framework.Servers;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes;
45
46namespace OpenSim.Client.Linden
47{
48 /// <summary>
49 /// Handles login user (expect user) and logoff user messages from the remote LL login server
50 /// </summary>
51 public class LLProxyLoginModule : ISharedRegionModule
52 {
53 private uint m_port = 0;
54
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 public LLProxyLoginModule(uint port)
58 {
59 m_log.DebugFormat("[CLIENT]: LLProxyLoginModule port {0}", port);
60 m_port = port;
61 }
62
63 protected bool RegionLoginsEnabled
64 {
65 get
66 {
67 if (m_firstScene != null)
68 {
69 return m_firstScene.SceneGridService.RegionLoginsEnabled;
70 }
71 else
72 {
73 return false;
74 }
75 }
76 }
77
78 protected List<Scene> m_scenes = new List<Scene>();
79 protected Scene m_firstScene;
80
81 protected bool m_enabled = false; // Module is only enabled if running in grid mode
82
83 #region IRegionModule Members
84
85 public void Initialise(IConfigSource source)
86 {
87 IConfig startupConfig = source.Configs["Modules"];
88 if (startupConfig != null)
89 {
90 m_enabled = startupConfig.GetBoolean("LLProxyLoginModule", false);
91 }
92 }
93
94 public void AddRegion(Scene scene)
95 {
96 if (m_firstScene == null)
97 {
98 m_firstScene = scene;
99
100 if (m_enabled)
101 {
102 AddHttpHandlers();
103 }
104 }
105
106 if (m_enabled)
107 {
108 AddScene(scene);
109 }
110
111 }
112
113 public void RemoveRegion(Scene scene)
114 {
115 if (m_enabled)
116 {
117 RemoveScene(scene);
118 }
119 }
120
121 public void PostInitialise()
122 {
123
124 }
125
126 public void Close()
127 {
128
129 }
130
131 public void RegionLoaded(Scene scene)
132 {
133
134 }
135
136 public Type ReplaceableInterface
137 {
138 get { return null; }
139 }
140
141 public string Name
142 {
143 get { return "LLProxyLoginModule"; }
144 }
145
146 public bool IsSharedModule
147 {
148 get { return true; }
149 }
150
151 #endregion
152
153 /// <summary>
154 /// Adds "expect_user" and "logoff_user" xmlrpc method handlers
155 /// </summary>
156 protected void AddHttpHandlers()
157 {
158 //we will add our handlers to the first scene we received, as all scenes share a http server. But will this ever change?
159 MainServer.GetHttpServer(m_port).AddXmlRPCHandler("expect_user", ExpectUser, false);
160 MainServer.GetHttpServer(m_port).AddXmlRPCHandler("logoff_user", LogOffUser, false);
161 }
162
163 protected void AddScene(Scene scene)
164 {
165 lock (m_scenes)
166 {
167 if (!m_scenes.Contains(scene))
168 {
169 m_scenes.Add(scene);
170 }
171 }
172 }
173
174 protected void RemoveScene(Scene scene)
175 {
176 lock (m_scenes)
177 {
178 if (m_scenes.Contains(scene))
179 {
180 m_scenes.Remove(scene);
181 }
182 }
183 }
184 /// <summary>
185 /// Received from the user server when a user starts logging in. This call allows
186 /// the region to prepare for direct communication from the client. Sends back an empty
187 /// xmlrpc response on completion.
188 /// </summary>
189 /// <param name="request"></param>
190 /// <returns></returns>
191 public XmlRpcResponse ExpectUser(XmlRpcRequest request, IPEndPoint remoteClient)
192 {
193 XmlRpcResponse resp = new XmlRpcResponse();
194
195 try
196 {
197 ulong regionHandle = 0;
198 Hashtable requestData = (Hashtable)request.Params[0];
199 AgentCircuitData agentData = new AgentCircuitData();
200 if (requestData.ContainsKey("session_id"))
201 agentData.SessionID = new UUID((string)requestData["session_id"]);
202 if (requestData.ContainsKey("secure_session_id"))
203 agentData.SecureSessionID = new UUID((string)requestData["secure_session_id"]);
204 if (requestData.ContainsKey("firstname"))
205 agentData.firstname = (string)requestData["firstname"];
206 if (requestData.ContainsKey("lastname"))
207 agentData.lastname = (string)requestData["lastname"];
208 if (requestData.ContainsKey("agent_id"))
209 agentData.AgentID = new UUID((string)requestData["agent_id"]);
210 if (requestData.ContainsKey("circuit_code"))
211 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
212 if (requestData.ContainsKey("caps_path"))
213 agentData.CapsPath = (string)requestData["caps_path"];
214 if (requestData.ContainsKey("regionhandle"))
215 regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
216 else
217 m_log.Warn("[CLIENT]: request from login server did not contain regionhandle");
218
219 // Appearance
220 if (requestData.ContainsKey("appearance"))
221 agentData.Appearance = new AvatarAppearance((Hashtable)requestData["appearance"]);
222
223 m_log.DebugFormat(
224 "[CLIENT]: Told by user service to prepare for a connection from {0} {1} {2}, circuit {3}",
225 agentData.firstname, agentData.lastname, agentData.AgentID, agentData.circuitcode);
226
227 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
228 {
229 //m_log.Debug("[CLIENT]: Child agent detected");
230 agentData.child = true;
231 }
232 else
233 {
234 //m_log.Debug("[CLIENT]: Main agent detected");
235 agentData.startpos =
236 new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
237 (float)Convert.ToDecimal((string)requestData["startpos_y"]),
238 (float)Convert.ToDecimal((string)requestData["startpos_z"]));
239 agentData.child = false;
240 }
241
242 if (!RegionLoginsEnabled)
243 {
244 m_log.InfoFormat(
245 "[CLIENT]: Denying access for user {0} {1} because region login is currently disabled",
246 agentData.firstname, agentData.lastname);
247
248 Hashtable respdata = new Hashtable();
249 respdata["success"] = "FALSE";
250 respdata["reason"] = "region login currently disabled";
251 resp.Value = respdata;
252 }
253 else
254 {
255 bool success = false;
256 string denyMess = "";
257
258 Scene scene;
259 if (TryGetRegion(regionHandle, out scene))
260 {
261 if (scene.RegionInfo.EstateSettings.IsBanned(agentData.AgentID))
262 {
263 denyMess = "User is banned from this region";
264 m_log.InfoFormat(
265 "[CLIENT]: Denying access for user {0} {1} because user is banned",
266 agentData.firstname, agentData.lastname);
267 }
268 else
269 {
270 string reason;
271 if (scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason))
272 {
273 success = true;
274 }
275 else
276 {
277 denyMess = String.Format("Login refused by region: {0}", reason);
278 m_log.InfoFormat(
279 "[CLIENT]: Denying access for user {0} {1} because user connection was refused by the region",
280 agentData.firstname, agentData.lastname);
281 }
282 }
283
284 }
285 else
286 {
287 denyMess = "Region not found";
288 }
289
290 if (success)
291 {
292 Hashtable respdata = new Hashtable();
293 respdata["success"] = "TRUE";
294 resp.Value = respdata;
295 }
296 else
297 {
298 Hashtable respdata = new Hashtable();
299 respdata["success"] = "FALSE";
300 respdata["reason"] = denyMess;
301 resp.Value = respdata;
302 }
303 }
304 }
305 catch (Exception e)
306 {
307 m_log.WarnFormat("[CLIENT]: Unable to receive user. Reason: {0} ({1})", e, e.StackTrace);
308 Hashtable respdata = new Hashtable();
309 respdata["success"] = "FALSE";
310 respdata["reason"] = "Exception occurred";
311 resp.Value = respdata;
312 }
313
314 return resp;
315 }
316
317 // Grid Request Processing
318 /// <summary>
319 /// Ooops, our Agent must be dead if we're getting this request!
320 /// </summary>
321 /// <param name="request"></param>
322 /// <returns></returns>
323 public XmlRpcResponse LogOffUser(XmlRpcRequest request, IPEndPoint remoteClient)
324 {
325 m_log.Debug("[CONNECTION DEBUGGING]: LogOff User Called");
326
327 Hashtable requestData = (Hashtable)request.Params[0];
328 string message = (string)requestData["message"];
329 UUID agentID = UUID.Zero;
330 UUID RegionSecret = UUID.Zero;
331 UUID.TryParse((string)requestData["agent_id"], out agentID);
332 UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
333
334 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
335
336 Scene scene;
337 if (TryGetRegion(regionHandle, out scene))
338 {
339 scene.HandleLogOffUserFromGrid(agentID, RegionSecret, message);
340 }
341
342 return new XmlRpcResponse();
343 }
344
345 protected bool TryGetRegion(ulong regionHandle, out Scene scene)
346 {
347 lock (m_scenes)
348 {
349 foreach (Scene nextScene in m_scenes)
350 {
351 if (nextScene.RegionInfo.RegionHandle == regionHandle)
352 {
353 scene = nextScene;
354 return true;
355 }
356 }
357 }
358
359 scene = null;
360 return false;
361 }
362
363 }
364}
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
deleted file mode 100644
index 8047f74..0000000
--- a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
+++ /dev/null
@@ -1,305 +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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Capabilities;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Interfaces;
44
45namespace OpenSim.Client.Linden
46{
47 public class LLStandaloneLoginModule : ISharedRegionModule, ILoginServiceToRegionsConnector
48 {
49 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 protected List<Scene> m_scenes = new List<Scene>();
52 protected Scene m_firstScene;
53
54 protected bool m_enabled = false; // Module is only enabled if running in standalone mode
55
56 protected bool authenticate;
57 protected string welcomeMessage;
58
59 public bool RegionLoginsEnabled
60 {
61 get
62 {
63 if (m_firstScene != null)
64 {
65 return m_firstScene.SceneGridService.RegionLoginsEnabled;
66 }
67 else
68 {
69 return false;
70 }
71 }
72 }
73
74 protected LLStandaloneLoginService m_loginService;
75
76 #region IRegionModule Members
77
78 public void Initialise(IConfigSource source)
79 {
80 IConfig startupConfig = source.Configs["Startup"];
81 if (startupConfig != null)
82 {
83 m_enabled = !startupConfig.GetBoolean("gridmode", false);
84 }
85
86 if (m_enabled)
87 {
88 authenticate = true;
89 welcomeMessage = "Welcome to OpenSim";
90 IConfig standaloneConfig = source.Configs["StandAlone"];
91 if (standaloneConfig != null)
92 {
93 authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true);
94 welcomeMessage = standaloneConfig.GetString("welcome_message");
95 }
96 }
97 }
98
99 public void AddRegion(Scene scene)
100 {
101 }
102
103 public void RemoveRegion(Scene scene)
104 {
105 if (m_enabled)
106 {
107 RemoveScene(scene);
108 }
109 }
110
111 public void PostInitialise()
112 {
113
114 }
115
116 public void Close()
117 {
118
119 }
120
121 public void RegionLoaded(Scene scene)
122 {
123 if (m_firstScene == null)
124 {
125 m_firstScene = scene;
126
127 if (m_enabled)
128 {
129 //TODO: fix casting.
130 LibraryRootFolder rootFolder
131 = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder;
132
133 IHttpServer httpServer = MainServer.Instance;
134
135 //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference
136 m_loginService
137 = new LLStandaloneLoginService(
138 (UserManagerBase)m_firstScene.CommsManager.UserAdminService, welcomeMessage,
139 m_firstScene.InventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate,
140 rootFolder, this);
141
142 httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
143
144 // provides the web form login
145 httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
146
147 // Provides the LLSD login
148 httpServer.SetDefaultLLSDHandler(m_loginService.LLSDLoginMethod);
149 }
150 }
151
152 if (m_enabled)
153 {
154 AddScene(scene);
155 }
156 }
157
158 public Type ReplaceableInterface
159 {
160 get { return null; }
161 }
162
163 public string Name
164 {
165 get { return "LLStandaloneLoginModule"; }
166 }
167
168 public bool IsSharedModule
169 {
170 get { return true; }
171 }
172
173 #endregion
174
175 protected void AddScene(Scene scene)
176 {
177 lock (m_scenes)
178 {
179 if (!m_scenes.Contains(scene))
180 {
181 m_scenes.Add(scene);
182 }
183 }
184 }
185
186 protected void RemoveScene(Scene scene)
187 {
188 lock (m_scenes)
189 {
190 if (m_scenes.Contains(scene))
191 {
192 m_scenes.Remove(scene);
193 }
194 }
195 }
196
197 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason)
198 {
199 Scene scene;
200 if (TryGetRegion(regionHandle, out scene))
201 {
202 return scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
203 }
204 reason = "Region not found.";
205 return false;
206 }
207
208 public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message)
209 {
210 Scene scene;
211 if (TryGetRegion(regionHandle, out scene))
212 {
213 scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message);
214 }
215 }
216
217 public RegionInfo RequestNeighbourInfo(ulong regionhandle)
218 {
219 Scene scene;
220 if (TryGetRegion(regionhandle, out scene))
221 {
222 return scene.RegionInfo;
223 }
224 return null;
225 }
226
227 public RegionInfo RequestClosestRegion(string region)
228 {
229 Scene scene;
230 if (TryGetRegion(region, out scene))
231 {
232 return scene.RegionInfo;
233 }
234 else if (m_scenes.Count > 0)
235 {
236 return m_scenes[0].RegionInfo;
237 }
238 return null;
239 }
240
241 public RegionInfo RequestNeighbourInfo(UUID regionID)
242 {
243 Scene scene;
244 if (TryGetRegion(regionID, out scene))
245 {
246 return scene.RegionInfo;
247 }
248 return null;
249 }
250
251 protected bool TryGetRegion(ulong regionHandle, out Scene scene)
252 {
253 lock (m_scenes)
254 {
255 foreach (Scene nextScene in m_scenes)
256 {
257 if (nextScene.RegionInfo.RegionHandle == regionHandle)
258 {
259 scene = nextScene;
260 return true;
261 }
262 }
263 }
264
265 scene = null;
266 return false;
267 }
268
269 protected bool TryGetRegion(UUID regionID, out Scene scene)
270 {
271 lock (m_scenes)
272 {
273 foreach (Scene nextScene in m_scenes)
274 {
275 if (nextScene.RegionInfo.RegionID == regionID)
276 {
277 scene = nextScene;
278 return true;
279 }
280 }
281 }
282
283 scene = null;
284 return false;
285 }
286
287 protected bool TryGetRegion(string regionName, out Scene scene)
288 {
289 lock (m_scenes)
290 {
291 foreach (Scene nextScene in m_scenes)
292 {
293 if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase))
294 {
295 scene = nextScene;
296 return true;
297 }
298 }
299 }
300
301 scene = null;
302 return false;
303 }
304 }
305}
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginService.cs b/OpenSim/Client/Linden/LLStandaloneLoginService.cs
deleted file mode 100644
index a975fa2..0000000
--- a/OpenSim/Client/Linden/LLStandaloneLoginService.cs
+++ /dev/null
@@ -1,245 +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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services;
40using LoginResponse = OpenSim.Framework.Communications.Services.LoginResponse;
41using OpenSim.Framework.Communications.Cache;
42using OpenSim.Framework.Capabilities;
43using OpenSim.Framework.Servers;
44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Services.Interfaces;
47
48namespace OpenSim.Client.Linden
49{
50 public class LLStandaloneLoginService : LoginService
51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 protected NetworkServersInfo m_serversInfo;
55 protected bool m_authUsers = false;
56
57 /// <summary>
58 /// Used to make requests to the local regions.
59 /// </summary>
60 protected ILoginServiceToRegionsConnector m_regionsConnector;
61
62 public LLStandaloneLoginService(
63 UserManagerBase userManager, string welcomeMess,
64 IInventoryService interServiceInventoryService,
65 NetworkServersInfo serversInfo,
66 bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector)
67 : base(userManager, libraryRootFolder, welcomeMess)
68 {
69 this.m_serversInfo = serversInfo;
70 m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX;
71 m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY;
72 m_authUsers = authenticate;
73
74 m_InventoryService = interServiceInventoryService;
75 m_regionsConnector = regionsConnector;
76 // Standard behavior: In StandAlone, silent logout of last hung session
77 m_warn_already_logged = false;
78 }
79
80 public override UserProfileData GetTheUser(string firstname, string lastname)
81 {
82 UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname);
83 if (profile != null)
84 {
85 return profile;
86 }
87
88 if (!m_authUsers)
89 {
90 //no current user account so make one
91 m_log.Info("[LOGIN]: No user account found so creating a new one.");
92
93 m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY);
94
95 return m_userManager.GetUserProfile(firstname, lastname);
96 }
97
98 return null;
99 }
100
101 public override bool AuthenticateUser(UserProfileData profile, string password)
102 {
103 if (!m_authUsers)
104 {
105 //for now we will accept any password in sandbox mode
106 m_log.Info("[LOGIN]: Authorising user (no actual password check)");
107
108 return true;
109 }
110 else
111 {
112 m_log.Info(
113 "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName);
114
115 if (!password.StartsWith("$1$"))
116 password = "$1$" + Util.Md5Hash(password);
117
118 password = password.Remove(0, 3); //remove $1$
119
120 string s = Util.Md5Hash(password + ":" + profile.PasswordSalt);
121
122 bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
123 || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture));
124 return loginresult;
125 }
126 }
127
128 protected override RegionInfo RequestClosestRegion(string region)
129 {
130 return m_regionsConnector.RequestClosestRegion(region);
131 }
132
133 protected override RegionInfo GetRegionInfo(ulong homeRegionHandle)
134 {
135 return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle);
136 }
137
138 protected override RegionInfo GetRegionInfo(UUID homeRegionId)
139 {
140 return m_regionsConnector.RequestNeighbourInfo(homeRegionId);
141 }
142
143 protected override bool PrepareLoginToRegion(
144 RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient)
145 {
146 IPEndPoint endPoint = regionInfo.ExternalEndPoint;
147 response.SimAddress = endPoint.Address.ToString();
148 response.SimPort = (uint)endPoint.Port;
149 response.RegionX = regionInfo.RegionLocX;
150 response.RegionY = regionInfo.RegionLocY;
151
152 string capsPath = CapsUtil.GetRandomCapsObjectPath();
153 string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath);
154
155 // Don't use the following! It Fails for logging into any region not on the same port as the http server!
156 // Kept here so it doesn't happen again!
157 // response.SeedCapability = regionInfo.ServerURI + capsSeedPath;
158
159 string seedcap = "http://";
160
161 if (m_serversInfo.HttpUsesSSL)
162 {
163 // For NAT
164 string host = NetworkUtil.GetHostFor(remoteClient.Address, m_serversInfo.HttpSSLCN);
165
166 seedcap = "https://" + host + ":" + m_serversInfo.httpSSLPort + capsSeedPath;
167 }
168 else
169 {
170 // For NAT
171 string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ExternalHostName);
172
173 seedcap = "http://" + host + ":" + m_serversInfo.HttpListenerPort + capsSeedPath;
174 }
175
176 response.SeedCapability = seedcap;
177
178 // Notify the target of an incoming user
179 m_log.InfoFormat(
180 "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection",
181 regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI);
182
183 // Update agent with target sim
184 user.CurrentAgent.Region = regionInfo.RegionID;
185 user.CurrentAgent.Handle = regionInfo.RegionHandle;
186
187 AgentCircuitData agent = new AgentCircuitData();
188 agent.AgentID = user.ID;
189 agent.firstname = user.FirstName;
190 agent.lastname = user.SurName;
191 agent.SessionID = user.CurrentAgent.SessionID;
192 agent.SecureSessionID = user.CurrentAgent.SecureSessionID;
193 agent.circuitcode = Convert.ToUInt32(response.CircuitCode);
194 agent.BaseFolder = UUID.Zero;
195 agent.InventoryFolder = UUID.Zero;
196 agent.startpos = user.CurrentAgent.Position;
197 agent.CapsPath = capsPath;
198 agent.Appearance = m_userManager.GetUserAppearance(user.ID);
199 if (agent.Appearance == null)
200 {
201 m_log.WarnFormat(
202 "[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
203 agent.Appearance = new AvatarAppearance(agent.AgentID);
204 }
205
206 if (m_regionsConnector.RegionLoginsEnabled)
207 {
208 string reason;
209 bool success = m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason);
210 if (!success)
211 {
212 response.ErrorReason = "key";
213 response.ErrorMessage = reason;
214 }
215 return success;
216 // return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason);
217 }
218
219 return false;
220 }
221
222 public override void LogOffUser(UserProfileData theUser, string message)
223 {
224 RegionInfo SimInfo;
225 try
226 {
227 SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle);
228
229 if (SimInfo == null)
230 {
231 m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in");
232 return;
233 }
234 }
235 catch (Exception)
236 {
237 m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off");
238 return;
239 }
240
241 m_regionsConnector.LogOffUserFromGrid(
242 SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off");
243 }
244 }
245}
diff --git a/OpenSim/Client/Linden/Resources/LindenModules.addin.xml b/OpenSim/Client/Linden/Resources/LindenModules.addin.xml
index a07a00f..af41e98 100644
--- a/OpenSim/Client/Linden/Resources/LindenModules.addin.xml
+++ b/OpenSim/Client/Linden/Resources/LindenModules.addin.xml
@@ -8,10 +8,6 @@
8 </Dependencies> 8 </Dependencies>
9 9
10 <Extension path = "/OpenSim/RegionModules"> 10 <Extension path = "/OpenSim/RegionModules">
11 <!--
12 <RegionModule id="LLStandaloneLoginModule" type="OpenSim.Client.Linden.LLStandaloneLoginModule" />
13 <RegionModule id="LLProxyLoginModule" type="OpenSim.Client.Linden.LLProxyLoginModule" />
14 -->
15 <RegionModule id="LLClientStackModule" type="OpenSim.Client.Linden.LLClientStackModule" /> 11 <RegionModule id="LLClientStackModule" type="OpenSim.Client.Linden.LLClientStackModule" />
16 </Extension> 12 </Extension>
17</Addin> 13</Addin>