aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLManager.cs24
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs2
-rw-r--r--OpenSim/Framework/Data.MSSQL/Resources/Mssql-users.sql1
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs8
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs8
-rw-r--r--OpenSim/Framework/Data.MySQL/Resources/CreateUsersTable.sql3
-rw-r--r--OpenSim/Framework/Data.MySQL/Resources/UpgradeUsersTableToVersion2.sql3
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteUserData.cs21
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs338
-rw-r--r--OpenSim/Framework/Servers/GenericHTTPMethod.cs34
-rw-r--r--OpenSim/Framework/Servers/IStreamHandler.cs7
-rw-r--r--OpenSim/Framework/UserProfileData.cs4
-rw-r--r--OpenSim/Grid/UserServer/Main.cs1
13 files changed, 321 insertions, 133 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
index 0dc3338..bf57492 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
@@ -95,6 +95,22 @@ namespace OpenSim.Framework.Data.MSSQL
95 MainLog.Instance.Verbose("DATASTORE", "MSSQL Database doesn't exist... creating"); 95 MainLog.Instance.Verbose("DATASTORE", "MSSQL Database doesn't exist... creating");
96 InitDB(conn); 96 InitDB(conn);
97 } 97 }
98 cmd = Query("select top 1 webLoginKey from users", new Dictionary<string, string>());
99 try
100 {
101 conn.Open();
102 cmd.ExecuteNonQuery();
103 cmd.Dispose();
104 conn.Close();
105 }
106 catch (Exception)
107 {
108 conn.Open();
109 cmd = Query("alter table users add column [webLoginKey] varchar(36) default NULL", new Dictionary<string, string>());
110 cmd.ExecuteNonQuery();
111 cmd.Dispose();
112 conn.Close();
113 }
98 return true; 114 return true;
99 } 115 }
100 116
@@ -380,6 +396,7 @@ namespace OpenSim.Framework.Data.MSSQL
380 396
381 retval.profileImage = new LLUUID((string) reader["profileImage"]); 397 retval.profileImage = new LLUUID((string) reader["profileImage"]);
382 retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]); 398 retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]);
399 retval.webLoginKey = new LLUUID((string)reader["webLoginKey"]);
383 } 400 }
384 else 401 else
385 { 402 {
@@ -595,7 +612,7 @@ namespace OpenSim.Framework.Data.MSSQL
595 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, 612 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
596 string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, 613 string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
597 string aboutText, string firstText, 614 string aboutText, string firstText,
598 LLUUID profileImage, LLUUID firstImage) 615 LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey)
599 { 616 {
600 string sql = "INSERT INTO users "; 617 string sql = "INSERT INTO users ";
601 sql += "([UUID], [username], [lastname], [passwordHash], [passwordSalt], [homeRegion], "; 618 sql += "([UUID], [username], [lastname], [passwordHash], [passwordSalt], [homeRegion], ";
@@ -603,14 +620,14 @@ namespace OpenSim.Framework.Data.MSSQL
603 "[homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], [homeLookAtY], [homeLookAtZ], [created], "; 620 "[homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], [homeLookAtY], [homeLookAtZ], [created], ";
604 sql += 621 sql +=
605 "[lastLogin], [userInventoryURI], [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], "; 622 "[lastLogin], [userInventoryURI], [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], ";
606 sql += "[profileFirstText], [profileImage], [profileFirstImage]) VALUES "; 623 sql += "[profileFirstText], [profileImage], [profileFirstImage], [webLoginKey]) VALUES ";
607 624
608 sql += "(@UUID, @username, @lastname, @passwordHash, @passwordSalt, @homeRegion, "; 625 sql += "(@UUID, @username, @lastname, @passwordHash, @passwordSalt, @homeRegion, ";
609 sql += 626 sql +=
610 "@homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, @homeLookAtY, @homeLookAtZ, @created, "; 627 "@homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, @homeLookAtY, @homeLookAtZ, @created, ";
611 sql += 628 sql +=
612 "@lastLogin, @userInventoryURI, @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, "; 629 "@lastLogin, @userInventoryURI, @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, ";
613 sql += "@profileFirstText, @profileImage, @profileFirstImage);"; 630 sql += "@profileFirstText, @profileImage, @profileFirstImage, @webLoginKey);";
614 631
615 Dictionary<string, string> parameters = new Dictionary<string, string>(); 632 Dictionary<string, string> parameters = new Dictionary<string, string>();
616 parameters["UUID"] = uuid.ToString(); 633 parameters["UUID"] = uuid.ToString();
@@ -635,6 +652,7 @@ namespace OpenSim.Framework.Data.MSSQL
635 parameters["profileFirstText"] = ""; 652 parameters["profileFirstText"] = "";
636 parameters["profileImage"] = LLUUID.Zero.ToString(); 653 parameters["profileImage"] = LLUUID.Zero.ToString();
637 parameters["profileFirstImage"] = LLUUID.Zero.ToString(); 654 parameters["profileFirstImage"] = LLUUID.Zero.ToString();
655 parameters["webLoginKey"] = LLUUID.Random().ToString();
638 656
639 bool returnval = false; 657 bool returnval = false;
640 658
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
index f8a951e..db3c1d6 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
@@ -315,7 +315,7 @@ namespace OpenSim.Framework.Data.MSSQL
315 user.lastLogin, user.userInventoryURI, user.userAssetURI, 315 user.lastLogin, user.userInventoryURI, user.userAssetURI,
316 user.profileCanDoMask, user.profileWantDoMask, 316 user.profileCanDoMask, user.profileWantDoMask,
317 user.profileAboutText, user.profileFirstText, user.profileImage, 317 user.profileAboutText, user.profileFirstText, user.profileImage,
318 user.profileFirstImage); 318 user.profileFirstImage,user.webLoginKey);
319 } 319 }
320 } 320 }
321 catch (Exception e) 321 catch (Exception e)
diff --git a/OpenSim/Framework/Data.MSSQL/Resources/Mssql-users.sql b/OpenSim/Framework/Data.MSSQL/Resources/Mssql-users.sql
index 3f5f896..abcc091 100644
--- a/OpenSim/Framework/Data.MSSQL/Resources/Mssql-users.sql
+++ b/OpenSim/Framework/Data.MSSQL/Resources/Mssql-users.sql
@@ -27,6 +27,7 @@ CREATE TABLE [users] (
27 [profileFirstText] [ntext], 27 [profileFirstText] [ntext],
28 [profileImage] [varchar](36) default NULL, 28 [profileImage] [varchar](36) default NULL,
29 [profileFirstImage] [varchar](36) default NULL, 29 [profileFirstImage] [varchar](36) default NULL,
30 [webLoginKey] [varchar](36) default NULL,
30 PRIMARY KEY CLUSTERED 31 PRIMARY KEY CLUSTERED
31( 32(
32 [UUID] ASC 33 [UUID] ASC
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
index 9532f21..223d902 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -446,6 +446,7 @@ namespace OpenSim.Framework.Data.MySQL
446 446
447 retval.profileImage = new LLUUID((string) reader["profileImage"]); 447 retval.profileImage = new LLUUID((string) reader["profileImage"]);
448 retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]); 448 retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]);
449 retval.webLoginKey = new LLUUID((string)reader["webLoginKey"]);
449 } 450 }
450 else 451 else
451 { 452 {
@@ -531,7 +532,7 @@ namespace OpenSim.Framework.Data.MySQL
531 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, 532 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
532 string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, 533 string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
533 string aboutText, string firstText, 534 string aboutText, string firstText,
534 LLUUID profileImage, LLUUID firstImage) 535 LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey)
535 { 536 {
536 string sql = 537 string sql =
537 "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; 538 "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
@@ -539,14 +540,14 @@ namespace OpenSim.Framework.Data.MySQL
539 "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; 540 "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, ";
540 sql += 541 sql +=
541 "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; 542 "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, ";
542 sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES "; 543 sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`) VALUES ";
543 544
544 sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; 545 sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, ";
545 sql += 546 sql +=
546 "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; 547 "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, ";
547 sql += 548 sql +=
548 "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; 549 "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, ";
549 sql += "?profileFirstText, ?profileImage, ?profileFirstImage)"; 550 sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey)";
550 551
551 Dictionary<string, string> parameters = new Dictionary<string, string>(); 552 Dictionary<string, string> parameters = new Dictionary<string, string>();
552 parameters["?UUID"] = uuid.ToString(); 553 parameters["?UUID"] = uuid.ToString();
@@ -571,6 +572,7 @@ namespace OpenSim.Framework.Data.MySQL
571 parameters["?profileFirstText"] = ""; 572 parameters["?profileFirstText"] = "";
572 parameters["?profileImage"] = LLUUID.Zero.ToString(); 573 parameters["?profileImage"] = LLUUID.Zero.ToString();
573 parameters["?profileFirstImage"] = LLUUID.Zero.ToString(); 574 parameters["?profileFirstImage"] = LLUUID.Zero.ToString();
575 parameters["?webLoginKey"] = LLUUID.Random().ToString();
574 576
575 bool returnval = false; 577 bool returnval = false;
576 578
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
index 7e2d4f0..e53ab18 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
@@ -114,6 +114,12 @@ namespace OpenSim.Framework.Data.MySQL
114 database.ExecuteResourceSql("CreateUsersTable.sql"); 114 database.ExecuteResourceSql("CreateUsersTable.sql");
115 return; 115 return;
116 } 116 }
117 else if (oldVersion.Contains("Rev. 1"))
118 {
119 database.ExecuteResourceSql("UpgradeUsersTableToVersion2.sql");
120 return;
121 }
122 //MainLog.Instance.Verbose("DB","DBVers:" + oldVersion);
117 } 123 }
118 124
119 /// <summary> 125 /// <summary>
@@ -512,7 +518,7 @@ namespace OpenSim.Framework.Data.MySQL
512 user.lastLogin, user.userInventoryURI, user.userAssetURI, 518 user.lastLogin, user.userInventoryURI, user.userAssetURI,
513 user.profileCanDoMask, user.profileWantDoMask, 519 user.profileCanDoMask, user.profileWantDoMask,
514 user.profileAboutText, user.profileFirstText, user.profileImage, 520 user.profileAboutText, user.profileFirstText, user.profileImage,
515 user.profileFirstImage); 521 user.profileFirstImage, user.webLoginKey);
516 } 522 }
517 } 523 }
518 catch (Exception e) 524 catch (Exception e)
diff --git a/OpenSim/Framework/Data.MySQL/Resources/CreateUsersTable.sql b/OpenSim/Framework/Data.MySQL/Resources/CreateUsersTable.sql
index faac541..d9e8ae2 100644
--- a/OpenSim/Framework/Data.MySQL/Resources/CreateUsersTable.sql
+++ b/OpenSim/Framework/Data.MySQL/Resources/CreateUsersTable.sql
@@ -25,9 +25,10 @@ CREATE TABLE `users` (
25 `profileFirstText` text, 25 `profileFirstText` text,
26 `profileImage` varchar(36) default NULL, 26 `profileImage` varchar(36) default NULL,
27 `profileFirstImage` varchar(36) default NULL, 27 `profileFirstImage` varchar(36) default NULL,
28 `webLoginKey` varchar(36) default NULL,
28 PRIMARY KEY (`UUID`), 29 PRIMARY KEY (`UUID`),
29 UNIQUE KEY `usernames` (`username`,`lastname`) 30 UNIQUE KEY `usernames` (`username`,`lastname`)
30) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; 31) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 2';
31 32
32-- ---------------------------- 33-- ----------------------------
33-- Records 34-- Records
diff --git a/OpenSim/Framework/Data.MySQL/Resources/UpgradeUsersTableToVersion2.sql b/OpenSim/Framework/Data.MySQL/Resources/UpgradeUsersTableToVersion2.sql
new file mode 100644
index 0000000..99a84a8
--- /dev/null
+++ b/OpenSim/Framework/Data.MySQL/Resources/UpgradeUsersTableToVersion2.sql
@@ -0,0 +1,3 @@
1ALTER TABLE `users`
2 ADD COLUMN `webLoginKey` varchar(36) default NULL,
3COMMENT='Rev. 2'; \ No newline at end of file
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
index e9a8eca..cbbb349 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
@@ -549,6 +549,7 @@ namespace OpenSim.Framework.Data.SQLite
549 createCol(users, "profileFirstText", typeof (String)); 549 createCol(users, "profileFirstText", typeof (String));
550 createCol(users, "profileImage", typeof (String)); 550 createCol(users, "profileImage", typeof (String));
551 createCol(users, "profileFirstImage", typeof (String)); 551 createCol(users, "profileFirstImage", typeof (String));
552 createCol(users, "webLoginKey", typeof(String));
552 // Add in contraints 553 // Add in contraints
553 users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]}; 554 users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]};
554 return users; 555 return users;
@@ -635,6 +636,8 @@ namespace OpenSim.Framework.Data.SQLite
635 user.profileFirstText = (String) row["profileFirstText"]; 636 user.profileFirstText = (String) row["profileFirstText"];
636 user.profileImage = new LLUUID((String) row["profileImage"]); 637 user.profileImage = new LLUUID((String) row["profileImage"]);
637 user.profileFirstImage = new LLUUID((String) row["profileFirstImage"]); 638 user.profileFirstImage = new LLUUID((String) row["profileFirstImage"]);
639 user.webLoginKey = new LLUUID((String) row["webLoginKey"]);
640
638 return user; 641 return user;
639 } 642 }
640 643
@@ -681,6 +684,7 @@ namespace OpenSim.Framework.Data.SQLite
681 row["profileFirstText"] = user.profileFirstText; 684 row["profileFirstText"] = user.profileFirstText;
682 row["profileImage"] = user.profileImage; 685 row["profileImage"] = user.profileImage;
683 row["profileFirstImage"] = user.profileFirstImage; 686 row["profileFirstImage"] = user.profileFirstImage;
687 row["webLoginKey"] = user.webLoginKey;
684 688
685 // ADO.NET doesn't handle NULL very well 689 // ADO.NET doesn't handle NULL very well
686 foreach (DataColumn col in ds.Tables["users"].Columns) 690 foreach (DataColumn col in ds.Tables["users"].Columns)
@@ -825,6 +829,23 @@ namespace OpenSim.Framework.Data.SQLite
825 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); 829 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
826 InitDB(conn); 830 InitDB(conn);
827 } 831 }
832 conn.Open();
833 try
834 {
835 cmd = new SqliteCommand("select webLoginKey from users limit 1;", conn);
836 cmd.ExecuteNonQuery();
837 }
838 catch (SqliteSyntaxException)
839 {
840 cmd = new SqliteCommand("alter table users add column webLoginKey text default '00000000-0000-0000-0000-000000000000';", conn);
841 cmd.ExecuteNonQuery();
842 pDa.Fill(tmpDS, "users");
843 }
844 finally
845 {
846 conn.Close();
847 }
848
828 return true; 849 return true;
829 } 850 }
830 } 851 }
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 004b330..32d65af 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -46,6 +46,8 @@ namespace OpenSim.Framework.Servers
46 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); 46 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
47 protected LLSDMethod m_llsdHandler = null; 47 protected LLSDMethod m_llsdHandler = null;
48 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); 48 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
49 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>();
50
49 protected uint m_port; 51 protected uint m_port;
50 protected bool m_ssl = false; 52 protected bool m_ssl = false;
51 protected bool m_firstcaps = true; 53 protected bool m_firstcaps = true;
@@ -92,6 +94,18 @@ namespace OpenSim.Framework.Servers
92 return false; 94 return false;
93 } 95 }
94 96
97 public bool AddHTTPHandler(string method, GenericHTTPMethod handler)
98 {
99 if (!m_HTTPHandlers.ContainsKey(method))
100 {
101 m_HTTPHandlers.Add(method, handler);
102 return true;
103 }
104
105 //must already have a handler for that path so return false
106 return false;
107 }
108
95 public bool SetLLSDHandler(LLSDMethod handler) 109 public bool SetLLSDHandler(LLSDMethod handler)
96 { 110 {
97 m_llsdHandler = handler; 111 m_llsdHandler = handler;
@@ -145,6 +159,10 @@ namespace OpenSim.Framework.Servers
145 { 159 {
146 switch (request.ContentType) 160 switch (request.ContentType)
147 { 161 {
162 case null:
163 case "text/html":
164 HandleHTTPRequest(request, response);
165 break;
148 case "application/xml+llsd": 166 case "application/xml+llsd":
149 HandleLLSDRequests(request, response); 167 HandleLLSDRequests(request, response);
150 break; 168 break;
@@ -184,6 +202,32 @@ namespace OpenSim.Framework.Servers
184 } 202 }
185 } 203 }
186 204
205 private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler)
206 {
207 string bestMatch = null;
208
209 foreach (string pattern in m_HTTPHandlers.Keys)
210 {
211 if (handlerKey.StartsWith(pattern))
212 {
213 if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length)
214 {
215 bestMatch = pattern;
216 }
217 }
218 }
219
220 if (String.IsNullOrEmpty(bestMatch))
221 {
222 HTTPHandler = null;
223 return false;
224 }
225 else
226 {
227 HTTPHandler = m_HTTPHandlers[bestMatch];
228 return true;
229 }
230 }
187 private void HandleXmlRpcRequests(HttpListenerRequest request, HttpListenerResponse response) 231 private void HandleXmlRpcRequests(HttpListenerRequest request, HttpListenerResponse response)
188 { 232 {
189 Stream requestStream = request.InputStream; 233 Stream requestStream = request.InputStream;
@@ -204,27 +248,7 @@ namespace OpenSim.Framework.Servers
204 } 248 }
205 catch (XmlException e) 249 catch (XmlException e)
206 { 250 {
207 Hashtable keysvals = new Hashtable(); 251
208 responseString = String.Format("XmlException:\n{0}", e.Message);
209 MainLog.Instance.Error("XML", responseString);
210 string[] querystringkeys = request.QueryString.AllKeys;
211 string[] rHeaders = request.Headers.AllKeys;
212
213
214 foreach (string queryname in querystringkeys)
215 {
216 keysvals.Add(queryname, request.QueryString[queryname]);
217 MainLog.Instance.Warn("HTTP", queryname + "=" + request.QueryString[queryname]);
218 }
219 foreach (string headername in rHeaders)
220 {
221 MainLog.Instance.Warn("HEADER", headername + "=" + request.Headers[headername]);
222 }
223 if (keysvals.ContainsKey("show_login_form"))
224 {
225 HandleHTTPRequest(keysvals, request, response);
226 return;
227 }
228 } 252 }
229 253
230 if (xmlRprcRequest != null) 254 if (xmlRprcRequest != null)
@@ -332,7 +356,7 @@ namespace OpenSim.Framework.Servers
332 } 356 }
333 } 357 }
334 358
335 public void HandleHTTPRequest(Hashtable keysvals, HttpListenerRequest request, HttpListenerResponse response) 359 public void HandleHTTPRequest(HttpListenerRequest request, HttpListenerResponse response)
336 { 360 {
337 // This is a test. There's a workable alternative.. as this way sucks. 361 // This is a test. There's a workable alternative.. as this way sucks.
338 // We'd like to put this into a text file parhaps that's easily editable. 362 // We'd like to put this into a text file parhaps that's easily editable.
@@ -345,119 +369,146 @@ namespace OpenSim.Framework.Servers
345 // I depend on show_login_form being in the secondlife.exe parameters to figure out 369 // I depend on show_login_form being in the secondlife.exe parameters to figure out
346 // to display the form, or process it. 370 // to display the form, or process it.
347 // a better way would be nifty. 371 // a better way would be nifty.
372 Stream requestStream = request.InputStream;
348 373
349 if ((string) keysvals["show_login_form"] == "TRUE") 374 Encoding encoding = Encoding.UTF8;
350 { 375 StreamReader reader = new StreamReader(requestStream, encoding);
351 string responseString = 376
352 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; 377 string requestBody = reader.ReadToEnd();
353 responseString = responseString + "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; 378 reader.Close();
354 responseString = responseString + "<head>"; 379 requestStream.Close();
355 responseString = responseString + 380
356 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; 381 string responseString = String.Empty;
357 responseString = responseString + "<meta http-equiv=\"cache-control\" content=\"no-cache\">"; 382
358 responseString = responseString + "<meta http-equiv=\"Pragma\" content=\"no-cache\">"; 383 Hashtable keysvals = new Hashtable();
359 responseString = responseString + "<title>Second Life Login</title>"; 384
360 responseString = responseString + "<body>"; 385 string[] querystringkeys = request.QueryString.AllKeys;
361 responseString = responseString + "<div id=\"login_box\">"; 386 string[] rHeaders = request.Headers.AllKeys;
362 // Linden Grid Form Post 387
363 //responseString = responseString + "<form action=\"https://secure-web16.secondlife.com/app/login/go.php?show_login_form=True&show_grid=&show_start_location=\" method=\"POST\" id=\"login-form\">"; 388
364 responseString = responseString + "<form action=\"/\" method=\"GET\" id=\"login-form\">"; 389 foreach (string queryname in querystringkeys)
365 390 {
366 responseString = responseString + "<div id=\"message\">"; 391 keysvals.Add(queryname, request.QueryString[queryname]);
367 responseString = responseString + "</div>"; 392 MainLog.Instance.Warn("HTTP", queryname + "=" + request.QueryString[queryname]);
368 responseString = responseString + "<fieldset id=\"firstname\">"; 393 }
369 responseString = responseString + "<legend>First Name:</legend>"; 394 //foreach (string headername in rHeaders)
370 responseString = responseString + 395 //{
371 "<input type=\"text\" id=\"firstname_input\" size=\"15\" maxlength=\"100\" name=\"username\" value=\"" + 396 //MainLog.Instance.Warn("HEADER", headername + "=" + request.Headers[headername]);
372 keysvals["username"] + "\" />"; 397 //}
373 responseString = responseString + "</fieldset>"; 398 if (keysvals.Contains("method"))
374 responseString = responseString + "<fieldset id=\"lastname\">"; 399 {
375 responseString = responseString + "<legend>Last Name:</legend>"; 400 MainLog.Instance.Warn("HTTP", "Contains Method");
376 responseString = responseString + 401 string method = (string) keysvals["method"];
377 "<input type=\"text\" size=\"15\" maxlength=\"100\" name=\"lastname\" value=\"" + 402 MainLog.Instance.Warn("HTTP", requestBody);
378 keysvals["lastname"] + "\" />"; 403 GenericHTTPMethod requestprocessor;
379 responseString = responseString + "</fieldset>"; 404 bool foundHandler = TryGetHTTPHandler(method, out requestprocessor);
380 responseString = responseString + "<fieldset id=\"password\">"; 405 if (foundHandler)
381 responseString = responseString + "<legend>Password:</legend>";
382 responseString = responseString + "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
383 responseString = responseString + "<tr>";
384 responseString = responseString +
385 "<td colspan=\"2\"><input type=\"password\" size=\"15\" maxlength=\"100\" name=\"password\" value=\"" +
386 keysvals["password"] + "\" /></td>";
387 responseString = responseString + "</tr>";
388 responseString = responseString + "<tr>";
389 responseString = responseString +
390 "<td valign=\"middle\"><input type=\"checkbox\" name=\"remember_password\" id=\"remember_password\" value=\"" +
391 keysvals["remember_password"] + "\" checked style=\"margin-left:0px;\"/></td>";
392 responseString = responseString + "<td><label for=\"remember_password\">Remember password</label></td>";
393 responseString = responseString + "</tr>";
394 responseString = responseString + "</table>";
395 responseString = responseString + "</fieldset>";
396 responseString = responseString + "<input type=\"hidden\" name=\"show_login_form\" value=\"FALSE\" />";
397 responseString = responseString + "<input type=\"hidden\" id=\"grid\" name=\"grid\" value=\"" +
398 keysvals["grid"] + "\" />";
399 responseString = responseString + "<div id=\"submitbtn\">";
400 responseString = responseString + "<input class=\"input_over\" type=\"submit\" value=\"Connect\" />";
401 responseString = responseString + "</div>";
402 responseString = responseString +
403 "<div id=\"connecting\" style=\"visibility:hidden\"><img src=\"/_img/sl_logo_rotate_black.gif\" align=\"absmiddle\"> Connecting...</div>";
404
405 responseString = responseString + "<div id=\"helplinks\">";
406 responseString = responseString +
407 "<a href=\"http://www.secondlife.com/join/index.php\" target=\"_blank\">Create new account</a> | ";
408 responseString = responseString +
409 "<a href=\"http://www.secondlife.com/account/request.php\" target=\"_blank\">Forgot password?</a>";
410 responseString = responseString + "</div>";
411
412 responseString = responseString + "<div id=\"channelinfo\"> " + keysvals["channel"] + " | " +
413 keysvals["version"] + "=" + keysvals["lang"] + "</div>";
414 responseString = responseString + "</form>";
415 responseString = responseString + "<script language=\"JavaScript\">";
416 responseString = responseString + "document.getElementById('firstname_input').focus();";
417 responseString = responseString + "</script>";
418 responseString = responseString + "</div>";
419 responseString = responseString + "</div>";
420 responseString = responseString + "</body>";
421 responseString = responseString + "</html>";
422 response.AddHeader("Content-type", "text/html");
423
424 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
425
426 response.SendChunked = false;
427 response.ContentLength64 = buffer.Length;
428 response.ContentEncoding = Encoding.UTF8;
429 try
430 {
431 response.OutputStream.Write(buffer, 0, buffer.Length);
432 }
433 catch (Exception ex)
434 { 406 {
435 MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message); 407 Hashtable responsedata = requestprocessor(keysvals);
408 DoHTTPGruntWork(responsedata,response);
409
410 //SendHTML500(response);
411
436 } 412 }
437 finally 413 else
438 { 414 {
439 response.OutputStream.Close(); 415 MainLog.Instance.Warn("HTTP", "Handler Not Found");
416 SendHTML404(response);
440 } 417 }
441 } // show_login_form == "TRUE" 418 }
442 else 419 else
443 { 420 {
444 // show_login_form is present but FALSE 421 MainLog.Instance.Warn("HTTP", "No Method specified");
445 // 422 SendHTML404(response);
446 // The idea here is that we're telling the client to log in immediately here using the following information 423 }
447 // For my testing, I'm hard coding the web_login_key temporarily. 424 }
448 // Telling the client to go to the new improved SLURL for immediate logins 425
426 private void DoHTTPGruntWork(Hashtable responsedata, HttpListenerResponse response)
427 {
428 int responsecode = (int)responsedata["int_response_code"];
429 string responseString = (string)responsedata["str_response_string"];
430
431 // We're forgoing the usual error status codes here because the client
432 // ignores anything but 200 and 301
449 433
450 // The fact that it says grid=Other is important 434 response.StatusCode = 200;
451 435
452 // 436 if (responsecode == 301)
437 {
438 response.RedirectLocation = (string)responsedata["str_redirect_location"];
439 response.StatusCode = responsecode;
440 }
441 response.AddHeader("Content-type", "text/html");
453 442
454 response.StatusCode = 301; 443 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
455 response.RedirectLocation = "secondlife:///app/login?first_name=" + keysvals["username"] + "&last_name=" +
456 keysvals["lastname"] +
457 "&location=home&grid=other&web_login_key=796f2b2a-0131-41e4-af12-00f60c24c458";
458 444
445 response.SendChunked = false;
446 response.ContentLength64 = buffer.Length;
447 response.ContentEncoding = Encoding.UTF8;
448 try
449 {
450 response.OutputStream.Write(buffer, 0, buffer.Length);
451 }
452 catch (Exception ex)
453 {
454 MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message);
455 }
456 finally
457 {
459 response.OutputStream.Close(); 458 response.OutputStream.Close();
460 } // show_login_form == "FALSE" 459 }
460
461
462 }
463 public void SendHTML404(HttpListenerResponse response)
464 {
465 // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s
466 response.StatusCode = 200;
467 response.AddHeader("Content-type", "text/html");
468
469 string responseString = GetHTTP404();
470 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
471
472 response.SendChunked = false;
473 response.ContentLength64 = buffer.Length;
474 response.ContentEncoding = Encoding.UTF8;
475 try
476 {
477 response.OutputStream.Write(buffer, 0, buffer.Length);
478 }
479 catch (Exception ex)
480 {
481 MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message);
482 }
483 finally
484 {
485 response.OutputStream.Close();
486 }
487 }
488 public void SendHTML500(HttpListenerResponse response)
489 {
490 // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s
491 response.StatusCode = 200;
492 response.AddHeader("Content-type", "text/html");
493
494 string responseString = GetHTTP500();
495 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
496
497 response.SendChunked = false;
498 response.ContentLength64 = buffer.Length;
499 response.ContentEncoding = Encoding.UTF8;
500 try
501 {
502 response.OutputStream.Write(buffer, 0, buffer.Length);
503 }
504 catch (Exception ex)
505 {
506 MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message);
507 }
508 finally
509 {
510 response.OutputStream.Close();
511 }
461 } 512 }
462 513
463 public void Start() 514 public void Start()
@@ -504,5 +555,46 @@ namespace OpenSim.Framework.Servers
504 { 555 {
505 m_streamHandlers.Remove(GetHandlerKey(httpMethod, path)); 556 m_streamHandlers.Remove(GetHandlerKey(httpMethod, path));
506 } 557 }
558
559 public void RemoveHTTPHandler(string httpMethod, string path)
560 {
561 m_HTTPHandlers.Remove(GetHandlerKey(httpMethod, path));
562 }
563
564 public string GetHTTP404()
565 {
566 string file = Path.Combine(Util.configDir(), "http_404.html");
567 if (!File.Exists(file))
568 return getDefaultHTTP404();
569
570 StreamReader sr = File.OpenText(file);
571 string result = sr.ReadToEnd();
572 sr.Close();
573 return result;
574 }
575
576 public string GetHTTP500()
577 {
578 string file = Path.Combine(Util.configDir(), "http_500.html");
579 if (!File.Exists(file))
580 return getDefaultHTTP500();
581
582 StreamReader sr = File.OpenText(file);
583 string result = sr.ReadToEnd();
584 sr.Close();
585 return result;
586 }
587
588 // Fallback HTTP responses in case the HTTP error response files don't exist
589 private string getDefaultHTTP404()
590 {
591 return "<HTML><HEAD><TITLE>404 Page not found</TITLE><BODY><BR /><H1>Ooops!</H1><P>The page you requested has been obsconded with by knomes. Find hippos quick!</P></BODY></HTML>";
592 }
593
594 private string getDefaultHTTP500()
595 {
596 return "<HTML><HEAD><TITLE>500 Internal Server Error</TITLE><BODY><BR /><H1>Ooops!</H1><P>The server you requested is overun by knomes! Find hippos quick!</P></BODY></HTML>";
597 }
598
507 } 599 }
508} 600}
diff --git a/OpenSim/Framework/Servers/GenericHTTPMethod.cs b/OpenSim/Framework/Servers/GenericHTTPMethod.cs
new file mode 100644
index 0000000..76aa8fe
--- /dev/null
+++ b/OpenSim/Framework/Servers/GenericHTTPMethod.cs
@@ -0,0 +1,34 @@
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*/
28using System;
29using System.Collections;
30
31namespace OpenSim.Framework.Servers
32{
33 public delegate Hashtable GenericHTTPMethod(Hashtable request);
34} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/IStreamHandler.cs b/OpenSim/Framework/Servers/IStreamHandler.cs
index c87937a..d52f9ac 100644
--- a/OpenSim/Framework/Servers/IStreamHandler.cs
+++ b/OpenSim/Framework/Servers/IStreamHandler.cs
@@ -25,7 +25,7 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28using System.Collections;
29using System.IO; 29using System.IO;
30 30
31namespace OpenSim.Framework.Servers 31namespace OpenSim.Framework.Servers
@@ -40,6 +40,7 @@ namespace OpenSim.Framework.Servers
40 40
41 // Return path 41 // Return path
42 string Path { get; } 42 string Path { get; }
43
43 } 44 }
44 45
45 public interface IStreamedRequestHandler : IRequestHandler 46 public interface IStreamedRequestHandler : IRequestHandler
@@ -53,4 +54,8 @@ namespace OpenSim.Framework.Servers
53 // Handle request stream, return byte array 54 // Handle request stream, return byte array
54 void Handle(string path, Stream request, Stream response); 55 void Handle(string path, Stream request, Stream response);
55 } 56 }
57 public interface IGenericHTTPHandler : IRequestHandler
58 {
59 Hashtable Handle(string path, Hashtable request);
60 }
56} \ No newline at end of file 61} \ No newline at end of file
diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs
index 4df1ebd..de44a0d 100644
--- a/OpenSim/Framework/UserProfileData.cs
+++ b/OpenSim/Framework/UserProfileData.cs
@@ -41,6 +41,10 @@ namespace OpenSim.Framework
41 public LLUUID UUID; 41 public LLUUID UUID;
42 42
43 /// <summary> 43 /// <summary>
44 /// The last used Web_login_key
45 /// </summary>
46 public LLUUID webLoginKey;
47 /// <summary>
44 /// The first component of a users account name 48 /// The first component of a users account name
45 /// </summary> 49 /// </summary>
46 public string username; 50 public string username;
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 8e6817d..02ca385 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -103,6 +103,7 @@ namespace OpenSim.Grid.UserServer
103 BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); 103 BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
104 104
105 httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); 105 httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
106
106 httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); 107 httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
107 108
108 httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); 109 httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);