aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client/Linden/LLStandaloneLoginService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Client/Linden/LLStandaloneLoginService.cs')
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginService.cs239
1 files changed, 0 insertions, 239 deletions
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginService.cs b/OpenSim/Client/Linden/LLStandaloneLoginService.cs
deleted file mode 100644
index 9ab043a..0000000
--- a/OpenSim/Client/Linden/LLStandaloneLoginService.cs
+++ /dev/null
@@ -1,239 +0,0 @@
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.Services;
40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Capabilities;
42using OpenSim.Framework.Servers;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces;
46
47namespace OpenSim.Client.Linden
48{
49 public class LLStandaloneLoginService : LoginService
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 protected NetworkServersInfo m_serversInfo;
54 protected bool m_authUsers = false;
55
56 /// <summary>
57 /// Used to make requests to the local regions.
58 /// </summary>
59 protected ILoginServiceToRegionsConnector m_regionsConnector;
60
61 public LLStandaloneLoginService(
62 UserManagerBase userManager, string welcomeMess,
63 IInventoryService interServiceInventoryService,
64 NetworkServersInfo serversInfo,
65 bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector)
66 : base(userManager, libraryRootFolder, welcomeMess)
67 {
68 this.m_serversInfo = serversInfo;
69 m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX;
70 m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY;
71 m_authUsers = authenticate;
72
73 m_InventoryService = interServiceInventoryService;
74 m_regionsConnector = regionsConnector;
75 // Standard behavior: In StandAlone, silent logout of last hung session
76 m_warn_already_logged = false;
77 }
78
79 public override UserProfileData GetTheUser(string firstname, string lastname)
80 {
81 UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname);
82 if (profile != null)
83 {
84 return profile;
85 }
86
87 if (!m_authUsers)
88 {
89 //no current user account so make one
90 m_log.Info("[LOGIN]: No user account found so creating a new one.");
91
92 m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY);
93
94 return m_userManager.GetUserProfile(firstname, lastname);
95 }
96
97 return null;
98 }
99
100 public override bool AuthenticateUser(UserProfileData profile, string password)
101 {
102 if (!m_authUsers)
103 {
104 //for now we will accept any password in sandbox mode
105 m_log.Info("[LOGIN]: Authorising user (no actual password check)");
106
107 return true;
108 }
109 else
110 {
111 m_log.Info(
112 "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName);
113
114 if (!password.StartsWith("$1$"))
115 password = "$1$" + Util.Md5Hash(password);
116
117 password = password.Remove(0, 3); //remove $1$
118
119 string s = Util.Md5Hash(password + ":" + profile.PasswordSalt);
120
121 bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
122 || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture));
123 return loginresult;
124 }
125 }
126
127 protected override RegionInfo RequestClosestRegion(string region)
128 {
129 return m_regionsConnector.RequestClosestRegion(region);
130 }
131
132 protected override RegionInfo GetRegionInfo(ulong homeRegionHandle)
133 {
134 return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle);
135 }
136
137 protected override RegionInfo GetRegionInfo(UUID homeRegionId)
138 {
139 return m_regionsConnector.RequestNeighbourInfo(homeRegionId);
140 }
141
142 protected override bool PrepareLoginToRegion(
143 RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient)
144 {
145 IPEndPoint endPoint = regionInfo.ExternalEndPoint;
146 response.SimAddress = endPoint.Address.ToString();
147 response.SimPort = (uint)endPoint.Port;
148 response.RegionX = regionInfo.RegionLocX;
149 response.RegionY = regionInfo.RegionLocY;
150
151 string capsPath = CapsUtil.GetRandomCapsObjectPath();
152 string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath);
153
154 // Don't use the following! It Fails for logging into any region not on the same port as the http server!
155 // Kept here so it doesn't happen again!
156 // response.SeedCapability = regionInfo.ServerURI + capsSeedPath;
157
158 string seedcap = "http://";
159
160 if (m_serversInfo.HttpUsesSSL)
161 {
162 // For NAT
163 string host = NetworkUtil.GetHostFor(remoteClient.Address, m_serversInfo.HttpSSLCN);
164
165 seedcap = "https://" + host + ":" + m_serversInfo.httpSSLPort + capsSeedPath;
166 }
167 else
168 {
169 // For NAT
170 string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ExternalHostName);
171
172 seedcap = "http://" + host + ":" + m_serversInfo.HttpListenerPort + capsSeedPath;
173 }
174
175 response.SeedCapability = seedcap;
176
177 // Notify the target of an incoming user
178 m_log.InfoFormat(
179 "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection",
180 regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI);
181
182 // Update agent with target sim
183 user.CurrentAgent.Region = regionInfo.RegionID;
184 user.CurrentAgent.Handle = regionInfo.RegionHandle;
185
186 AgentCircuitData agent = new AgentCircuitData();
187 agent.AgentID = user.ID;
188 agent.firstname = user.FirstName;
189 agent.lastname = user.SurName;
190 agent.SessionID = user.CurrentAgent.SessionID;
191 agent.SecureSessionID = user.CurrentAgent.SecureSessionID;
192 agent.circuitcode = Convert.ToUInt32(response.CircuitCode);
193 agent.BaseFolder = UUID.Zero;
194 agent.InventoryFolder = UUID.Zero;
195 agent.startpos = user.CurrentAgent.Position;
196 agent.CapsPath = capsPath;
197 agent.Appearance = m_userManager.GetUserAppearance(user.ID);
198 if (agent.Appearance == null)
199 {
200 m_log.WarnFormat(
201 "[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
202 agent.Appearance = new AvatarAppearance(agent.AgentID);
203 }
204
205 string reason;
206 bool success = m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason);
207 if (!success)
208 {
209 response.ErrorReason = "key";
210 response.ErrorMessage = reason;
211 }
212 return success;
213 // return m_regionsConnector.NewUserConnection(regionInfo.RegionHandle, agent, out reason);
214 }
215
216 public override void LogOffUser(UserProfileData theUser, string message)
217 {
218 RegionInfo SimInfo;
219 try
220 {
221 SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle);
222
223 if (SimInfo == null)
224 {
225 m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in");
226 return;
227 }
228 }
229 catch (Exception)
230 {
231 m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off");
232 return;
233 }
234
235 m_regionsConnector.LogOffUserFromGrid(
236 SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off");
237 }
238 }
239}