diff options
Diffstat (limited to 'OpenSim/Client')
-rw-r--r-- | OpenSim/Client/Linden/LLProxyLoginModule.cs | 335 | ||||
-rw-r--r-- | OpenSim/Client/Linden/LLStandaloneLoginModule.cs | 290 | ||||
-rw-r--r-- | OpenSim/Client/Linden/LLStandaloneLoginService.cs | 239 | ||||
-rw-r--r-- | OpenSim/Client/Linden/Resources/LindenModules.addin.xml | 2 | ||||
-rw-r--r-- | OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 2 | ||||
-rw-r--r-- | OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | 121 |
6 files changed, 29 insertions, 960 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using Nwc.XmlRpc; | ||
33 | using System.Net; | ||
34 | using System.Net.Sockets; | ||
35 | using System.Reflection; | ||
36 | using System.Security.Authentication; | ||
37 | using log4net; | ||
38 | using Nini.Config; | ||
39 | using OpenMetaverse; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Communications; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | |||
46 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Capabilities; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | |||
45 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Services; | ||
40 | using OpenSim.Framework.Communications.Cache; | ||
41 | using OpenSim.Framework.Capabilities; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Region.Framework.Interfaces; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | |||
47 | namespace 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> |
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 3c98229..2d80d83 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs | |||
@@ -427,7 +427,7 @@ namespace OpenSim.Client.MXP.ClientStack | |||
427 | pe.ObjectFragment.ObjectIndex = (uint)(m_scene.RegionInfo.RegionSettings.RegionUUID.GetHashCode() + ((long)int.MaxValue) / 2); | 427 | pe.ObjectFragment.ObjectIndex = (uint)(m_scene.RegionInfo.RegionSettings.RegionUUID.GetHashCode() + ((long)int.MaxValue) / 2); |
428 | pe.ObjectFragment.ParentObjectId = UUID.Zero.Guid; | 428 | pe.ObjectFragment.ParentObjectId = UUID.Zero.Guid; |
429 | pe.ObjectFragment.ObjectName = "Terrain of " + m_scene.RegionInfo.RegionName; | 429 | pe.ObjectFragment.ObjectName = "Terrain of " + m_scene.RegionInfo.RegionName; |
430 | pe.ObjectFragment.OwnerId = m_scene.RegionInfo.MasterAvatarAssignedUUID.Guid; | 430 | pe.ObjectFragment.OwnerId = m_scene.RegionInfo.EstateSettings.EstateOwner.Guid; |
431 | pe.ObjectFragment.TypeId = Guid.Empty; | 431 | pe.ObjectFragment.TypeId = Guid.Empty; |
432 | pe.ObjectFragment.TypeName = "Terrain"; | 432 | pe.ObjectFragment.TypeName = "Terrain"; |
433 | pe.ObjectFragment.Acceleration = new MsdVector3f(); | 433 | pe.ObjectFragment.Acceleration = new MsdVector3f(); |
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs index 7d71f18..821aea2 100644 --- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs +++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Client.MXP.ClientStack; | |||
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Framework.Communications; | 43 | using OpenSim.Framework.Communications; |
44 | using OpenSim.Services.Interfaces; | ||
44 | using System.Security.Cryptography; | 45 | using System.Security.Cryptography; |
45 | 46 | ||
46 | namespace OpenSim.Client.MXP.PacketHandler | 47 | namespace OpenSim.Client.MXP.PacketHandler |
@@ -295,13 +296,11 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
295 | regionExists = false; | 296 | regionExists = false; |
296 | } | 297 | } |
297 | 298 | ||
298 | UserProfileData user = null; | ||
299 | UUID userId = UUID.Zero; | 299 | UUID userId = UUID.Zero; |
300 | string firstName = null; | 300 | UserAccount account = null; |
301 | string lastName = null; | ||
302 | bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName, | 301 | bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName, |
303 | joinRequestMessage.ParticipantPassphrase, | 302 | joinRequestMessage.ParticipantPassphrase, |
304 | new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName, out user) | 303 | new UUID(joinRequestMessage.BubbleId), out account) |
305 | : false; | 304 | : false; |
306 | 305 | ||
307 | if (authorized) | 306 | if (authorized) |
@@ -316,10 +315,11 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
316 | session.RemoteEndPoint.Port + ")"); | 315 | session.RemoteEndPoint.Port + ")"); |
317 | 316 | ||
318 | m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile..."); | 317 | m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile..."); |
319 | AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user); | 318 | UUID secureSession = UUID.Zero; |
319 | AttachUserAgentToUserProfile(account, session, mxpSessionID, sceneId, out secureSession); | ||
320 | m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile."); | 320 | m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile."); |
321 | m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection..."); | 321 | m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection..."); |
322 | if (!PrepareSceneForConnection(mxpSessionID, sceneId, user, out reason)) | 322 | if (!PrepareSceneForConnection(mxpSessionID, secureSession, sceneId, account, out reason)) |
323 | { | 323 | { |
324 | m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason); | 324 | m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason); |
325 | DeclineConnection(session, joinRequestMessage); | 325 | DeclineConnection(session, joinRequestMessage); |
@@ -332,7 +332,7 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
332 | m_log.Info("[MXP ClientStack]: Accepted connection."); | 332 | m_log.Info("[MXP ClientStack]: Accepted connection."); |
333 | 333 | ||
334 | m_log.Debug("[MXP ClientStack]: Creating ClientView...."); | 334 | m_log.Debug("[MXP ClientStack]: Creating ClientView...."); |
335 | MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, firstName, lastName); | 335 | MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, account.FirstName, account.LastName); |
336 | m_clients.Add(client); | 336 | m_clients.Add(client); |
337 | m_log.Debug("[MXP ClientStack]: Created ClientView."); | 337 | m_log.Debug("[MXP ClientStack]: Created ClientView."); |
338 | 338 | ||
@@ -489,12 +489,12 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
489 | session.SetStateDisconnected(); | 489 | session.SetStateDisconnected(); |
490 | } | 490 | } |
491 | 491 | ||
492 | public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UUID userId, out string firstName, out string lastName, out UserProfileData userProfile) | 492 | public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UserAccount account) |
493 | { | 493 | { |
494 | userId = UUID.Zero; | 494 | UUID userId = UUID.Zero; |
495 | firstName = ""; | 495 | string firstName = ""; |
496 | lastName = ""; | 496 | string lastName = ""; |
497 | userProfile = null; | 497 | account = null; |
498 | 498 | ||
499 | string[] nameParts = participantName.Split(' '); | 499 | string[] nameParts = participantName.Split(' '); |
500 | if (nameParts.Length != 2) | 500 | if (nameParts.Length != 2) |
@@ -505,103 +505,38 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
505 | firstName = nameParts[0]; | 505 | firstName = nameParts[0]; |
506 | lastName = nameParts[1]; | 506 | lastName = nameParts[1]; |
507 | 507 | ||
508 | userProfile = m_scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName); | 508 | account = m_scenes[sceneId].UserAccountService.GetUserAccount(m_scenes[sceneId].RegionInfo.ScopeID, firstName, lastName); |
509 | if (account != null) | ||
510 | return (m_scenes[sceneId].AuthenticationService.Authenticate(account.PrincipalID, password, 1) != string.Empty); | ||
509 | 511 | ||
510 | if (userProfile == null && !m_accountsAuthenticate) | 512 | return false; |
511 | { | ||
512 | userId = ((UserManagerBase)m_scenes[sceneId].CommsManager.UserService).AddUser(firstName, lastName, "test", "", 1000, 1000); | ||
513 | } | ||
514 | else | ||
515 | { | ||
516 | if (userProfile == null) | ||
517 | { | ||
518 | m_log.Error("[MXP ClientStack]: Login failed as user was not found: " + participantName); | ||
519 | return false; | ||
520 | } | ||
521 | userId = userProfile.ID; | ||
522 | } | ||
523 | |||
524 | if (m_accountsAuthenticate) | ||
525 | { | ||
526 | if (!password.StartsWith("$1$")) | ||
527 | { | ||
528 | password = "$1$" + Util.Md5Hash(password); | ||
529 | } | ||
530 | password = password.Remove(0, 3); //remove $1$ | ||
531 | string s = Util.Md5Hash(password + ":" + userProfile.PasswordSalt); | ||
532 | return (userProfile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | ||
533 | || userProfile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); | ||
534 | } | ||
535 | else | ||
536 | { | ||
537 | return true; | ||
538 | } | ||
539 | } | 513 | } |
540 | 514 | ||
541 | private void AttachUserAgentToUserProfile(Session session, UUID sessionId, UUID sceneId, UserProfileData userProfile) | 515 | private void AttachUserAgentToUserProfile(UserAccount account, Session session, UUID sessionId, UUID sceneId, out UUID secureSessionId) |
542 | { | 516 | { |
543 | //Scene scene = m_scenes[sceneId]; | 517 | secureSessionId = UUID.Random(); |
544 | CommunicationsManager commsManager = m_scenes[sceneId].CommsManager; | 518 | Scene scene = m_scenes[sceneId]; |
545 | IUserService userService = (IUserService)commsManager.UserService; | 519 | scene.PresenceService.LoginAgent(account.PrincipalID.ToString(), sessionId, secureSessionId); |
546 | |||
547 | UserAgentData agent = new UserAgentData(); | ||
548 | |||
549 | // User connection | ||
550 | agent.AgentOnline = true; | ||
551 | agent.AgentIP = session.RemoteEndPoint.Address.ToString(); | ||
552 | agent.AgentPort = (uint)session.RemoteEndPoint.Port; | ||
553 | |||
554 | agent.SecureSessionID = UUID.Random(); | ||
555 | agent.SessionID = sessionId; | ||
556 | |||
557 | // Profile UUID | ||
558 | agent.ProfileID = userProfile.ID; | ||
559 | |||
560 | // Current location/position/alignment | ||
561 | if (userProfile.CurrentAgent != null) | ||
562 | { | ||
563 | agent.Region = userProfile.CurrentAgent.Region; | ||
564 | agent.Handle = userProfile.CurrentAgent.Handle; | ||
565 | agent.Position = userProfile.CurrentAgent.Position; | ||
566 | agent.LookAt = userProfile.CurrentAgent.LookAt; | ||
567 | } | ||
568 | else | ||
569 | { | ||
570 | agent.Region = userProfile.HomeRegionID; | ||
571 | agent.Handle = userProfile.HomeRegion; | ||
572 | agent.Position = userProfile.HomeLocation; | ||
573 | agent.LookAt = userProfile.HomeLookAt; | ||
574 | } | ||
575 | |||
576 | // What time did the user login? | ||
577 | agent.LoginTime = Util.UnixTimeSinceEpoch(); | ||
578 | agent.LogoutTime = 0; | ||
579 | |||
580 | userProfile.CurrentAgent = agent; | ||
581 | |||
582 | |||
583 | userService.UpdateUserProfile(userProfile); | ||
584 | //userService.CommitAgent(ref userProfile); | ||
585 | } | 520 | } |
586 | 521 | ||
587 | private bool PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile, out string reason) | 522 | private bool PrepareSceneForConnection(UUID sessionId, UUID secureSessionId, UUID sceneId, UserAccount account, out string reason) |
588 | { | 523 | { |
589 | Scene scene = m_scenes[sceneId]; | 524 | Scene scene = m_scenes[sceneId]; |
590 | CommunicationsManager commsManager = m_scenes[sceneId].CommsManager; | ||
591 | UserManagerBase userService = (UserManagerBase)commsManager.UserService; | ||
592 | 525 | ||
593 | AgentCircuitData agent = new AgentCircuitData(); | 526 | AgentCircuitData agent = new AgentCircuitData(); |
594 | agent.AgentID = userProfile.ID; | 527 | agent.AgentID = account.PrincipalID; |
595 | agent.firstname = userProfile.FirstName; | 528 | agent.firstname = account.FirstName; |
596 | agent.lastname = userProfile.SurName; | 529 | agent.lastname = account.LastName; |
597 | agent.SessionID = sessionId; | 530 | agent.SessionID = sessionId; |
598 | agent.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; | 531 | agent.SecureSessionID = secureSessionId; |
599 | agent.circuitcode = sessionId.CRC(); | 532 | agent.circuitcode = sessionId.CRC(); |
600 | agent.BaseFolder = UUID.Zero; | 533 | agent.BaseFolder = UUID.Zero; |
601 | agent.InventoryFolder = UUID.Zero; | 534 | agent.InventoryFolder = UUID.Zero; |
602 | agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position | 535 | agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position |
603 | agent.CapsPath = "http://localhost/"; | 536 | agent.CapsPath = "http://localhost/"; |
604 | agent.Appearance = userService.GetUserAppearance(userProfile.ID); | 537 | AvatarData avatar = scene.AvatarService.GetAvatar(account.PrincipalID); |
538 | if (avatar != null) | ||
539 | agent.Appearance = avatar.ToAvatarAppearance(account.PrincipalID); //userService.GetUserAppearance(userProfile.ID); | ||
605 | 540 | ||
606 | if (agent.Appearance == null) | 541 | if (agent.Appearance == null) |
607 | { | 542 | { |