aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/LLLoginService/LLLoginService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/LLLoginService/LLLoginService.cs')
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs84
1 files changed, 63 insertions, 21 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 25a65b5..7d24637 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -1,5 +1,6 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Net;
3using System.Reflection; 4using System.Reflection;
4using System.Text.RegularExpressions; 5using System.Text.RegularExpressions;
5 6
@@ -8,6 +9,7 @@ using Nini.Config;
8using OpenMetaverse; 9using OpenMetaverse;
9 10
10using OpenSim.Framework; 11using OpenSim.Framework;
12using OpenSim.Framework.Capabilities;
11using OpenSim.Server.Base; 13using OpenSim.Server.Base;
12using OpenSim.Services.Interfaces; 14using OpenSim.Services.Interfaces;
13using GridRegion = OpenSim.Services.Interfaces.GridRegion; 15using GridRegion = OpenSim.Services.Interfaces.GridRegion;
@@ -27,6 +29,8 @@ namespace OpenSim.Services.LLLoginService
27 29
28 private string m_DefaultRegionName; 30 private string m_DefaultRegionName;
29 private string m_RemoteSimulationDll; 31 private string m_RemoteSimulationDll;
32 private string m_WelcomeMessage;
33 private bool m_RequireInventory;
30 34
31 public LLLoginService(IConfigSource config, ISimulationService simService) 35 public LLLoginService(IConfigSource config, ISimulationService simService)
32 { 36 {
@@ -42,6 +46,8 @@ namespace OpenSim.Services.LLLoginService
42 46
43 m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty); 47 m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty);
44 m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty); 48 m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty);
49 m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
50 m_RequireInventory = serverConfig.GetBoolean("RequireInventory", true);
45 51
46 // These 3 are required; the other 2 aren't 52 // These 3 are required; the other 2 aren't
47 if (accountService == string.Empty || authService == string.Empty || 53 if (accountService == string.Empty || authService == string.Empty ||
@@ -64,50 +70,76 @@ namespace OpenSim.Services.LLLoginService
64 { 70 {
65 } 71 }
66 72
67 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation) 73 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP)
68 { 74 {
69 bool success = false; 75 bool success = false;
70 76
71 // Get the account and check that it exists 77 // Get the account and check that it exists
72 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); 78 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
73 if (account == null) 79 if (account == null)
80 {
81 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found");
74 return LLFailedLoginResponse.UserProblem; 82 return LLFailedLoginResponse.UserProblem;
83 }
75 84
76 // Authenticate this user 85 // Authenticate this user
77 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); 86 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30);
78 UUID secureSession = UUID.Zero; 87 UUID secureSession = UUID.Zero;
79 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) 88 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
89 {
90 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed");
80 return LLFailedLoginResponse.UserProblem; 91 return LLFailedLoginResponse.UserProblem;
92 }
81 93
82 // Get the user's inventory 94 // Get the user's inventory
83 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); 95 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
84 if ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)) 96 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
97 {
98 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory");
85 return LLFailedLoginResponse.InventoryProblem; 99 return LLFailedLoginResponse.InventoryProblem;
100 }
86 101
87 // Login the presence 102 // Login the presence
103 // We may want to check for user already logged in, to
104 // stay compatible with what people expect...
88 UUID session = UUID.Random(); 105 UUID session = UUID.Random();
106 PresenceInfo presence = null;
107 GridRegion home = null;
89 if (m_PresenceService != null) 108 if (m_PresenceService != null)
90 { 109 {
91 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); 110 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
92 if (!success) 111 if (!success)
112 {
113 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence");
93 return LLFailedLoginResponse.GridProblem; 114 return LLFailedLoginResponse.GridProblem;
115 }
116 // Get the updated presence info
117 presence = m_PresenceService.GetAgent(session);
118
119 // Get the home region
120 if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null)
121 {
122 home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID);
123 }
94 } 124 }
95 125
96 // Find the destination region/grid 126 // Find the destination region/grid
97 string where = string.Empty; 127 string where = string.Empty;
98 Vector3 position = Vector3.Zero; 128 Vector3 position = Vector3.Zero;
99 Vector3 lookAt = Vector3.Zero; 129 Vector3 lookAt = Vector3.Zero;
100 GridRegion destination = FindDestination(account, session, startLocation, out where, out position, out lookAt); 130 GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt);
101 if (destination == null) 131 if (destination == null)
102 { 132 {
103 m_PresenceService.LogoutAgent(session); 133 m_PresenceService.LogoutAgent(session);
134 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
104 return LLFailedLoginResponse.GridProblem; 135 return LLFailedLoginResponse.GridProblem;
105 } 136 }
106 137
107 // Instantiate/get the simulation interface and launch an agent at the destination 138 // Instantiate/get the simulation interface and launch an agent at the destination
108 ISimulationService simConnector = null; 139 ISimulationService simConnector = null;
109 success = false;
110 string reason = string.Empty; 140 string reason = string.Empty;
141 uint circuitCode = 0;
142 AgentCircuitData aCircuit = null;
111 Object[] args = new Object[] { destination }; 143 Object[] args = new Object[] { destination };
112 // HG standalones have both a localSimulatonDll and a remoteSimulationDll 144 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
113 // non-HG standalones have just a localSimulationDll 145 // non-HG standalones have just a localSimulationDll
@@ -117,20 +149,27 @@ namespace OpenSim.Services.LLLoginService
117 else if (m_RemoteSimulationDll != string.Empty) 149 else if (m_RemoteSimulationDll != string.Empty)
118 simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args); 150 simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
119 if (simConnector != null) 151 if (simConnector != null)
120 success = LaunchAgent(simConnector, destination, account, session, out reason); 152 {
121 if (!success) 153 circuitCode = (uint)Util.RandomClass.Next(); ;
154 aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason);
155 }
156 if (aCircuit == null)
122 { 157 {
123 m_PresenceService.LogoutAgent(session); 158 m_PresenceService.LogoutAgent(session);
159 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
124 return LLFailedLoginResponse.GridProblem; 160 return LLFailedLoginResponse.GridProblem;
125 } 161 }
126 162
163 // TODO: Get Friends list...
164
127 // Finally, fill out the response and return it 165 // Finally, fill out the response and return it
128 LLLoginResponse response = new LLLoginResponse(); 166 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel,
129 //.... 167 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
168
130 return response; 169 return response;
131 } 170 }
132 171
133 private GridRegion FindDestination(UserAccount account, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) 172 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt)
134 { 173 {
135 where = "home"; 174 where = "home";
136 position = new Vector3(128, 128, 0); 175 position = new Vector3(128, 128, 0);
@@ -141,12 +180,11 @@ namespace OpenSim.Services.LLLoginService
141 if (m_PresenceService == null || m_GridService == null) 180 if (m_PresenceService == null || m_GridService == null)
142 return null; 181 return null;
143 182
144 GridRegion region = null;
145 PresenceInfo pinfo = m_PresenceService.GetAgent(sessionID);
146 // this should succeed; if it doesn't there's something wrong with this grid
147 if (pinfo == null) 183 if (pinfo == null)
148 return null; 184 return null;
149 185
186 GridRegion region = null;
187
150 if (pinfo.HomeRegionID.Equals(UUID.Zero)) 188 if (pinfo.HomeRegionID.Equals(UUID.Zero))
151 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); 189 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
152 else 190 else
@@ -161,12 +199,11 @@ namespace OpenSim.Services.LLLoginService
161 if (m_PresenceService == null || m_GridService == null) 199 if (m_PresenceService == null || m_GridService == null)
162 return null; 200 return null;
163 201
164 GridRegion region = null;
165 PresenceInfo pinfo = m_PresenceService.GetAgent(sessionID);
166 // this should succeed; if it doesn't there's something wrong with this grid
167 if (pinfo == null) 202 if (pinfo == null)
168 return null; 203 return null;
169 204
205 GridRegion region = null;
206
170 if (pinfo.RegionID.Equals(UUID.Zero)) 207 if (pinfo.RegionID.Equals(UUID.Zero))
171 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); 208 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
172 else 209 else
@@ -250,24 +287,29 @@ namespace OpenSim.Services.LLLoginService
250 287
251 } 288 }
252 289
253 private bool LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account, UUID session, out string reason) 290 private AgentCircuitData LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account,
291 UUID session, UUID secureSession, uint circuit, Vector3 position, out string reason)
254 { 292 {
255 reason = string.Empty; 293 reason = string.Empty;
256 AgentCircuitData aCircuit = new AgentCircuitData(); 294 AgentCircuitData aCircuit = new AgentCircuitData();
295
257 aCircuit.AgentID = account.PrincipalID; 296 aCircuit.AgentID = account.PrincipalID;
258 //aCircuit.Appearance = optional 297 //aCircuit.Appearance = optional
259 //aCircuit.BaseFolder = irrelevant 298 //aCircuit.BaseFolder = irrelevant
260 //aCircuit.CapsPath = required 299 aCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
261 aCircuit.child = false; 300 aCircuit.child = false;
262 //aCircuit.circuitcode = required 301 aCircuit.circuitcode = circuit;
263 aCircuit.firstname = account.FirstName; 302 aCircuit.firstname = account.FirstName;
264 //aCircuit.InventoryFolder = irrelevant 303 //aCircuit.InventoryFolder = irrelevant
265 aCircuit.lastname = account.LastName; 304 aCircuit.lastname = account.LastName;
266 //aCircuit.SecureSessionID = required 305 aCircuit.SecureSessionID = secureSession;
267 aCircuit.SessionID = session; 306 aCircuit.SessionID = session;
268 //aCircuit.startpos = required 307 aCircuit.startpos = position;
308
309 if (simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason))
310 return aCircuit;
269 311
270 return simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason); 312 return null;
271 313
272 } 314 }
273 } 315 }