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