diff options
author | MW | 2009-03-03 15:41:21 +0000 |
---|---|---|
committer | MW | 2009-03-03 15:41:21 +0000 |
commit | 171015f65fc2226b92b0f881a49e0110445e5045 (patch) | |
tree | e4d1dcbb4739cc61057dd3d89dc278ed67e56c29 /OpenSim | |
parent | Refactoring of CreateCommsManagerPlugin. (diff) | |
download | opensim-SC_OLD-171015f65fc2226b92b0f881a49e0110445e5045.zip opensim-SC_OLD-171015f65fc2226b92b0f881a49e0110445e5045.tar.gz opensim-SC_OLD-171015f65fc2226b92b0f881a49e0110445e5045.tar.bz2 opensim-SC_OLD-171015f65fc2226b92b0f881a49e0110445e5045.tar.xz |
Moved Linden protocol login handling to modules in OpenSim.Client.Linden. There are two region modules in there LLStandaloneLoginModule (for standalone mode) and LLProxyLoginModule (for grid mode which just handles incoming expect_user and logoff_user messages from the remote login server)
Changed OpenSim.Framework.Communications.Tests.LoginServiceTests to use the LLStandaloneLoginService (from the LLStandaloneLoginModule) rather than LocalLoginService. Really these login tests should most likely be somewhere else as they are testing specific implementations of login services.
Commented out the old LocalLoginService as its no longer used, but want to check there are no problems before it gets deleted.
Diffstat (limited to '')
9 files changed, 919 insertions, 42 deletions
diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs index 7323ad7..e6b4a89 100644 --- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs +++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs | |||
@@ -176,7 +176,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager | |||
176 | 176 | ||
177 | LocalBackEndServices backendService = new LocalBackEndServices(); | 177 | LocalBackEndServices backendService = new LocalBackEndServices(); |
178 | 178 | ||
179 | LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService); | 179 | //LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService); |
180 | 180 | ||
181 | m_commsManager | 181 | m_commsManager |
182 | = new CommunicationsLocal( | 182 | = new CommunicationsLocal( |
@@ -207,10 +207,9 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager | |||
207 | m_openSim.NetServersInfo.DefaultHomeLocX, m_openSim.NetServersInfo.DefaultHomeLocY, inventoryService); | 207 | m_openSim.NetServersInfo.DefaultHomeLocX, m_openSim.NetServersInfo.DefaultHomeLocY, inventoryService); |
208 | userService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneUserPlugin, m_openSim.ConfigurationSettings.StandaloneUserSource); | 208 | userService.AddPlugin(m_openSim.ConfigurationSettings.StandaloneUserPlugin, m_openSim.ConfigurationSettings.StandaloneUserSource); |
209 | 209 | ||
210 | //LocalBackEndServices backendService = new LocalBackEndServices(); | ||
211 | HGGridServicesStandalone gridService = new HGGridServicesStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager); | 210 | HGGridServicesStandalone gridService = new HGGridServicesStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager); |
212 | 211 | ||
213 | LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, gridService.LocalBackend); | 212 | // LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, gridService.LocalBackend); |
214 | 213 | ||
215 | m_commsManager = new HGCommunicationsStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, | 214 | m_commsManager = new HGCommunicationsStandalone(m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, |
216 | userService, userService, inventoryService, gridService, userService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); | 215 | userService, userService, inventoryService, gridService, userService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); |
@@ -231,24 +230,24 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager | |||
231 | m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler()); | 230 | m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler()); |
232 | } | 231 | } |
233 | 232 | ||
234 | private LocalLoginService CreateLoginService(LibraryRootFolder libraryRootFolder, IInterServiceInventoryServices inventoryService, LocalUserServices userService, LocalBackEndServices backendService) | 233 | //private LocalLoginService CreateLoginService(LibraryRootFolder libraryRootFolder, IInterServiceInventoryServices inventoryService, LocalUserServices userService, LocalBackEndServices backendService) |
235 | { | 234 | //{ |
236 | LocalLoginService loginService = | 235 | // LocalLoginService loginService = |
237 | new LocalLoginService( | 236 | // new LocalLoginService( |
238 | userService, m_openSim.ConfigurationSettings.StandaloneWelcomeMessage, inventoryService, backendService, m_openSim.NetServersInfo, | 237 | // userService, m_openSim.ConfigurationSettings.StandaloneWelcomeMessage, inventoryService, backendService, m_openSim.NetServersInfo, |
239 | m_openSim.ConfigurationSettings.StandaloneAuthenticate, libraryRootFolder); | 238 | // m_openSim.ConfigurationSettings.StandaloneAuthenticate, libraryRootFolder); |
240 | 239 | ||
241 | // set up XMLRPC handler for client's initial login request message | 240 | // // set up XMLRPC handler for client's initial login request message |
242 | m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod); | 241 | // m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod); |
243 | 242 | ||
244 | // provides the web form login | 243 | // // provides the web form login |
245 | m_httpServer.AddHTTPHandler("login", loginService.ProcessHTMLLogin); | 244 | // m_httpServer.AddHTTPHandler("login", loginService.ProcessHTMLLogin); |
246 | 245 | ||
247 | // Provides the LLSD login | 246 | // // Provides the LLSD login |
248 | m_httpServer.SetDefaultLLSDHandler(loginService.LLSDLoginMethod); | 247 | // m_httpServer.SetDefaultLLSDHandler(loginService.LLSDLoginMethod); |
249 | 248 | ||
250 | return loginService; | 249 | // return loginService; |
251 | } | 250 | //} |
252 | 251 | ||
253 | private void CreateGridInfoService() | 252 | private void CreateGridInfoService() |
254 | { | 253 | { |
diff --git a/OpenSim/Client/Linden/ILoginRegionsConnector.cs b/OpenSim/Client/Linden/ILoginRegionsConnector.cs new file mode 100644 index 0000000..3f3cee0 --- /dev/null +++ b/OpenSim/Client/Linden/ILoginRegionsConnector.cs | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | |||
32 | namespace OpenSim.Client.Linden | ||
33 | { | ||
34 | public interface ILoginRegionsConnector | ||
35 | { | ||
36 | bool RegionLoginsEnabled { get; } | ||
37 | void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message); | ||
38 | bool NewUserConnection(ulong regionHandle, AgentCircuitData agent); | ||
39 | RegionInfo RequestClosestRegion(string region); | ||
40 | RegionInfo RequestNeighbourInfo(UUID regionID); | ||
41 | RegionInfo RequestNeighbourInfo(ulong regionhandle); | ||
42 | } | ||
43 | } | ||
diff --git a/OpenSim/Client/Linden/LLClientStackModule.cs b/OpenSim/Client/Linden/LLClientStackModule.cs index 6b23224..4639db8 100644 --- a/OpenSim/Client/Linden/LLClientStackModule.cs +++ b/OpenSim/Client/Linden/LLClientStackModule.cs | |||
@@ -1,4 +1,31 @@ | |||
1 | using System; | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
2 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
3 | using System.Net; | 30 | using System.Net; |
4 | using System.Reflection; | 31 | using System.Reflection; |
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs new file mode 100644 index 0000000..c5db38b --- /dev/null +++ b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs | |||
@@ -0,0 +1,259 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Communications.Capabilities; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | |||
45 | namespace OpenSim.Client.Linden | ||
46 | { | ||
47 | public class LLStandaloneLoginModule : IRegionModule, ILoginRegionsConnector | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | protected List<Scene> m_scenes = new List<Scene>(); | ||
52 | protected Scene m_firstScene; | ||
53 | |||
54 | protected bool m_enabled = false; // Module is only enabled if running in standalone mode | ||
55 | |||
56 | |||
57 | public bool RegionLoginsEnabled | ||
58 | { | ||
59 | get | ||
60 | { | ||
61 | if (m_firstScene != null) | ||
62 | { | ||
63 | return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; | ||
64 | } | ||
65 | else | ||
66 | { | ||
67 | return false; | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | protected LLStandaloneLoginService m_loginService; | ||
73 | |||
74 | #region IRegionModule Members | ||
75 | |||
76 | public void Initialise(Scene scene, IConfigSource source) | ||
77 | { | ||
78 | if (m_firstScene == null) | ||
79 | { | ||
80 | m_firstScene = scene; | ||
81 | |||
82 | IConfig startupConfig = source.Configs["Startup"]; | ||
83 | if (startupConfig != null) | ||
84 | { | ||
85 | m_enabled = !startupConfig.GetBoolean("gridmode", false); | ||
86 | } | ||
87 | |||
88 | if (m_enabled) | ||
89 | { | ||
90 | bool authenticate = true; | ||
91 | string welcomeMessage = "Welcome to OpenSim"; | ||
92 | IConfig standaloneConfig = source.Configs["StandAlone"]; | ||
93 | if (standaloneConfig != null) | ||
94 | { | ||
95 | authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true); | ||
96 | welcomeMessage = standaloneConfig.GetString("welcome_message"); | ||
97 | } | ||
98 | |||
99 | //TODO: fix casting. | ||
100 | LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder; | ||
101 | |||
102 | BaseHttpServer httpServer = m_firstScene.CommsManager.HttpServer; | ||
103 | |||
104 | //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference | ||
105 | m_loginService = new LLStandaloneLoginService((UserManagerBase)m_firstScene.CommsManager.UserService, welcomeMessage, m_firstScene.CommsManager.InterServiceInventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate, rootFolder, this); | ||
106 | |||
107 | httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); | ||
108 | |||
109 | // provides the web form login | ||
110 | httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin); | ||
111 | |||
112 | // Provides the LLSD login | ||
113 | httpServer.SetDefaultLLSDHandler(m_loginService.LLSDLoginMethod); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | if (m_enabled) | ||
118 | { | ||
119 | AddScene(scene); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | public void PostInitialise() | ||
124 | { | ||
125 | |||
126 | } | ||
127 | |||
128 | public void Close() | ||
129 | { | ||
130 | |||
131 | } | ||
132 | |||
133 | public string Name | ||
134 | { | ||
135 | get { return "LLStandaloneLoginModule"; } | ||
136 | } | ||
137 | |||
138 | public bool IsSharedModule | ||
139 | { | ||
140 | get { return true; } | ||
141 | } | ||
142 | |||
143 | #endregion | ||
144 | |||
145 | protected void AddScene(Scene scene) | ||
146 | { | ||
147 | lock (m_scenes) | ||
148 | { | ||
149 | if (!m_scenes.Contains(scene)) | ||
150 | { | ||
151 | m_scenes.Add(scene); | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | |||
156 | public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) | ||
157 | { | ||
158 | Scene scene; | ||
159 | if (TryGetRegion(regionHandle, out scene)) | ||
160 | { | ||
161 | return scene.NewUserConnection(agent); | ||
162 | } | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message) | ||
167 | { | ||
168 | Scene scene; | ||
169 | if (TryGetRegion(regionHandle, out scene)) | ||
170 | { | ||
171 | scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | public RegionInfo RequestNeighbourInfo(ulong regionhandle) | ||
176 | { | ||
177 | Scene scene; | ||
178 | if (TryGetRegion(regionhandle, out scene)) | ||
179 | { | ||
180 | return scene.RegionInfo; | ||
181 | } | ||
182 | return null; | ||
183 | } | ||
184 | |||
185 | public RegionInfo RequestClosestRegion(string region) | ||
186 | { | ||
187 | Scene scene; | ||
188 | if (TryGetRegion(region, out scene)) | ||
189 | { | ||
190 | return scene.RegionInfo; | ||
191 | } | ||
192 | return null; | ||
193 | } | ||
194 | |||
195 | public RegionInfo RequestNeighbourInfo(UUID regionID) | ||
196 | { | ||
197 | Scene scene; | ||
198 | if (TryGetRegion(regionID, out scene)) | ||
199 | { | ||
200 | return scene.RegionInfo; | ||
201 | } | ||
202 | return null; | ||
203 | } | ||
204 | |||
205 | protected bool TryGetRegion(ulong regionHandle, out Scene scene) | ||
206 | { | ||
207 | lock (m_scenes) | ||
208 | { | ||
209 | foreach (Scene nextScene in m_scenes) | ||
210 | { | ||
211 | if (nextScene.RegionInfo.RegionHandle == regionHandle) | ||
212 | { | ||
213 | scene = nextScene; | ||
214 | return true; | ||
215 | } | ||
216 | } | ||
217 | } | ||
218 | |||
219 | scene = null; | ||
220 | return false; | ||
221 | } | ||
222 | |||
223 | protected bool TryGetRegion(UUID regionID, out Scene scene) | ||
224 | { | ||
225 | lock (m_scenes) | ||
226 | { | ||
227 | foreach (Scene nextScene in m_scenes) | ||
228 | { | ||
229 | if (nextScene.RegionInfo.RegionID == regionID) | ||
230 | { | ||
231 | scene = nextScene; | ||
232 | return true; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
237 | scene = null; | ||
238 | return false; | ||
239 | } | ||
240 | |||
241 | protected bool TryGetRegion(string regionName, out Scene scene) | ||
242 | { | ||
243 | lock (m_scenes) | ||
244 | { | ||
245 | foreach (Scene nextScene in m_scenes) | ||
246 | { | ||
247 | if (nextScene.RegionInfo.RegionName == regionName) | ||
248 | { | ||
249 | scene = nextScene; | ||
250 | return true; | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | |||
255 | scene = null; | ||
256 | return false; | ||
257 | } | ||
258 | } | ||
259 | } | ||
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginService.cs b/OpenSim/Client/Linden/LLStandaloneLoginService.cs new file mode 100644 index 0000000..f772185 --- /dev/null +++ b/OpenSim/Client/Linden/LLStandaloneLoginService.cs | |||
@@ -0,0 +1,433 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Communications.Capabilities; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | |||
45 | namespace OpenSim.Client.Linden | ||
46 | { | ||
47 | public class LLStandaloneLoginService : LoginService | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | protected NetworkServersInfo serversInfo; | ||
52 | protected uint defaultHomeX; | ||
53 | protected uint defaultHomeY; | ||
54 | protected bool authUsers = false; | ||
55 | |||
56 | /// <summary> | ||
57 | /// Used by the login service to make requests to the inventory service. | ||
58 | /// </summary> | ||
59 | protected IInterServiceInventoryServices m_interServiceInventoryService; | ||
60 | |||
61 | /// <summary> | ||
62 | /// Used to make requests to the local regions. | ||
63 | /// </summary> | ||
64 | protected ILoginRegionsConnector m_regionsConnector; | ||
65 | |||
66 | |||
67 | public LLStandaloneLoginService( | ||
68 | UserManagerBase userManager, string welcomeMess, | ||
69 | IInterServiceInventoryServices interServiceInventoryService, | ||
70 | NetworkServersInfo serversInfo, | ||
71 | bool authenticate, LibraryRootFolder libraryRootFolder, ILoginRegionsConnector regionsConnector) | ||
72 | : base(userManager, libraryRootFolder, welcomeMess) | ||
73 | { | ||
74 | this.serversInfo = serversInfo; | ||
75 | defaultHomeX = this.serversInfo.DefaultHomeLocX; | ||
76 | defaultHomeY = this.serversInfo.DefaultHomeLocY; | ||
77 | authUsers = authenticate; | ||
78 | |||
79 | m_interServiceInventoryService = interServiceInventoryService; | ||
80 | m_regionsConnector = regionsConnector; | ||
81 | } | ||
82 | |||
83 | public override UserProfileData GetTheUser(string firstname, string lastname) | ||
84 | { | ||
85 | UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); | ||
86 | if (profile != null) | ||
87 | { | ||
88 | return profile; | ||
89 | } | ||
90 | |||
91 | if (!authUsers) | ||
92 | { | ||
93 | //no current user account so make one | ||
94 | m_log.Info("[LOGIN]: No user account found so creating a new one."); | ||
95 | |||
96 | m_userManager.AddUser(firstname, lastname, "test", "", defaultHomeX, defaultHomeY); | ||
97 | |||
98 | return m_userManager.GetUserProfile(firstname, lastname); | ||
99 | } | ||
100 | |||
101 | return null; | ||
102 | } | ||
103 | |||
104 | public override bool AuthenticateUser(UserProfileData profile, string password) | ||
105 | { | ||
106 | if (!authUsers) | ||
107 | { | ||
108 | //for now we will accept any password in sandbox mode | ||
109 | m_log.Info("[LOGIN]: Authorising user (no actual password check)"); | ||
110 | |||
111 | return true; | ||
112 | } | ||
113 | else | ||
114 | { | ||
115 | m_log.Info( | ||
116 | "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); | ||
117 | |||
118 | if (!password.StartsWith("$1$")) | ||
119 | password = "$1$" + Util.Md5Hash(password); | ||
120 | |||
121 | password = password.Remove(0, 3); //remove $1$ | ||
122 | |||
123 | string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); | ||
124 | |||
125 | bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | ||
126 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); | ||
127 | return loginresult; | ||
128 | } | ||
129 | } | ||
130 | |||
131 | /// <summary> | ||
132 | /// Customises the login response and fills in missing values. | ||
133 | /// </summary> | ||
134 | /// <param name="response">The existing response</param> | ||
135 | /// <param name="theUser">The user profile</param> | ||
136 | /// <param name="startLocationRequest">The requested start location</param> | ||
137 | public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) | ||
138 | { | ||
139 | // add active gestures to login-response | ||
140 | AddActiveGestures(response, theUser); | ||
141 | |||
142 | // HomeLocation | ||
143 | RegionInfo homeInfo = null; | ||
144 | |||
145 | // use the homeRegionID if it is stored already. If not, use the regionHandle as before | ||
146 | UUID homeRegionId = theUser.HomeRegionID; | ||
147 | ulong homeRegionHandle = theUser.HomeRegion; | ||
148 | if (homeRegionId != UUID.Zero) | ||
149 | { | ||
150 | homeInfo = GetRegionInfo(homeRegionId); | ||
151 | } | ||
152 | else | ||
153 | { | ||
154 | homeInfo = GetRegionInfo(homeRegionHandle); | ||
155 | } | ||
156 | |||
157 | if (homeInfo != null) | ||
158 | { | ||
159 | response.Home = | ||
160 | string.Format( | ||
161 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
162 | (homeInfo.RegionLocX * Constants.RegionSize), | ||
163 | (homeInfo.RegionLocY * Constants.RegionSize), | ||
164 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
165 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); | ||
170 | // Emergency mode: Home-region isn't available, so we can't request the region info. | ||
171 | // Use the stored home regionHandle instead. | ||
172 | // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again | ||
173 | ulong regionX = homeRegionHandle >> 32; | ||
174 | ulong regionY = homeRegionHandle & 0xffffffff; | ||
175 | response.Home = | ||
176 | string.Format( | ||
177 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
178 | regionX, regionY, | ||
179 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
180 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
181 | |||
182 | m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", | ||
183 | theUser.FirstName, theUser.SurName, | ||
184 | regionX, regionY); | ||
185 | } | ||
186 | |||
187 | // StartLocation | ||
188 | RegionInfo regionInfo = null; | ||
189 | if (startLocationRequest == "home") | ||
190 | { | ||
191 | regionInfo = homeInfo; | ||
192 | theUser.CurrentAgent.Position = theUser.HomeLocation; | ||
193 | response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; | ||
194 | } | ||
195 | else if (startLocationRequest == "last") | ||
196 | { | ||
197 | UUID lastRegion = theUser.CurrentAgent.Region; | ||
198 | regionInfo = GetRegionInfo(lastRegion); | ||
199 | response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
204 | Match uriMatch = reURI.Match(startLocationRequest); | ||
205 | if (uriMatch == null) | ||
206 | { | ||
207 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); | ||
208 | } | ||
209 | else | ||
210 | { | ||
211 | string region = uriMatch.Groups["region"].ToString(); | ||
212 | regionInfo = RequestClosestRegion(region); | ||
213 | if (regionInfo == null) | ||
214 | { | ||
215 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), | ||
220 | float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); | ||
221 | } | ||
222 | } | ||
223 | response.LookAt = "[r0,r1,r0]"; | ||
224 | // can be: last, home, safe, url | ||
225 | response.StartLocation = "url"; | ||
226 | } | ||
227 | |||
228 | if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) | ||
229 | { | ||
230 | return true; | ||
231 | } | ||
232 | |||
233 | // StartLocation not available, send him to a nearby region instead | ||
234 | // regionInfo = m_gridService.RequestClosestRegion(""); | ||
235 | //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); | ||
236 | |||
237 | // Send him to default region instead | ||
238 | ulong defaultHandle = (((ulong)defaultHomeX * Constants.RegionSize) << 32) | | ||
239 | ((ulong)defaultHomeY * Constants.RegionSize); | ||
240 | |||
241 | if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) | ||
242 | { | ||
243 | m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); | ||
244 | return false; | ||
245 | } | ||
246 | |||
247 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); | ||
248 | regionInfo = GetRegionInfo(defaultHandle); | ||
249 | |||
250 | // Customise the response | ||
251 | //response.Home = | ||
252 | // string.Format( | ||
253 | // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
254 | // (SimInfo.regionLocX * Constants.RegionSize), | ||
255 | // (SimInfo.regionLocY*Constants.RegionSize), | ||
256 | // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
257 | // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
258 | theUser.CurrentAgent.Position = new Vector3(128, 128, 0); | ||
259 | response.StartLocation = "safe"; | ||
260 | |||
261 | return PrepareLoginToRegion(regionInfo, theUser, response); | ||
262 | } | ||
263 | |||
264 | protected RegionInfo RequestClosestRegion(string region) | ||
265 | { | ||
266 | return m_regionsConnector.RequestClosestRegion(region); | ||
267 | } | ||
268 | |||
269 | protected RegionInfo GetRegionInfo(ulong homeRegionHandle) | ||
270 | { | ||
271 | return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); | ||
272 | } | ||
273 | |||
274 | protected RegionInfo GetRegionInfo(UUID homeRegionId) | ||
275 | { | ||
276 | return m_regionsConnector.RequestNeighbourInfo(homeRegionId); | ||
277 | } | ||
278 | |||
279 | /// <summary> | ||
280 | /// Add active gestures of the user to the login response. | ||
281 | /// </summary> | ||
282 | /// <param name="response"> | ||
283 | /// A <see cref="LoginResponse"/> | ||
284 | /// </param> | ||
285 | /// <param name="theUser"> | ||
286 | /// A <see cref="UserProfileData"/> | ||
287 | /// </param> | ||
288 | private void AddActiveGestures(LoginResponse response, UserProfileData theUser) | ||
289 | { | ||
290 | List<InventoryItemBase> gestures = m_interServiceInventoryService.GetActiveGestures(theUser.ID); | ||
291 | //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); | ||
292 | ArrayList list = new ArrayList(); | ||
293 | if (gestures != null) | ||
294 | { | ||
295 | foreach (InventoryItemBase gesture in gestures) | ||
296 | { | ||
297 | Hashtable item = new Hashtable(); | ||
298 | item["item_id"] = gesture.ID.ToString(); | ||
299 | item["asset_id"] = gesture.AssetID.ToString(); | ||
300 | list.Add(item); | ||
301 | } | ||
302 | } | ||
303 | response.ActiveGestures = list; | ||
304 | } | ||
305 | |||
306 | /// <summary> | ||
307 | /// Prepare a login to the given region. This involves both telling the region to expect a connection | ||
308 | /// and appropriately customising the response to the user. | ||
309 | /// </summary> | ||
310 | /// <param name="sim"></param> | ||
311 | /// <param name="user"></param> | ||
312 | /// <param name="response"></param> | ||
313 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | ||
314 | protected bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) | ||
315 | { | ||
316 | IPEndPoint endPoint = regionInfo.ExternalEndPoint; | ||
317 | response.SimAddress = endPoint.Address.ToString(); | ||
318 | response.SimPort = (uint)endPoint.Port; | ||
319 | response.RegionX = regionInfo.RegionLocX; | ||
320 | response.RegionY = regionInfo.RegionLocY; | ||
321 | |||
322 | string capsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
323 | string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); | ||
324 | |||
325 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! | ||
326 | // Kept here so it doesn't happen again! | ||
327 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; | ||
328 | |||
329 | string seedcap = "http://"; | ||
330 | |||
331 | if (serversInfo.HttpUsesSSL) | ||
332 | { | ||
333 | seedcap = "https://" + serversInfo.HttpSSLCN + ":" + serversInfo.httpSSLPort + capsSeedPath; | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | seedcap = "http://" + regionInfo.ExternalHostName + ":" + serversInfo.HttpListenerPort + capsSeedPath; | ||
338 | } | ||
339 | |||
340 | response.SeedCapability = seedcap; | ||
341 | |||
342 | // Notify the target of an incoming user | ||
343 | m_log.InfoFormat( | ||
344 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", | ||
345 | regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); | ||
346 | |||
347 | // Update agent with target sim | ||
348 | user.CurrentAgent.Region = regionInfo.RegionID; | ||
349 | user.CurrentAgent.Handle = regionInfo.RegionHandle; | ||
350 | |||
351 | AgentCircuitData agent = new AgentCircuitData(); | ||
352 | agent.AgentID = user.ID; | ||
353 | agent.firstname = user.FirstName; | ||
354 | agent.lastname = user.SurName; | ||
355 | agent.SessionID = user.CurrentAgent.SessionID; | ||
356 | agent.SecureSessionID = user.CurrentAgent.SecureSessionID; | ||
357 | agent.circuitcode = Convert.ToUInt32(response.CircuitCode); | ||
358 | agent.BaseFolder = UUID.Zero; | ||
359 | agent.InventoryFolder = UUID.Zero; | ||
360 | agent.startpos = user.CurrentAgent.Position; | ||
361 | agent.CapsPath = capsPath; | ||
362 | agent.Appearance = m_userManager.GetUserAppearance(user.ID); | ||
363 | if (agent.Appearance == null) | ||
364 | { | ||
365 | m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname); | ||
366 | agent.Appearance = new AvatarAppearance(); | ||
367 | } | ||
368 | |||
369 | if (m_regionsConnector.RegionLoginsEnabled) | ||
370 | { | ||
371 | // m_log.Info("[LLStandaloneLoginModule] Informing region about user"); | ||
372 | return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent); | ||
373 | } | ||
374 | |||
375 | return false; | ||
376 | } | ||
377 | |||
378 | // See LoginService | ||
379 | protected override InventoryData GetInventorySkeleton(UUID userID) | ||
380 | { | ||
381 | List<InventoryFolderBase> folders = m_interServiceInventoryService.GetInventorySkeleton(userID); | ||
382 | |||
383 | // If we have user auth but no inventory folders for some reason, create a new set of folders. | ||
384 | if (null == folders || 0 == folders.Count) | ||
385 | { | ||
386 | m_interServiceInventoryService.CreateNewUserInventory(userID); | ||
387 | folders = m_interServiceInventoryService.GetInventorySkeleton(userID); | ||
388 | } | ||
389 | |||
390 | UUID rootID = UUID.Zero; | ||
391 | ArrayList AgentInventoryArray = new ArrayList(); | ||
392 | Hashtable TempHash; | ||
393 | foreach (InventoryFolderBase InvFolder in folders) | ||
394 | { | ||
395 | if (InvFolder.ParentID == UUID.Zero) | ||
396 | { | ||
397 | rootID = InvFolder.ID; | ||
398 | } | ||
399 | TempHash = new Hashtable(); | ||
400 | TempHash["name"] = InvFolder.Name; | ||
401 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); | ||
402 | TempHash["version"] = (Int32)InvFolder.Version; | ||
403 | TempHash["type_default"] = (Int32)InvFolder.Type; | ||
404 | TempHash["folder_id"] = InvFolder.ID.ToString(); | ||
405 | AgentInventoryArray.Add(TempHash); | ||
406 | } | ||
407 | |||
408 | return new InventoryData(AgentInventoryArray, rootID); | ||
409 | } | ||
410 | |||
411 | public override void LogOffUser(UserProfileData theUser, string message) | ||
412 | { | ||
413 | RegionInfo SimInfo; | ||
414 | try | ||
415 | { | ||
416 | SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); | ||
417 | |||
418 | if (SimInfo == null) | ||
419 | { | ||
420 | m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); | ||
421 | return; | ||
422 | } | ||
423 | } | ||
424 | catch (Exception) | ||
425 | { | ||
426 | m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); | ||
427 | return; | ||
428 | } | ||
429 | |||
430 | m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); | ||
431 | } | ||
432 | } | ||
433 | } | ||
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index bb8e452..3363c24 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenSim.Framework.Communications.Cache; | 31 | using OpenSim.Framework.Communications.Cache; |
@@ -111,6 +112,7 @@ namespace OpenSim.Framework.Communications | |||
111 | } | 112 | } |
112 | protected BaseHttpServer m_httpServer; | 113 | protected BaseHttpServer m_httpServer; |
113 | 114 | ||
115 | |||
114 | /// <summary> | 116 | /// <summary> |
115 | /// Constructor | 117 | /// Constructor |
116 | /// </summary> | 118 | /// </summary> |
@@ -125,7 +127,6 @@ namespace OpenSim.Framework.Communications | |||
125 | m_assetCache = assetCache; | 127 | m_assetCache = assetCache; |
126 | m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); | 128 | m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); |
127 | m_httpServer = httpServer; | 129 | m_httpServer = httpServer; |
128 | // m_transactionsManager = new AgentAssetTransactionsManager(this, dumpAssetsToFile); | ||
129 | } | 130 | } |
130 | 131 | ||
131 | #region Inventory | 132 | #region Inventory |
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 57ed0f5..854d68d 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Net; | 31 | using System.Net; |
31 | using System.Text.RegularExpressions; | 32 | using System.Text.RegularExpressions; |
32 | using NUnit.Framework; | 33 | using NUnit.Framework; |
@@ -35,6 +36,7 @@ using Nwc.XmlRpc; | |||
35 | using OpenSim.Framework.Communications.Cache; | 36 | using OpenSim.Framework.Communications.Cache; |
36 | using OpenSim.Region.Communications.Local; | 37 | using OpenSim.Region.Communications.Local; |
37 | using OpenSim.Tests.Common.Mock; | 38 | using OpenSim.Tests.Common.Mock; |
39 | using OpenSim.Client.Linden; | ||
38 | 40 | ||
39 | namespace OpenSim.Framework.Communications.Tests | 41 | namespace OpenSim.Framework.Communications.Tests |
40 | { | 42 | { |
@@ -60,16 +62,22 @@ namespace OpenSim.Framework.Communications.Tests | |||
60 | 62 | ||
61 | CommunicationsManager commsManager | 63 | CommunicationsManager commsManager |
62 | = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); | 64 | = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); |
65 | |||
66 | //commsManager.GridService.RegisterRegion( | ||
67 | // new RegionInfo(42, 43, capsEndPoint, regionExternalName)); | ||
68 | //commsManager.GridService.RegionLoginsEnabled = true; | ||
63 | 69 | ||
64 | commsManager.GridService.RegisterRegion( | 70 | //LoginService loginService |
65 | new RegionInfo(42, 43, capsEndPoint, regionExternalName)); | 71 | // = new LocalLoginService( |
66 | commsManager.GridService.RegionLoginsEnabled = true; | 72 | // (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, |
73 | // (LocalBackEndServices)commsManager.GridService, | ||
74 | // commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty)); | ||
67 | 75 | ||
68 | LoginService loginService | 76 | TestLoginToRegionConnector regionConnector = new TestLoginToRegionConnector(); |
69 | = new LocalLoginService( | 77 | regionConnector.AddRegion(new RegionInfo(42, 43, capsEndPoint, regionExternalName)); |
70 | (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, | 78 | |
71 | (LocalBackEndServices)commsManager.GridService, | 79 | LoginService loginService = new LLStandaloneLoginService((UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, |
72 | commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty)); | 80 | commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), regionConnector); |
73 | 81 | ||
74 | Hashtable loginParams = new Hashtable(); | 82 | Hashtable loginParams = new Hashtable(); |
75 | loginParams["first"] = firstName; | 83 | loginParams["first"] = firstName; |
@@ -108,21 +116,25 @@ namespace OpenSim.Framework.Communications.Tests | |||
108 | CommunicationsManager commsManager | 116 | CommunicationsManager commsManager |
109 | = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); | 117 | = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); |
110 | 118 | ||
111 | commsManager.GridService.RegisterRegion( | ||
112 | new RegionInfo(42, 43, capsEndPoint, regionExternalName)); | ||
113 | commsManager.GridService.RegionLoginsEnabled = true; | ||
114 | |||
115 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; | 119 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; |
116 | 120 | ||
117 | lus.AddUser(firstName,lastName,"boingboing","abc@ftw.com",42,43); | 121 | lus.AddUser(firstName,lastName,"boingboing","abc@ftw.com",42,43); |
118 | 122 | ||
123 | //commsManager.GridService.RegisterRegion( | ||
124 | // new RegionInfo(42, 43, capsEndPoint, regionExternalName)); | ||
125 | //commsManager.GridService.RegionLoginsEnabled = true; | ||
119 | 126 | ||
120 | LoginService loginService | 127 | //LoginService loginService |
121 | = new LocalLoginService( | 128 | // = new LocalLoginService( |
122 | (UserManagerBase)lus, "Hello folks", commsManager.InterServiceInventoryService, | 129 | // (UserManagerBase)lus, "Hello folks", commsManager.InterServiceInventoryService, |
123 | (LocalBackEndServices)commsManager.GridService, | 130 | // (LocalBackEndServices)commsManager.GridService, |
124 | commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty)); | 131 | // commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty)); |
125 | 132 | ||
133 | TestLoginToRegionConnector regionConnector = new TestLoginToRegionConnector(); | ||
134 | regionConnector.AddRegion(new RegionInfo(42, 43, capsEndPoint, regionExternalName)); | ||
135 | |||
136 | LoginService loginService = new LLStandaloneLoginService((UserManagerBase) lus, "Hello folks", commsManager.InterServiceInventoryService, | ||
137 | commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), regionConnector); | ||
126 | 138 | ||
127 | // TODO: Not check inventory part of response yet. | 139 | // TODO: Not check inventory part of response yet. |
128 | // TODO: Not checking all of login response thoroughly yet. | 140 | // TODO: Not checking all of login response thoroughly yet. |
@@ -277,5 +289,89 @@ namespace OpenSim.Framework.Communications.Tests | |||
277 | responseData = (Hashtable)response.Value; | 289 | responseData = (Hashtable)response.Value; |
278 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); | 290 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); |
279 | } | 291 | } |
292 | |||
293 | public class TestLoginToRegionConnector : ILoginRegionsConnector | ||
294 | { | ||
295 | |||
296 | private List<RegionInfo> m_regionsList = new List<RegionInfo>(); | ||
297 | |||
298 | public void AddRegion(RegionInfo regionInfo) | ||
299 | { | ||
300 | lock (m_regionsList) | ||
301 | { | ||
302 | if (!m_regionsList.Contains(regionInfo)) | ||
303 | { | ||
304 | m_regionsList.Add(regionInfo); | ||
305 | } | ||
306 | } | ||
307 | } | ||
308 | |||
309 | #region ILoginRegionsConnector Members | ||
310 | public bool RegionLoginsEnabled | ||
311 | { | ||
312 | get { return true; } | ||
313 | } | ||
314 | |||
315 | public void LogOffUserFromGrid(ulong regionHandle, OpenMetaverse.UUID AvatarID, OpenMetaverse.UUID RegionSecret, string message) | ||
316 | { | ||
317 | } | ||
318 | |||
319 | public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) | ||
320 | { | ||
321 | lock (m_regionsList) | ||
322 | { | ||
323 | foreach (RegionInfo regInfo in m_regionsList) | ||
324 | { | ||
325 | if (regInfo.RegionHandle == regionHandle) | ||
326 | return true; | ||
327 | } | ||
328 | } | ||
329 | return false; | ||
330 | } | ||
331 | |||
332 | public RegionInfo RequestClosestRegion(string region) | ||
333 | { | ||
334 | lock (m_regionsList) | ||
335 | { | ||
336 | foreach (RegionInfo regInfo in m_regionsList) | ||
337 | { | ||
338 | if (regInfo.RegionName == region) | ||
339 | return regInfo; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | return null; | ||
344 | } | ||
345 | |||
346 | public RegionInfo RequestNeighbourInfo(OpenMetaverse.UUID regionID) | ||
347 | { | ||
348 | lock (m_regionsList) | ||
349 | { | ||
350 | foreach (RegionInfo regInfo in m_regionsList) | ||
351 | { | ||
352 | if (regInfo.RegionID == regionID) | ||
353 | return regInfo; | ||
354 | } | ||
355 | } | ||
356 | |||
357 | return null; | ||
358 | } | ||
359 | |||
360 | public RegionInfo RequestNeighbourInfo(ulong regionHandle) | ||
361 | { | ||
362 | lock (m_regionsList) | ||
363 | { | ||
364 | foreach (RegionInfo regInfo in m_regionsList) | ||
365 | { | ||
366 | if (regInfo.RegionHandle == regionHandle) | ||
367 | return regInfo; | ||
368 | } | ||
369 | } | ||
370 | |||
371 | return null; | ||
372 | } | ||
373 | |||
374 | #endregion | ||
375 | } | ||
280 | } | 376 | } |
281 | } | 377 | } |
diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 4e0ed13..bd2910f 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Framework.Communications.Capabilities; | |||
39 | 39 | ||
40 | namespace OpenSim.Region.Communications.Local | 40 | namespace OpenSim.Region.Communications.Local |
41 | { | 41 | { |
42 | /* | ||
42 | public delegate void LoginToRegionEvent(ulong regionHandle, Login login); | 43 | public delegate void LoginToRegionEvent(ulong regionHandle, Login login); |
43 | 44 | ||
44 | public class LocalLoginService : LoginService | 45 | public class LocalLoginService : LoginService |
@@ -168,6 +169,7 @@ namespace OpenSim.Region.Communications.Local | |||
168 | } | 169 | } |
169 | else | 170 | else |
170 | { | 171 | { |
172 | m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); | ||
171 | // Emergency mode: Home-region isn't available, so we can't request the region info. | 173 | // Emergency mode: Home-region isn't available, so we can't request the region info. |
172 | // Use the stored home regionHandle instead. | 174 | // Use the stored home regionHandle instead. |
173 | // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again | 175 | // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again |
@@ -427,5 +429,5 @@ namespace OpenSim.Region.Communications.Local | |||
427 | m_gridService.TriggerLogOffUser(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); | 429 | m_gridService.TriggerLogOffUser(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); |
428 | } | 430 | } |
429 | 431 | ||
430 | } | 432 | }*/ |
431 | } | 433 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2006c2b..b1a79c2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2296,7 +2296,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2296 | /// </summary> | 2296 | /// </summary> |
2297 | public void RegisterCommsEvents() | 2297 | public void RegisterCommsEvents() |
2298 | { | 2298 | { |
2299 | m_sceneGridService.OnExpectUser += NewUserConnection; | 2299 | m_sceneGridService.OnExpectUser += HandleNewUserConnection; |
2300 | m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; | 2300 | m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; |
2301 | m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; | 2301 | m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; |
2302 | m_sceneGridService.OnRegionUp += OtherRegionUp; | 2302 | m_sceneGridService.OnRegionUp += OtherRegionUp; |
@@ -2328,7 +2328,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2328 | m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; | 2328 | m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; |
2329 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 2329 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
2330 | m_sceneGridService.OnRegionUp -= OtherRegionUp; | 2330 | m_sceneGridService.OnRegionUp -= OtherRegionUp; |
2331 | m_sceneGridService.OnExpectUser -= NewUserConnection; | 2331 | m_sceneGridService.OnExpectUser -= HandleNewUserConnection; |
2332 | m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; | 2332 | m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; |
2333 | m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; | 2333 | m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; |
2334 | m_sceneGridService.OnGetLandData -= GetLandData; | 2334 | m_sceneGridService.OnGetLandData -= GetLandData; |
@@ -2340,12 +2340,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
2340 | } | 2340 | } |
2341 | 2341 | ||
2342 | /// <summary> | 2342 | /// <summary> |
2343 | /// A handler for the SceneCommunicationService event, to match that events return type of void. | ||
2344 | /// Use NewUserConnection() directly if possible so the return type can refuse connections. | ||
2345 | /// At the moment nothing actually seems to use this event, | ||
2346 | /// as everything is switching to calling the NewUserConnection method directly. | ||
2347 | /// </summary> | ||
2348 | /// <param name="agent"></param> | ||
2349 | public void HandleNewUserConnection(AgentCircuitData agent) | ||
2350 | { | ||
2351 | NewUserConnection(agent); | ||
2352 | } | ||
2353 | |||
2354 | /// <summary> | ||
2343 | /// Do the work necessary to initiate a new user connection for a particular scene. | 2355 | /// Do the work necessary to initiate a new user connection for a particular scene. |
2344 | /// At the moment, this consists of setting up the caps infrastructure | 2356 | /// At the moment, this consists of setting up the caps infrastructure |
2357 | /// The return bool should allow for connections to be refused, but as not all calling paths | ||
2358 | /// take proper notice of it let, we allowed banned users in still. | ||
2345 | /// </summary> | 2359 | /// </summary> |
2346 | /// <param name="regionHandle"></param> | 2360 | /// <param name="regionHandle"></param> |
2347 | /// <param name="agent"></param> | 2361 | /// <param name="agent"></param> |
2348 | public void NewUserConnection(AgentCircuitData agent) | 2362 | public bool NewUserConnection(AgentCircuitData agent) |
2349 | { | 2363 | { |
2350 | CapsModule.NewUserConnection(agent); | 2364 | CapsModule.NewUserConnection(agent); |
2351 | 2365 | ||
@@ -2358,7 +2372,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2358 | 2372 | ||
2359 | sp.AdjustKnownSeeds(); | 2373 | sp.AdjustKnownSeeds(); |
2360 | 2374 | ||
2361 | return; | 2375 | return true; |
2362 | } | 2376 | } |
2363 | 2377 | ||
2364 | // Don't disable this log message - it's too helpful | 2378 | // Don't disable this log message - it's too helpful |
@@ -2371,6 +2385,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2371 | m_log.WarnFormat( | 2385 | m_log.WarnFormat( |
2372 | "[CONNECTION BEGIN]: Incoming user {0} at {1} is on the region banlist", | 2386 | "[CONNECTION BEGIN]: Incoming user {0} at {1} is on the region banlist", |
2373 | agent.AgentID, RegionInfo.RegionName); | 2387 | agent.AgentID, RegionInfo.RegionName); |
2388 | //return false; | ||
2374 | } | 2389 | } |
2375 | 2390 | ||
2376 | CapsModule.AddCapsHandler(agent.AgentID); | 2391 | CapsModule.AddCapsHandler(agent.AgentID); |
@@ -2402,6 +2417,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2402 | m_log.WarnFormat( | 2417 | m_log.WarnFormat( |
2403 | "[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID); | 2418 | "[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID); |
2404 | } | 2419 | } |
2420 | |||
2421 | return true; | ||
2405 | } | 2422 | } |
2406 | 2423 | ||
2407 | public void UpdateCircuitData(AgentCircuitData data) | 2424 | public void UpdateCircuitData(AgentCircuitData data) |
@@ -2414,7 +2431,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2414 | return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); | 2431 | return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); |
2415 | } | 2432 | } |
2416 | 2433 | ||
2417 | protected void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) | 2434 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) |
2418 | { | 2435 | { |
2419 | ScenePresence loggingOffUser = null; | 2436 | ScenePresence loggingOffUser = null; |
2420 | loggingOffUser = GetScenePresence(AvatarID); | 2437 | loggingOffUser = GetScenePresence(AvatarID); |