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