aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs')
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs223
1 files changed, 223 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Text.RegularExpressions;
33using log4net;
34using Nwc.XmlRpc;
35using OpenMetaverse;
36using OpenSim.Data;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Communications.Capabilities;
41using OpenSim.Framework.Servers;
42
43namespace 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}