aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/LoginService.cs
diff options
context:
space:
mode:
authorlbsa712007-10-05 11:27:46 +0000
committerlbsa712007-10-05 11:27:46 +0000
commited6168b96b687a2f44177af8200d13b427089099 (patch)
tree2d87efb9c800f06233cbef0612617eba2c931f68 /OpenSim/Framework/Communications/LoginService.cs
parent== The "right name and place" commit == (diff)
downloadopensim-SC_OLD-ed6168b96b687a2f44177af8200d13b427089099.zip
opensim-SC_OLD-ed6168b96b687a2f44177af8200d13b427089099.tar.gz
opensim-SC_OLD-ed6168b96b687a2f44177af8200d13b427089099.tar.bz2
opensim-SC_OLD-ed6168b96b687a2f44177af8200d13b427089099.tar.xz
* UserProfileData meets code conventions
Diffstat (limited to 'OpenSim/Framework/Communications/LoginService.cs')
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs572
1 files changed, 286 insertions, 286 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 06abb69..31c9363 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -1,287 +1,287 @@
1using System; 1using System;
2using System.Collections; 2using System.Collections;
3using System.Collections.Generic; 3using System.Collections.Generic;
4using System.Reflection; 4using System.Reflection;
5using System.Security.Cryptography; 5using System.Security.Cryptography;
6using libsecondlife; 6using libsecondlife;
7using Nwc.XmlRpc; 7using Nwc.XmlRpc;
8using OpenSim.Framework.Console; 8using OpenSim.Framework.Console;
9using OpenSim.Framework.Interfaces; 9using OpenSim.Framework.Interfaces;
10using OpenSim.Framework.Inventory; 10using OpenSim.Framework.Inventory;
11using OpenSim.Framework.Types; 11using OpenSim.Framework.Types;
12using OpenSim.Framework.Utilities; 12using OpenSim.Framework.Utilities;
13 13
14using OpenSim.Framework.Configuration; 14using OpenSim.Framework.Configuration;
15using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; 15using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder;
16 16
17namespace OpenSim.Framework.UserManagement 17namespace OpenSim.Framework.UserManagement
18{ 18{
19 public class LoginService 19 public class LoginService
20 { 20 {
21 protected string m_welcomeMessage = "Welcome to OpenSim"; 21 protected string m_welcomeMessage = "Welcome to OpenSim";
22 protected UserManagerBase m_userManager = null; 22 protected UserManagerBase m_userManager = null;
23 23
24 public LoginService(UserManagerBase userManager, string welcomeMess) 24 public LoginService(UserManagerBase userManager, string welcomeMess)
25 { 25 {
26 m_userManager = userManager; 26 m_userManager = userManager;
27 if (welcomeMess != "") 27 if (welcomeMess != "")
28 { 28 {
29 m_welcomeMessage = welcomeMess; 29 m_welcomeMessage = welcomeMess;
30 } 30 }
31 } 31 }
32 32
33 /// <summary> 33 /// <summary>
34 /// Main user login function 34 /// Main user login function
35 /// </summary> 35 /// </summary>
36 /// <param name="request">The XMLRPC request</param> 36 /// <param name="request">The XMLRPC request</param>
37 /// <returns>The response to send</returns> 37 /// <returns>The response to send</returns>
38 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) 38 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
39 { 39 {
40 40
41 System.Console.WriteLine("Attempting login now..."); 41 System.Console.WriteLine("Attempting login now...");
42 XmlRpcResponse response = new XmlRpcResponse(); 42 XmlRpcResponse response = new XmlRpcResponse();
43 Hashtable requestData = (Hashtable)request.Params[0]; 43 Hashtable requestData = (Hashtable)request.Params[0];
44 44
45 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); 45 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
46 bool GoodLogin = false; 46 bool GoodLogin = false;
47 47
48 UserProfileData userProfile; 48 UserProfileData userProfile;
49 LoginResponse logResponse = new LoginResponse(); 49 LoginResponse logResponse = new LoginResponse();
50 50
51 if (GoodXML) 51 if (GoodXML)
52 { 52 {
53 string firstname = (string)requestData["first"]; 53 string firstname = (string)requestData["first"];
54 string lastname = (string)requestData["last"]; 54 string lastname = (string)requestData["last"];
55 string passwd = (string)requestData["passwd"]; 55 string passwd = (string)requestData["passwd"];
56 56
57 userProfile = GetTheUser(firstname, lastname); 57 userProfile = GetTheUser(firstname, lastname);
58 if (userProfile == null) 58 if (userProfile == null)
59 return logResponse.CreateLoginFailedResponse(); 59 return logResponse.CreateLoginFailedResponse();
60 60
61 GoodLogin = AuthenticateUser(userProfile, passwd); 61 GoodLogin = AuthenticateUser(userProfile, passwd);
62 } 62 }
63 else 63 else
64 { 64 {
65 return logResponse.CreateGridErrorResponse(); 65 return logResponse.CreateGridErrorResponse();
66 } 66 }
67 67
68 if (!GoodLogin) 68 if (!GoodLogin)
69 { 69 {
70 return logResponse.CreateLoginFailedResponse(); 70 return logResponse.CreateLoginFailedResponse();
71 } 71 }
72 else 72 else
73 { 73 {
74 // If we already have a session... 74 // If we already have a session...
75 if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) 75 if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline)
76 { 76 {
77 // Reject the login 77 // Reject the login
78 return logResponse.CreateAlreadyLoggedInResponse(); 78 return logResponse.CreateAlreadyLoggedInResponse();
79 } 79 }
80 // Otherwise... 80 // Otherwise...
81 // Create a new agent session 81 // Create a new agent session
82 CreateAgent(userProfile, request); 82 CreateAgent(userProfile, request);
83 83
84 try 84 try
85 { 85 {
86 LLUUID agentID = userProfile.UUID; 86 LLUUID agentID = userProfile.UUID;
87 87
88 // Inventory Library Section 88 // Inventory Library Section
89 InventoryData inventData = this.CreateInventoryData(agentID); 89 InventoryData inventData = this.CreateInventoryData(agentID);
90 ArrayList AgentInventoryArray = inventData.InventoryArray; 90 ArrayList AgentInventoryArray = inventData.InventoryArray;
91 91
92 Hashtable InventoryRootHash = new Hashtable(); 92 Hashtable InventoryRootHash = new Hashtable();
93 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); 93 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated();
94 ArrayList InventoryRoot = new ArrayList(); 94 ArrayList InventoryRoot = new ArrayList();
95 InventoryRoot.Add(InventoryRootHash); 95 InventoryRoot.Add(InventoryRootHash);
96 userProfile.rootInventoryFolderID = inventData.RootFolderID; 96 userProfile.RootInventoryFolderId = inventData.RootFolderID;
97 97
98 // Circuit Code 98 // Circuit Code
99 uint circode = (uint)(Util.RandomClass.Next()); 99 uint circode = (uint)(Util.RandomClass.Next());
100 100
101 logResponse.Lastname = userProfile.surname; 101 logResponse.Lastname = userProfile.Lastname;
102 logResponse.Firstname = userProfile.username; 102 logResponse.Firstname = userProfile.Firstname;
103 logResponse.AgentID = agentID.ToStringHyphenated(); 103 logResponse.AgentID = agentID.ToStringHyphenated();
104 logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); 104 logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToStringHyphenated();
105 logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); 105 logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToStringHyphenated();
106 logResponse.InventoryRoot = InventoryRoot; 106 logResponse.InventoryRoot = InventoryRoot;
107 logResponse.InventorySkeleton = AgentInventoryArray; 107 logResponse.InventorySkeleton = AgentInventoryArray;
108 logResponse.InventoryLibrary = this.GetInventoryLibrary(); 108 logResponse.InventoryLibrary = this.GetInventoryLibrary();
109 logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); 109 logResponse.InventoryLibraryOwner = this.GetLibraryOwner();
110 logResponse.CircuitCode = (Int32)circode; 110 logResponse.CircuitCode = (Int32)circode;
111 //logResponse.RegionX = 0; //overwritten 111 //logResponse.RegionX = 0; //overwritten
112 //logResponse.RegionY = 0; //overwritten 112 //logResponse.RegionY = 0; //overwritten
113 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten 113 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
114 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; 114 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
115 //logResponse.SimAddress = "127.0.0.1"; //overwritten 115 //logResponse.SimAddress = "127.0.0.1"; //overwritten
116 //logResponse.SimPort = 0; //overwritten 116 //logResponse.SimPort = 0; //overwritten
117 logResponse.Message = this.GetMessage(); 117 logResponse.Message = this.GetMessage();
118 118
119 try 119 try
120 { 120 {
121 this.CustomiseResponse(logResponse, userProfile); 121 this.CustomiseResponse(logResponse, userProfile);
122 } 122 }
123 catch (Exception e) 123 catch (Exception e)
124 { 124 {
125 System.Console.WriteLine(e.ToString()); 125 System.Console.WriteLine(e.ToString());
126 return logResponse.CreateDeadRegionResponse(); 126 return logResponse.CreateDeadRegionResponse();
127 //return logResponse.ToXmlRpcResponse(); 127 //return logResponse.ToXmlRpcResponse();
128 } 128 }
129 CommitAgent(ref userProfile); 129 CommitAgent(ref userProfile);
130 return logResponse.ToXmlRpcResponse(); 130 return logResponse.ToXmlRpcResponse();
131 131
132 } 132 }
133 133
134 catch (Exception E) 134 catch (Exception E)
135 { 135 {
136 System.Console.WriteLine(E.ToString()); 136 System.Console.WriteLine(E.ToString());
137 } 137 }
138 //} 138 //}
139 } 139 }
140 return response; 140 return response;
141 141
142 } 142 }
143 143
144 /// <summary> 144 /// <summary>
145 /// Customises the login response and fills in missing values. 145 /// Customises the login response and fills in missing values.
146 /// </summary> 146 /// </summary>
147 /// <param name="response">The existing response</param> 147 /// <param name="response">The existing response</param>
148 /// <param name="theUser">The user profile</param> 148 /// <param name="theUser">The user profile</param>
149 public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) 149 public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser)
150 { 150 {
151 } 151 }
152 152
153 /// <summary> 153 /// <summary>
154 /// Saves a target agent to the database 154 /// Saves a target agent to the database
155 /// </summary> 155 /// </summary>
156 /// <param name="profile">The users profile</param> 156 /// <param name="profile">The users profile</param>
157 /// <returns>Successful?</returns> 157 /// <returns>Successful?</returns>
158 public bool CommitAgent(ref UserProfileData profile) 158 public bool CommitAgent(ref UserProfileData profile)
159 { 159 {
160 // Saves the agent to database 160 // Saves the agent to database
161 return true; 161 return true;
162 } 162 }
163 163
164 164
165 /// <summary> 165 /// <summary>
166 /// Checks a user against it's password hash 166 /// Checks a user against it's password hash
167 /// </summary> 167 /// </summary>
168 /// <param name="profile">The users profile</param> 168 /// <param name="profile">The users profile</param>
169 /// <param name="password">The supplied password</param> 169 /// <param name="password">The supplied password</param>
170 /// <returns>Authenticated?</returns> 170 /// <returns>Authenticated?</returns>
171 public virtual bool AuthenticateUser(UserProfileData profile, string password) 171 public virtual bool AuthenticateUser(UserProfileData profile, string password)
172 { 172 {
173 173
174 MainLog.Instance.Verbose( 174 MainLog.Instance.Verbose(
175 "Authenticating " + profile.username + " " + profile.surname); 175 "Authenticating " + profile.Firstname + " " + profile.Lastname);
176 176
177 password = password.Remove(0, 3); //remove $1$ 177 password = password.Remove(0, 3); //remove $1$
178 178
179 string s = Util.Md5Hash(password + ":" + profile.passwordSalt); 179 string s = Util.Md5Hash(password + ":" + profile.PasswordSalt);
180 180
181 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); 181 return profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
182 } 182 }
183 183
184 /// <summary> 184 /// <summary>
185 /// 185 ///
186 /// </summary> 186 /// </summary>
187 /// <param name="profile"></param> 187 /// <param name="profile"></param>
188 /// <param name="request"></param> 188 /// <param name="request"></param>
189 public void CreateAgent(UserProfileData profile, XmlRpcRequest request) 189 public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
190 { 190 {
191 this.m_userManager.CreateAgent(profile, request); 191 this.m_userManager.CreateAgent(profile, request);
192 } 192 }
193 193
194 /// <summary> 194 /// <summary>
195 /// 195 ///
196 /// </summary> 196 /// </summary>
197 /// <param name="firstname"></param> 197 /// <param name="firstname"></param>
198 /// <param name="lastname"></param> 198 /// <param name="lastname"></param>
199 /// <returns></returns> 199 /// <returns></returns>
200 public virtual UserProfileData GetTheUser(string firstname, string lastname) 200 public virtual UserProfileData GetTheUser(string firstname, string lastname)
201 { 201 {
202 return this.m_userManager.GetUserProfile(firstname, lastname); 202 return this.m_userManager.GetUserProfile(firstname, lastname);
203 } 203 }
204 204
205 /// <summary> 205 /// <summary>
206 /// 206 ///
207 /// </summary> 207 /// </summary>
208 /// <returns></returns> 208 /// <returns></returns>
209 public virtual string GetMessage() 209 public virtual string GetMessage()
210 { 210 {
211 return m_welcomeMessage; 211 return m_welcomeMessage;
212 } 212 }
213 213
214 /// <summary> 214 /// <summary>
215 /// 215 ///
216 /// </summary> 216 /// </summary>
217 /// <returns></returns> 217 /// <returns></returns>
218 protected virtual ArrayList GetInventoryLibrary() 218 protected virtual ArrayList GetInventoryLibrary()
219 { 219 {
220 //return new ArrayList(); 220 //return new ArrayList();
221 Hashtable TempHash = new Hashtable(); 221 Hashtable TempHash = new Hashtable();
222 TempHash["name"] = "OpenSim Library"; 222 TempHash["name"] = "OpenSim Library";
223 TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); 223 TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated();
224 TempHash["version"] = 1; 224 TempHash["version"] = 1;
225 TempHash["type_default"] = -1; 225 TempHash["type_default"] = -1;
226 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; 226 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
227 ArrayList temp = new ArrayList(); 227 ArrayList temp = new ArrayList();
228 temp.Add(TempHash); 228 temp.Add(TempHash);
229 229
230 TempHash = new Hashtable(); 230 TempHash = new Hashtable();
231 TempHash["name"] = "Texture Library"; 231 TempHash["name"] = "Texture Library";
232 TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; 232 TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000";
233 TempHash["version"] = 1; 233 TempHash["version"] = 1;
234 TempHash["type_default"] = -1; 234 TempHash["type_default"] = -1;
235 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; 235 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001";
236 temp.Add(TempHash); 236 temp.Add(TempHash);
237 return temp; 237 return temp;
238 } 238 }
239 239
240 /// <summary> 240 /// <summary>
241 /// 241 ///
242 /// </summary> 242 /// </summary>
243 /// <returns></returns> 243 /// <returns></returns>
244 protected virtual ArrayList GetLibraryOwner() 244 protected virtual ArrayList GetLibraryOwner()
245 { 245 {
246 //for now create random inventory library owner 246 //for now create random inventory library owner
247 Hashtable TempHash = new Hashtable(); 247 Hashtable TempHash = new Hashtable();
248 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; 248 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000";
249 ArrayList inventoryLibOwner = new ArrayList(); 249 ArrayList inventoryLibOwner = new ArrayList();
250 inventoryLibOwner.Add(TempHash); 250 inventoryLibOwner.Add(TempHash);
251 return inventoryLibOwner; 251 return inventoryLibOwner;
252 } 252 }
253 253
254 protected virtual InventoryData CreateInventoryData(LLUUID userID) 254 protected virtual InventoryData CreateInventoryData(LLUUID userID)
255 { 255 {
256 AgentInventory userInventory = new AgentInventory(); 256 AgentInventory userInventory = new AgentInventory();
257 userInventory.CreateRootFolder(userID, false); 257 userInventory.CreateRootFolder(userID, false);
258 258
259 ArrayList AgentInventoryArray = new ArrayList(); 259 ArrayList AgentInventoryArray = new ArrayList();
260 Hashtable TempHash; 260 Hashtable TempHash;
261 foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) 261 foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
262 { 262 {
263 TempHash = new Hashtable(); 263 TempHash = new Hashtable();
264 TempHash["name"] = InvFolder.FolderName; 264 TempHash["name"] = InvFolder.FolderName;
265 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); 265 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
266 TempHash["version"] = (Int32)InvFolder.Version; 266 TempHash["version"] = (Int32)InvFolder.Version;
267 TempHash["type_default"] = (Int32)InvFolder.DefaultType; 267 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
268 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); 268 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
269 AgentInventoryArray.Add(TempHash); 269 AgentInventoryArray.Add(TempHash);
270 } 270 }
271 271
272 return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); 272 return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
273 } 273 }
274 274
275 public class InventoryData 275 public class InventoryData
276 { 276 {
277 public ArrayList InventoryArray = null; 277 public ArrayList InventoryArray = null;
278 public LLUUID RootFolderID = LLUUID.Zero; 278 public LLUUID RootFolderID = LLUUID.Zero;
279 279
280 public InventoryData(ArrayList invList, LLUUID rootID) 280 public InventoryData(ArrayList invList, LLUUID rootID)
281 { 281 {
282 InventoryArray = invList; 282 InventoryArray = invList;
283 RootFolderID = rootID; 283 RootFolderID = rootID;
284 } 284 }
285 } 285 }
286 } 286 }
287} 287}