diff options
Diffstat (limited to 'OpenSim/Framework/Communications/LoginService.cs')
-rw-r--r-- | OpenSim/Framework/Communications/LoginService.cs | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index fa78a30..bd0fa53 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs | |||
@@ -48,8 +48,8 @@ namespace OpenSim.Framework.Communications | |||
48 | 48 | ||
49 | protected string m_welcomeMessage = "Welcome to OpenSim"; | 49 | protected string m_welcomeMessage = "Welcome to OpenSim"; |
50 | protected UserManagerBase m_userManager = null; | 50 | protected UserManagerBase m_userManager = null; |
51 | protected Mutex m_loginMutex = new Mutex(false); | 51 | protected Mutex m_loginMutex = new Mutex(false); |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// Used during login to send the skeleton of the OpenSim Library to the client. | 54 | /// Used during login to send the skeleton of the OpenSim Library to the client. |
55 | /// </summary> | 55 | /// </summary> |
@@ -61,12 +61,12 @@ namespace OpenSim.Framework.Communications | |||
61 | /// <param name="userManager"></param> | 61 | /// <param name="userManager"></param> |
62 | /// <param name="libraryRootFolder"></param> | 62 | /// <param name="libraryRootFolder"></param> |
63 | /// <param name="welcomeMess"></param> | 63 | /// <param name="welcomeMess"></param> |
64 | public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, | 64 | public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, |
65 | string welcomeMess) | 65 | string welcomeMess) |
66 | { | 66 | { |
67 | m_userManager = userManager; | 67 | m_userManager = userManager; |
68 | m_libraryRootFolder = libraryRootFolder; | 68 | m_libraryRootFolder = libraryRootFolder; |
69 | 69 | ||
70 | if (welcomeMess != String.Empty) | 70 | if (welcomeMess != String.Empty) |
71 | { | 71 | { |
72 | m_welcomeMessage = welcomeMess; | 72 | m_welcomeMessage = welcomeMess; |
@@ -79,15 +79,15 @@ namespace OpenSim.Framework.Communications | |||
79 | /// <param name="response">The existing response</param> | 79 | /// <param name="response">The existing response</param> |
80 | /// <param name="theUser">The user profile</param> | 80 | /// <param name="theUser">The user profile</param> |
81 | public abstract void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); | 81 | public abstract void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); |
82 | 82 | ||
83 | /// <summary> | 83 | /// <summary> |
84 | /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. | 84 | /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. |
85 | /// </summary> | 85 | /// </summary> |
86 | /// <param name="userID"></param> | 86 | /// <param name="userID"></param> |
87 | /// <returns></returns> | 87 | /// <returns></returns> |
88 | /// <exception cref='System.Exception'>This will be thrown if there is a problem with the inventory service</exception> | 88 | /// <exception cref='System.Exception'>This will be thrown if there is a problem with the inventory service</exception> |
89 | protected abstract InventoryData GetInventorySkeleton(LLUUID userID); | 89 | protected abstract InventoryData GetInventorySkeleton(LLUUID userID); |
90 | 90 | ||
91 | /// <summary> | 91 | /// <summary> |
92 | /// Called when we receive the client's initial XMLRPC login_to_simulator request message | 92 | /// Called when we receive the client's initial XMLRPC login_to_simulator request message |
93 | /// </summary> | 93 | /// </summary> |
@@ -112,7 +112,7 @@ namespace OpenSim.Framework.Communications | |||
112 | 112 | ||
113 | UserProfileData userProfile; | 113 | UserProfileData userProfile; |
114 | LoginResponse logResponse = new LoginResponse(); | 114 | LoginResponse logResponse = new LoginResponse(); |
115 | 115 | ||
116 | string firstname = String.Empty; | 116 | string firstname = String.Empty; |
117 | string lastname = String.Empty; | 117 | string lastname = String.Empty; |
118 | 118 | ||
@@ -120,23 +120,23 @@ namespace OpenSim.Framework.Communications | |||
120 | { | 120 | { |
121 | firstname = (string) requestData["first"]; | 121 | firstname = (string) requestData["first"]; |
122 | lastname = (string) requestData["last"]; | 122 | lastname = (string) requestData["last"]; |
123 | 123 | ||
124 | m_log.InfoFormat( | 124 | m_log.InfoFormat( |
125 | "[LOGIN BEGIN]: Received login request message from user {0} {1}", | 125 | "[LOGIN BEGIN]: Received login request message from user {0} {1}", |
126 | firstname, lastname); | 126 | firstname, lastname); |
127 | 127 | ||
128 | string clientVersion = "Unknown"; | 128 | string clientVersion = "Unknown"; |
129 | 129 | ||
130 | if (requestData.Contains("version")) | 130 | if (requestData.Contains("version")) |
131 | { | 131 | { |
132 | clientVersion = (string)requestData["version"]; | 132 | clientVersion = (string)requestData["version"]; |
133 | } | 133 | } |
134 | 134 | ||
135 | if (requestData.Contains("start")) | 135 | if (requestData.Contains("start")) |
136 | { | 136 | { |
137 | startLocationRequest = (string)requestData["start"]; | 137 | startLocationRequest = (string)requestData["start"]; |
138 | } | 138 | } |
139 | 139 | ||
140 | m_log.DebugFormat( | 140 | m_log.DebugFormat( |
141 | "[LOGIN]: Client is {0}, start location is {1}", clientVersion, startLocationRequest); | 141 | "[LOGIN]: Client is {0}, start location is {1}", clientVersion, startLocationRequest); |
142 | 142 | ||
@@ -163,9 +163,9 @@ namespace OpenSim.Framework.Communications | |||
163 | catch (Exception e) | 163 | catch (Exception e) |
164 | { | 164 | { |
165 | m_log.InfoFormat( | 165 | m_log.InfoFormat( |
166 | "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", | 166 | "[LOGIN END]: Bad web_login_key: {0} for user {1} {2}, exception {3}", |
167 | requestData["web_login_key"], firstname, lastname, e); | 167 | requestData["web_login_key"], firstname, lastname, e); |
168 | 168 | ||
169 | return logResponse.CreateFailedResponse(); | 169 | return logResponse.CreateFailedResponse(); |
170 | } | 170 | } |
171 | GoodLogin = AuthenticateUser(userProfile, webloginkey); | 171 | GoodLogin = AuthenticateUser(userProfile, webloginkey); |
@@ -176,14 +176,14 @@ namespace OpenSim.Framework.Communications | |||
176 | { | 176 | { |
177 | m_log.Info( | 177 | m_log.Info( |
178 | "[LOGIN END]: login_to_simulator login message did not contain all the required data"); | 178 | "[LOGIN END]: login_to_simulator login message did not contain all the required data"); |
179 | 179 | ||
180 | return logResponse.CreateGridErrorResponse(); | 180 | return logResponse.CreateGridErrorResponse(); |
181 | } | 181 | } |
182 | 182 | ||
183 | if (!GoodLogin) | 183 | if (!GoodLogin) |
184 | { | 184 | { |
185 | m_log.InfoFormat("[LOGIN END]: User {0} {1} failed authentication", firstname, lastname); | 185 | m_log.InfoFormat("[LOGIN END]: User {0} {1} failed authentication", firstname, lastname); |
186 | 186 | ||
187 | return logResponse.CreateLoginFailedResponse(); | 187 | return logResponse.CreateLoginFailedResponse(); |
188 | } | 188 | } |
189 | else | 189 | else |
@@ -199,11 +199,11 @@ namespace OpenSim.Framework.Communications | |||
199 | m_userManager.CommitAgent(ref userProfile); | 199 | m_userManager.CommitAgent(ref userProfile); |
200 | 200 | ||
201 | // Reject the login | 201 | // Reject the login |
202 | 202 | ||
203 | m_log.InfoFormat( | 203 | m_log.InfoFormat( |
204 | "[LOGIN END]: Notifying user {0} {1} that they are already logged in", | 204 | "[LOGIN END]: Notifying user {0} {1} that they are already logged in", |
205 | firstname, lastname); | 205 | firstname, lastname); |
206 | 206 | ||
207 | return logResponse.CreateAlreadyLoggedInResponse(); | 207 | return logResponse.CreateAlreadyLoggedInResponse(); |
208 | } | 208 | } |
209 | // Otherwise... | 209 | // Otherwise... |
@@ -214,9 +214,9 @@ namespace OpenSim.Framework.Communications | |||
214 | { | 214 | { |
215 | LLUUID agentID = userProfile.ID; | 215 | LLUUID agentID = userProfile.ID; |
216 | InventoryData inventData = null; | 216 | InventoryData inventData = null; |
217 | 217 | ||
218 | try | 218 | try |
219 | { | 219 | { |
220 | inventData = GetInventorySkeleton(agentID); | 220 | inventData = GetInventorySkeleton(agentID); |
221 | } | 221 | } |
222 | catch (Exception e) | 222 | catch (Exception e) |
@@ -224,10 +224,10 @@ namespace OpenSim.Framework.Communications | |||
224 | m_log.ErrorFormat( | 224 | m_log.ErrorFormat( |
225 | "[LOGIN END]: Error retrieving inventory skeleton of agent {0}, {1} - {2}", | 225 | "[LOGIN END]: Error retrieving inventory skeleton of agent {0}, {1} - {2}", |
226 | agentID, e.GetType(), e.Message); | 226 | agentID, e.GetType(), e.Message); |
227 | 227 | ||
228 | return logResponse.CreateLoginInventoryFailedResponse(); | 228 | return logResponse.CreateLoginInventoryFailedResponse(); |
229 | } | 229 | } |
230 | 230 | ||
231 | ArrayList AgentInventoryArray = inventData.InventoryArray; | 231 | ArrayList AgentInventoryArray = inventData.InventoryArray; |
232 | 232 | ||
233 | Hashtable InventoryRootHash = new Hashtable(); | 233 | Hashtable InventoryRootHash = new Hashtable(); |
@@ -235,7 +235,7 @@ namespace OpenSim.Framework.Communications | |||
235 | ArrayList InventoryRoot = new ArrayList(); | 235 | ArrayList InventoryRoot = new ArrayList(); |
236 | InventoryRoot.Add(InventoryRootHash); | 236 | InventoryRoot.Add(InventoryRootHash); |
237 | userProfile.RootInventoryFolderID = inventData.RootFolderID; | 237 | userProfile.RootInventoryFolderID = inventData.RootFolderID; |
238 | 238 | ||
239 | // Inventory Library Section | 239 | // Inventory Library Section |
240 | Hashtable InventoryLibRootHash = new Hashtable(); | 240 | Hashtable InventoryLibRootHash = new Hashtable(); |
241 | InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | 241 | InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; |
@@ -244,10 +244,10 @@ namespace OpenSim.Framework.Communications | |||
244 | logResponse.InventoryLibRoot = InventoryLibRoot; | 244 | logResponse.InventoryLibRoot = InventoryLibRoot; |
245 | 245 | ||
246 | logResponse.InventoryLibraryOwner = GetLibraryOwner(); | 246 | logResponse.InventoryLibraryOwner = GetLibraryOwner(); |
247 | 247 | ||
248 | logResponse.InventoryRoot = InventoryRoot; | 248 | logResponse.InventoryRoot = InventoryRoot; |
249 | logResponse.InventorySkeleton = AgentInventoryArray; | 249 | logResponse.InventorySkeleton = AgentInventoryArray; |
250 | logResponse.InventoryLibrary = GetInventoryLibrary(); | 250 | logResponse.InventoryLibrary = GetInventoryLibrary(); |
251 | 251 | ||
252 | // Circuit Code | 252 | // Circuit Code |
253 | uint circode = (uint) (Util.RandomClass.Next()); | 253 | uint circode = (uint) (Util.RandomClass.Next()); |
@@ -280,15 +280,15 @@ namespace OpenSim.Framework.Communications | |||
280 | //return logResponse.ToXmlRpcResponse(); | 280 | //return logResponse.ToXmlRpcResponse(); |
281 | } | 281 | } |
282 | CommitAgent(ref userProfile); | 282 | CommitAgent(ref userProfile); |
283 | 283 | ||
284 | // If we reach this point, then the login has successfully logged onto the grid | 284 | // If we reach this point, then the login has successfully logged onto the grid |
285 | if (StatsManager.UserStats != null) | 285 | if (StatsManager.UserStats != null) |
286 | StatsManager.UserStats.AddSuccessfulLogin(); | 286 | StatsManager.UserStats.AddSuccessfulLogin(); |
287 | 287 | ||
288 | m_log.DebugFormat( | 288 | m_log.DebugFormat( |
289 | "[LOGIN END]: Authentication of user {0} {1} successful. Sending response to client.", | 289 | "[LOGIN END]: Authentication of user {0} {1} successful. Sending response to client.", |
290 | firstname, lastname); | 290 | firstname, lastname); |
291 | 291 | ||
292 | return logResponse.ToXmlRpcResponse(); | 292 | return logResponse.ToXmlRpcResponse(); |
293 | } | 293 | } |
294 | catch (Exception e) | 294 | catch (Exception e) |
@@ -422,10 +422,10 @@ namespace OpenSim.Framework.Communications | |||
422 | } | 422 | } |
423 | 423 | ||
424 | CommitAgent(ref userProfile); | 424 | CommitAgent(ref userProfile); |
425 | 425 | ||
426 | // If we reach this point, then the login has successfully logged onto the grid | 426 | // If we reach this point, then the login has successfully logged onto the grid |
427 | if (StatsManager.UserStats != null) | 427 | if (StatsManager.UserStats != null) |
428 | StatsManager.UserStats.AddSuccessfulLogin(); | 428 | StatsManager.UserStats.AddSuccessfulLogin(); |
429 | 429 | ||
430 | return logResponse.ToLLSDResponse(); | 430 | return logResponse.ToLLSDResponse(); |
431 | } | 431 | } |
@@ -449,7 +449,7 @@ namespace OpenSim.Framework.Communications | |||
449 | // period, space, parens, and dash. | 449 | // period, space, parens, and dash. |
450 | 450 | ||
451 | Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); | 451 | Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); |
452 | 452 | ||
453 | Hashtable returnactions = new Hashtable(); | 453 | Hashtable returnactions = new Hashtable(); |
454 | int statuscode = 200; | 454 | int statuscode = 200; |
455 | 455 | ||
@@ -467,7 +467,7 @@ namespace OpenSim.Framework.Communications | |||
467 | // the client requires the HTML form field be named 'username' | 467 | // the client requires the HTML form field be named 'username' |
468 | // however, the data it sends when it loads the first time is 'firstname' | 468 | // however, the data it sends when it loads the first time is 'firstname' |
469 | // another one of those little nuances. | 469 | // another one of those little nuances. |
470 | 470 | ||
471 | if (keysvals.Contains("firstname")) | 471 | if (keysvals.Contains("firstname")) |
472 | firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); | 472 | firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); |
473 | 473 | ||
@@ -494,7 +494,7 @@ namespace OpenSim.Framework.Communications | |||
494 | 494 | ||
495 | if (keysvals.Contains("lang")) | 495 | if (keysvals.Contains("lang")) |
496 | lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); | 496 | lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); |
497 | 497 | ||
498 | if (keysvals.Contains("password")) | 498 | if (keysvals.Contains("password")) |
499 | password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); | 499 | password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); |
500 | 500 | ||
@@ -541,8 +541,8 @@ namespace OpenSim.Framework.Communications | |||
541 | return returnactions; | 541 | return returnactions; |
542 | } | 542 | } |
543 | 543 | ||
544 | public string GetLoginForm(string firstname, string lastname, string location, string region, | 544 | public string GetLoginForm(string firstname, string lastname, string location, string region, |
545 | string grid, string channel, string version, string lang, | 545 | string grid, string channel, string version, string lang, |
546 | string password, string errormessages) | 546 | string password, string errormessages) |
547 | { | 547 | { |
548 | // inject our values in the form at the markers | 548 | // inject our values in the form at the markers |
@@ -559,7 +559,7 @@ namespace OpenSim.Framework.Communications | |||
559 | loginform = sr.ReadToEnd(); | 559 | loginform = sr.ReadToEnd(); |
560 | sr.Close(); | 560 | sr.Close(); |
561 | } | 561 | } |
562 | 562 | ||
563 | loginform = loginform.Replace("[$firstname]", firstname); | 563 | loginform = loginform.Replace("[$firstname]", firstname); |
564 | loginform = loginform.Replace("[$lastname]", lastname); | 564 | loginform = loginform.Replace("[$lastname]", lastname); |
565 | loginform = loginform.Replace("[$location]", location); | 565 | loginform = loginform.Replace("[$location]", location); |
@@ -586,7 +586,7 @@ namespace OpenSim.Framework.Communications | |||
586 | responseString += "<title>OpenSim Login</title>"; | 586 | responseString += "<title>OpenSim Login</title>"; |
587 | responseString += "<body><br />"; | 587 | responseString += "<body><br />"; |
588 | responseString += "<div id=\"login_box\">"; | 588 | responseString += "<div id=\"login_box\">"; |
589 | 589 | ||
590 | responseString += "<form action=\"/go.cgi\" method=\"GET\" id=\"login-form\">"; | 590 | responseString += "<form action=\"/go.cgi\" method=\"GET\" id=\"login-form\">"; |
591 | 591 | ||
592 | responseString += "<div id=\"message\">[$errors]</div>"; | 592 | responseString += "<div id=\"message\">[$errors]</div>"; |
@@ -670,13 +670,13 @@ namespace OpenSim.Framework.Communications | |||
670 | password = "$1$" + Util.Md5Hash(password); | 670 | password = "$1$" + Util.Md5Hash(password); |
671 | 671 | ||
672 | password = password.Remove(0, 3); //remove $1$ | 672 | password = password.Remove(0, 3); //remove $1$ |
673 | 673 | ||
674 | string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); | 674 | string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); |
675 | // Testing... | 675 | // Testing... |
676 | //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); | 676 | //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); |
677 | //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); | 677 | //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); |
678 | 678 | ||
679 | passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | 679 | passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) |
680 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); | 680 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); |
681 | 681 | ||
682 | return passwordSuccess; | 682 | return passwordSuccess; |
@@ -694,7 +694,7 @@ namespace OpenSim.Framework.Communications | |||
694 | } | 694 | } |
695 | 695 | ||
696 | /// <summary> | 696 | /// <summary> |
697 | /// | 697 | /// |
698 | /// </summary> | 698 | /// </summary> |
699 | /// <param name="profile"></param> | 699 | /// <param name="profile"></param> |
700 | /// <param name="request"></param> | 700 | /// <param name="request"></param> |
@@ -709,7 +709,7 @@ namespace OpenSim.Framework.Communications | |||
709 | } | 709 | } |
710 | 710 | ||
711 | /// <summary> | 711 | /// <summary> |
712 | /// | 712 | /// |
713 | /// </summary> | 713 | /// </summary> |
714 | /// <param name="firstname"></param> | 714 | /// <param name="firstname"></param> |
715 | /// <param name="lastname"></param> | 715 | /// <param name="lastname"></param> |
@@ -720,7 +720,7 @@ namespace OpenSim.Framework.Communications | |||
720 | } | 720 | } |
721 | 721 | ||
722 | /// <summary> | 722 | /// <summary> |
723 | /// | 723 | /// |
724 | /// </summary> | 724 | /// </summary> |
725 | /// <returns></returns> | 725 | /// <returns></returns> |
726 | public virtual string GetMessage() | 726 | public virtual string GetMessage() |
@@ -741,17 +741,17 @@ namespace OpenSim.Framework.Communications | |||
741 | } | 741 | } |
742 | return buddylistreturn; | 742 | return buddylistreturn; |
743 | } | 743 | } |
744 | 744 | ||
745 | /// <summary> | 745 | /// <summary> |
746 | /// Converts the inventory library skeleton into the form required by the rpc request. | 746 | /// Converts the inventory library skeleton into the form required by the rpc request. |
747 | /// </summary> | 747 | /// </summary> |
748 | /// <returns></returns> | 748 | /// <returns></returns> |
749 | protected virtual ArrayList GetInventoryLibrary() | 749 | protected virtual ArrayList GetInventoryLibrary() |
750 | { | 750 | { |
751 | Dictionary<LLUUID, InventoryFolderImpl> rootFolders | 751 | Dictionary<LLUUID, InventoryFolderImpl> rootFolders |
752 | = m_libraryRootFolder.RequestSelfAndDescendentFolders(); | 752 | = m_libraryRootFolder.RequestSelfAndDescendentFolders(); |
753 | ArrayList folderHashes = new ArrayList(); | 753 | ArrayList folderHashes = new ArrayList(); |
754 | 754 | ||
755 | foreach (InventoryFolderBase folder in rootFolders.Values) | 755 | foreach (InventoryFolderBase folder in rootFolders.Values) |
756 | { | 756 | { |
757 | Hashtable TempHash = new Hashtable(); | 757 | Hashtable TempHash = new Hashtable(); |
@@ -762,12 +762,12 @@ namespace OpenSim.Framework.Communications | |||
762 | TempHash["folder_id"] = folder.ID.ToString(); | 762 | TempHash["folder_id"] = folder.ID.ToString(); |
763 | folderHashes.Add(TempHash); | 763 | folderHashes.Add(TempHash); |
764 | } | 764 | } |
765 | 765 | ||
766 | return folderHashes; | 766 | return folderHashes; |
767 | } | 767 | } |
768 | 768 | ||
769 | /// <summary> | 769 | /// <summary> |
770 | /// | 770 | /// |
771 | /// </summary> | 771 | /// </summary> |
772 | /// <returns></returns> | 772 | /// <returns></returns> |
773 | protected virtual ArrayList GetLibraryOwner() | 773 | protected virtual ArrayList GetLibraryOwner() |