diff options
Diffstat (limited to 'OpenSim/Client/Linden/LLStandaloneLoginModule.cs')
-rw-r--r-- | OpenSim/Client/Linden/LLStandaloneLoginModule.cs | 290 |
1 files changed, 0 insertions, 290 deletions
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs deleted file mode 100644 index e51eace..0000000 --- a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs +++ /dev/null | |||
@@ -1,290 +0,0 @@ | |||
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.Capabilities; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | |||
45 | namespace OpenSim.Client.Linden | ||
46 | { | ||
47 | public class LLStandaloneLoginModule : ISharedRegionModule, ILoginServiceToRegionsConnector | ||
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 | protected bool authenticate; | ||
57 | protected string welcomeMessage; | ||
58 | |||
59 | protected LLStandaloneLoginService m_loginService; | ||
60 | |||
61 | #region IRegionModule Members | ||
62 | |||
63 | public void Initialise(IConfigSource source) | ||
64 | { | ||
65 | IConfig startupConfig = source.Configs["Startup"]; | ||
66 | if (startupConfig != null) | ||
67 | { | ||
68 | m_enabled = !startupConfig.GetBoolean("gridmode", false); | ||
69 | } | ||
70 | |||
71 | if (m_enabled) | ||
72 | { | ||
73 | authenticate = true; | ||
74 | welcomeMessage = "Welcome to OpenSim"; | ||
75 | IConfig standaloneConfig = source.Configs["StandAlone"]; | ||
76 | if (standaloneConfig != null) | ||
77 | { | ||
78 | authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true); | ||
79 | welcomeMessage = standaloneConfig.GetString("welcome_message"); | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | |||
84 | public void AddRegion(Scene scene) | ||
85 | { | ||
86 | } | ||
87 | |||
88 | public void RemoveRegion(Scene scene) | ||
89 | { | ||
90 | if (m_enabled) | ||
91 | { | ||
92 | RemoveScene(scene); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public void PostInitialise() | ||
97 | { | ||
98 | |||
99 | } | ||
100 | |||
101 | public void Close() | ||
102 | { | ||
103 | |||
104 | } | ||
105 | |||
106 | public void RegionLoaded(Scene scene) | ||
107 | { | ||
108 | if (m_firstScene == null) | ||
109 | { | ||
110 | m_firstScene = scene; | ||
111 | |||
112 | if (m_enabled) | ||
113 | { | ||
114 | //TODO: fix casting. | ||
115 | LibraryRootFolder rootFolder | ||
116 | = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder; | ||
117 | |||
118 | IHttpServer httpServer = MainServer.Instance; | ||
119 | |||
120 | //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference | ||
121 | m_loginService | ||
122 | = new LLStandaloneLoginService( | ||
123 | (UserManagerBase)m_firstScene.CommsManager.UserAdminService, welcomeMessage, | ||
124 | m_firstScene.InventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate, | ||
125 | rootFolder, this); | ||
126 | |||
127 | httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); | ||
128 | |||
129 | // provides the web form login | ||
130 | httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin); | ||
131 | |||
132 | // Provides the LLSD login | ||
133 | httpServer.SetDefaultLLSDHandler(m_loginService.LLSDLoginMethod); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | if (m_enabled) | ||
138 | { | ||
139 | AddScene(scene); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | public Type ReplaceableInterface | ||
144 | { | ||
145 | get { return null; } | ||
146 | } | ||
147 | |||
148 | public string Name | ||
149 | { | ||
150 | get { return "LLStandaloneLoginModule"; } | ||
151 | } | ||
152 | |||
153 | public bool IsSharedModule | ||
154 | { | ||
155 | get { return true; } | ||
156 | } | ||
157 | |||
158 | #endregion | ||
159 | |||
160 | protected void AddScene(Scene scene) | ||
161 | { | ||
162 | lock (m_scenes) | ||
163 | { | ||
164 | if (!m_scenes.Contains(scene)) | ||
165 | { | ||
166 | m_scenes.Add(scene); | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | protected void RemoveScene(Scene scene) | ||
172 | { | ||
173 | lock (m_scenes) | ||
174 | { | ||
175 | if (m_scenes.Contains(scene)) | ||
176 | { | ||
177 | m_scenes.Remove(scene); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason) | ||
183 | { | ||
184 | Scene scene; | ||
185 | if (TryGetRegion(regionHandle, out scene)) | ||
186 | { | ||
187 | return scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason); | ||
188 | } | ||
189 | reason = "Region not found."; | ||
190 | return false; | ||
191 | } | ||
192 | |||
193 | public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message) | ||
194 | { | ||
195 | Scene scene; | ||
196 | if (TryGetRegion(regionHandle, out scene)) | ||
197 | { | ||
198 | scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | public RegionInfo RequestNeighbourInfo(ulong regionhandle) | ||
203 | { | ||
204 | Scene scene; | ||
205 | if (TryGetRegion(regionhandle, out scene)) | ||
206 | { | ||
207 | return scene.RegionInfo; | ||
208 | } | ||
209 | return null; | ||
210 | } | ||
211 | |||
212 | public RegionInfo RequestClosestRegion(string region) | ||
213 | { | ||
214 | Scene scene; | ||
215 | if (TryGetRegion(region, out scene)) | ||
216 | { | ||
217 | return scene.RegionInfo; | ||
218 | } | ||
219 | else if (m_scenes.Count > 0) | ||
220 | { | ||
221 | return m_scenes[0].RegionInfo; | ||
222 | } | ||
223 | return null; | ||
224 | } | ||
225 | |||
226 | public RegionInfo RequestNeighbourInfo(UUID regionID) | ||
227 | { | ||
228 | Scene scene; | ||
229 | if (TryGetRegion(regionID, out scene)) | ||
230 | { | ||
231 | return scene.RegionInfo; | ||
232 | } | ||
233 | return null; | ||
234 | } | ||
235 | |||
236 | protected bool TryGetRegion(ulong regionHandle, out Scene scene) | ||
237 | { | ||
238 | lock (m_scenes) | ||
239 | { | ||
240 | foreach (Scene nextScene in m_scenes) | ||
241 | { | ||
242 | if (nextScene.RegionInfo.RegionHandle == regionHandle) | ||
243 | { | ||
244 | scene = nextScene; | ||
245 | return true; | ||
246 | } | ||
247 | } | ||
248 | } | ||
249 | |||
250 | scene = null; | ||
251 | return false; | ||
252 | } | ||
253 | |||
254 | protected bool TryGetRegion(UUID regionID, out Scene scene) | ||
255 | { | ||
256 | lock (m_scenes) | ||
257 | { | ||
258 | foreach (Scene nextScene in m_scenes) | ||
259 | { | ||
260 | if (nextScene.RegionInfo.RegionID == regionID) | ||
261 | { | ||
262 | scene = nextScene; | ||
263 | return true; | ||
264 | } | ||
265 | } | ||
266 | } | ||
267 | |||
268 | scene = null; | ||
269 | return false; | ||
270 | } | ||
271 | |||
272 | protected bool TryGetRegion(string regionName, out Scene scene) | ||
273 | { | ||
274 | lock (m_scenes) | ||
275 | { | ||
276 | foreach (Scene nextScene in m_scenes) | ||
277 | { | ||
278 | if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase)) | ||
279 | { | ||
280 | scene = nextScene; | ||
281 | return true; | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | |||
286 | scene = null; | ||
287 | return false; | ||
288 | } | ||
289 | } | ||
290 | } | ||