aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Servers/LoginServer.cs
diff options
context:
space:
mode:
authorMW2007-06-28 11:26:22 +0000
committerMW2007-06-28 11:26:22 +0000
commit1aca39a7a6148e77bc75b912ec7da5d4ed6fe427 (patch)
tree2fc3441d0357d80b6827bec32e740c21c0ba6e6b /Common/OpenSim.Servers/LoginServer.cs
parent* Run prebuild, and stuff. (Fixed bug) (diff)
downloadopensim-SC-1aca39a7a6148e77bc75b912ec7da5d4ed6fe427.zip
opensim-SC-1aca39a7a6148e77bc75b912ec7da5d4ed6fe427.tar.gz
opensim-SC-1aca39a7a6148e77bc75b912ec7da5d4ed6fe427.tar.bz2
opensim-SC-1aca39a7a6148e77bc75b912ec7da5d4ed6fe427.tar.xz
Deleted some files that are no longer in use. (I am sure I deleted these yesterday but they seem to have returned).
Diffstat (limited to '')
-rw-r--r--Common/OpenSim.Servers/LoginServer.cs258
1 files changed, 0 insertions, 258 deletions
diff --git a/Common/OpenSim.Servers/LoginServer.cs b/Common/OpenSim.Servers/LoginServer.cs
deleted file mode 100644
index e5373dd..0000000
--- a/Common/OpenSim.Servers/LoginServer.cs
+++ /dev/null
@@ -1,258 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 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;
46using OpenSim.Framework.Types;
47
48namespace OpenSim.UserServer
49{
50 public delegate bool AddNewSessionHandler(ulong regionHandle, Login loginData);
51 /// <summary>
52 /// When running in local (default) mode , handles client logins.
53 /// </summary>
54 public class LoginServer : LoginService, IUserServer
55 {
56 //private IGridServer m_gridServer;
57 public IPAddress clientAddress = IPAddress.Loopback;
58 public IPAddress remoteAddress = IPAddress.Any;
59 private int NumClients;
60 private bool userAccounts = false;
61 private string _mpasswd;
62 private bool _needPasswd = false;
63 private LocalUserProfileManager userManager;
64 private int m_simPort;
65 private string m_simAddr;
66 private uint regionX;
67 private uint regionY;
68 private AddNewSessionHandler AddSession;
69
70 public LocalUserProfileManager LocalUserManager
71 {
72 get
73 {
74 return userManager;
75 }
76 }
77
78 public LoginServer( string simAddr, int simPort, uint regX, uint regY, bool useAccounts)
79 {
80 m_simPort = simPort;
81 m_simAddr = simAddr;
82 regionX = regX;
83 regionY = regY;
84 this.userAccounts = useAccounts;
85 }
86
87 public void SetSessionHandler(AddNewSessionHandler sessionHandler)
88 {
89 this.AddSession = sessionHandler;
90 this.userManager.SetSessionHandler(sessionHandler);
91 }
92
93 public void Startup()
94 {
95 this._needPasswd = false;
96
97 this._mpasswd = EncodePassword("testpass");
98
99 userManager = new LocalUserProfileManager( m_simPort, m_simAddr, regionX, regionY);
100 //userManager.InitUserProfiles();
101 userManager.SetKeys("", "", "", "Welcome to OpenSim");
102 }
103
104 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
105 {
106 Console.WriteLine("login attempt");
107 Hashtable requestData = (Hashtable)request.Params[0];
108 string first;
109 string last;
110 string passwd;
111
112 LoginResponse loginResponse = new LoginResponse();
113 loginResponse.RegionX = regionX;
114 loginResponse.RegionY = regionY;
115
116 //get login name
117 if (requestData.Contains("first"))
118 {
119 first = (string)requestData["first"];
120 }
121 else
122 {
123 first = "test";
124 }
125
126 if (requestData.Contains("last"))
127 {
128 last = (string)requestData["last"];
129 }
130 else
131 {
132 last = "User" + NumClients.ToString();
133 }
134
135 if (requestData.Contains("passwd"))
136 {
137 passwd = (string)requestData["passwd"];
138 }
139 else
140 {
141 passwd = "notfound";
142 }
143
144 if (!Authenticate(first, last, passwd))
145 {
146 return loginResponse.LoginFailedResponse();
147 }
148
149 NumClients++;
150
151 loginResponse.SimPort = m_simPort.ToString();
152 loginResponse.SimAddress = m_simAddr.ToString();
153
154 loginResponse.CircuitCode = (Int32)(Util.RandomClass.Next());
155 XmlRpcResponse response = loginResponse.ToXmlRpcResponse();
156 Hashtable responseData = (Hashtable)response.Value;
157
158
159 CustomiseLoginResponse(responseData, first, last);
160
161 Login _login = new Login();
162 //copy data to login object
163 _login.First = first;
164 _login.Last = last;
165 _login.Agent = loginResponse.AgentID;
166 _login.Session = loginResponse.SessionID;
167 _login.SecureSession = loginResponse.SecureSessionID;
168 _login.CircuitCode = (uint) loginResponse.CircuitCode;
169 _login.BaseFolder = loginResponse.BaseFolderID;
170 _login.InventoryFolder = loginResponse.InventoryFolderID;
171
172 ulong reghand = Helpers.UIntsToLong((regionX * 256), (regionY * 256));
173 AddSession(reghand,_login);
174
175 return response;
176 }
177
178 protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last)
179 {
180 }
181
182 protected virtual LLUUID GetAgentId(string firstName, string lastName)
183 {
184 LLUUID Agent;
185 int AgentRand = Util.RandomClass.Next(1, 9999);
186 Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
187 return Agent;
188 }
189
190 protected virtual bool Authenticate(string first, string last, string passwd)
191 {
192 if (this._needPasswd)
193 {
194 //every user needs the password to login
195 string encodedPass = passwd.Remove(0, 3); //remove $1$
196 if (encodedPass == this._mpasswd)
197 {
198 return true;
199 }
200 else
201 {
202 return false;
203 }
204 }
205 else
206 {
207 //do not need password to login
208 return true;
209 }
210 }
211
212 private static string EncodePassword(string passwd)
213 {
214 Byte[] originalBytes;
215 Byte[] encodedBytes;
216 MD5 md5;
217
218 md5 = new MD5CryptoServiceProvider();
219 originalBytes = ASCIIEncoding.Default.GetBytes(passwd);
220 encodedBytes = md5.ComputeHash(originalBytes);
221
222 return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
223 }
224
225 public bool CreateUserAccount(string firstName, string lastName, string password)
226 {
227 Console.WriteLine("creating new user account");
228 string mdPassword = EncodePassword(password);
229 Console.WriteLine("with password: " + mdPassword);
230 this.userManager.CreateNewProfile(firstName, lastName, mdPassword);
231 return true;
232 }
233
234 //IUserServer implementation
235 public AgentInventory RequestAgentsInventory(LLUUID agentID)
236 {
237 AgentInventory aInventory = null;
238 if (this.userAccounts)
239 {
240 aInventory = this.userManager.GetUsersInventory(agentID);
241 }
242
243 return aInventory;
244 }
245
246 public bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory)
247 {
248 return true;
249 }
250
251 public void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
252 {
253
254 }
255 }
256
257
258}