diff options
author | diva | 2009-03-27 16:23:52 +0000 |
---|---|---|
committer | diva | 2009-03-27 16:23:52 +0000 |
commit | 6b9125b31944c126fa9bf25529a27de5c3972244 (patch) | |
tree | 45ad9a9480dffab1bfe357afed744365e13ad665 /OpenSim/Grid/UserServer | |
parent | svn:eol-style property set. (diff) | |
download | opensim-SC_OLD-6b9125b31944c126fa9bf25529a27de5c3972244.zip opensim-SC_OLD-6b9125b31944c126fa9bf25529a27de5c3972244.tar.gz opensim-SC_OLD-6b9125b31944c126fa9bf25529a27de5c3972244.tar.bz2 opensim-SC_OLD-6b9125b31944c126fa9bf25529a27de5c3972244.tar.xz |
Added the hg login procedure to the user server.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs | 223 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/Main.cs | 8 |
2 files changed, 231 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs new file mode 100644 index 0000000..774b4e1 --- /dev/null +++ b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs | |||
@@ -0,0 +1,223 @@ | |||
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 OpenSim 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.Reflection; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Data; | ||
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 | |||
43 | namespace OpenSim.Grid.UserServer.Modules | ||
44 | { | ||
45 | |||
46 | /// <summary> | ||
47 | /// Hypergrid login service used in grid mode. | ||
48 | /// </summary> | ||
49 | public class UserLoginAuthService : HGLoginAuthService | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | public UserConfig m_config; | ||
54 | private readonly IRegionProfileRouter m_regionProfileService; | ||
55 | |||
56 | protected BaseHttpServer m_httpServer; | ||
57 | |||
58 | public UserLoginAuthService( | ||
59 | UserManagerBase userManager, IInterServiceInventoryServices inventoryService, | ||
60 | LibraryRootFolder libraryRootFolder, | ||
61 | UserConfig config, string welcomeMess, IRegionProfileRouter regionProfileService) | ||
62 | : base(userManager, welcomeMess, inventoryService, null, true, libraryRootFolder, null) | ||
63 | { | ||
64 | m_config = config; | ||
65 | m_defaultHomeX = m_config.DefaultX; | ||
66 | m_defaultHomeY = m_config.DefaultY; | ||
67 | m_inventoryService = inventoryService; | ||
68 | m_regionProfileService = regionProfileService; | ||
69 | |||
70 | NetworkServersInfo serversinfo = new NetworkServersInfo(1000, 1000); | ||
71 | serversinfo.GridRecvKey = m_config.GridRecvKey; | ||
72 | serversinfo.GridSendKey = m_config.GridSendKey; | ||
73 | serversinfo.GridURL = m_config.GridServerURL.ToString(); | ||
74 | serversinfo.InventoryURL = m_config.InventoryUrl.ToString(); | ||
75 | serversinfo.UserURL = m_config.AuthUrl.ToString(); | ||
76 | SetServersInfo(serversinfo); | ||
77 | } | ||
78 | |||
79 | public void RegisterHandlers(BaseHttpServer httpServer) | ||
80 | { | ||
81 | m_httpServer = httpServer; | ||
82 | |||
83 | httpServer.AddXmlRPCHandler("hg_login", XmlRpcLoginMethod); | ||
84 | httpServer.AddXmlRPCHandler("hg_new_auth_key", XmlRpcGenerateKeyMethod); | ||
85 | httpServer.AddXmlRPCHandler("hg_verify_auth_key", XmlRpcVerifyKeyMethod); | ||
86 | } | ||
87 | |||
88 | |||
89 | public override void LogOffUser(UserProfileData theUser, string message) | ||
90 | { | ||
91 | RegionProfileData SimInfo; | ||
92 | try | ||
93 | { | ||
94 | SimInfo = m_regionProfileService.RequestSimProfileData( | ||
95 | theUser.CurrentAgent.Handle, m_config.GridServerURL, | ||
96 | m_config.GridSendKey, m_config.GridRecvKey); | ||
97 | |||
98 | if (SimInfo == null) | ||
99 | { | ||
100 | m_log.Error("[GRID]: Region user was in isn't currently logged in"); | ||
101 | return; | ||
102 | } | ||
103 | } | ||
104 | catch (Exception) | ||
105 | { | ||
106 | m_log.Error("[GRID]: Unable to look up region to log user off"); | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | // Prepare notification | ||
111 | Hashtable SimParams = new Hashtable(); | ||
112 | SimParams["agent_id"] = theUser.ID.ToString(); | ||
113 | SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); | ||
114 | SimParams["region_secret2"] = SimInfo.regionSecret; | ||
115 | //m_log.Info(SimInfo.regionSecret); | ||
116 | SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); | ||
117 | SimParams["message"] = message; | ||
118 | ArrayList SendParams = new ArrayList(); | ||
119 | SendParams.Add(SimParams); | ||
120 | |||
121 | m_log.InfoFormat( | ||
122 | "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", | ||
123 | SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, | ||
124 | theUser.FirstName + " " + theUser.SurName); | ||
125 | |||
126 | try | ||
127 | { | ||
128 | XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); | ||
129 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); | ||
130 | |||
131 | if (GridResp.IsFault) | ||
132 | { | ||
133 | m_log.ErrorFormat( | ||
134 | "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", | ||
135 | SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); | ||
136 | } | ||
137 | } | ||
138 | catch (Exception) | ||
139 | { | ||
140 | m_log.Error("[LOGIN]: Error telling region to logout user!"); | ||
141 | } | ||
142 | |||
143 | // Prepare notification | ||
144 | SimParams = new Hashtable(); | ||
145 | SimParams["agent_id"] = theUser.ID.ToString(); | ||
146 | SimParams["region_secret"] = SimInfo.regionSecret; | ||
147 | //m_log.Info(SimInfo.regionSecret); | ||
148 | SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); | ||
149 | SimParams["message"] = message; | ||
150 | SendParams = new ArrayList(); | ||
151 | SendParams.Add(SimParams); | ||
152 | |||
153 | m_log.InfoFormat( | ||
154 | "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", | ||
155 | SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, | ||
156 | theUser.FirstName + " " + theUser.SurName); | ||
157 | |||
158 | try | ||
159 | { | ||
160 | XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); | ||
161 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); | ||
162 | |||
163 | if (GridResp.IsFault) | ||
164 | { | ||
165 | m_log.ErrorFormat( | ||
166 | "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", | ||
167 | SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); | ||
168 | } | ||
169 | } | ||
170 | catch (Exception) | ||
171 | { | ||
172 | m_log.Error("[LOGIN]: Error telling region to logout user!"); | ||
173 | } | ||
174 | //base.LogOffUser(theUser); | ||
175 | } | ||
176 | |||
177 | protected override RegionInfo RequestClosestRegion(string region) | ||
178 | { | ||
179 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region, | ||
180 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | ||
181 | |||
182 | if (profileData != null) | ||
183 | { | ||
184 | return profileData.ToRegionInfo(); | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | return null; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) | ||
193 | { | ||
194 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle, | ||
195 | m_config.GridServerURL, m_config.GridSendKey, | ||
196 | m_config.GridRecvKey); | ||
197 | if (profileData != null) | ||
198 | { | ||
199 | return profileData.ToRegionInfo(); | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | return null; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) | ||
208 | { | ||
209 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId, | ||
210 | m_config.GridServerURL, m_config.GridSendKey, | ||
211 | m_config.GridRecvKey); | ||
212 | if (profileData != null) | ||
213 | { | ||
214 | return profileData.ToRegionInfo(); | ||
215 | } | ||
216 | else | ||
217 | { | ||
218 | return null; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | } | ||
223 | } | ||
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 5a1dfd1..c0cba4a 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs | |||
@@ -62,6 +62,7 @@ namespace OpenSim.Grid.UserServer | |||
62 | protected UserServerFriendsModule m_friendsModule; | 62 | protected UserServerFriendsModule m_friendsModule; |
63 | 63 | ||
64 | public UserLoginService m_loginService; | 64 | public UserLoginService m_loginService; |
65 | public UserLoginAuthService m_loginAuthService; | ||
65 | public MessageServersConnector m_messagesService; | 66 | public MessageServersConnector m_messagesService; |
66 | 67 | ||
67 | protected GridInfoServiceModule m_gridInfoService; | 68 | protected GridInfoServiceModule m_gridInfoService; |
@@ -191,6 +192,10 @@ namespace OpenSim.Grid.UserServer | |||
191 | { | 192 | { |
192 | m_loginService = new UserLoginService( | 193 | m_loginService = new UserLoginService( |
193 | m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); | 194 | m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); |
195 | |||
196 | if (Cfg.EnableHGLogin) | ||
197 | m_loginAuthService = new UserLoginAuthService(m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), | ||
198 | Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); | ||
194 | } | 199 | } |
195 | 200 | ||
196 | protected virtual void PostInitialiseModules() | 201 | protected virtual void PostInitialiseModules() |
@@ -209,6 +214,9 @@ namespace OpenSim.Grid.UserServer | |||
209 | { | 214 | { |
210 | m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); | 215 | m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); |
211 | 216 | ||
217 | if (m_loginAuthService != null) | ||
218 | m_loginAuthService.RegisterHandlers(m_httpServer); | ||
219 | |||
212 | m_userManager.RegisterHandlers(m_httpServer); | 220 | m_userManager.RegisterHandlers(m_httpServer); |
213 | m_friendsModule.RegisterHandlers(m_httpServer); | 221 | m_friendsModule.RegisterHandlers(m_httpServer); |
214 | m_avatarAppearanceModule.RegisterHandlers(m_httpServer); | 222 | m_avatarAppearanceModule.RegisterHandlers(m_httpServer); |