diff options
author | lbsa71 | 2009-03-10 09:20:27 +0000 |
---|---|---|
committer | lbsa71 | 2009-03-10 09:20:27 +0000 |
commit | 1956930e0d6204b7533d69805a179665f6dbd83e (patch) | |
tree | d49b70b85954ab8b3ed1ab7837f70d6a125447ea /OpenSim/Region/Communications | |
parent | * Refactored out Create() methods to ensure proper transformation between Reg... (diff) | |
download | opensim-SC_OLD-1956930e0d6204b7533d69805a179665f6dbd83e.zip opensim-SC_OLD-1956930e0d6204b7533d69805a179665f6dbd83e.tar.gz opensim-SC_OLD-1956930e0d6204b7533d69805a179665f6dbd83e.tar.bz2 opensim-SC_OLD-1956930e0d6204b7533d69805a179665f6dbd83e.tar.xz |
* Removed unused and uncommented file
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Communications/Local/LocalLoginService.cs | 433 |
1 files changed, 0 insertions, 433 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs deleted file mode 100644 index bd2910f..0000000 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ /dev/null | |||
@@ -1,433 +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 OpenSim 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.Reflection; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Communications; | ||
37 | using OpenSim.Framework.Communications.Cache; | ||
38 | using OpenSim.Framework.Communications.Capabilities; | ||
39 | |||
40 | namespace OpenSim.Region.Communications.Local | ||
41 | { | ||
42 | /* | ||
43 | public delegate void LoginToRegionEvent(ulong regionHandle, Login login); | ||
44 | |||
45 | public class LocalLoginService : LoginService | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | protected NetworkServersInfo serversInfo; | ||
50 | protected uint defaultHomeX; | ||
51 | protected uint defaultHomeY; | ||
52 | protected bool authUsers = false; | ||
53 | |||
54 | /// <summary> | ||
55 | /// Used by the login service to make requests to the inventory service. | ||
56 | /// </summary> | ||
57 | protected IInterServiceInventoryServices m_interServiceInventoryService; | ||
58 | |||
59 | /// <summary> | ||
60 | /// Used to make requests to the local regions. | ||
61 | /// </summary> | ||
62 | protected LocalBackEndServices m_gridService; | ||
63 | |||
64 | public event LoginToRegionEvent OnLoginToRegion; | ||
65 | |||
66 | protected LoginToRegionEvent handlerLoginToRegion = null; // OnLoginToRegion; | ||
67 | |||
68 | public LocalLoginService( | ||
69 | UserManagerBase userManager, string welcomeMess, | ||
70 | IInterServiceInventoryServices interServiceInventoryService, LocalBackEndServices gridService, | ||
71 | NetworkServersInfo serversInfo, | ||
72 | bool authenticate, LibraryRootFolder libraryRootFolder) | ||
73 | : base(userManager, libraryRootFolder, welcomeMess) | ||
74 | { | ||
75 | this.serversInfo = serversInfo; | ||
76 | defaultHomeX = this.serversInfo.DefaultHomeLocX; | ||
77 | defaultHomeY = this.serversInfo.DefaultHomeLocY; | ||
78 | authUsers = authenticate; | ||
79 | |||
80 | m_interServiceInventoryService = interServiceInventoryService; | ||
81 | m_gridService = gridService; | ||
82 | |||
83 | OnLoginToRegion += gridService.AddNewSession; | ||
84 | } | ||
85 | |||
86 | public override UserProfileData GetTheUser(string firstname, string lastname) | ||
87 | { | ||
88 | UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); | ||
89 | if (profile != null) | ||
90 | { | ||
91 | return profile; | ||
92 | } | ||
93 | |||
94 | if (!authUsers) | ||
95 | { | ||
96 | //no current user account so make one | ||
97 | m_log.Info("[LOGIN]: No user account found so creating a new one."); | ||
98 | |||
99 | m_userManager.AddUser(firstname, lastname, "test", "", defaultHomeX, defaultHomeY); | ||
100 | |||
101 | return m_userManager.GetUserProfile(firstname, lastname); | ||
102 | } | ||
103 | |||
104 | return null; | ||
105 | } | ||
106 | |||
107 | public override bool AuthenticateUser(UserProfileData profile, string password) | ||
108 | { | ||
109 | if (!authUsers) | ||
110 | { | ||
111 | //for now we will accept any password in sandbox mode | ||
112 | m_log.Info("[LOGIN]: Authorising user (no actual password check)"); | ||
113 | |||
114 | return true; | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | m_log.Info( | ||
119 | "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); | ||
120 | |||
121 | if (!password.StartsWith("$1$")) | ||
122 | password = "$1$" + Util.Md5Hash(password); | ||
123 | |||
124 | password = password.Remove(0, 3); //remove $1$ | ||
125 | |||
126 | string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); | ||
127 | |||
128 | bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | ||
129 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); | ||
130 | return loginresult; | ||
131 | } | ||
132 | } | ||
133 | |||
134 | /// <summary> | ||
135 | /// Customises the login response and fills in missing values. | ||
136 | /// </summary> | ||
137 | /// <param name="response">The existing response</param> | ||
138 | /// <param name="theUser">The user profile</param> | ||
139 | /// <param name="startLocationRequest">The requested start location</param> | ||
140 | public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) | ||
141 | { | ||
142 | // add active gestures to login-response | ||
143 | AddActiveGestures(response, theUser); | ||
144 | |||
145 | // HomeLocation | ||
146 | RegionInfo homeInfo = null; | ||
147 | |||
148 | // use the homeRegionID if it is stored already. If not, use the regionHandle as before | ||
149 | UUID homeRegionId = theUser.HomeRegionID; | ||
150 | ulong homeRegionHandle = theUser.HomeRegion; | ||
151 | if (homeRegionId != UUID.Zero) | ||
152 | { | ||
153 | homeInfo = GetRegionInfo(homeRegionId); | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | homeInfo = GetRegionInfo(homeRegionHandle); | ||
158 | } | ||
159 | |||
160 | if (homeInfo != null) | ||
161 | { | ||
162 | response.Home = | ||
163 | string.Format( | ||
164 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
165 | (homeInfo.RegionLocX*Constants.RegionSize), | ||
166 | (homeInfo.RegionLocY*Constants.RegionSize), | ||
167 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
168 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); | ||
173 | // Emergency mode: Home-region isn't available, so we can't request the region info. | ||
174 | // Use the stored home regionHandle instead. | ||
175 | // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again | ||
176 | ulong regionX = homeRegionHandle >> 32; | ||
177 | ulong regionY = homeRegionHandle & 0xffffffff; | ||
178 | response.Home = | ||
179 | string.Format( | ||
180 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
181 | regionX, regionY, | ||
182 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
183 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
184 | |||
185 | m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", | ||
186 | theUser.FirstName, theUser.SurName, | ||
187 | regionX, regionY); | ||
188 | } | ||
189 | |||
190 | // StartLocation | ||
191 | RegionInfo regionInfo = null; | ||
192 | if (startLocationRequest == "home") | ||
193 | { | ||
194 | regionInfo = homeInfo; | ||
195 | theUser.CurrentAgent.Position = theUser.HomeLocation; | ||
196 | response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; | ||
197 | } | ||
198 | else if (startLocationRequest == "last") | ||
199 | { | ||
200 | UUID lastRegion = theUser.CurrentAgent.Region; | ||
201 | regionInfo = GetRegionInfo(lastRegion); | ||
202 | response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
207 | Match uriMatch = reURI.Match(startLocationRequest); | ||
208 | if (uriMatch == null) | ||
209 | { | ||
210 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | string region = uriMatch.Groups["region"].ToString(); | ||
215 | regionInfo = RequestClosestRegion(region); | ||
216 | if (regionInfo == null) | ||
217 | { | ||
218 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), | ||
223 | float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); | ||
224 | } | ||
225 | } | ||
226 | response.LookAt = "[r0,r1,r0]"; | ||
227 | // can be: last, home, safe, url | ||
228 | response.StartLocation = "url"; | ||
229 | } | ||
230 | |||
231 | if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) | ||
232 | { | ||
233 | return true; | ||
234 | } | ||
235 | |||
236 | // StartLocation not available, send him to a nearby region instead | ||
237 | // regionInfo = m_gridService.RequestClosestRegion(""); | ||
238 | //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); | ||
239 | |||
240 | // Send him to default region instead | ||
241 | ulong defaultHandle = (((ulong)defaultHomeX * Constants.RegionSize) << 32) | | ||
242 | ((ulong)defaultHomeY * Constants.RegionSize); | ||
243 | |||
244 | if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) | ||
245 | { | ||
246 | m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); | ||
247 | return false; | ||
248 | } | ||
249 | |||
250 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); | ||
251 | regionInfo = GetRegionInfo(defaultHandle); | ||
252 | |||
253 | // Customise the response | ||
254 | //response.Home = | ||
255 | // string.Format( | ||
256 | // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
257 | // (SimInfo.regionLocX * Constants.RegionSize), | ||
258 | // (SimInfo.regionLocY*Constants.RegionSize), | ||
259 | // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
260 | // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
261 | theUser.CurrentAgent.Position = new Vector3(128,128,0); | ||
262 | response.StartLocation = "safe"; | ||
263 | |||
264 | return PrepareLoginToRegion(regionInfo, theUser, response); | ||
265 | } | ||
266 | |||
267 | protected RegionInfo RequestClosestRegion(string region) | ||
268 | { | ||
269 | return m_gridService.RequestClosestRegion(region); | ||
270 | } | ||
271 | |||
272 | protected RegionInfo GetRegionInfo(ulong homeRegionHandle) | ||
273 | { | ||
274 | return m_gridService.RequestNeighbourInfo(homeRegionHandle); | ||
275 | } | ||
276 | |||
277 | protected RegionInfo GetRegionInfo(UUID homeRegionId) | ||
278 | { | ||
279 | return m_gridService.RequestNeighbourInfo(homeRegionId); | ||
280 | } | ||
281 | |||
282 | /// <summary> | ||
283 | /// Add active gestures of the user to the login response. | ||
284 | /// </summary> | ||
285 | /// <param name="response"> | ||
286 | /// A <see cref="LoginResponse"/> | ||
287 | /// </param> | ||
288 | /// <param name="theUser"> | ||
289 | /// A <see cref="UserProfileData"/> | ||
290 | /// </param> | ||
291 | private void AddActiveGestures(LoginResponse response, UserProfileData theUser) | ||
292 | { | ||
293 | List<InventoryItemBase> gestures = m_interServiceInventoryService.GetActiveGestures(theUser.ID); | ||
294 | //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); | ||
295 | ArrayList list = new ArrayList(); | ||
296 | if (gestures != null) | ||
297 | { | ||
298 | foreach (InventoryItemBase gesture in gestures) | ||
299 | { | ||
300 | Hashtable item = new Hashtable(); | ||
301 | item["item_id"] = gesture.ID.ToString(); | ||
302 | item["asset_id"] = gesture.AssetID.ToString(); | ||
303 | list.Add(item); | ||
304 | } | ||
305 | } | ||
306 | response.ActiveGestures = list; | ||
307 | } | ||
308 | |||
309 | /// <summary> | ||
310 | /// Prepare a login to the given region. This involves both telling the region to expect a connection | ||
311 | /// and appropriately customising the response to the user. | ||
312 | /// </summary> | ||
313 | /// <param name="sim"></param> | ||
314 | /// <param name="user"></param> | ||
315 | /// <param name="response"></param> | ||
316 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | ||
317 | protected bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) | ||
318 | { | ||
319 | response.SimAddress = regionInfo.ExternalEndPoint.Address.ToString(); | ||
320 | response.SimPort = (uint)regionInfo.ExternalEndPoint.Port; | ||
321 | response.RegionX = regionInfo.RegionLocX; | ||
322 | response.RegionY = regionInfo.RegionLocY; | ||
323 | |||
324 | string capsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
325 | string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); | ||
326 | |||
327 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! | ||
328 | // Kept here so it doesn't happen again! | ||
329 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; | ||
330 | |||
331 | string seedcap = "http://"; | ||
332 | |||
333 | if (serversInfo.HttpUsesSSL) | ||
334 | { | ||
335 | seedcap = "https://" + serversInfo.HttpSSLCN + ":" + serversInfo.httpSSLPort + capsSeedPath; | ||
336 | } | ||
337 | else | ||
338 | { | ||
339 | seedcap = "http://" + regionInfo.ExternalHostName + ":" + serversInfo.HttpListenerPort + capsSeedPath; | ||
340 | } | ||
341 | |||
342 | response.SeedCapability = seedcap; | ||
343 | |||
344 | // Notify the target of an incoming user | ||
345 | m_log.InfoFormat( | ||
346 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", | ||
347 | regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); | ||
348 | |||
349 | // Update agent with target sim | ||
350 | user.CurrentAgent.Region = regionInfo.RegionID; | ||
351 | user.CurrentAgent.Handle = regionInfo.RegionHandle; | ||
352 | |||
353 | // Prepare notification | ||
354 | Login loginParams = new Login(); | ||
355 | loginParams.Session = user.CurrentAgent.SessionID; | ||
356 | loginParams.SecureSession = user.CurrentAgent.SecureSessionID; | ||
357 | loginParams.First = user.FirstName; | ||
358 | loginParams.Last = user.SurName; | ||
359 | loginParams.Agent = user.ID; | ||
360 | loginParams.CircuitCode = Convert.ToUInt32(response.CircuitCode); | ||
361 | loginParams.StartPos = user.CurrentAgent.Position; | ||
362 | loginParams.CapsPath = capsPath; | ||
363 | |||
364 | // Appearance | ||
365 | loginParams.Appearance = m_userManager.GetUserAppearance(user.ID); | ||
366 | |||
367 | if (m_gridService.RegionLoginsEnabled) | ||
368 | { | ||
369 | handlerLoginToRegion = OnLoginToRegion; | ||
370 | handlerLoginToRegion(user.CurrentAgent.Handle, loginParams); | ||
371 | return true; | ||
372 | } | ||
373 | |||
374 | return false; | ||
375 | } | ||
376 | |||
377 | // See LoginService | ||
378 | protected override InventoryData GetInventorySkeleton(UUID userID) | ||
379 | { | ||
380 | List<InventoryFolderBase> folders = m_interServiceInventoryService.GetInventorySkeleton(userID); | ||
381 | |||
382 | // If we have user auth but no inventory folders for some reason, create a new set of folders. | ||
383 | if (null == folders || 0 == folders.Count) | ||
384 | { | ||
385 | m_interServiceInventoryService.CreateNewUserInventory(userID); | ||
386 | folders = m_interServiceInventoryService.GetInventorySkeleton(userID); | ||
387 | } | ||
388 | |||
389 | UUID rootID = UUID.Zero; | ||
390 | ArrayList AgentInventoryArray = new ArrayList(); | ||
391 | Hashtable TempHash; | ||
392 | foreach (InventoryFolderBase InvFolder in folders) | ||
393 | { | ||
394 | if (InvFolder.ParentID == UUID.Zero) | ||
395 | { | ||
396 | rootID = InvFolder.ID; | ||
397 | } | ||
398 | TempHash = new Hashtable(); | ||
399 | TempHash["name"] = InvFolder.Name; | ||
400 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); | ||
401 | TempHash["version"] = (Int32) InvFolder.Version; | ||
402 | TempHash["type_default"] = (Int32) InvFolder.Type; | ||
403 | TempHash["folder_id"] = InvFolder.ID.ToString(); | ||
404 | AgentInventoryArray.Add(TempHash); | ||
405 | } | ||
406 | |||
407 | return new InventoryData(AgentInventoryArray, rootID); | ||
408 | } | ||
409 | |||
410 | public override void LogOffUser(UserProfileData theUser, string message) | ||
411 | { | ||
412 | RegionInfo SimInfo; | ||
413 | try | ||
414 | { | ||
415 | SimInfo = this.m_gridService.RequestNeighbourInfo(theUser.CurrentAgent.Handle); | ||
416 | |||
417 | if (SimInfo == null) | ||
418 | { | ||
419 | m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); | ||
420 | return; | ||
421 | } | ||
422 | } | ||
423 | catch (Exception) | ||
424 | { | ||
425 | m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); | ||
426 | return; | ||
427 | } | ||
428 | |||
429 | m_gridService.TriggerLogOffUser(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); | ||
430 | } | ||
431 | |||
432 | }*/ | ||
433 | } | ||