aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Client/Linden/LLStandaloneLoginModule.cs')
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginModule.cs259
1 files changed, 259 insertions, 0 deletions
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Communications.Capabilities;
41using OpenSim.Framework.Servers;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Interfaces;
44
45namespace 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}