From 114807b9d1caeffad1f245982baa2c07e88ee470 Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 11 Aug 2007 11:59:51 +0000 Subject: Made account Authentication optional in "sandbox/standalone" mode. Just change "standalone_authenticate = false" to be true in OpenSim.ini. Then as per grid mode, you can use the "create user" command to create new accounts. --- .../Communications/Local/CommunicationsLocal.cs | 32 ++++++++++++++++++++-- .../Communications/Local/LocalUserServices.cs | 23 +++++++++++++--- 2 files changed, 49 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Communications') diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 0c40453..69352d1 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -25,10 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; using OpenSim.Framework.Communications; using OpenSim.Framework.Types; using OpenSim.Framework.Servers; using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Console; +using OpenSim.Framework.Utilities; namespace OpenSim.Region.Communications.Local { @@ -37,10 +40,10 @@ namespace OpenSim.Region.Communications.Local public LocalBackEndServices SandBoxServices = new LocalBackEndServices(); public LocalUserServices UserServices; - public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache ) + public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool accountsAuthenticate ) : base(serversInfo, httpServer, assetCache) { - UserServices = new LocalUserServices(this, serversInfo); + UserServices = new LocalUserServices(this, serversInfo, accountsAuthenticate); UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll"); UserServer = UserServices; GridServer = SandBoxServices; @@ -52,5 +55,30 @@ namespace OpenSim.Region.Communications.Local { this.SandBoxServices.AddNewSession(regionHandle, login); } + + public void do_create(string what) + { + switch (what) + { + case "user": + string tempfirstname; + string templastname; + string tempMD5Passwd; + uint regX = 1000; + uint regY = 1000; + + tempfirstname = MainLog.Instance.CmdPrompt("First name"); + templastname = MainLog.Instance.CmdPrompt("Last name"); + tempMD5Passwd = MainLog.Instance.PasswdPrompt("Password"); + regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X")); + regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y")); + + tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); + + this.UserServices.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); + break; + } + } + } } diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index cc80c81..223c157 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs @@ -15,13 +15,15 @@ namespace OpenSim.Region.Communications.Local private NetworkServersInfo serversInfo; private uint defaultHomeX ; private uint defaultHomeY; + private bool authUsers = false; - public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversInfo) + public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) { m_Parent = parent; this.serversInfo = serversInfo; defaultHomeX = this.serversInfo.DefaultHomeLocX; defaultHomeY = this.serversInfo.DefaultHomeLocY; + this.authUsers = authenticate; } public UserProfileData GetUserProfile(string firstName, string lastName) @@ -68,9 +70,22 @@ namespace OpenSim.Region.Communications.Local public override bool AuthenticateUser(UserProfileData profile, string password) { - //for now we will accept any password in sandbox mode - Console.WriteLine("authorising user"); - return true; + if (!authUsers) + { + //for now we will accept any password in sandbox mode + Console.WriteLine("authorising user"); + return true; + } + else + { + Console.WriteLine( "Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } } public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) -- cgit v1.1