diff options
Diffstat (limited to 'OpenSim/Services/LLLoginService/LLLoginService.cs')
-rw-r--r-- | OpenSim/Services/LLLoginService/LLLoginService.cs | 189 |
1 files changed, 110 insertions, 79 deletions
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 | { |