aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Local/LocalLoginService.cs
diff options
context:
space:
mode:
authorMW2007-08-13 16:24:12 +0000
committerMW2007-08-13 16:24:12 +0000
commit9cd64931d6067155c0214c62673f4196e251e7f7 (patch)
tree8f911ad80ffe2ad3aa356a5f8f285d99e899786d /OpenSim/Region/Communications/Local/LocalLoginService.cs
parentSeparated Login Service from usermanager, which helps to clean up the code a ... (diff)
downloadopensim-SC_OLD-9cd64931d6067155c0214c62673f4196e251e7f7.zip
opensim-SC_OLD-9cd64931d6067155c0214c62673f4196e251e7f7.tar.gz
opensim-SC_OLD-9cd64931d6067155c0214c62673f4196e251e7f7.tar.bz2
opensim-SC_OLD-9cd64931d6067155c0214c62673f4196e251e7f7.tar.xz
oops , guess I should include the new files next time
Diffstat (limited to 'OpenSim/Region/Communications/Local/LocalLoginService.cs')
-rw-r--r--OpenSim/Region/Communications/Local/LocalLoginService.cs113
1 files changed, 113 insertions, 0 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs
new file mode 100644
index 0000000..19a1e8c
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs
@@ -0,0 +1,113 @@
1using System;
2using libsecondlife;
3using OpenSim.Framework.Communications;
4using OpenSim.Framework.Data;
5using OpenSim.Framework.Types;
6using OpenSim.Framework.UserManagement;
7using OpenSim.Framework.Utilities;
8
9namespace OpenSim.Region.Communications.Local
10{
11 public class LocalLoginService : LoginService
12 {
13 private CommunicationsLocal m_Parent;
14
15 private NetworkServersInfo serversInfo;
16 private uint defaultHomeX;
17 private uint defaultHomeY;
18 private bool authUsers = false;
19
20 public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate)
21 : base(userManager, welcomeMess)
22 {
23 m_Parent = parent;
24 this.serversInfo = serversInfo;
25 defaultHomeX = this.serversInfo.DefaultHomeLocX;
26 defaultHomeY = this.serversInfo.DefaultHomeLocY;
27 this.authUsers = authenticate;
28 }
29
30
31 public override UserProfileData GetTheUser(string firstname, string lastname)
32 {
33 UserProfileData profile = this.m_userManager.getUserProfile(firstname, lastname);
34 if (profile != null)
35 {
36
37 return profile;
38 }
39
40 if (!authUsers)
41 {
42 //no current user account so make one
43 Console.WriteLine("No User account found so creating a new one ");
44 this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
45
46 profile = this.m_userManager.getUserProfile(firstname, lastname);
47
48 return profile;
49 }
50 return null;
51 }
52
53 public override bool AuthenticateUser(UserProfileData profile, string password)
54 {
55 if (!authUsers)
56 {
57 //for now we will accept any password in sandbox mode
58 Console.WriteLine("authorising user");
59 return true;
60 }
61 else
62 {
63 Console.WriteLine("Authenticating " + profile.username + " " + profile.surname);
64
65 password = password.Remove(0, 3); //remove $1$
66
67 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
68
69 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
70 }
71 }
72
73 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
74 {
75 ulong currentRegion = theUser.currentAgent.currentHandle;
76 RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion);
77
78 if (reg != null)
79 {
80 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
81 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
82 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
83 string capsPath = Util.GetRandomCapsPath();
84 response.SimAddress = reg.ExternalEndPoint.Address.ToString();
85 response.SimPort = (Int32)reg.ExternalEndPoint.Port;
86 response.RegionX = reg.RegionLocX;
87 response.RegionY = reg.RegionLocY;
88
89 //following port needs changing as we don't want a http listener for every region (or do we?)
90 response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
91 theUser.currentAgent.currentRegion = reg.SimUUID;
92 theUser.currentAgent.currentHandle = reg.RegionHandle;
93
94 Login _login = new Login();
95 //copy data to login object
96 _login.First = response.Firstname;
97 _login.Last = response.Lastname;
98 _login.Agent = response.AgentID;
99 _login.Session = response.SessionID;
100 _login.SecureSession = response.SecureSessionID;
101 _login.CircuitCode = (uint)response.CircuitCode;
102 _login.CapsPath = capsPath;
103
104 m_Parent.InformRegionOfLogin(currentRegion, _login);
105 }
106 else
107 {
108 Console.WriteLine("not found region " + currentRegion);
109 }
110
111 }
112 }
113}