aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Servers/LoginResponse.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Servers/LoginResponse.cs398
1 files changed, 398 insertions, 0 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