diff options
Diffstat (limited to 'OpenSim/Services/LLLoginService')
-rw-r--r-- | OpenSim/Services/LLLoginService/LLLoginResponse.cs | 18 | ||||
-rw-r--r-- | OpenSim/Services/LLLoginService/LLLoginService.cs | 189 |
2 files changed, 121 insertions, 86 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 18a4f02..c80ab7f 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs | |||
@@ -51,6 +51,7 @@ namespace OpenSim.Services.LLLoginService | |||
51 | string m_login; | 51 | string m_login; |
52 | 52 | ||
53 | public static LLFailedLoginResponse UserProblem; | 53 | public static LLFailedLoginResponse UserProblem; |
54 | public static LLFailedLoginResponse AuthorizationProblem; | ||
54 | public static LLFailedLoginResponse GridProblem; | 55 | public static LLFailedLoginResponse GridProblem; |
55 | public static LLFailedLoginResponse InventoryProblem; | 56 | public static LLFailedLoginResponse InventoryProblem; |
56 | public static LLFailedLoginResponse DeadRegionProblem; | 57 | public static LLFailedLoginResponse DeadRegionProblem; |
@@ -63,8 +64,11 @@ namespace OpenSim.Services.LLLoginService | |||
63 | UserProblem = new LLFailedLoginResponse("key", | 64 | UserProblem = new LLFailedLoginResponse("key", |
64 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | 65 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", |
65 | "false"); | 66 | "false"); |
67 | AuthorizationProblem = new LLFailedLoginResponse("key", | ||
68 | "Error connecting to grid. Unable to authorize your session into the region.", | ||
69 | "false"); | ||
66 | GridProblem = new LLFailedLoginResponse("key", | 70 | GridProblem = new LLFailedLoginResponse("key", |
67 | "Error connecting to grid. Could not percieve credentials from login XML.", | 71 | "Error connecting to the desired location. Try connecting to another region.", |
68 | "false"); | 72 | "false"); |
69 | InventoryProblem = new LLFailedLoginResponse("key", | 73 | InventoryProblem = new LLFailedLoginResponse("key", |
70 | "The inventory service is not responding. Please notify your login region operator.", | 74 | "The inventory service is not responding. Please notify your login region operator.", |
@@ -288,8 +292,8 @@ namespace OpenSim.Services.LLLoginService | |||
288 | 292 | ||
289 | Home = string.Format( | 293 | Home = string.Format( |
290 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | 294 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", |
291 | home.RegionLocX, | 295 | x, |
292 | home.RegionLocY, | 296 | y, |
293 | pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z, | 297 | pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z, |
294 | pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z); | 298 | pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z); |
295 | 299 | ||
@@ -441,8 +445,8 @@ namespace OpenSim.Services.LLLoginService | |||
441 | responseData["home"] = home; | 445 | responseData["home"] = home; |
442 | responseData["look_at"] = lookAt; | 446 | responseData["look_at"] = lookAt; |
443 | responseData["message"] = welcomeMessage; | 447 | responseData["message"] = welcomeMessage; |
444 | responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); | 448 | responseData["region_x"] = (Int32)(RegionX); |
445 | responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); | 449 | responseData["region_y"] = (Int32)(RegionY); |
446 | 450 | ||
447 | if (m_buddyList != null) | 451 | if (m_buddyList != null) |
448 | { | 452 | { |
@@ -537,8 +541,8 @@ namespace OpenSim.Services.LLLoginService | |||
537 | map["home"] = OSD.FromString(home); | 541 | map["home"] = OSD.FromString(home); |
538 | map["look_at"] = OSD.FromString(lookAt); | 542 | map["look_at"] = OSD.FromString(lookAt); |
539 | map["message"] = OSD.FromString(welcomeMessage); | 543 | map["message"] = OSD.FromString(welcomeMessage); |
540 | map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); | 544 | map["region_x"] = OSD.FromInteger(RegionX); |
541 | map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); | 545 | map["region_y"] = OSD.FromInteger(RegionY); |
542 | 546 | ||
543 | if (m_buddyList != null) | 547 | if (m_buddyList != null) |
544 | { | 548 | { |
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 57b703c..ba3fd53 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -75,104 +75,120 @@ namespace OpenSim.Services.LLLoginService | |||
75 | public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP) | 75 | public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP) |
76 | { | 76 | { |
77 | bool success = false; | 77 | bool success = false; |
78 | UUID session = UUID.Random(); | ||
78 | 79 | ||
79 | // Get the account and check that it exists | 80 | try |
80 | UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); | ||
81 | if (account == null) | ||
82 | { | 81 | { |
83 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); | 82 | // Get the account and check that it exists |
84 | return LLFailedLoginResponse.UserProblem; | 83 | UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); |
85 | } | 84 | if (account == null) |
85 | { | ||
86 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); | ||
87 | return LLFailedLoginResponse.UserProblem; | ||
88 | } | ||
86 | 89 | ||
87 | // Authenticate this user | 90 | // Authenticate this user |
88 | string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); | 91 | if (!passwd.StartsWith("$1$")) |
89 | UUID secureSession = UUID.Zero; | 92 | passwd = "$1$" + Util.Md5Hash(passwd); |
90 | if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) | 93 | passwd = passwd.Remove(0, 3); //remove $1$ |
91 | { | 94 | string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); |
92 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed"); | 95 | UUID secureSession = UUID.Zero; |
93 | return LLFailedLoginResponse.UserProblem; | 96 | if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) |
94 | } | 97 | { |
98 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed"); | ||
99 | return LLFailedLoginResponse.UserProblem; | ||
100 | } | ||
95 | 101 | ||
96 | // Get the user's inventory | 102 | // Get the user's inventory |
97 | List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); | 103 | List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); |
98 | if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))) | 104 | if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))) |
99 | { | 105 | { |
100 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory"); | 106 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory"); |
101 | return LLFailedLoginResponse.InventoryProblem; | 107 | return LLFailedLoginResponse.InventoryProblem; |
102 | } | 108 | } |
103 | 109 | ||
104 | // Login the presence | 110 | // Login the presence |
105 | // We may want to check for user already logged in, to | 111 | // We may want to check for user already logged in, to |
106 | // stay compatible with what people expect... | 112 | // stay compatible with what people expect... |
107 | UUID session = UUID.Random(); | 113 | PresenceInfo presence = null; |
108 | PresenceInfo presence = null; | 114 | GridRegion home = null; |
109 | GridRegion home = null; | 115 | if (m_PresenceService != null) |
110 | if (m_PresenceService != null) | 116 | { |
111 | { | 117 | success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); |
112 | success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); | 118 | if (!success) |
113 | if (!success) | 119 | { |
120 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence"); | ||
121 | return LLFailedLoginResponse.GridProblem; | ||
122 | } | ||
123 | |||
124 | // Get the updated presence info | ||
125 | presence = m_PresenceService.GetAgent(session); | ||
126 | |||
127 | // Get the home region | ||
128 | if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null) | ||
129 | { | ||
130 | home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | // Find the destination region/grid | ||
135 | string where = string.Empty; | ||
136 | Vector3 position = Vector3.Zero; | ||
137 | Vector3 lookAt = Vector3.Zero; | ||
138 | GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt); | ||
139 | if (destination == null) | ||
114 | { | 140 | { |
115 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence"); | 141 | m_PresenceService.LogoutAgent(session); |
142 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found"); | ||
116 | return LLFailedLoginResponse.GridProblem; | 143 | return LLFailedLoginResponse.GridProblem; |
117 | } | 144 | } |
118 | // Get the updated presence info | ||
119 | presence = m_PresenceService.GetAgent(session); | ||
120 | 145 | ||
121 | // Get the home region | 146 | // Instantiate/get the simulation interface and launch an agent at the destination |
122 | if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null) | 147 | ISimulationService simConnector = null; |
148 | string reason = string.Empty; | ||
149 | uint circuitCode = 0; | ||
150 | AgentCircuitData aCircuit = null; | ||
151 | Object[] args = new Object[] { destination }; | ||
152 | // HG standalones have both a localSimulatonDll and a remoteSimulationDll | ||
153 | // non-HG standalones have just a localSimulationDll | ||
154 | // independent login servers have just a remoteSimulationDll | ||
155 | if (!startLocation.Contains("@") && (m_LocalSimulationService != null)) | ||
156 | simConnector = m_LocalSimulationService; | ||
157 | else if (m_RemoteSimulationDll != string.Empty) | ||
158 | simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args); | ||
159 | if (simConnector != null) | ||
123 | { | 160 | { |
124 | home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID); | 161 | circuitCode = (uint)Util.RandomClass.Next(); ; |
162 | aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason); | ||
163 | } | ||
164 | if (aCircuit == null) | ||
165 | { | ||
166 | m_PresenceService.LogoutAgent(session); | ||
167 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); | ||
168 | return LLFailedLoginResponse.AuthorizationProblem; | ||
125 | } | 169 | } |
126 | } | ||
127 | 170 | ||
128 | // Find the destination region/grid | 171 | // TODO: Get Friends list... |
129 | string where = string.Empty; | ||
130 | Vector3 position = Vector3.Zero; | ||
131 | Vector3 lookAt = Vector3.Zero; | ||
132 | GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt); | ||
133 | if (destination == null) | ||
134 | { | ||
135 | m_PresenceService.LogoutAgent(session); | ||
136 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found"); | ||
137 | return LLFailedLoginResponse.GridProblem; | ||
138 | } | ||
139 | 172 | ||
140 | // Instantiate/get the simulation interface and launch an agent at the destination | 173 | // Finally, fill out the response and return it |
141 | ISimulationService simConnector = null; | 174 | LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, |
142 | string reason = string.Empty; | 175 | where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); |
143 | uint circuitCode = 0; | 176 | |
144 | AgentCircuitData aCircuit = null; | 177 | return response; |
145 | Object[] args = new Object[] { destination }; | ||
146 | // HG standalones have both a localSimulatonDll and a remoteSimulationDll | ||
147 | // non-HG standalones have just a localSimulationDll | ||
148 | // independent login servers have just a remoteSimulationDll | ||
149 | if (!startLocation.Contains("@") && (m_LocalSimulationService != null)) | ||
150 | simConnector = m_LocalSimulationService; | ||
151 | else if (m_RemoteSimulationDll != string.Empty) | ||
152 | simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args); | ||
153 | if (simConnector != null) | ||
154 | { | ||
155 | circuitCode = (uint)Util.RandomClass.Next(); ; | ||
156 | aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason); | ||
157 | } | 178 | } |
158 | if (aCircuit == null) | 179 | catch (Exception e) |
159 | { | 180 | { |
160 | m_PresenceService.LogoutAgent(session); | 181 | m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2}", firstName, lastName, e.StackTrace); |
161 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); | 182 | if (m_PresenceService != null) |
162 | return LLFailedLoginResponse.GridProblem; | 183 | m_PresenceService.LogoutAgent(session); |
184 | return LLFailedLoginResponse.InternalError; | ||
163 | } | 185 | } |
164 | |||
165 | // TODO: Get Friends list... | ||
166 | |||
167 | // Finally, fill out the response and return it | ||
168 | LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, | ||
169 | where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); | ||
170 | |||
171 | return response; | ||
172 | } | 186 | } |
173 | 187 | ||
174 | private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) | 188 | private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) |
175 | { | 189 | { |
190 | m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); | ||
191 | |||
176 | where = "home"; | 192 | where = "home"; |
177 | position = new Vector3(128, 128, 0); | 193 | position = new Vector3(128, 128, 0); |
178 | lookAt = new Vector3(0, 1, 0); | 194 | lookAt = new Vector3(0, 1, 0); |
@@ -188,7 +204,16 @@ namespace OpenSim.Services.LLLoginService | |||
188 | GridRegion region = null; | 204 | GridRegion region = null; |
189 | 205 | ||
190 | if (pinfo.HomeRegionID.Equals(UUID.Zero)) | 206 | if (pinfo.HomeRegionID.Equals(UUID.Zero)) |
191 | region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | 207 | { |
208 | if (m_DefaultRegionName != string.Empty) | ||
209 | { | ||
210 | region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | ||
211 | where = "safe"; | ||
212 | } | ||
213 | else | ||
214 | m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a home set and this grid does not have a default location." + | ||
215 | "Please specify DefaultLocation in [LoginService]", account.FirstName, account.LastName); | ||
216 | } | ||
192 | else | 217 | else |
193 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID); | 218 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID); |
194 | 219 | ||
@@ -207,7 +232,10 @@ namespace OpenSim.Services.LLLoginService | |||
207 | GridRegion region = null; | 232 | GridRegion region = null; |
208 | 233 | ||
209 | if (pinfo.RegionID.Equals(UUID.Zero)) | 234 | if (pinfo.RegionID.Equals(UUID.Zero)) |
235 | { | ||
210 | region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | 236 | region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); |
237 | where = "safe"; | ||
238 | } | ||
211 | else | 239 | else |
212 | { | 240 | { |
213 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID); | 241 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID); |
@@ -240,6 +268,9 @@ namespace OpenSim.Services.LLLoginService | |||
240 | { | 268 | { |
241 | if (!regionName.Contains("@")) | 269 | if (!regionName.Contains("@")) |
242 | { | 270 | { |
271 | if (m_GridService == null) | ||
272 | return null; | ||
273 | |||
243 | List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1); | 274 | List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1); |
244 | if ((regions == null) || (regions != null && regions.Count == 0)) | 275 | if ((regions == null) || (regions != null && regions.Count == 0)) |
245 | { | 276 | { |