diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/LoginService.cs | 175 |
1 files changed, 93 insertions, 82 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 497cc5d..e24d858 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Threading; | ||
31 | using libsecondlife; | 32 | using libsecondlife; |
32 | using Nwc.XmlRpc; | 33 | using Nwc.XmlRpc; |
33 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
@@ -38,6 +39,7 @@ namespace OpenSim.Framework.UserManagement | |||
38 | { | 39 | { |
39 | protected string m_welcomeMessage = "Welcome to OpenSim"; | 40 | protected string m_welcomeMessage = "Welcome to OpenSim"; |
40 | protected UserManagerBase m_userManager = null; | 41 | protected UserManagerBase m_userManager = null; |
42 | protected Mutex m_loginMutex = new Mutex(false); | ||
41 | 43 | ||
42 | public LoginService(UserManagerBase userManager, string welcomeMess) | 44 | public LoginService(UserManagerBase userManager, string welcomeMess) |
43 | { | 45 | { |
@@ -55,104 +57,113 @@ namespace OpenSim.Framework.UserManagement | |||
55 | /// <returns>The response to send</returns> | 57 | /// <returns>The response to send</returns> |
56 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | 58 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) |
57 | { | 59 | { |
58 | MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); | 60 | // Temporary fix |
59 | XmlRpcResponse response = new XmlRpcResponse(); | 61 | m_loginMutex.WaitOne(); |
60 | Hashtable requestData = (Hashtable) request.Params[0]; | 62 | try |
61 | 63 | { | |
62 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && | 64 | MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); |
63 | requestData.Contains("passwd")); | 65 | XmlRpcResponse response = new XmlRpcResponse(); |
64 | bool GoodLogin = false; | 66 | Hashtable requestData = (Hashtable)request.Params[0]; |
65 | 67 | ||
66 | UserProfileData userProfile; | 68 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && |
67 | LoginResponse logResponse = new LoginResponse(); | 69 | requestData.Contains("passwd")); |
70 | bool GoodLogin = false; | ||
68 | 71 | ||
69 | if (GoodXML) | 72 | UserProfileData userProfile; |
70 | { | 73 | LoginResponse logResponse = new LoginResponse(); |
71 | string firstname = (string) requestData["first"]; | ||
72 | string lastname = (string) requestData["last"]; | ||
73 | string passwd = (string) requestData["passwd"]; | ||
74 | 74 | ||
75 | userProfile = GetTheUser(firstname, lastname); | 75 | if (GoodXML) |
76 | if (userProfile == null) | 76 | { |
77 | return logResponse.CreateLoginFailedResponse(); | 77 | string firstname = (string)requestData["first"]; |
78 | string lastname = (string)requestData["last"]; | ||
79 | string passwd = (string)requestData["passwd"]; | ||
78 | 80 | ||
79 | GoodLogin = AuthenticateUser(userProfile, passwd); | 81 | userProfile = GetTheUser(firstname, lastname); |
80 | } | 82 | if (userProfile == null) |
81 | else | 83 | return logResponse.CreateLoginFailedResponse(); |
82 | { | ||
83 | return logResponse.CreateGridErrorResponse(); | ||
84 | } | ||
85 | 84 | ||
86 | if (!GoodLogin) | 85 | GoodLogin = AuthenticateUser(userProfile, passwd); |
87 | { | 86 | } |
88 | return logResponse.CreateLoginFailedResponse(); | 87 | else |
89 | } | ||
90 | else | ||
91 | { | ||
92 | // If we already have a session... | ||
93 | if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) | ||
94 | { | 88 | { |
95 | // Reject the login | 89 | return logResponse.CreateGridErrorResponse(); |
96 | return logResponse.CreateAlreadyLoggedInResponse(); | ||
97 | } | 90 | } |
98 | // Otherwise... | ||
99 | // Create a new agent session | ||
100 | CreateAgent(userProfile, request); | ||
101 | 91 | ||
102 | try | 92 | if (!GoodLogin) |
103 | { | 93 | { |
104 | LLUUID agentID = userProfile.UUID; | 94 | return logResponse.CreateLoginFailedResponse(); |
105 | 95 | } | |
106 | // Inventory Library Section | 96 | else |
107 | InventoryData inventData = CreateInventoryData(agentID); | 97 | { |
108 | ArrayList AgentInventoryArray = inventData.InventoryArray; | 98 | // If we already have a session... |
109 | 99 | if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) | |
110 | Hashtable InventoryRootHash = new Hashtable(); | 100 | { |
111 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); | 101 | // Reject the login |
112 | ArrayList InventoryRoot = new ArrayList(); | 102 | return logResponse.CreateAlreadyLoggedInResponse(); |
113 | InventoryRoot.Add(InventoryRootHash); | 103 | } |
114 | userProfile.rootInventoryFolderID = inventData.RootFolderID; | 104 | // Otherwise... |
115 | 105 | // Create a new agent session | |
116 | // Circuit Code | 106 | CreateAgent(userProfile, request); |
117 | uint circode = (uint) (Util.RandomClass.Next()); | ||
118 | |||
119 | logResponse.Lastname = userProfile.surname; | ||
120 | logResponse.Firstname = userProfile.username; | ||
121 | logResponse.AgentID = agentID.ToStringHyphenated(); | ||
122 | logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); | ||
123 | logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); | ||
124 | logResponse.InventoryRoot = InventoryRoot; | ||
125 | logResponse.InventorySkeleton = AgentInventoryArray; | ||
126 | logResponse.InventoryLibrary = GetInventoryLibrary(); | ||
127 | logResponse.InventoryLibraryOwner = GetLibraryOwner(); | ||
128 | logResponse.CircuitCode = (Int32) circode; | ||
129 | //logResponse.RegionX = 0; //overwritten | ||
130 | //logResponse.RegionY = 0; //overwritten | ||
131 | logResponse.Home = "!!null temporary value {home}!!"; // Overwritten | ||
132 | //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; | ||
133 | //logResponse.SimAddress = "127.0.0.1"; //overwritten | ||
134 | //logResponse.SimPort = 0; //overwritten | ||
135 | logResponse.Message = GetMessage(); | ||
136 | 107 | ||
137 | try | 108 | try |
138 | { | 109 | { |
139 | CustomiseResponse(logResponse, userProfile); | 110 | LLUUID agentID = userProfile.UUID; |
111 | |||
112 | // Inventory Library Section | ||
113 | InventoryData inventData = CreateInventoryData(agentID); | ||
114 | ArrayList AgentInventoryArray = inventData.InventoryArray; | ||
115 | |||
116 | Hashtable InventoryRootHash = new Hashtable(); | ||
117 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); | ||
118 | ArrayList InventoryRoot = new ArrayList(); | ||
119 | InventoryRoot.Add(InventoryRootHash); | ||
120 | userProfile.rootInventoryFolderID = inventData.RootFolderID; | ||
121 | |||
122 | // Circuit Code | ||
123 | uint circode = (uint)(Util.RandomClass.Next()); | ||
124 | |||
125 | logResponse.Lastname = userProfile.surname; | ||
126 | logResponse.Firstname = userProfile.username; | ||
127 | logResponse.AgentID = agentID.ToStringHyphenated(); | ||
128 | logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); | ||
129 | logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); | ||
130 | logResponse.InventoryRoot = InventoryRoot; | ||
131 | logResponse.InventorySkeleton = AgentInventoryArray; | ||
132 | logResponse.InventoryLibrary = GetInventoryLibrary(); | ||
133 | logResponse.InventoryLibraryOwner = GetLibraryOwner(); | ||
134 | logResponse.CircuitCode = (Int32)circode; | ||
135 | //logResponse.RegionX = 0; //overwritten | ||
136 | //logResponse.RegionY = 0; //overwritten | ||
137 | logResponse.Home = "!!null temporary value {home}!!"; // Overwritten | ||
138 | //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; | ||
139 | //logResponse.SimAddress = "127.0.0.1"; //overwritten | ||
140 | //logResponse.SimPort = 0; //overwritten | ||
141 | logResponse.Message = GetMessage(); | ||
142 | |||
143 | try | ||
144 | { | ||
145 | CustomiseResponse(logResponse, userProfile); | ||
146 | } | ||
147 | catch (Exception e) | ||
148 | { | ||
149 | MainLog.Instance.Verbose(e.ToString()); | ||
150 | return logResponse.CreateDeadRegionResponse(); | ||
151 | //return logResponse.ToXmlRpcResponse(); | ||
152 | } | ||
153 | CommitAgent(ref userProfile); | ||
154 | return logResponse.ToXmlRpcResponse(); | ||
140 | } | 155 | } |
141 | catch (Exception e) | 156 | |
157 | catch (Exception E) | ||
142 | { | 158 | { |
143 | MainLog.Instance.Verbose(e.ToString()); | 159 | MainLog.Instance.Verbose(E.ToString()); |
144 | return logResponse.CreateDeadRegionResponse(); | ||
145 | //return logResponse.ToXmlRpcResponse(); | ||
146 | } | 160 | } |
147 | CommitAgent(ref userProfile); | 161 | //} |
148 | return logResponse.ToXmlRpcResponse(); | ||
149 | } | 162 | } |
150 | 163 | } | |
151 | catch (Exception E) | 164 | finally |
152 | { | 165 | { |
153 | MainLog.Instance.Verbose(E.ToString()); | 166 | m_loginMutex.ReleaseMutex(); |
154 | } | ||
155 | //} | ||
156 | } | 167 | } |
157 | return response; | 168 | return response; |
158 | } | 169 | } |