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