aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/LLLoginService
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs (renamed from OpenSim/Framework/Communications/Services/LoginResponse.cs)510
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs639
2 files changed, 968 insertions, 181 deletions
diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index ec5f428..4db6a05 100644
--- a/OpenSim/Framework/Communications/Services/LoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -28,25 +28,107 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net;
31using System.Reflection; 32using System.Reflection;
33
34using OpenSim.Framework;
35using OpenSim.Framework.Capabilities;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38
32using log4net; 39using log4net;
33using Nwc.XmlRpc;
34using OpenMetaverse; 40using OpenMetaverse;
35using OpenMetaverse.StructuredData; 41using OpenMetaverse.StructuredData;
42using OSDArray = OpenMetaverse.StructuredData.OSDArray;
43using OSDMap = OpenMetaverse.StructuredData.OSDMap;
36 44
37namespace OpenSim.Framework.Communications.Services 45namespace OpenSim.Services.LLLoginService
38{ 46{
47 public class LLFailedLoginResponse : OpenSim.Services.Interfaces.FailedLoginResponse
48 {
49 string m_key;
50 string m_value;
51 string m_login;
52
53 public static LLFailedLoginResponse UserProblem;
54 public static LLFailedLoginResponse AuthorizationProblem;
55 public static LLFailedLoginResponse GridProblem;
56 public static LLFailedLoginResponse InventoryProblem;
57 public static LLFailedLoginResponse DeadRegionProblem;
58 public static LLFailedLoginResponse LoginBlockedProblem;
59 public static LLFailedLoginResponse AlreadyLoggedInProblem;
60 public static LLFailedLoginResponse InternalError;
61
62 static LLFailedLoginResponse()
63 {
64 UserProblem = new LLFailedLoginResponse("key",
65 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
66 "false");
67 AuthorizationProblem = new LLFailedLoginResponse("key",
68 "Error connecting to grid. Unable to authorize your session into the region.",
69 "false");
70 GridProblem = new LLFailedLoginResponse("key",
71 "Error connecting to the desired location. Try connecting to another region.",
72 "false");
73 InventoryProblem = new LLFailedLoginResponse("key",
74 "The inventory service is not responding. Please notify your login region operator.",
75 "false");
76 DeadRegionProblem = new LLFailedLoginResponse("key",
77 "The region you are attempting to log into is not responding. Please select another region and try again.",
78 "false");
79 LoginBlockedProblem = new LLFailedLoginResponse("presence",
80 "Logins are currently restricted. Please try again later.",
81 "false");
82 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
83 "You appear to be already logged in. " +
84 "If this is not the case please wait for your session to timeout. " +
85 "If this takes longer than a few minutes please contact the grid owner. " +
86 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.",
87 "false");
88 InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false");
89 }
90
91 public LLFailedLoginResponse(string key, string value, string login)
92 {
93 m_key = key;
94 m_value = value;
95 m_login = login;
96 }
97
98 public override Hashtable ToHashtable()
99 {
100 Hashtable loginError = new Hashtable();
101 loginError["reason"] = m_key;
102 loginError["message"] = m_value;
103 loginError["login"] = m_login;
104 return loginError;
105 }
106
107 public override OSD ToOSDMap()
108 {
109 OSDMap map = new OSDMap();
110
111 map["reason"] = OSD.FromString(m_key);
112 map["message"] = OSD.FromString(m_value);
113 map["login"] = OSD.FromString(m_login);
114
115 return map;
116 }
117 }
118
39 /// <summary> 119 /// <summary>
40 /// A temp class to handle login response. 120 /// A class to handle LL login response.
41 /// Should make use of UserProfileManager where possible.
42 /// </summary> 121 /// </summary>
43 public class LoginResponse 122 public class LLLoginResponse : OpenSim.Services.Interfaces.LoginResponse
44 { 123 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 124 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
125 private static Hashtable globalTexturesHash;
126 // Global Textures
127 private static string sunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
128 private static string cloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621";
129 private static string moonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621";
46 130
47 private Hashtable loginFlagsHash; 131 private Hashtable loginFlagsHash;
48 private Hashtable globalTexturesHash;
49 private Hashtable loginError;
50 private Hashtable uiConfigHash; 132 private Hashtable uiConfigHash;
51 133
52 private ArrayList loginFlags; 134 private ArrayList loginFlags;
@@ -87,19 +169,10 @@ namespace OpenSim.Framework.Communications.Services
87 private string firstname; 169 private string firstname;
88 private string lastname; 170 private string lastname;
89 171
90 // Global Textures
91 private string sunTexture;
92 private string cloudTexture;
93 private string moonTexture;
94
95 // Error Flags 172 // Error Flags
96 private string errorReason; 173 private string errorReason;
97 private string errorMessage; 174 private string errorMessage;
98 175
99 // Response
100 private XmlRpcResponse xmlRpcResponse;
101 // private XmlRpcResponse defaultXmlRpcResponse;
102
103 private string welcomeMessage; 176 private string welcomeMessage;
104 private string startLocation; 177 private string startLocation;
105 private string allowFirstLife; 178 private string allowFirstLife;
@@ -109,7 +182,17 @@ namespace OpenSim.Framework.Communications.Services
109 182
110 private BuddyList m_buddyList = null; 183 private BuddyList m_buddyList = null;
111 184
112 public LoginResponse() 185 static LLLoginResponse()
186 {
187 // This is being set, but it's not used
188 // not sure why.
189 globalTexturesHash = new Hashtable();
190 globalTexturesHash["sun_texture_id"] = sunTexture;
191 globalTexturesHash["cloud_texture_id"] = cloudTexture;
192 globalTexturesHash["moon_texture_id"] = moonTexture;
193 }
194
195 public LLLoginResponse()
113 { 196 {
114 loginFlags = new ArrayList(); 197 loginFlags = new ArrayList();
115 globalTextures = new ArrayList(); 198 globalTextures = new ArrayList();
@@ -117,7 +200,6 @@ namespace OpenSim.Framework.Communications.Services
117 uiConfig = new ArrayList(); 200 uiConfig = new ArrayList();
118 classifiedCategories = new ArrayList(); 201 classifiedCategories = new ArrayList();
119 202
120 loginError = new Hashtable();
121 uiConfigHash = new Hashtable(); 203 uiConfigHash = new Hashtable();
122 204
123 // defaultXmlRpcResponse = new XmlRpcResponse(); 205 // defaultXmlRpcResponse = new XmlRpcResponse();
@@ -129,12 +211,138 @@ namespace OpenSim.Framework.Communications.Services
129 inventoryLibraryOwner = new ArrayList(); 211 inventoryLibraryOwner = new ArrayList();
130 activeGestures = new ArrayList(); 212 activeGestures = new ArrayList();
131 213
132 xmlRpcResponse = new XmlRpcResponse();
133 // defaultXmlRpcResponse = new XmlRpcResponse();
134
135 SetDefaultValues(); 214 SetDefaultValues();
136 } 215 }
137 216
217 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo,
218 GridRegion destination, List<InventoryFolderBase> invSkel, ILibraryService libService,
219 string where, string startlocation, Vector3 position, Vector3 lookAt, string message,
220 GridRegion home, IPEndPoint clientIP)
221 : this()
222 {
223 FillOutInventoryData(invSkel, libService);
224
225 CircuitCode = (int)aCircuit.circuitcode;
226 Lastname = account.LastName;
227 Firstname = account.FirstName;
228 AgentID = account.PrincipalID;
229 SessionID = aCircuit.SessionID;
230 SecureSessionID = aCircuit.SecureSessionID;
231 Message = message;
232 // While we don't have friends...
233 //BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
234 BuddList = new LLLoginResponse.BuddyList();
235 StartLocation = where;
236
237 FillOutHomeData(pinfo, home);
238 LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);
239
240 FillOutRegionData(destination);
241
242 FillOutSeedCap(aCircuit, destination, clientIP);
243
244 }
245
246 private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService)
247 {
248 InventoryData inventData = null;
249
250 try
251 {
252 inventData = GetInventorySkeleton(invSkel);
253 }
254 catch (Exception e)
255 {
256 m_log.WarnFormat(
257 "[LLLOGIN SERVICE]: Error processing inventory skeleton of agent {0} - {1}",
258 agentID, e);
259
260 // ignore and continue
261 }
262
263 if (inventData != null)
264 {
265 ArrayList AgentInventoryArray = inventData.InventoryArray;
266
267 Hashtable InventoryRootHash = new Hashtable();
268 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
269 InventoryRoot = new ArrayList();
270 InventoryRoot.Add(InventoryRootHash);
271 InventorySkeleton = AgentInventoryArray;
272 }
273
274 // Inventory Library Section
275 if (libService != null && libService.LibraryRootFolder != null)
276 {
277 Hashtable InventoryLibRootHash = new Hashtable();
278 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
279 InventoryLibRoot = new ArrayList();
280 InventoryLibRoot.Add(InventoryLibRootHash);
281
282 InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder);
283 InventoryLibrary = GetInventoryLibrary(libService);
284 }
285 }
286
287 private void FillOutHomeData(PresenceInfo pinfo, GridRegion home)
288 {
289 int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize;
290 if (home != null)
291 {
292 x = home.RegionLocX;
293 y = home.RegionLocY;
294 }
295
296 Home = string.Format(
297 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
298 x,
299 y,
300 pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
301 pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
302
303 }
304
305 private void FillOutRegionData(GridRegion destination)
306 {
307 IPEndPoint endPoint = destination.ExternalEndPoint;
308 SimAddress = endPoint.Address.ToString();
309 SimPort = (uint)endPoint.Port;
310 RegionX = (uint)destination.RegionLocX;
311 RegionY = (uint)destination.RegionLocY;
312 }
313
314 private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient)
315 {
316 string capsSeedPath = String.Empty;
317
318 // Don't use the following! It Fails for logging into any region not on the same port as the http server!
319 // Kept here so it doesn't happen again!
320 // response.SeedCapability = regionInfo.ServerURI + capsSeedPath;
321
322 #region IP Translation for NAT
323 if (ipepClient != null)
324 {
325 capsSeedPath
326 = "http://"
327 + NetworkUtil.GetHostFor(ipepClient.Address, destination.ExternalHostName)
328 + ":"
329 + destination.HttpPort
330 + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath);
331 }
332 else
333 {
334 capsSeedPath
335 = "http://"
336 + destination.ExternalHostName
337 + ":"
338 + destination.HttpPort
339 + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath);
340 }
341 #endregion
342
343 SeedCapability = capsSeedPath;
344 }
345
138 private void SetDefaultValues() 346 private void SetDefaultValues()
139 { 347 {
140 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; 348 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
@@ -149,10 +357,6 @@ namespace OpenSim.Framework.Communications.Services
149 startLocation = "last"; 357 startLocation = "last";
150 allowFirstLife = "Y"; 358 allowFirstLife = "Y";
151 359
152 SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
153 CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621";
154 MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621";
155
156 ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; 360 ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
157 ErrorReason = "key"; 361 ErrorReason = "key";
158 welcomeMessage = "Welcome to OpenSim!"; 362 welcomeMessage = "Welcome to OpenSim!";
@@ -186,149 +390,8 @@ namespace OpenSim.Framework.Communications.Services
186 initialOutfit.Add(InitialOutfitHash); 390 initialOutfit.Add(InitialOutfitHash);
187 } 391 }
188 392
189 #region Login Failure Methods
190 393
191 public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) 394 public override Hashtable ToHashtable()
192 {
193 // Overwrite any default values;
194 xmlRpcResponse = new XmlRpcResponse();
195
196 // Ensure Login Failed message/reason;
197 ErrorMessage = message;
198 ErrorReason = reason;
199
200 loginError["reason"] = ErrorReason;
201 loginError["message"] = ErrorMessage;
202 loginError["login"] = login;
203 xmlRpcResponse.Value = loginError;
204 return (xmlRpcResponse);
205 }
206
207 public OSD GenerateFailureResponseLLSD(string reason, string message, string login)
208 {
209 OSDMap map = new OSDMap();
210
211 // Ensure Login Failed message/reason;
212 ErrorMessage = message;
213 ErrorReason = reason;
214
215 map["reason"] = OSD.FromString(ErrorReason);
216 map["message"] = OSD.FromString(ErrorMessage);
217 map["login"] = OSD.FromString(login);
218
219 return map;
220 }
221
222 public XmlRpcResponse CreateFailedResponse()
223 {
224 return (CreateLoginFailedResponse());
225 }
226
227 public OSD CreateFailedResponseLLSD()
228 {
229 return CreateLoginFailedResponseLLSD();
230 }
231
232 public XmlRpcResponse CreateLoginFailedResponse()
233 {
234 return
235 (GenerateFailureResponse("key",
236 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
237 "false"));
238 }
239
240 public OSD CreateLoginFailedResponseLLSD()
241 {
242 return GenerateFailureResponseLLSD(
243 "key",
244 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
245 "false");
246 }
247
248 /// <summary>
249 /// Response to indicate that login failed because the agent's inventory was not available.
250 /// </summary>
251 /// <returns></returns>
252 public XmlRpcResponse CreateLoginInventoryFailedResponse()
253 {
254 return GenerateFailureResponse(
255 "key",
256 "The avatar inventory service is not responding. Please notify your login region operator.",
257 "false");
258 }
259
260 public XmlRpcResponse CreateAlreadyLoggedInResponse()
261 {
262 return
263 (GenerateFailureResponse("presence",
264 "You appear to be already logged in. " +
265 "If this is not the case please wait for your session to timeout. " +
266 "If this takes longer than a few minutes please contact the grid owner. " +
267 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.",
268 "false"));
269 }
270
271 public OSD CreateAlreadyLoggedInResponseLLSD()
272 {
273 return GenerateFailureResponseLLSD(
274 "presence",
275 "You appear to be already logged in. " +
276 "If this is not the case please wait for your session to timeout. " +
277 "If this takes longer than a few minutes please contact the grid owner",
278 "false");
279 }
280
281 public XmlRpcResponse CreateLoginBlockedResponse()
282 {
283 return
284 (GenerateFailureResponse("presence",
285 "Logins are currently restricted. Please try again later",
286 "false"));
287 }
288
289 public OSD CreateLoginBlockedResponseLLSD()
290 {
291 return GenerateFailureResponseLLSD(
292 "presence",
293 "Logins are currently restricted. Please try again later",
294 "false");
295 }
296
297 public XmlRpcResponse CreateDeadRegionResponse()
298 {
299 return
300 (GenerateFailureResponse("key",
301 "The region you are attempting to log into is not responding. Please select another region and try again.",
302 "false"));
303 }
304
305 public OSD CreateDeadRegionResponseLLSD()
306 {
307 return GenerateFailureResponseLLSD(
308 "key",
309 "The region you are attempting to log into is not responding. Please select another region and try again.",
310 "false");
311 }
312
313 public XmlRpcResponse CreateGridErrorResponse()
314 {
315 return
316 (GenerateFailureResponse("key",
317 "Error connecting to grid. Could not percieve credentials from login XML.",
318 "false"));
319 }
320
321 public OSD CreateGridErrorResponseLLSD()
322 {
323 return GenerateFailureResponseLLSD(
324 "key",
325 "Error connecting to grid. Could not perceive credentials from login XML.",
326 "false");
327 }
328
329 #endregion
330
331 public virtual XmlRpcResponse ToXmlRpcResponse()
332 { 395 {
333 try 396 try
334 { 397 {
@@ -346,10 +409,6 @@ namespace OpenSim.Framework.Communications.Services
346 responseData["agent_access"] = agentAccess; 409 responseData["agent_access"] = agentAccess;
347 responseData["agent_access_max"] = agentAccessMax; 410 responseData["agent_access_max"] = agentAccessMax;
348 411
349 globalTexturesHash = new Hashtable();
350 globalTexturesHash["sun_texture_id"] = SunTexture;
351 globalTexturesHash["cloud_texture_id"] = CloudTexture;
352 globalTexturesHash["moon_texture_id"] = MoonTexture;
353 globalTextures.Add(globalTexturesHash); 412 globalTextures.Add(globalTexturesHash);
354 // this.eventCategories.Add(this.eventCategoriesHash); 413 // this.eventCategories.Add(this.eventCategoriesHash);
355 414
@@ -389,8 +448,8 @@ namespace OpenSim.Framework.Communications.Services
389 responseData["home"] = home; 448 responseData["home"] = home;
390 responseData["look_at"] = lookAt; 449 responseData["look_at"] = lookAt;
391 responseData["message"] = welcomeMessage; 450 responseData["message"] = welcomeMessage;
392 responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); 451 responseData["region_x"] = (Int32)(RegionX);
393 responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); 452 responseData["region_y"] = (Int32)(RegionY);
394 453
395 if (m_buddyList != null) 454 if (m_buddyList != null)
396 { 455 {
@@ -398,19 +457,18 @@ namespace OpenSim.Framework.Communications.Services
398 } 457 }
399 458
400 responseData["login"] = "true"; 459 responseData["login"] = "true";
401 xmlRpcResponse.Value = responseData;
402 460
403 return (xmlRpcResponse); 461 return responseData;
404 } 462 }
405 catch (Exception e) 463 catch (Exception e)
406 { 464 {
407 m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); 465 m_log.Warn("[CLIENT]: LoginResponse: Error creating Hashtable Response: " + e.Message);
408 466
409 return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); 467 return LLFailedLoginResponse.InternalError.ToHashtable();
410 } 468 }
411 } 469 }
412 470
413 public OSD ToLLSDResponse() 471 public override OSD ToOSDMap()
414 { 472 {
415 try 473 try
416 { 474 {
@@ -486,8 +544,8 @@ namespace OpenSim.Framework.Communications.Services
486 map["home"] = OSD.FromString(home); 544 map["home"] = OSD.FromString(home);
487 map["look_at"] = OSD.FromString(lookAt); 545 map["look_at"] = OSD.FromString(lookAt);
488 map["message"] = OSD.FromString(welcomeMessage); 546 map["message"] = OSD.FromString(welcomeMessage);
489 map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); 547 map["region_x"] = OSD.FromInteger(RegionX);
490 map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); 548 map["region_y"] = OSD.FromInteger(RegionY);
491 549
492 if (m_buddyList != null) 550 if (m_buddyList != null)
493 { 551 {
@@ -502,7 +560,7 @@ namespace OpenSim.Framework.Communications.Services
502 { 560 {
503 m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); 561 m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message);
504 562
505 return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); 563 return LLFailedLoginResponse.InternalError.ToOSDMap();
506 } 564 }
507 } 565 }
508 566
@@ -548,6 +606,96 @@ namespace OpenSim.Framework.Communications.Services
548 // this.classifiedCategoriesHash.Clear(); 606 // this.classifiedCategoriesHash.Clear();
549 } 607 }
550 608
609
610 private static LLLoginResponse.BuddyList ConvertFriendListItem(List<FriendListItem> LFL)
611 {
612 LLLoginResponse.BuddyList buddylistreturn = new LLLoginResponse.BuddyList();
613 foreach (FriendListItem fl in LFL)
614 {
615 LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(fl.Friend);
616 buddyitem.BuddyID = fl.Friend;
617 buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms;
618 buddyitem.BuddyRightsGiven = (int)fl.FriendPerms;
619 buddylistreturn.AddNewBuddy(buddyitem);
620 }
621 return buddylistreturn;
622 }
623
624 private InventoryData GetInventorySkeleton(List<InventoryFolderBase> folders)
625 {
626 UUID rootID = UUID.Zero;
627 ArrayList AgentInventoryArray = new ArrayList();
628 Hashtable TempHash;
629 foreach (InventoryFolderBase InvFolder in folders)
630 {
631 if (InvFolder.ParentID == UUID.Zero)
632 {
633 rootID = InvFolder.ID;
634 }
635 TempHash = new Hashtable();
636 TempHash["name"] = InvFolder.Name;
637 TempHash["parent_id"] = InvFolder.ParentID.ToString();
638 TempHash["version"] = (Int32)InvFolder.Version;
639 TempHash["type_default"] = (Int32)InvFolder.Type;
640 TempHash["folder_id"] = InvFolder.ID.ToString();
641 AgentInventoryArray.Add(TempHash);
642 }
643
644 return new InventoryData(AgentInventoryArray, rootID);
645
646 }
647
648 /// <summary>
649 /// Converts the inventory library skeleton into the form required by the rpc request.
650 /// </summary>
651 /// <returns></returns>
652 protected virtual ArrayList GetInventoryLibrary(ILibraryService library)
653 {
654 Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders();
655 m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count);
656 //Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>();
657 ArrayList folderHashes = new ArrayList();
658
659 foreach (InventoryFolderBase folder in rootFolders.Values)
660 {
661 Hashtable TempHash = new Hashtable();
662 TempHash["name"] = folder.Name;
663 TempHash["parent_id"] = folder.ParentID.ToString();
664 TempHash["version"] = (Int32)folder.Version;
665 TempHash["type_default"] = (Int32)folder.Type;
666 TempHash["folder_id"] = folder.ID.ToString();
667 folderHashes.Add(TempHash);
668 }
669
670 return folderHashes;
671 }
672
673 /// <summary>
674 ///
675 /// </summary>
676 /// <returns></returns>
677 protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder)
678 {
679 //for now create random inventory library owner
680 Hashtable TempHash = new Hashtable();
681 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner
682 ArrayList inventoryLibOwner = new ArrayList();
683 inventoryLibOwner.Add(TempHash);
684 return inventoryLibOwner;
685 }
686
687 public class InventoryData
688 {
689 public ArrayList InventoryArray = null;
690 public UUID RootFolderID = UUID.Zero;
691
692 public InventoryData(ArrayList invList, UUID rootID)
693 {
694 InventoryArray = invList;
695 RootFolderID = rootID;
696 }
697 }
698
551 #region Properties 699 #region Properties
552 700
553 public string Login 701 public string Login
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
new file mode 100644
index 0000000..ba50e3f
--- /dev/null
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -0,0 +1,639 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.Reflection;
5using System.Text.RegularExpressions;
6
7using log4net;
8using Nini.Config;
9using OpenMetaverse;
10
11using OpenSim.Framework;
12using OpenSim.Framework.Capabilities;
13using OpenSim.Framework.Console;
14using OpenSim.Server.Base;
15using OpenSim.Services.Interfaces;
16using GridRegion = OpenSim.Services.Interfaces.GridRegion;
17using OpenSim.Services.Connectors.Hypergrid;
18
19namespace OpenSim.Services.LLLoginService
20{
21 public class LLLoginService : ILoginService
22 {
23 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
24 private static bool Initialized = false;
25
26 private IUserAccountService m_UserAccountService;
27 private IAuthenticationService m_AuthenticationService;
28 private IInventoryService m_InventoryService;
29 private IGridService m_GridService;
30 private IPresenceService m_PresenceService;
31 private ISimulationService m_LocalSimulationService;
32 private ISimulationService m_RemoteSimulationService;
33 private ILibraryService m_LibraryService;
34 private IAvatarService m_AvatarService;
35 private IUserAgentService m_UserAgentService;
36
37 private GatekeeperServiceConnector m_GatekeeperConnector;
38
39 private string m_DefaultRegionName;
40 private string m_WelcomeMessage;
41 private bool m_RequireInventory;
42 private int m_MinLoginLevel;
43 private string m_GatekeeperURL;
44
45 IConfig m_LoginServerConfig;
46
47 public LLLoginService(IConfigSource config, ISimulationService simService, ILibraryService libraryService)
48 {
49 m_LoginServerConfig = config.Configs["LoginService"];
50 if (m_LoginServerConfig == null)
51 throw new Exception(String.Format("No section LoginService in config file"));
52
53 string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty);
54 string agentService = m_LoginServerConfig.GetString("UserAgentService", String.Empty);
55 string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty);
56 string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty);
57 string gridService = m_LoginServerConfig.GetString("GridService", String.Empty);
58 string presenceService = m_LoginServerConfig.GetString("PresenceService", String.Empty);
59 string libService = m_LoginServerConfig.GetString("LibraryService", String.Empty);
60 string avatarService = m_LoginServerConfig.GetString("AvatarService", String.Empty);
61 string simulationService = m_LoginServerConfig.GetString("SimulationService", String.Empty);
62
63 m_DefaultRegionName = m_LoginServerConfig.GetString("DefaultRegion", String.Empty);
64 m_WelcomeMessage = m_LoginServerConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
65 m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true);
66 m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty);
67
68 // These are required; the others aren't
69 if (accountService == string.Empty || authService == string.Empty)
70 throw new Exception("LoginService is missing service specifications");
71
72 Object[] args = new Object[] { config };
73 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
74 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
75 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
76 if (gridService != string.Empty)
77 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
78 if (presenceService != string.Empty)
79 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
80 if (avatarService != string.Empty)
81 m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args);
82 if (simulationService != string.Empty)
83 m_RemoteSimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args);
84 if (agentService != string.Empty)
85 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(agentService, args);
86
87 //
88 // deal with the services given as argument
89 //
90 m_LocalSimulationService = simService;
91 if (libraryService != null)
92 {
93 m_log.DebugFormat("[LLOGIN SERVICE]: Using LibraryService given as argument");
94 m_LibraryService = libraryService;
95 }
96 else if (libService != string.Empty)
97 {
98 m_log.DebugFormat("[LLOGIN SERVICE]: Using instantiated LibraryService");
99 m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args);
100 }
101
102 m_GatekeeperConnector = new GatekeeperServiceConnector();
103
104 if (!Initialized)
105 {
106 Initialized = true;
107 RegisterCommands();
108 }
109
110 m_log.DebugFormat("[LLOGIN SERVICE]: Starting...");
111
112 }
113
114 public LLLoginService(IConfigSource config) : this(config, null, null)
115 {
116 }
117
118 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP)
119 {
120 bool success = false;
121 UUID session = UUID.Random();
122
123 try
124 {
125 //
126 // Get the account and check that it exists
127 //
128 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
129 if (account == null)
130 {
131 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found");
132 return LLFailedLoginResponse.UserProblem;
133 }
134
135 if (account.UserLevel < m_MinLoginLevel)
136 {
137 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: login is blocked for user level {0}", account.UserLevel);
138 return LLFailedLoginResponse.LoginBlockedProblem;
139 }
140
141 //
142 // Authenticate this user
143 //
144 if (!passwd.StartsWith("$1$"))
145 passwd = "$1$" + Util.Md5Hash(passwd);
146 passwd = passwd.Remove(0, 3); //remove $1$
147 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30);
148 UUID secureSession = UUID.Zero;
149 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
150 {
151 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed");
152 return LLFailedLoginResponse.UserProblem;
153 }
154
155 //
156 // Get the user's inventory
157 //
158 if (m_RequireInventory && m_InventoryService == null)
159 {
160 m_log.WarnFormat("[LLOGIN SERVICE]: Login failed, reason: inventory service not set up");
161 return LLFailedLoginResponse.InventoryProblem;
162 }
163 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
164 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
165 {
166 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory");
167 return LLFailedLoginResponse.InventoryProblem;
168 }
169
170 //
171 // Login the presence
172 //
173 PresenceInfo presence = null;
174 GridRegion home = null;
175 if (m_PresenceService != null)
176 {
177 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
178 if (!success)
179 {
180 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence");
181 return LLFailedLoginResponse.GridProblem;
182 }
183
184 // Get the updated presence info
185 presence = m_PresenceService.GetAgent(session);
186
187 // Get the home region
188 if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null)
189 {
190 home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID);
191 }
192 }
193
194 //
195 // Find the destination region/grid
196 //
197 string where = string.Empty;
198 Vector3 position = Vector3.Zero;
199 Vector3 lookAt = Vector3.Zero;
200 GridRegion gatekeeper = null;
201 GridRegion destination = FindDestination(account, presence, session, startLocation, out gatekeeper, out where, out position, out lookAt);
202 if (destination == null)
203 {
204 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt);
205 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
206 return LLFailedLoginResponse.GridProblem;
207 }
208
209 //
210 // Get the avatar
211 //
212 AvatarData avatar = null;
213 if (m_AvatarService != null)
214 {
215 avatar = m_AvatarService.GetAvatar(account.PrincipalID);
216 }
217
218 //
219 // Instantiate/get the simulation interface and launch an agent at the destination
220 //
221 string reason = string.Empty;
222 AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, out where, out reason);
223
224 if (aCircuit == null)
225 {
226 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt);
227 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
228 return LLFailedLoginResponse.AuthorizationProblem;
229
230 }
231 // TODO: Get Friends list...
232
233 //
234 // Finally, fill out the response and return it
235 //
236 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, m_LibraryService,
237 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
238
239 return response;
240 }
241 catch (Exception e)
242 {
243 m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2}", firstName, lastName, e.ToString());
244 if (m_PresenceService != null)
245 m_PresenceService.LogoutAgent(session, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
246 return LLFailedLoginResponse.InternalError;
247 }
248 }
249
250 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt)
251 {
252 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation);
253
254 gatekeeper = null;
255 where = "home";
256 position = new Vector3(128, 128, 0);
257 lookAt = new Vector3(0, 1, 0);
258
259 if (m_GridService == null)
260 return null;
261
262 if (startLocation.Equals("home"))
263 {
264 // logging into home region
265 if (pinfo == null)
266 return null;
267
268 GridRegion region = null;
269
270 if (pinfo.HomeRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID)) == null)
271 {
272 List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID);
273 if (defaults != null && defaults.Count > 0)
274 {
275 region = defaults[0];
276 where = "safe";
277 }
278 else
279 m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a home set and this grid does not have default locations.",
280 account.FirstName, account.LastName);
281 }
282
283 return region;
284 }
285 else if (startLocation.Equals("last"))
286 {
287 // logging into last visited region
288 where = "last";
289
290 if (pinfo == null)
291 return null;
292
293 GridRegion region = null;
294
295 if (pinfo.RegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID)) == null)
296 {
297 List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID);
298 if (defaults != null && defaults.Count > 0)
299 {
300 region = defaults[0];
301 where = "safe";
302 }
303 }
304 else
305 {
306 position = pinfo.Position;
307 lookAt = pinfo.LookAt;
308 }
309 return region;
310
311 }
312 else
313 {
314 // free uri form
315 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34
316 where = "url";
317 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
318 Match uriMatch = reURI.Match(startLocation);
319 if (uriMatch == null)
320 {
321 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation);
322 return null;
323 }
324 else
325 {
326 position = new Vector3(float.Parse(uriMatch.Groups["x"].Value),
327 float.Parse(uriMatch.Groups["y"].Value),
328 float.Parse(uriMatch.Groups["z"].Value));
329
330 string regionName = uriMatch.Groups["region"].ToString();
331 if (regionName != null)
332 {
333 if (!regionName.Contains("@"))
334 {
335
336 List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1);
337 if ((regions == null) || (regions != null && regions.Count == 0))
338 {
339 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName);
340 regions = m_GridService.GetDefaultRegions(UUID.Zero);
341 if (regions != null && regions.Count > 0)
342 {
343 where = "safe";
344 return regions[0];
345 }
346 else
347 {
348 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not provide default regions.", startLocation);
349 return null;
350 }
351 }
352 return regions[0];
353 }
354 else
355 {
356 if (m_UserAgentService == null)
357 {
358 m_log.WarnFormat("[LLLOGIN SERVICE]: This llogin service is not running a user agent service, as such it can't lauch agents at foreign grids");
359 return null;
360 }
361 string[] parts = regionName.Split(new char[] { '@' });
362 if (parts.Length < 2)
363 {
364 m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName);
365 return null;
366 }
367 // Valid specification of a remote grid
368 regionName = parts[0];
369 string domainLocator = parts[1];
370 parts = domainLocator.Split(new char[] {':'});
371 string domainName = parts[0];
372 uint port = 0;
373 if (parts.Length > 1)
374 UInt32.TryParse(parts[1], out port);
375 GridRegion region = FindForeignRegion(domainName, port, regionName, out gatekeeper);
376 return region;
377 }
378 }
379 else
380 {
381 List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID);
382 if (defaults != null && defaults.Count > 0)
383 {
384 where = "safe";
385 return defaults[0];
386 }
387 else
388 return null;
389 }
390 }
391 //response.LookAt = "[r0,r1,r0]";
392 //// can be: last, home, safe, url
393 //response.StartLocation = "url";
394
395 }
396
397 }
398
399 private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper)
400 {
401 gatekeeper = new GridRegion();
402 gatekeeper.ExternalHostName = domainName;
403 gatekeeper.HttpPort = port;
404 gatekeeper.RegionName = regionName;
405 gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
406
407 UUID regionID;
408 ulong handle;
409 string imageURL = string.Empty, reason = string.Empty;
410 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason))
411 {
412 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID);
413 return destination;
414 }
415
416 return null;
417 }
418
419 private string hostName = string.Empty;
420 private int port = 0;
421
422 private void SetHostAndPort(string url)
423 {
424 try
425 {
426 Uri uri = new Uri(url);
427 hostName = uri.Host;
428 port = uri.Port;
429 }
430 catch
431 {
432 m_log.WarnFormat("[LLLogin SERVICE]: Unable to parse GatekeeperURL {0}", url);
433 }
434 }
435
436 private AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar,
437 UUID session, UUID secureSession, Vector3 position, string currentWhere, out string where, out string reason)
438 {
439 where = currentWhere;
440 ISimulationService simConnector = null;
441 reason = string.Empty;
442 uint circuitCode = 0;
443 AgentCircuitData aCircuit = null;
444
445 if (m_UserAgentService == null)
446 {
447 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
448 // non-HG standalones have just a localSimulationDll
449 // independent login servers have just a remoteSimulationDll
450 if (m_LocalSimulationService != null)
451 simConnector = m_LocalSimulationService;
452 else if (m_RemoteSimulationService != null)
453 simConnector = m_RemoteSimulationService;
454 }
455 else // User Agent Service is on
456 {
457 if (gatekeeper == null) // login to local grid
458 {
459 if (hostName == string.Empty)
460 SetHostAndPort(m_GatekeeperURL);
461
462 gatekeeper = new GridRegion(destination);
463 gatekeeper.ExternalHostName = hostName;
464 gatekeeper.HttpPort = (uint)port;
465
466 }
467 else // login to foreign grid
468 {
469 }
470 }
471
472 bool success = false;
473
474 if (m_UserAgentService == null && simConnector != null)
475 {
476 circuitCode = (uint)Util.RandomClass.Next(); ;
477 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position);
478 success = LaunchAgentDirectly(simConnector, destination, aCircuit, out reason);
479 if (!success && m_GridService != null)
480 {
481 // Try the fallback regions
482 List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
483 if (fallbacks != null)
484 {
485 foreach (GridRegion r in fallbacks)
486 {
487 success = LaunchAgentDirectly(simConnector, r, aCircuit, out reason);
488 if (success)
489 {
490 where = "safe";
491 destination = r;
492 break;
493 }
494 }
495 }
496 }
497 }
498
499 if (m_UserAgentService != null)
500 {
501 circuitCode = (uint)Util.RandomClass.Next(); ;
502 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position);
503 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, out reason);
504 if (!success && m_GridService != null)
505 {
506 // Try the fallback regions
507 List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
508 if (fallbacks != null)
509 {
510 foreach (GridRegion r in fallbacks)
511 {
512 success = LaunchAgentIndirectly(gatekeeper, r, aCircuit, out reason);
513 if (success)
514 {
515 where = "safe";
516 destination = r;
517 break;
518 }
519 }
520 }
521 }
522 }
523
524 if (success)
525 return aCircuit;
526 else
527 return null;
528 }
529
530 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
531 AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position)
532 {
533 AgentCircuitData aCircuit = new AgentCircuitData();
534
535 aCircuit.AgentID = account.PrincipalID;
536 if (avatar != null)
537 aCircuit.Appearance = avatar.ToAvatarAppearance(account.PrincipalID);
538 else
539 aCircuit.Appearance = new AvatarAppearance(account.PrincipalID);
540
541 //aCircuit.BaseFolder = irrelevant
542 aCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
543 aCircuit.child = false; // the first login agent is root
544 aCircuit.ChildrenCapSeeds = new Dictionary<ulong, string>();
545 aCircuit.circuitcode = circuit;
546 aCircuit.firstname = account.FirstName;
547 //aCircuit.InventoryFolder = irrelevant
548 aCircuit.lastname = account.LastName;
549 aCircuit.SecureSessionID = secureSession;
550 aCircuit.SessionID = session;
551 aCircuit.startpos = position;
552 SetServiceURLs(aCircuit, account);
553
554 return aCircuit;
555
556 //m_UserAgentService.LoginAgentToGrid(aCircuit, GatekeeperServiceConnector, region, out reason);
557 //if (simConnector.CreateAgent(region, aCircuit, 0, out reason))
558 // return aCircuit;
559
560 //return null;
561
562 }
563
564 private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account)
565 {
566 aCircuit.ServiceURLs = new Dictionary<string, object>();
567 if (account.ServiceURLs == null)
568 return;
569
570 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
571 {
572 if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty))
573 {
574 aCircuit.ServiceURLs[kvp.Key] = m_LoginServerConfig.GetString(kvp.Key, string.Empty);
575 }
576 else
577 {
578 aCircuit.ServiceURLs[kvp.Key] = kvp.Value;
579 }
580 }
581 }
582
583 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason)
584 {
585 return simConnector.CreateAgent(region, aCircuit, (int)Constants.TeleportFlags.ViaLogin, out reason);
586 }
587
588 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, out string reason)
589 {
590 m_log.Debug("XXX Launching agent at {0}" + destination.RegionName);
591 return m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason);
592 }
593
594 #region Console Commands
595 private void RegisterCommands()
596 {
597 //MainConsole.Instance.Commands.AddCommand
598 MainConsole.Instance.Commands.AddCommand("loginservice", false, "login level",
599 "login level <level>",
600 "Set the minimum user level to log in", HandleLoginCommand);
601
602 MainConsole.Instance.Commands.AddCommand("loginservice", false, "login reset",
603 "login reset",
604 "Reset the login level to allow all users",
605 HandleLoginCommand);
606
607 MainConsole.Instance.Commands.AddCommand("loginservice", false, "login text",
608 "login text <text>",
609 "Set the text users will see on login", HandleLoginCommand);
610
611 }
612
613 private void HandleLoginCommand(string module, string[] cmd)
614 {
615 string subcommand = cmd[1];
616
617 switch (subcommand)
618 {
619 case "level":
620 // Set the minimum level to allow login
621 // Useful to allow grid update without worrying about users.
622 // or fixing critical issues
623 //
624 if (cmd.Length > 2)
625 Int32.TryParse(cmd[2], out m_MinLoginLevel);
626 break;
627 case "reset":
628 m_MinLoginLevel = 0;
629 break;
630 case "text":
631 if (cmd.Length > 2)
632 m_WelcomeMessage = cmd[2];
633 break;
634 }
635 }
636 }
637
638 #endregion
639}