From 0d37907c581f0417b7dece11417bd2e61de5a61e Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Sun, 15 Mar 2009 16:17:01 +0000 Subject: Thanks Tommil for a patch which added support for creating user accounts automatically in local sandbox if accounts authenticate is set off and connecting with MXP protocol. Mantis #3300 --- .../Client/MXP/PacketHandler/MXPPacketServer.cs | 45 +++++++++++++++------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs') diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs index 4f77f2c..ba7bd00 100644 --- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs +++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs @@ -39,6 +39,7 @@ using OpenMetaverse; using OpenSim.Client.MXP.ClientStack; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; +using OpenSim.Framework.Communications; namespace OpenSim.Client.MXP.PacketHandler { @@ -59,6 +60,8 @@ namespace OpenSim.Client.MXP.PacketHandler private readonly IList m_sessionsToRemove = new List(); private readonly int m_port; + private readonly bool m_accountsAuthenticate; + private readonly String m_programName; private readonly byte m_programMajorVersion; private readonly byte m_programMinorVersion; @@ -67,13 +70,13 @@ namespace OpenSim.Client.MXP.PacketHandler #region Constructors - public MXPPacketServer(int port, Dictionary scenes) + public MXPPacketServer(int port, Dictionary scenes, bool accountsAuthenticate) { - this.m_port = port; + m_port = port; + m_accountsAuthenticate = accountsAuthenticate; m_scenes = scenes; - m_programMinorVersion = 63; m_programMajorVersion = 0; m_programName = "OpenSimulator"; @@ -259,7 +262,7 @@ namespace OpenSim.Client.MXP.PacketHandler m_log.Info("Login failed as region was not found: " + sceneId); return false; } - + string[] nameParts=participantName.Split(' '); if (nameParts.Length != 2) { @@ -270,21 +273,35 @@ namespace OpenSim.Client.MXP.PacketHandler lastName = nameParts[1]; UserProfileData userProfile = m_scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName); - if (userProfile == null) + if (userProfile == null && !m_accountsAuthenticate) { - m_log.Info("Login failed as user was not found: " + participantName); - return false; + userId = ((UserManagerBase)m_scenes[sceneId].CommsManager.UserService).AddUser(firstName, lastName, "test", "", 1000, 1000); + } + else + { + if (userProfile == null) + { + m_log.Info("Login failed as user was not found: " + participantName); + return false; + } + userId = userProfile.ID; } - userId = userProfile.ID; - if (!password.StartsWith("$1$")) + if (m_accountsAuthenticate) + { + if (!password.StartsWith("$1$")) + { + password = "$1$" + Util.Md5Hash(password); + } + password = password.Remove(0, 3); //remove $1$ + string s = Util.Md5Hash(password + ":" + userProfile.PasswordSalt); + return (userProfile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || userProfile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + } + else { - password = "$1$" + Util.Md5Hash(password); + return true; } - password = password.Remove(0, 3); //remove $1$ - string s = Util.Md5Hash(password + ":" + userProfile.PasswordSalt); - return (userProfile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || userProfile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); } public void ProcessMessages() -- cgit v1.1