aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer
diff options
context:
space:
mode:
authorlbsa712007-03-29 19:42:58 +0000
committerlbsa712007-03-29 19:42:58 +0000
commitfeaf036aa2d83d493f1a5c7bb3ba7bec57f4c41e (patch)
treea0fe02996a7d0cd226ab7a658ad55e204c3a2410 /OpenSim.RegionServer
parent* Now the rest handlers try to match path as close as possibly, so it's possi... (diff)
downloadopensim-SC_OLD-feaf036aa2d83d493f1a5c7bb3ba7bec57f4c41e.zip
opensim-SC_OLD-feaf036aa2d83d493f1a5c7bb3ba7bec57f4c41e.tar.gz
opensim-SC_OLD-feaf036aa2d83d493f1a5c7bb3ba7bec57f4c41e.tar.bz2
opensim-SC_OLD-feaf036aa2d83d493f1a5c7bb3ba7bec57f4c41e.tar.xz
* Moved LoginServer and LocalUserProfileManager to OpenSim.Servers
Diffstat (limited to 'OpenSim.RegionServer')
-rw-r--r--OpenSim.RegionServer/OpenSim.RegionServer.csproj6
-rw-r--r--OpenSim.RegionServer/OpenSim.RegionServer.dll.build2
-rw-r--r--OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs109
-rw-r--r--OpenSim.RegionServer/UserServer/LoginServer.cs307
4 files changed, 0 insertions, 424 deletions
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
index bc736b0..bd9ffb6 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
@@ -148,12 +148,6 @@
148 <Compile Include="types\Triangle.cs"> 148 <Compile Include="types\Triangle.cs">
149 <SubType>Code</SubType> 149 <SubType>Code</SubType>
150 </Compile> 150 </Compile>
151 <Compile Include="UserServer\LocalUserProfileManager.cs">
152 <SubType>Code</SubType>
153 </Compile>
154 <Compile Include="UserServer\LoginServer.cs">
155 <SubType>Code</SubType>
156 </Compile>
157 <Compile Include="world\Avatar.cs"> 151 <Compile Include="world\Avatar.cs">
158 <SubType>Code</SubType> 152 <SubType>Code</SubType>
159 </Compile> 153 </Compile>
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
index 0cb9bf6..5e29b48 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
@@ -25,8 +25,6 @@
25 <include name="CAPS/AdminWebFront.cs" /> 25 <include name="CAPS/AdminWebFront.cs" />
26 <include name="types/Mesh.cs" /> 26 <include name="types/Mesh.cs" />
27 <include name="types/Triangle.cs" /> 27 <include name="types/Triangle.cs" />
28 <include name="UserServer/LocalUserProfileManager.cs" />
29 <include name="UserServer/LoginServer.cs" />
30 <include name="world/Avatar.cs" /> 28 <include name="world/Avatar.cs" />
31 <include name="world/AvatarAnimations.cs" /> 29 <include name="world/AvatarAnimations.cs" />
32 <include name="world/Entity.cs" /> 30 <include name="world/Entity.cs" />
diff --git a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs
deleted file mode 100644
index 6166e02..0000000
--- a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs
+++ /dev/null
@@ -1,109 +0,0 @@
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 System;
29using System.Collections.Generic;
30using System.Collections;
31using System.Text;
32using OpenSim.Framework.User;
33using OpenSim.Framework.Grid;
34using OpenSim.Framework.Inventory;
35using OpenSim.Framework.Interfaces;
36using libsecondlife;
37
38namespace OpenSim.UserServer
39{
40 public class LocalUserProfileManager : UserProfileManager
41 {
42 private IGridServer m_gridServer;
43 private int m_port;
44 private string m_ipAddr;
45
46 public LocalUserProfileManager(IGridServer gridServer, int simPort, string ipAddr)
47 {
48 m_gridServer = gridServer;
49 m_port = simPort;
50 m_ipAddr = ipAddr;
51 }
52
53 public override void InitUserProfiles()
54 {
55 // TODO: need to load from database
56 }
57
58 public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser)
59 {
60 Int32 circode = (Int32)response["circuit_code"];
61 theUser.AddSimCircuit((uint)circode, LLUUID.Random());
62 response["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
63 response["sim_port"] = m_port;
64 response["sim_ip"] = m_ipAddr;
65 response["region_y"] = (Int32)996 * 256;
66 response["region_x"] = (Int32)997* 256;
67
68 string first;
69 string last;
70 if (response.Contains("first_name"))
71 {
72 first = (string)response["first_name"];
73 }
74 else
75 {
76 first = "test";
77 }
78
79 if (response.Contains("last_name"))
80 {
81 last = (string)response["last_name"];
82 }
83 else
84 {
85 last = "User";
86 }
87
88 ArrayList InventoryList = (ArrayList)response["inventory-skeleton"];
89 Hashtable Inventory1 = (Hashtable)InventoryList[0];
90
91 Login _login = new Login();
92 //copy data to login object
93 _login.First = first;
94 _login.Last = last;
95 _login.Agent = new LLUUID((string)response["agent_id"]) ;
96 _login.Session = new LLUUID((string)response["session_id"]);
97 _login.SecureSession = new LLUUID((string)response["secure_session_id"]);
98 _login.BaseFolder = null;
99 _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]);
100
101 //working on local computer if so lets add to the gridserver's list of sessions?
102 if (m_gridServer.GetName() == "Local")
103 {
104 Console.WriteLine("adding login data to gridserver");
105 ((LocalGridBase)this.m_gridServer).AddNewSession(_login);
106 }
107 }
108 }
109}
diff --git a/OpenSim.RegionServer/UserServer/LoginServer.cs b/OpenSim.RegionServer/UserServer/LoginServer.cs
deleted file mode 100644
index 4c77389..0000000
--- a/OpenSim.RegionServer/UserServer/LoginServer.cs
+++ /dev/null
@@ -1,307 +0,0 @@
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
50 /// <summary>
51 /// When running in local (default) mode , handles client logins.
52 /// </summary>
53 public class LoginServer : LoginService, IUserServer
54 {
55 private IGridServer m_gridServer;
56 private ushort _loginPort = 8080;
57 public IPAddress clientAddress = IPAddress.Loopback;
58 public IPAddress remoteAddress = IPAddress.Any;
59 private Socket loginServer;
60 private int NumClients;
61 private string _defaultResponse;
62 private bool userAccounts = false;
63 private string _mpasswd;
64 private bool _needPasswd = false;
65 private LocalUserProfileManager userManager;
66 private int m_simPort;
67 private string m_simAddr;
68
69 public LocalUserProfileManager LocalUserManager
70 {
71 get
72 {
73 return userManager;
74 }
75 }
76
77 public LoginServer(IGridServer gridServer, string simAddr, int simPort, bool useAccounts)
78 {
79 m_gridServer = gridServer;
80 m_simPort = simPort;
81 m_simAddr = simAddr;
82 this.userAccounts = useAccounts;
83 }
84
85 public void Startup()
86 {
87 this._needPasswd = false;
88 //read in default response string
89 StreamReader SR;
90 string lines;
91 SR = File.OpenText("new-login.dat");
92
93 while (!SR.EndOfStream)
94 {
95 lines = SR.ReadLine();
96 _defaultResponse += lines;
97 }
98 SR.Close();
99 this._mpasswd = EncodePassword("testpass");
100
101 userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr);
102 userManager.InitUserProfiles();
103 userManager.SetKeys("", "", "", "Welcome to OpenSim");
104 }
105
106 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
107 {
108 Console.WriteLine("login attempt");
109 Hashtable requestData = (Hashtable)request.Params[0];
110 string first;
111 string last;
112 string passwd;
113 LLUUID Agent;
114 LLUUID Session;
115
116 XmlRpcResponse response = new XmlRpcResponse();
117
118 //get login name
119 if (requestData.Contains("first"))
120 {
121 first = (string)requestData["first"];
122 }
123 else
124 {
125 first = "test";
126 }
127
128 if (requestData.Contains("last"))
129 {
130 last = (string)requestData["last"];
131 }
132 else
133 {
134 last = "User" + NumClients.ToString();
135 }
136
137 if (requestData.Contains("passwd"))
138 {
139 passwd = (string)requestData["passwd"];
140 }
141 else
142 {
143 passwd = "notfound";
144 }
145
146 if (!Authenticate(first, last, passwd))
147 {
148 Hashtable loginError = new Hashtable();
149 loginError["reason"] = "key"; ;
150 loginError["message"] = "You have entered an invalid name/password combination. Check Caps/lock.";
151 loginError["login"] = "false";
152 response.Value = loginError;
153 }
154
155 NumClients++;
156
157 //create a agent and session LLUUID
158 Agent = GetAgentId(first, last);
159 int SessionRand = Util.RandomClass.Next(1, 999);
160 Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
161 LLUUID secureSess = LLUUID.Random();
162 //create some login info
163 Hashtable LoginFlagsHash = new Hashtable();
164 LoginFlagsHash["daylight_savings"] = "N";
165 LoginFlagsHash["stipend_since_login"] = "N";
166 LoginFlagsHash["gendered"] = "Y";
167 LoginFlagsHash["ever_logged_in"] = "Y";
168 ArrayList LoginFlags = new ArrayList();
169 LoginFlags.Add(LoginFlagsHash);
170
171 Hashtable GlobalT = new Hashtable();
172 GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
173 GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
174 GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
175 ArrayList GlobalTextures = new ArrayList();
176 GlobalTextures.Add(GlobalT);
177
178 response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
179 Hashtable responseData = (Hashtable)response.Value;
180
181 responseData["sim_port"] = m_simPort;
182 responseData["sim_ip"] = m_simAddr;
183 responseData["agent_id"] = Agent.ToStringHyphenated();
184 responseData["session_id"] = Session.ToStringHyphenated();
185 responseData["secure_session_id"] = secureSess.ToStringHyphenated();
186 responseData["circuit_code"] = (Int32)(Util.RandomClass.Next());
187 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
188 responseData["login-flags"] = LoginFlags;
189 responseData["global-textures"] = GlobalTextures;
190
191 //inventory
192 ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"];
193 Hashtable Inventory1 = (Hashtable)InventoryList[0];
194 Hashtable Inventory2 = (Hashtable)InventoryList[1];
195 LLUUID BaseFolderID = LLUUID.Random();
196 LLUUID InventoryFolderID = LLUUID.Random();
197 Inventory2["name"] = "Textures";
198 Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated();
199 Inventory2["type_default"] = 0;
200 Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated();
201
202 ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"];
203 Hashtable Inventoryroot = (Hashtable)InventoryRoot[0];
204 Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated();
205
206 CustomiseLoginResponse(responseData, first, last);
207
208 Login _login = new Login();
209 //copy data to login object
210 _login.First = first;
211 _login.Last = last;
212 _login.Agent = Agent;
213 _login.Session = Session;
214 _login.SecureSession = secureSess;
215 _login.BaseFolder = BaseFolderID;
216 _login.InventoryFolder = InventoryFolderID;
217
218 //working on local computer if so lets add to the gridserver's list of sessions?
219 if (m_gridServer.GetName() == "Local")
220 {
221 ((LocalGridBase)m_gridServer).AddNewSession(_login);
222 }
223
224 return response;
225 }
226
227 protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last)
228 {
229 }
230
231 protected virtual LLUUID GetAgentId(string firstName, string lastName)
232 {
233 LLUUID Agent;
234 int AgentRand = Util.RandomClass.Next(1, 9999);
235 Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
236 return Agent;
237 }
238
239 protected virtual bool Authenticate(string first, string last, string passwd)
240 {
241 if (this._needPasswd)
242 {
243 //every user needs the password to login
244 string encodedPass = passwd.Remove(0, 3); //remove $1$
245 if (encodedPass == this._mpasswd)
246 {
247 return true;
248 }
249 else
250 {
251 return false;
252 }
253 }
254 else
255 {
256 //do not need password to login
257 return true;
258 }
259 }
260
261 private static string EncodePassword(string passwd)
262 {
263 Byte[] originalBytes;
264 Byte[] encodedBytes;
265 MD5 md5;
266
267 md5 = new MD5CryptoServiceProvider();
268 originalBytes = ASCIIEncoding.Default.GetBytes(passwd);
269 encodedBytes = md5.ComputeHash(originalBytes);
270
271 return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
272 }
273
274 public bool CreateUserAccount(string firstName, string lastName, string password)
275 {
276 Console.WriteLine("creating new user account");
277 string mdPassword = EncodePassword(password);
278 Console.WriteLine("with password: " + mdPassword);
279 this.userManager.CreateNewProfile(firstName, lastName, mdPassword);
280 return true;
281 }
282
283 //IUserServer implementation
284 public AgentInventory RequestAgentsInventory(LLUUID agentID)
285 {
286 AgentInventory aInventory = null;
287 if (this.userAccounts)
288 {
289 aInventory = this.userManager.GetUsersInventory(agentID);
290 }
291
292 return aInventory;
293 }
294
295 public bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory)
296 {
297 return true;
298 }
299
300 public void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
301 {
302
303 }
304 }
305
306
307}