aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorTeravus Ovares2008-01-09 18:57:03 +0000
committerTeravus Ovares2008-01-09 18:57:03 +0000
commit49fe4eb3cdf4b5cb11e5fe0980bb7c3a3d47b6ea (patch)
tree37de8fc8d0f2507fd892b6f24ae6b5899a0f0bd7 /OpenSim/Framework/Communications
parentdefault to OpenSim.Framework.Data.SQLite which is the new storage (diff)
downloadopensim-SC_OLD-49fe4eb3cdf4b5cb11e5fe0980bb7c3a3d47b6ea.zip
opensim-SC_OLD-49fe4eb3cdf4b5cb11e5fe0980bb7c3a3d47b6ea.tar.gz
opensim-SC_OLD-49fe4eb3cdf4b5cb11e5fe0980bb7c3a3d47b6ea.tar.bz2
opensim-SC_OLD-49fe4eb3cdf4b5cb11e5fe0980bb7c3a3d47b6ea.tar.xz
* This may be broken.. it hasn't been tested, however I wanted to get the last database changes in before sdauge changes them significantly.
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs149
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs17
2 files changed, 162 insertions, 4 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 9cfac1c..f0a0a0b 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -29,6 +29,7 @@
29using System; 29using System;
30using System.Collections; 30using System.Collections;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.IO;
32using System.Threading; 33using System.Threading;
33using libsecondlife; 34using libsecondlife;
34using libsecondlife.StructuredData; 35using libsecondlife.StructuredData;
@@ -79,7 +80,7 @@ namespace OpenSim.Framework.UserManagement
79 Hashtable requestData = (Hashtable) request.Params[0]; 80 Hashtable requestData = (Hashtable) request.Params[0];
80 81
81 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && 82 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") &&
82 requestData.Contains("passwd")); 83 (requestData.Contains("passwd") || requestData.Contains("web_login_key")));
83 bool GoodLogin = false; 84 bool GoodLogin = false;
84 85
85 UserProfileData userProfile; 86 UserProfileData userProfile;
@@ -89,7 +90,8 @@ namespace OpenSim.Framework.UserManagement
89 { 90 {
90 string firstname = (string) requestData["first"]; 91 string firstname = (string) requestData["first"];
91 string lastname = (string) requestData["last"]; 92 string lastname = (string) requestData["last"];
92 string passwd = (string) requestData["passwd"]; 93
94
93 95
94 userProfile = GetTheUser(firstname, lastname); 96 userProfile = GetTheUser(firstname, lastname);
95 if (userProfile == null) 97 if (userProfile == null)
@@ -100,8 +102,29 @@ namespace OpenSim.Framework.UserManagement
100 102
101 return logResponse.CreateLoginFailedResponse(); 103 return logResponse.CreateLoginFailedResponse();
102 } 104 }
105 if (requestData.Contains("passwd"))
106 {
107 string passwd = (string)requestData["passwd"];
108 GoodLogin = AuthenticateUser(userProfile, passwd);
109 }
110 else if (requestData.Contains("web_login_key"))
111 {
112 LLUUID webloginkey = null;
113 try
114 {
115 webloginkey = new LLUUID((string)requestData["web_login_key"]);
116 }
117 catch (System.Exception)
118 {
119 return logResponse.CreateFailedResponse();
120 }
121 GoodLogin = AuthenticateUser(userProfile, webloginkey);
103 122
104 GoodLogin = AuthenticateUser(userProfile, passwd); 123 }
124 else
125 {
126 return logResponse.CreateFailedResponse();
127 }
105 } 128 }
106 else 129 else
107 { 130 {
@@ -334,6 +357,105 @@ namespace OpenSim.Framework.UserManagement
334 { 357 {
335 } 358 }
336 359
360 public Hashtable ProcessHTMLLogin(Hashtable keysvals)
361 {
362 Hashtable returnactions = new Hashtable();
363 int statuscode = 200;
364
365 returnactions["int_response_code"] = statuscode;
366 returnactions["str_response_string"] = GetDefaultLoginForm();
367
368 if (keysvals.ContainsKey("show_login_form"))
369 {
370 if ((string)keysvals["show_login_form"] == "TRUE")
371 {
372
373 }
374 else
375 {
376
377
378 }
379
380 }
381 return returnactions;
382
383 }
384
385 public string GetLoginForm()
386 {
387 string file = Path.Combine(Util.configDir(), "http_loginform.html");
388 if (!File.Exists(file))
389 return GetDefaultLoginForm();
390
391 StreamReader sr = File.OpenText(file);
392 string result = sr.ReadToEnd();
393 sr.Close();
394 return result;
395 }
396
397 public string GetDefaultLoginForm()
398 {
399 string responseString =
400 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
401 responseString = responseString + "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
402 responseString = responseString + "<head>";
403 responseString = responseString +
404 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
405 responseString = responseString + "<meta http-equiv=\"cache-control\" content=\"no-cache\">";
406 responseString = responseString + "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
407 responseString = responseString + "<title>Second Life Login</title>";
408 responseString = responseString + "<body>";
409 responseString = responseString + "<div id=\"login_box\">";
410
411 responseString = responseString + "<form action=\"/\" method=\"GET\" id=\"login-form\">";
412
413 responseString = responseString + "<div id=\"message\">[$errors]</div>";
414 responseString = responseString + "<fieldset id=\"firstname\">";
415 responseString = responseString + "<legend>First Name:</legend>";
416 responseString = responseString + "<input type=\"text\" id=\"firstname_input\" size=\"15\" maxlength=\"100\" name=\"username\" value=\"[$firstname]\" />";
417 responseString = responseString + "</fieldset>";
418 responseString = responseString + "<fieldset id=\"lastname\">";
419 responseString = responseString + "<legend>Last Name:</legend>";
420 responseString = responseString + "<input type=\"text\" size=\"15\" maxlength=\"100\" name=\"lastname\" value=\"[$lastname]\" />";
421 responseString = responseString + "</fieldset>";
422 responseString = responseString + "<fieldset id=\"password\">";
423 responseString = responseString + "<legend>Password:</legend>";
424 responseString = responseString + "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
425 responseString = responseString + "<tr>";
426 responseString = responseString + "<td colspan=\"2\"><input type=\"password\" size=\"15\" maxlength=\"100\" name=\"password\" value=\"[$password]\" /></td>";
427 responseString = responseString + "</tr>";
428 responseString = responseString + "<tr>";
429 responseString = responseString + "<td valign=\"middle\"><input type=\"checkbox\" name=\"remember_password\" id=\"remember_password\" [$remember_password] style=\"margin-left:0px;\"/></td>";
430 responseString = responseString + "<td><label for=\"remember_password\">Remember password</label></td>";
431 responseString = responseString + "</tr>";
432 responseString = responseString + "</table>";
433 responseString = responseString + "</fieldset>";
434 responseString = responseString + "<input type=\"hidden\" name=\"show_login_form\" value=\"FALSE\" />";
435 responseString = responseString + "<input type=\"hidden\" name=\"method\" value=\"login\" />";
436 responseString = responseString + "<input type=\"hidden\" id=\"grid\" name=\"grid\" value=\"[$grid]\" />";
437 responseString = responseString + "<div id=\"submitbtn\">";
438 responseString = responseString + "<input class=\"input_over\" type=\"submit\" value=\"Connect\" />";
439 responseString = responseString + "</div>";
440 responseString = responseString + "<div id=\"connecting\" style=\"visibility:hidden\"> Connecting...</div>";
441
442 responseString = responseString + "<div id=\"helplinks\">";
443 responseString = responseString + "<a href=\"http://www.secondlife.com/join/index.php\" target=\"_blank\">Create new account</a> | ";
444 responseString = responseString + "<a href=\"http://www.secondlife.com/account/request.php\" target=\"_blank\">Forgot password?</a>";
445 responseString = responseString + "</div>";
446
447 responseString = responseString + "<div id=\"channelinfo\"> [$clientchannelinfo] | [$clientversion]=[$clientlanguage]</div>";
448 responseString = responseString + "</form>";
449 responseString = responseString + "<script language=\"JavaScript\">";
450 responseString = responseString + "document.getElementById('firstname_input').focus();";
451 responseString = responseString + "</script>";
452 responseString = responseString + "</div>";
453 responseString = responseString + "</div>";
454 responseString = responseString + "</body>";
455 responseString = responseString + "</html>";
456 return responseString;
457 }
458
337 /// <summary> 459 /// <summary>
338 /// Saves a target agent to the database 460 /// Saves a target agent to the database
339 /// </summary> 461 /// </summary>
@@ -353,14 +475,33 @@ namespace OpenSim.Framework.UserManagement
353 /// <returns>Authenticated?</returns> 475 /// <returns>Authenticated?</returns>
354 public virtual bool AuthenticateUser(UserProfileData profile, string password) 476 public virtual bool AuthenticateUser(UserProfileData profile, string password)
355 { 477 {
478 bool passwordSuccess = false;
356 MainLog.Instance.Verbose( 479 MainLog.Instance.Verbose(
357 "LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); 480 "LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID);
358 481
482 // Web Login method seems to also occasionally send the hashed password itself
483
484
359 password = password.Remove(0, 3); //remove $1$ 485 password = password.Remove(0, 3); //remove $1$
360 486
361 string s = Util.Md5Hash(password + ":" + profile.passwordSalt); 487 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
362 488
363 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); 489 passwordSuccess = (profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
490 || profile.passwordHash.Equals(password.ToString(),StringComparison.InvariantCultureIgnoreCase));
491
492 return passwordSuccess;
493 }
494
495 public virtual bool AuthenticateUser(UserProfileData profile, LLUUID webloginkey)
496 {
497 bool passwordSuccess = false;
498 MainLog.Instance.Verbose(
499 "LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID);
500
501 // Match web login key unless it's the default weblogin key LLUUID.Zero
502 passwordSuccess = ((profile.webLoginKey==webloginkey) && profile.webLoginKey != LLUUID.Zero);
503
504 return passwordSuccess;
364 } 505 }
365 506
366 /// <summary> 507 /// <summary>
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index bea56ea..2d72629 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -222,6 +222,23 @@ namespace OpenSim.Framework.UserManagement
222 222
223 } 223 }
224 224
225 public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey)
226 {
227
228 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
229 {
230 try
231 {
232 plugin.Value.StoreWebLoginKey(agentID, webLoginKey);
233 }
234 catch (Exception e)
235 {
236 MainLog.Instance.Verbose("USERSTORAGE",
237 "Unable to Store WebLoginKey via " + plugin.Key + "(" + e.ToString() + ")");
238 }
239 }
240 }
241
225 public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) 242 public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
226 { 243 {
227 foreach (KeyValuePair<string, IUserData> plugin in _plugins) 244 foreach (KeyValuePair<string, IUserData> plugin in _plugins)