aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorandy2007-03-30 18:02:07 +0000
committerandy2007-03-30 18:02:07 +0000
commit94e9a411abadce3b78df8560eca5e8e1fc241f4f (patch)
tree5d3e939b4240f55118a0e5fe05f9bee8267a8dcb
parentSome very basic terraforming, can raise and lower the terrain, but currently ... (diff)
downloadopensim-SC_OLD-94e9a411abadce3b78df8560eca5e8e1fc241f4f.zip
opensim-SC_OLD-94e9a411abadce3b78df8560eca5e8e1fc241f4f.tar.gz
opensim-SC_OLD-94e9a411abadce3b78df8560eca5e8e1fc241f4f.tar.bz2
opensim-SC_OLD-94e9a411abadce3b78df8560eca5e8e1fc241f4f.tar.xz
Added a LoginResponse class for LoginServer.
Diffstat (limited to '')
-rw-r--r--Servers/LoginResponse.cs398
-rw-r--r--Servers/LoginServer.cs52
2 files changed, 412 insertions, 38 deletions
diff --git a/Servers/LoginResponse.cs b/Servers/LoginResponse.cs
new file mode 100644
index 0000000..2e29889
--- /dev/null
+++ b/Servers/LoginResponse.cs
@@ -0,0 +1,398 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using Nwc.XmlRpc;
29using System;
30using System.IO;
31using System.Net;
32using System.Net.Sockets;
33using System.Text;
34using System.Text.RegularExpressions;
35using System.Threading;
36using System.Collections;
37using System.Security.Cryptography;
38using System.Xml;
39using libsecondlife;
40using OpenSim;
41using OpenSim.Framework.Interfaces;
42using OpenSim.Framework.Grid;
43using OpenSim.Framework.Inventory;
44using OpenSim.Framework.User;
45using OpenSim.Framework.Utilities;
46
47namespace OpenSim.UserServer
48{
49 /// <summary>
50 /// A temp class to handle login response.
51 /// Should make use of UserProfileManager where possible.
52 /// </summary>
53
54 public class LoginResponse
55 {
56 private Hashtable loginFlagsHash;
57 private Hashtable globalTexturesHash;
58 private Hashtable loginError;
59
60 private ArrayList loginFlags;
61 private ArrayList globalTextures;
62
63 // Login Flags
64 private string dst;
65 private string stipendSinceLogin;
66 private string gendered;
67 private string everLoggedIn;
68 private string login;
69 private string simPort;
70 private string simAddress;
71 private string agentID;
72 private string sessionID;
73 private string secureSessionID;
74 private Int32 circuitCode;
75
76 // Global Textures
77 private string sunTexture;
78 private string cloudTexture;
79 private string moonTexture;
80
81 // Error Flags
82 private string errorReason;
83 private string errorMessage;
84
85 // Response
86 private XmlRpcResponse xmlRpcResponse;
87 private XmlRpcResponse defaultXmlRpcResponse;
88 private string defaultTextResponse;
89
90 public LoginResponse()
91 {
92 this.loginFlags = new ArrayList();
93 this.globalTextures = new ArrayList();
94 this.SetDefaultValues();
95 } // LoginServer
96
97 // This will go away as we replace new-login.dat:
98 private void GetDefaultResponse()
99 {
100 try
101 {
102 // read in default response string
103 StreamReader SR;
104 string lines;
105 SR = File.OpenText("new-login.dat");
106
107 this.defaultTextResponse = "";
108 while (!SR.EndOfStream)
109 {
110 lines = SR.ReadLine();
111 this.defaultTextResponse += lines;
112 }
113 SR.Close();
114 this.defaultXmlRpcResponse = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this.defaultTextResponse);
115 }
116 catch (Exception E)
117 {
118 Console.WriteLine(E.ToString());
119 }
120 } // GetDefaultResponse
121
122 public void SetDefaultValues()
123 {
124 this.GetDefaultResponse();
125
126 this.DST = "N";
127 this.StipendSinceLogin = "N";
128 this.Gendered = "Y";
129 this.EverLoggedIn = "Y";
130 this.login = "false";
131
132 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
133 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
134 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
135
136 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
137 this.ErrorReason = "key";
138
139 } // SetDefaultValues
140
141 private XmlRpcResponse GenerateResponse(string reason, string message, string login)
142 {
143 // Overwrite any default values;
144 this.xmlRpcResponse = new XmlRpcResponse();
145
146 // Ensure Login Failed message/reason;
147 this.ErrorMessage = message;
148 this.ErrorReason = reason;
149
150 this.loginError = new Hashtable();
151 this.loginError["reason"] = this.ErrorReason;
152 this.loginError["message"] = this.ErrorMessage;
153 this.loginError["login"] = login;
154 this.xmlRpcResponse.Value = this.loginError;
155 return (this.xmlRpcResponse);
156 } // GenerateResponse
157
158 public XmlRpcResponse LoginFailedResponse()
159 {
160 return (this.GenerateResponse("key", "You have entered an invalid name/password combination. Check Caps/lock.", "false"));
161 } // LoginFailedResponse
162
163 public XmlRpcResponse ConnectionFailedResponse()
164 {
165 return (this.LoginFailedResponse());
166 } // CreateErrorConnectingToGridResponse()
167
168 public XmlRpcResponse CreateAlreadyLoggedInResponse()
169 {
170 return(this.GenerateResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false"));
171 } // CreateAlreadyLoggedInResponse()
172
173 public XmlRpcResponse ToXmlRpcResponse()
174 {
175 this.xmlRpcResponse = this.defaultXmlRpcResponse;
176 Hashtable responseData = (Hashtable)this.xmlRpcResponse.Value;
177
178 this.loginFlagsHash = new Hashtable();
179 this.loginFlagsHash["daylight_savings"] = this.DST;
180 this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
181 this.loginFlagsHash["gendered"] = this.Gendered;
182 this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
183 this.loginFlags.Add(this.loginFlagsHash);
184
185 this.globalTexturesHash = new Hashtable();
186 this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
187 this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
188 this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
189 this.globalTextures.Add(this.globalTexturesHash);
190
191 responseData["sim_port"] = this.SimPort;
192 responseData["sim_ip"] = this.SimAddress;
193 responseData["agent_id"] = this.AgentID;
194 responseData["session_id"] = this.SessionID;
195 responseData["secure_session_id"] = this.SecureSessionID;
196 responseData["circuit_code"] = this.CircuitCode;
197 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
198 responseData["login-flags"] = this.loginFlags;
199 responseData["global-textures"] = this.globalTextures;
200
201 return (this.xmlRpcResponse);
202
203 } // ToXmlRpcResponse
204
205 public string Login
206 {
207 get
208 {
209 return this.login;
210 }
211 set
212 {
213 this.login = value;
214 }
215 } // Login
216
217 public string DST
218 {
219 get
220 {
221 return this.dst;
222 }
223 set
224 {
225 this.dst = value;
226 }
227 } // DST
228
229 public string StipendSinceLogin
230 {
231 get
232 {
233 return this.stipendSinceLogin;
234 }
235 set
236 {
237 this.stipendSinceLogin = value;
238 }
239 } // StipendSinceLogin
240
241 public string Gendered
242 {
243 get
244 {
245 return this.gendered;
246 }
247 set
248 {
249 this.gendered = value;
250 }
251 } // Gendered
252
253 public string EverLoggedIn
254 {
255 get
256 {
257 return this.everLoggedIn;
258 }
259 set
260 {
261 this.everLoggedIn = value;
262 }
263 } // EverLoggedIn
264
265 public string SimPort
266 {
267 get
268 {
269 return this.simPort;
270 }
271 set
272 {
273 this.simPort = value;
274 }
275 } // SimPort
276
277 public string SimAddress
278 {
279 get
280 {
281 return this.simAddress;
282 }
283 set
284 {
285 this.simAddress = value;
286 }
287 } // SimAddress
288
289 public string AgentID
290 {
291 get
292 {
293 return this.agentID;
294 }
295 set
296 {
297 this.agentID = value;
298 }
299 } // AgentID
300
301 public string SessionID
302 {
303 get
304 {
305 return this.sessionID;
306 }
307 set
308 {
309 this.sessionID = value;
310 }
311 } // SessionID
312
313 public string SecureSessionID
314 {
315 get
316 {
317 return this.secureSessionID;
318 }
319 set
320 {
321 this.secureSessionID = value;
322 }
323 } // SecureSessionID
324
325 public Int32 CircuitCode
326 {
327 get
328 {
329 return this.circuitCode;
330 }
331 set
332 {
333 this.circuitCode = value;
334 }
335 } // CircuitCode
336
337 public string SunTexture
338 {
339 get
340 {
341 return this.sunTexture;
342 }
343 set
344 {
345 this.sunTexture = value;
346 }
347 } // SunTexture
348
349 public string CloudTexture
350 {
351 get
352 {
353 return this.cloudTexture;
354 }
355 set
356 {
357 this.cloudTexture = value;
358 }
359 } // CloudTexture
360
361 public string MoonTexture
362 {
363 get
364 {
365 return this.moonTexture;
366 }
367 set
368 {
369 this.moonTexture = value;
370 }
371 } // MoonTexture
372
373 public string ErrorReason
374 {
375 get
376 {
377 return this.errorReason;
378 }
379 set
380 {
381 this.errorReason = value;
382 }
383 } // ErrorReason
384
385 public string ErrorMessage
386 {
387 get
388 {
389 return this.errorMessage;
390 }
391 set
392 {
393 this.errorMessage = value;
394 }
395 } // ErrorMessage
396
397 } // LoginResponse
398} // namespace OpenSim.UserServer \ No newline at end of file
diff --git a/Servers/LoginServer.cs b/Servers/LoginServer.cs
index e0c090a..9be0966 100644
--- a/Servers/LoginServer.cs
+++ b/Servers/LoginServer.cs
@@ -46,7 +46,6 @@ using OpenSim.Framework.Utilities;
46 46
47namespace OpenSim.UserServer 47namespace OpenSim.UserServer
48{ 48{
49
50 /// <summary> 49 /// <summary>
51 /// When running in local (default) mode , handles client logins. 50 /// When running in local (default) mode , handles client logins.
52 /// </summary> 51 /// </summary>
@@ -83,7 +82,7 @@ namespace OpenSim.UserServer
83 public void Startup() 82 public void Startup()
84 { 83 {
85 this._needPasswd = false; 84 this._needPasswd = false;
86 //read in default response string 85 // read in default response string
87 StreamReader SR; 86 StreamReader SR;
88 string lines; 87 string lines;
89 SR = File.OpenText("new-login.dat"); 88 SR = File.OpenText("new-login.dat");
@@ -111,7 +110,7 @@ namespace OpenSim.UserServer
111 LLUUID Agent; 110 LLUUID Agent;
112 LLUUID Session; 111 LLUUID Session;
113 112
114 XmlRpcResponse response = new XmlRpcResponse(); 113 LoginResponse loginResponse = new LoginResponse();
115 114
116 //get login name 115 //get login name
117 if (requestData.Contains("first")) 116 if (requestData.Contains("first"))
@@ -143,50 +142,27 @@ namespace OpenSim.UserServer
143 142
144 if (!Authenticate(first, last, passwd)) 143 if (!Authenticate(first, last, passwd))
145 { 144 {
146 Hashtable loginError = new Hashtable(); 145 return loginResponse.LoginFailedResponse();
147 loginError["reason"] = "key"; ;
148 loginError["message"] = "You have entered an invalid name/password combination. Check Caps/lock.";
149 loginError["login"] = "false";
150 response.Value = loginError;
151 } 146 }
152 147
153 NumClients++; 148 NumClients++;
154 149
155 //create a agent and session LLUUID 150 // Create a agent and session LLUUID
156 Agent = GetAgentId(first, last); 151 Agent = GetAgentId(first, last);
157 int SessionRand = Util.RandomClass.Next(1, 999); 152 int SessionRand = Util.RandomClass.Next(1, 999);
158 Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797"); 153 Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
159 LLUUID secureSess = LLUUID.Random(); 154 LLUUID secureSess = LLUUID.Random();
160 //create some login info 155
161 Hashtable LoginFlagsHash = new Hashtable(); 156 loginResponse.SimPort = m_simPort.ToString();
162 LoginFlagsHash["daylight_savings"] = "N"; 157 loginResponse.SimAddress = m_simAddr.ToString();
163 LoginFlagsHash["stipend_since_login"] = "N"; 158 loginResponse.AgentID = Agent.ToStringHyphenated();
164 LoginFlagsHash["gendered"] = "Y"; 159 loginResponse.SessionID = Session.ToStringHyphenated();
165 LoginFlagsHash["ever_logged_in"] = "Y"; 160 loginResponse.SecureSessionID = secureSess.ToStringHyphenated();
166 ArrayList LoginFlags = new ArrayList(); 161 loginResponse.CircuitCode = (Int32)(Util.RandomClass.Next());
167 LoginFlags.Add(LoginFlagsHash); 162 XmlRpcResponse response = loginResponse.ToXmlRpcResponse();
168
169 Hashtable GlobalT = new Hashtable();
170 GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
171 GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
172 GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
173 ArrayList GlobalTextures = new ArrayList();
174 GlobalTextures.Add(GlobalT);
175
176 response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
177 Hashtable responseData = (Hashtable)response.Value; 163 Hashtable responseData = (Hashtable)response.Value;
178 164
179 responseData["sim_port"] = m_simPort; 165 // inventory
180 responseData["sim_ip"] = m_simAddr;
181 responseData["agent_id"] = Agent.ToStringHyphenated();
182 responseData["session_id"] = Session.ToStringHyphenated();
183 responseData["secure_session_id"] = secureSess.ToStringHyphenated();
184 responseData["circuit_code"] = (Int32)(Util.RandomClass.Next());
185 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
186 responseData["login-flags"] = LoginFlags;
187 responseData["global-textures"] = GlobalTextures;
188
189 //inventory
190 ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"]; 166 ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"];
191 Hashtable Inventory1 = (Hashtable)InventoryList[0]; 167 Hashtable Inventory1 = (Hashtable)InventoryList[0];
192 Hashtable Inventory2 = (Hashtable)InventoryList[1]; 168 Hashtable Inventory2 = (Hashtable)InventoryList[1];