aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Local/LocalLoginService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Communications/Local/LocalLoginService.cs')
-rw-r--r--OpenSim/Region/Communications/Local/LocalLoginService.cs339
1 files changed, 173 insertions, 166 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs
index ed1858d..ab8e397 100644
--- a/OpenSim/Region/Communications/Local/LocalLoginService.cs
+++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs
@@ -1,166 +1,173 @@
1using System; 1using System;
2using System.Collections; 2using System.Collections;
3using System.Collections.Generic; 3using System.Collections.Generic;
4using libsecondlife; 4using libsecondlife;
5using OpenSim.Framework.Communications; 5using OpenSim.Framework.Communications;
6using OpenSim.Framework.Data; 6using OpenSim.Framework.Data;
7using OpenSim.Framework.Types; 7using OpenSim.Framework.Types;
8using OpenSim.Framework.UserManagement; 8using OpenSim.Framework.UserManagement;
9using OpenSim.Framework.Utilities; 9using OpenSim.Framework.Utilities;
10using OpenSim.Framework.Inventory; 10using OpenSim.Framework.Inventory;
11 11
12namespace OpenSim.Region.Communications.Local 12namespace OpenSim.Region.Communications.Local
13{ 13{
14 public class LocalLoginService : LoginService 14 public delegate void LoginToRegionEvent(ulong regionHandle, Login login);
15 { 15
16 private CommunicationsLocal m_Parent; 16 public class LocalLoginService : LoginService
17 17 {
18 private NetworkServersInfo serversInfo; 18 private CommunicationsLocal m_Parent;
19 private uint defaultHomeX; 19
20 private uint defaultHomeY; 20 private NetworkServersInfo serversInfo;
21 private bool authUsers = false; 21 private uint defaultHomeX;
22 22 private uint defaultHomeY;
23 public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) 23 private bool authUsers = false;
24 : base(userManager, welcomeMess) 24
25 { 25 public event LoginToRegionEvent OnLoginToRegion;
26 m_Parent = parent; 26
27 this.serversInfo = serversInfo; 27 public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate)
28 defaultHomeX = this.serversInfo.DefaultHomeLocX; 28 : base(userManager, welcomeMess)
29 defaultHomeY = this.serversInfo.DefaultHomeLocY; 29 {
30 this.authUsers = authenticate; 30 m_Parent = parent;
31 } 31 this.serversInfo = serversInfo;
32 32 defaultHomeX = this.serversInfo.DefaultHomeLocX;
33 33 defaultHomeY = this.serversInfo.DefaultHomeLocY;
34 public override UserProfileData GetTheUser(string firstname, string lastname) 34 this.authUsers = authenticate;
35 { 35 }
36 UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname); 36
37 if (profile != null) 37
38 { 38 public override UserProfileData GetTheUser(string firstname, string lastname)
39 39 {
40 return profile; 40 UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname);
41 } 41 if (profile != null)
42 42 {
43 if (!authUsers) 43
44 { 44 return profile;
45 //no current user account so make one 45 }
46 Console.WriteLine("No User account found so creating a new one "); 46
47 this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); 47 if (!authUsers)
48 48 {
49 profile = this.m_userManager.GetUserProfile(firstname, lastname); 49 //no current user account so make one
50 if (profile != null) 50 Console.WriteLine("No User account found so creating a new one ");
51 { 51 this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
52 m_Parent.InventoryService.CreateNewUserInventory(profile.UUID); 52
53 } 53 profile = this.m_userManager.GetUserProfile(firstname, lastname);
54 54 if (profile != null)
55 return profile; 55 {
56 } 56 m_Parent.InventoryService.CreateNewUserInventory(profile.UUID);
57 return null; 57 }
58 } 58
59 59 return profile;
60 public override bool AuthenticateUser(UserProfileData profile, string password) 60 }
61 { 61 return null;
62 if (!authUsers) 62 }
63 { 63
64 //for now we will accept any password in sandbox mode 64 public override bool AuthenticateUser(UserProfileData profile, string password)
65 Console.WriteLine("authorising user"); 65 {
66 return true; 66 if (!authUsers)
67 } 67 {
68 else 68 //for now we will accept any password in sandbox mode
69 { 69 Console.WriteLine("authorising user");
70 Console.WriteLine("Authenticating " + profile.username + " " + profile.surname); 70 return true;
71 71 }
72 password = password.Remove(0, 3); //remove $1$ 72 else
73 73 {
74 string s = Util.Md5Hash(password + ":" + profile.passwordSalt); 74 Console.WriteLine("Authenticating " + profile.username + " " + profile.surname);
75 75
76 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); 76 password = password.Remove(0, 3); //remove $1$
77 } 77
78 } 78 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
79 79
80 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) 80 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
81 { 81 }
82 ulong currentRegion = theUser.currentAgent.currentHandle; 82 }
83 RegionInfo reg = m_Parent.GridService.RequestNeighbourInfo(currentRegion); 83
84 84 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
85 if (reg != null) 85 {
86 { 86 ulong currentRegion = theUser.currentAgent.currentHandle;
87 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + 87 RegionInfo reg = m_Parent.GridService.RequestNeighbourInfo(currentRegion);
88 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + 88
89 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; 89 if (reg != null)
90 string capsPath = Util.GetRandomCapsPath(); 90 {
91 response.SimAddress = reg.ExternalEndPoint.Address.ToString(); 91 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
92 response.SimPort = (Int32)reg.ExternalEndPoint.Port; 92 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
93 response.RegionX = reg.RegionLocX; 93 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
94 response.RegionY = reg.RegionLocY; 94 string capsPath = Util.GetRandomCapsPath();
95 95 response.SimAddress = reg.ExternalEndPoint.Address.ToString();
96 response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; 96 response.SimPort = (Int32)reg.ExternalEndPoint.Port;
97 // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; 97 response.RegionX = reg.RegionLocX;
98 theUser.currentAgent.currentRegion = reg.SimUUID; 98 response.RegionY = reg.RegionLocY;
99 theUser.currentAgent.currentHandle = reg.RegionHandle; 99
100 100 response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
101 Login _login = new Login(); 101 // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/";
102 //copy data to login object 102 theUser.currentAgent.currentRegion = reg.SimUUID;
103 _login.First = response.Firstname; 103 theUser.currentAgent.currentHandle = reg.RegionHandle;
104 _login.Last = response.Lastname; 104
105 _login.Agent = response.AgentID; 105 Login _login = new Login();
106 _login.Session = response.SessionID; 106 //copy data to login object
107 _login.SecureSession = response.SecureSessionID; 107 _login.First = response.Firstname;
108 _login.CircuitCode = (uint)response.CircuitCode; 108 _login.Last = response.Lastname;
109 _login.CapsPath = capsPath; 109 _login.Agent = response.AgentID;
110 110 _login.Session = response.SessionID;
111 m_Parent.InformRegionOfLogin(currentRegion, _login); 111 _login.SecureSession = response.SecureSessionID;
112 } 112 _login.CircuitCode = (uint)response.CircuitCode;
113 else 113 _login.CapsPath = capsPath;
114 { 114
115 Console.WriteLine("not found region " + currentRegion); 115 if( OnLoginToRegion != null )
116 } 116 {
117 117 OnLoginToRegion(currentRegion, _login);
118 } 118 }
119 119 }
120 protected override InventoryData CreateInventoryData(LLUUID userID) 120 else
121 { 121 {
122 List<InventoryFolderBase> folders = m_Parent.InventoryService.RequestFirstLevelFolders(userID); 122 Console.WriteLine("not found region " + currentRegion);
123 if (folders.Count > 0) 123 }
124 { 124
125 LLUUID rootID = LLUUID.Zero; 125 }
126 ArrayList AgentInventoryArray = new ArrayList(); 126
127 Hashtable TempHash; 127 protected override InventoryData CreateInventoryData(LLUUID userID)
128 foreach (InventoryFolderBase InvFolder in folders) 128 {
129 { 129 List<InventoryFolderBase> folders = m_Parent.InventoryService.RequestFirstLevelFolders(userID);
130 if (InvFolder.parentID == LLUUID.Zero) 130 if (folders.Count > 0)
131 { 131 {
132 rootID = InvFolder.folderID; 132 LLUUID rootID = LLUUID.Zero;
133 } 133 ArrayList AgentInventoryArray = new ArrayList();
134 TempHash = new Hashtable(); 134 Hashtable TempHash;
135 TempHash["name"] = InvFolder.name; 135 foreach (InventoryFolderBase InvFolder in folders)
136 TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); 136 {
137 TempHash["version"] = (Int32)InvFolder.version; 137 if (InvFolder.parentID == LLUUID.Zero)
138 TempHash["type_default"] = (Int32)InvFolder.type; 138 {
139 TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated(); 139 rootID = InvFolder.folderID;
140 AgentInventoryArray.Add(TempHash); 140 }
141 } 141 TempHash = new Hashtable();
142 return new InventoryData(AgentInventoryArray, rootID); 142 TempHash["name"] = InvFolder.name;
143 } 143 TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated();
144 else 144 TempHash["version"] = (Int32)InvFolder.version;
145 { 145 TempHash["type_default"] = (Int32)InvFolder.type;
146 AgentInventory userInventory = new AgentInventory(); 146 TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated();
147 userInventory.CreateRootFolder(userID, false); 147 AgentInventoryArray.Add(TempHash);
148 148 }
149 ArrayList AgentInventoryArray = new ArrayList(); 149 return new InventoryData(AgentInventoryArray, rootID);
150 Hashtable TempHash; 150 }
151 foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values) 151 else
152 { 152 {
153 TempHash = new Hashtable(); 153 AgentInventory userInventory = new AgentInventory();
154 TempHash["name"] = InvFolder.FolderName; 154 userInventory.CreateRootFolder(userID, false);
155 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); 155
156 TempHash["version"] = (Int32)InvFolder.Version; 156 ArrayList AgentInventoryArray = new ArrayList();
157 TempHash["type_default"] = (Int32)InvFolder.DefaultType; 157 Hashtable TempHash;
158 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); 158 foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
159 AgentInventoryArray.Add(TempHash); 159 {
160 } 160 TempHash = new Hashtable();
161 161 TempHash["name"] = InvFolder.FolderName;
162 return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); 162 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
163 } 163 TempHash["version"] = (Int32)InvFolder.Version;
164 } 164 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
165 } 165 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
166} 166 AgentInventoryArray.Add(TempHash);
167 }
168
169 return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
170 }
171 }
172 }
173}