diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs | 506 |
1 files changed, 253 insertions, 253 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs index 9e134be..f0e957b 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs | |||
@@ -1,253 +1,253 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using log4net; | 34 | using log4net; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Services; | 39 | using OpenSim.Framework.Communications.Services; |
40 | using OpenSim.Framework.Communications.Cache; | 40 | using OpenSim.Framework.Communications.Cache; |
41 | using OpenSim.Framework.Communications.Capabilities; | 41 | using OpenSim.Framework.Communications.Capabilities; |
42 | using OpenSim.Framework.Servers.Interfaces; | 42 | using OpenSim.Framework.Servers.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
45 | 45 | ||
46 | namespace OpenSim.Region.CoreModules.Hypergrid | 46 | namespace OpenSim.Region.CoreModules.Hypergrid |
47 | { | 47 | { |
48 | public class HGStandaloneLoginModule : IRegionModule, ILoginServiceToRegionsConnector | 48 | public class HGStandaloneLoginModule : IRegionModule, ILoginServiceToRegionsConnector |
49 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 51 | ||
52 | protected List<Scene> m_scenes = new List<Scene>(); | 52 | protected List<Scene> m_scenes = new List<Scene>(); |
53 | protected Scene m_firstScene; | 53 | protected Scene m_firstScene; |
54 | 54 | ||
55 | protected bool m_enabled = false; // Module is only enabled if running in standalone mode | 55 | protected bool m_enabled = false; // Module is only enabled if running in standalone mode |
56 | 56 | ||
57 | 57 | ||
58 | public bool RegionLoginsEnabled | 58 | public bool RegionLoginsEnabled |
59 | { | 59 | { |
60 | get | 60 | get |
61 | { | 61 | { |
62 | if (m_firstScene != null) | 62 | if (m_firstScene != null) |
63 | { | 63 | { |
64 | return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; | 64 | return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; |
65 | } | 65 | } |
66 | else | 66 | else |
67 | { | 67 | { |
68 | return false; | 68 | return false; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | protected HGLoginAuthService m_loginService; | 73 | protected HGLoginAuthService m_loginService; |
74 | 74 | ||
75 | #region IRegionModule Members | 75 | #region IRegionModule Members |
76 | 76 | ||
77 | public void Initialise(Scene scene, IConfigSource source) | 77 | public void Initialise(Scene scene, IConfigSource source) |
78 | { | 78 | { |
79 | if (m_firstScene == null) | 79 | if (m_firstScene == null) |
80 | { | 80 | { |
81 | m_firstScene = scene; | 81 | m_firstScene = scene; |
82 | 82 | ||
83 | IConfig startupConfig = source.Configs["Startup"]; | 83 | IConfig startupConfig = source.Configs["Startup"]; |
84 | if (startupConfig != null) | 84 | if (startupConfig != null) |
85 | { | 85 | { |
86 | m_enabled = !startupConfig.GetBoolean("gridmode", false); | 86 | m_enabled = !startupConfig.GetBoolean("gridmode", false); |
87 | } | 87 | } |
88 | 88 | ||
89 | if (m_enabled) | 89 | if (m_enabled) |
90 | { | 90 | { |
91 | m_log.Debug("[HGLogin] HGlogin module enabled"); | 91 | m_log.Debug("[HGLogin] HGlogin module enabled"); |
92 | bool authenticate = true; | 92 | bool authenticate = true; |
93 | string welcomeMessage = "Welcome to OpenSim"; | 93 | string welcomeMessage = "Welcome to OpenSim"; |
94 | IConfig standaloneConfig = source.Configs["StandAlone"]; | 94 | IConfig standaloneConfig = source.Configs["StandAlone"]; |
95 | if (standaloneConfig != null) | 95 | if (standaloneConfig != null) |
96 | { | 96 | { |
97 | authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true); | 97 | authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true); |
98 | welcomeMessage = standaloneConfig.GetString("welcome_message"); | 98 | welcomeMessage = standaloneConfig.GetString("welcome_message"); |
99 | } | 99 | } |
100 | 100 | ||
101 | //TODO: fix casting. | 101 | //TODO: fix casting. |
102 | LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder; | 102 | LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder; |
103 | 103 | ||
104 | IHttpServer httpServer = m_firstScene.CommsManager.HttpServer; | 104 | IHttpServer httpServer = m_firstScene.CommsManager.HttpServer; |
105 | 105 | ||
106 | //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference | 106 | //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference |
107 | m_loginService = new HGLoginAuthService((UserManagerBase)m_firstScene.CommsManager.UserService, welcomeMessage, m_firstScene.CommsManager.InterServiceInventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate, rootFolder, this); | 107 | m_loginService = new HGLoginAuthService((UserManagerBase)m_firstScene.CommsManager.UserService, welcomeMessage, m_firstScene.CommsManager.InterServiceInventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate, rootFolder, this); |
108 | 108 | ||
109 | httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod); | 109 | httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod); |
110 | httpServer.AddXmlRPCHandler("hg_new_auth_key", m_loginService.XmlRpcGenerateKeyMethod); | 110 | httpServer.AddXmlRPCHandler("hg_new_auth_key", m_loginService.XmlRpcGenerateKeyMethod); |
111 | httpServer.AddXmlRPCHandler("hg_verify_auth_key", m_loginService.XmlRpcVerifyKeyMethod); | 111 | httpServer.AddXmlRPCHandler("hg_verify_auth_key", m_loginService.XmlRpcVerifyKeyMethod); |
112 | 112 | ||
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | if (m_enabled) | 116 | if (m_enabled) |
117 | { | 117 | { |
118 | AddScene(scene); | 118 | AddScene(scene); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | public void PostInitialise() | 122 | public void PostInitialise() |
123 | { | 123 | { |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | public void Close() | 127 | public void Close() |
128 | { | 128 | { |
129 | 129 | ||
130 | } | 130 | } |
131 | 131 | ||
132 | public string Name | 132 | public string Name |
133 | { | 133 | { |
134 | get { return "HGStandaloneLoginModule"; } | 134 | get { return "HGStandaloneLoginModule"; } |
135 | } | 135 | } |
136 | 136 | ||
137 | public bool IsSharedModule | 137 | public bool IsSharedModule |
138 | { | 138 | { |
139 | get { return true; } | 139 | get { return true; } |
140 | } | 140 | } |
141 | 141 | ||
142 | #endregion | 142 | #endregion |
143 | 143 | ||
144 | protected void AddScene(Scene scene) | 144 | protected void AddScene(Scene scene) |
145 | { | 145 | { |
146 | lock (m_scenes) | 146 | lock (m_scenes) |
147 | { | 147 | { |
148 | if (!m_scenes.Contains(scene)) | 148 | if (!m_scenes.Contains(scene)) |
149 | { | 149 | { |
150 | m_scenes.Add(scene); | 150 | m_scenes.Add(scene); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) | 155 | public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) |
156 | { | 156 | { |
157 | return true; | 157 | return true; |
158 | } | 158 | } |
159 | 159 | ||
160 | public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message) | 160 | public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message) |
161 | { | 161 | { |
162 | Scene scene; | 162 | Scene scene; |
163 | if (TryGetRegion(regionHandle, out scene)) | 163 | if (TryGetRegion(regionHandle, out scene)) |
164 | { | 164 | { |
165 | scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message); | 165 | scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | public RegionInfo RequestNeighbourInfo(ulong regionhandle) | 169 | public RegionInfo RequestNeighbourInfo(ulong regionhandle) |
170 | { | 170 | { |
171 | Scene scene; | 171 | Scene scene; |
172 | if (TryGetRegion(regionhandle, out scene)) | 172 | if (TryGetRegion(regionhandle, out scene)) |
173 | { | 173 | { |
174 | return scene.RegionInfo; | 174 | return scene.RegionInfo; |
175 | } | 175 | } |
176 | return null; | 176 | return null; |
177 | } | 177 | } |
178 | 178 | ||
179 | public RegionInfo RequestClosestRegion(string region) | 179 | public RegionInfo RequestClosestRegion(string region) |
180 | { | 180 | { |
181 | Scene scene; | 181 | Scene scene; |
182 | if (TryGetRegion(region, out scene)) | 182 | if (TryGetRegion(region, out scene)) |
183 | { | 183 | { |
184 | return scene.RegionInfo; | 184 | return scene.RegionInfo; |
185 | } | 185 | } |
186 | return null; | 186 | return null; |
187 | } | 187 | } |
188 | 188 | ||
189 | public RegionInfo RequestNeighbourInfo(UUID regionID) | 189 | public RegionInfo RequestNeighbourInfo(UUID regionID) |
190 | { | 190 | { |
191 | Scene scene; | 191 | Scene scene; |
192 | if (TryGetRegion(regionID, out scene)) | 192 | if (TryGetRegion(regionID, out scene)) |
193 | { | 193 | { |
194 | return scene.RegionInfo; | 194 | return scene.RegionInfo; |
195 | } | 195 | } |
196 | return null; | 196 | return null; |
197 | } | 197 | } |
198 | 198 | ||
199 | protected bool TryGetRegion(ulong regionHandle, out Scene scene) | 199 | protected bool TryGetRegion(ulong regionHandle, out Scene scene) |
200 | { | 200 | { |
201 | lock (m_scenes) | 201 | lock (m_scenes) |
202 | { | 202 | { |
203 | foreach (Scene nextScene in m_scenes) | 203 | foreach (Scene nextScene in m_scenes) |
204 | { | 204 | { |
205 | if (nextScene.RegionInfo.RegionHandle == regionHandle) | 205 | if (nextScene.RegionInfo.RegionHandle == regionHandle) |
206 | { | 206 | { |
207 | scene = nextScene; | 207 | scene = nextScene; |
208 | return true; | 208 | return true; |
209 | } | 209 | } |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | scene = null; | 213 | scene = null; |
214 | return false; | 214 | return false; |
215 | } | 215 | } |
216 | 216 | ||
217 | protected bool TryGetRegion(UUID regionID, out Scene scene) | 217 | protected bool TryGetRegion(UUID regionID, out Scene scene) |
218 | { | 218 | { |
219 | lock (m_scenes) | 219 | lock (m_scenes) |
220 | { | 220 | { |
221 | foreach (Scene nextScene in m_scenes) | 221 | foreach (Scene nextScene in m_scenes) |
222 | { | 222 | { |
223 | if (nextScene.RegionInfo.RegionID == regionID) | 223 | if (nextScene.RegionInfo.RegionID == regionID) |
224 | { | 224 | { |
225 | scene = nextScene; | 225 | scene = nextScene; |
226 | return true; | 226 | return true; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | scene = null; | 231 | scene = null; |
232 | return false; | 232 | return false; |
233 | } | 233 | } |
234 | 234 | ||
235 | protected bool TryGetRegion(string regionName, out Scene scene) | 235 | protected bool TryGetRegion(string regionName, out Scene scene) |
236 | { | 236 | { |
237 | lock (m_scenes) | 237 | lock (m_scenes) |
238 | { | 238 | { |
239 | foreach (Scene nextScene in m_scenes) | 239 | foreach (Scene nextScene in m_scenes) |
240 | { | 240 | { |
241 | if (nextScene.RegionInfo.RegionName == regionName) | 241 | if (nextScene.RegionInfo.RegionName == regionName) |
242 | { | 242 | { |
243 | scene = nextScene; | 243 | scene = nextScene; |
244 | return true; | 244 | return true; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | scene = null; | 249 | scene = null; |
250 | return false; | 250 | return false; |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } | 253 | } |