aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Hypergrid/Login/HGStandaloneLoginModule.cs
diff options
context:
space:
mode:
authordiva2009-03-21 20:16:35 +0000
committerdiva2009-03-21 20:16:35 +0000
commit09732b4d5dfdb3a9e326e99c2e86d7492bc06e55 (patch)
tree2fcb55c9e341c7abf7225c5880a6984ab8544ff2 /OpenSim/Region/CoreModules/Hypergrid/Login/HGStandaloneLoginModule.cs
parentMinor changes in names inside. (diff)
downloadopensim-SC_OLD-09732b4d5dfdb3a9e326e99c2e86d7492bc06e55.zip
opensim-SC_OLD-09732b4d5dfdb3a9e326e99c2e86d7492bc06e55.tar.gz
opensim-SC_OLD-09732b4d5dfdb3a9e326e99c2e86d7492bc06e55.tar.bz2
opensim-SC_OLD-09732b4d5dfdb3a9e326e99c2e86d7492bc06e55.tar.xz
Initial support for authentication/authorization keys in UserManagerBase, and use of it in HGStandaloneLoginService (producer of initial key for user, and of subsequent keys) and HGStandaloneInventoryService (consumer of a key).
Keys are of the form http://<authority>/<random uuid> and they are sent over http header "authorization".
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/Login/HGStandaloneLoginModule.cs252
1 files changed, 252 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/Login/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/Login/HGStandaloneLoginModule.cs
new file mode 100644
index 0000000..4b74ed5
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Hypergrid/Login/HGStandaloneLoginModule.cs
@@ -0,0 +1,252 @@
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.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Interfaces;
44
45namespace OpenSim.Region.CoreModules.Hypergrid
46{
47 public class HGStandaloneLoginModule : IRegionModule, 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
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 HGStandaloneLoginService 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 m_log.Debug("[HGLogin] HGlogin module enabled");
91 bool authenticate = true;
92 string welcomeMessage = "Welcome to OpenSim";
93 IConfig standaloneConfig = source.Configs["StandAlone"];
94 if (standaloneConfig != null)
95 {
96 authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true);
97 welcomeMessage = standaloneConfig.GetString("welcome_message");
98 }
99
100 //TODO: fix casting.
101 LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder;
102
103 IHttpServer httpServer = m_firstScene.CommsManager.HttpServer;
104
105 //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 m_loginService = new HGStandaloneLoginService((UserManagerBase)m_firstScene.CommsManager.UserService, welcomeMessage, m_firstScene.CommsManager.InterServiceInventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate, rootFolder, this);
107
108 httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod);
109 httpServer.AddXmlRPCHandler("hg_new_auth_key", m_loginService.XmlRpcGenerateKeyMethod);
110 httpServer.AddXmlRPCHandler("hg_verify_auth_key", m_loginService.XmlRpcVerifyKeyMethod);
111
112 }
113 }
114
115 if (m_enabled)
116 {
117 AddScene(scene);
118 }
119 }
120
121 public void PostInitialise()
122 {
123
124 }
125
126 public void Close()
127 {
128
129 }
130
131 public string Name
132 {
133 get { return "HGStandaloneLoginModule"; }
134 }
135
136 public bool IsSharedModule
137 {
138 get { return true; }
139 }
140
141 #endregion
142
143 protected void AddScene(Scene scene)
144 {
145 lock (m_scenes)
146 {
147 if (!m_scenes.Contains(scene))
148 {
149 m_scenes.Add(scene);
150 }
151 }
152 }
153
154 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent)
155 {
156 return true;
157 }
158
159 public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message)
160 {
161 Scene scene;
162 if (TryGetRegion(regionHandle, out scene))
163 {
164 scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message);
165 }
166 }
167
168 public RegionInfo RequestNeighbourInfo(ulong regionhandle)
169 {
170 Scene scene;
171 if (TryGetRegion(regionhandle, out scene))
172 {
173 return scene.RegionInfo;
174 }
175 return null;
176 }
177
178 public RegionInfo RequestClosestRegion(string region)
179 {
180 Scene scene;
181 if (TryGetRegion(region, out scene))
182 {
183 return scene.RegionInfo;
184 }
185 return null;
186 }
187
188 public RegionInfo RequestNeighbourInfo(UUID regionID)
189 {
190 Scene scene;
191 if (TryGetRegion(regionID, out scene))
192 {
193 return scene.RegionInfo;
194 }
195 return null;
196 }
197
198 protected bool TryGetRegion(ulong regionHandle, out Scene scene)
199 {
200 lock (m_scenes)
201 {
202 foreach (Scene nextScene in m_scenes)
203 {
204 if (nextScene.RegionInfo.RegionHandle == regionHandle)
205 {
206 scene = nextScene;
207 return true;
208 }
209 }
210 }
211
212 scene = null;
213 return false;
214 }
215
216 protected bool TryGetRegion(UUID regionID, out Scene scene)
217 {
218 lock (m_scenes)
219 {
220 foreach (Scene nextScene in m_scenes)
221 {
222 if (nextScene.RegionInfo.RegionID == regionID)
223 {
224 scene = nextScene;
225 return true;
226 }
227 }
228 }
229
230 scene = null;
231 return false;
232 }
233
234 protected bool TryGetRegion(string regionName, out Scene scene)
235 {
236 lock (m_scenes)
237 {
238 foreach (Scene nextScene in m_scenes)
239 {
240 if (nextScene.RegionInfo.RegionName == regionName)
241 {
242 scene = nextScene;
243 return true;
244 }
245 }
246 }
247
248 scene = null;
249 return false;
250 }
251 }
252}