From be2f0336269e36fd987392209c8d5bf382a043f5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Dec 2009 17:21:16 -0800 Subject: More renames to make everything consistent. This is the UserAccountService. --- .../UserAccountService/UserAccountService.cs | 75 ++++++++++++++++++++++ .../UserAccountService/UserAccountServiceBase.cs | 73 +++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 OpenSim/Services/UserAccountService/UserAccountService.cs create mode 100644 OpenSim/Services/UserAccountService/UserAccountServiceBase.cs (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs new file mode 100644 index 0000000..2e6f7dc --- /dev/null +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -0,0 +1,75 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using Nini.Config; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using System.Collections.Generic; +using OpenMetaverse; + +namespace OpenSim.Services.UserAccountService +{ + public class UserAccountService : UserAccountServiceBase, IUserAccountService + { + public UserAccountService(IConfigSource config) : base(config) + { + } + + public UserAccount GetUserAccount(UUID scopeID, string firstName, + string lastName) + { + return null; + } + + public UserAccount GetUserAccount(UUID scopeID, string email) + { + return null; + } + + public UserAccount GetUserAccount(UUID scopeID, UUID userID) + { + return null; + } + + public bool SetUserAccount(UserAccount data) + { + return false; + } + + public bool CreateUserAccount(UserAccount data) + { + return false; + } + + public List GetUserAccounts(UUID scopeID, string query) + { + return null; + } + } +} diff --git a/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs new file mode 100644 index 0000000..70ed594 --- /dev/null +++ b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs @@ -0,0 +1,73 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using Nini.Config; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Base; + +namespace OpenSim.Services.UserAccountService +{ + public class UserAccountServiceBase: ServiceBase + { + protected IUserAccountData m_Database = null; + + public UserAccountServiceBase(IConfigSource config) : base(config) + { + string dllName = String.Empty; + string connString = String.Empty; + string realm = "useraccounts"; + + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig != null) + { + dllName = dbConfig.GetString("StorageProvider", String.Empty); + connString = dbConfig.GetString("ConnectionString", String.Empty); + } + + IConfig userConfig = config.Configs["UserAccountService"]; + if (userConfig == null) + throw new Exception("No UserAccountService configuration"); + + dllName = userConfig.GetString("StorageProvider", dllName); + + if (dllName == String.Empty) + throw new Exception("No StorageProvider configured"); + + connString = userConfig.GetString("ConnectionString", connString); + + realm = userConfig.GetString("Realm", realm); + + m_Database = LoadPlugin(dllName, new Object[] {connString, realm}); + + if (m_Database == null) + throw new Exception("Could not find a storage interface in the given module"); + } + } +} -- cgit v1.1 From b6097ae9a8a4566330d882213179feba6d05da62 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 30 Dec 2009 22:23:17 +0000 Subject: Some modifications to user service. Query by name is implemented now --- OpenSim/Services/UserAccountService/UserAccountService.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 2e6f7dc..ee9ea94 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -44,6 +44,21 @@ namespace OpenSim.Services.UserAccountService public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) { + UserAccountData[] d = m_Database.Get( + new string[] {"ScopeID", "FirstName", "LastName"}, + new string[] {scopeID.ToString(), firstName, lastName}); + + if (d.Length < 1) + return null; + + UserAccount u = new UserAccount(); + u.FirstName = d[0].FirstName; + u.LastName = d[0].LastName; + u.PrincipalID = d[0].PrincipalID; + u.ScopeID = d[0].ScopeID; + u.Email = d[0].Data["Email"].ToString(); + u.Created = Convert.ToInt32(d[0].Data["Created"].ToString()); + return null; } -- cgit v1.1 From 96f387ce491e033344f6097dcaf9852fc6309aed Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 30 Dec 2009 22:44:04 +0000 Subject: Make ScopeID be wild on user queries. Just pass it as UUID.Zero --- .../Services/UserAccountService/UserAccountService.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index ee9ea94..0270f9d 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -44,9 +44,20 @@ namespace OpenSim.Services.UserAccountService public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) { - UserAccountData[] d = m_Database.Get( - new string[] {"ScopeID", "FirstName", "LastName"}, - new string[] {scopeID.ToString(), firstName, lastName}); + UserAccountData[] d; + + if (scopeID != UUID.Zero) + { + d = m_Database.Get( + new string[] {"ScopeID", "FirstName", "LastName"}, + new string[] {scopeID.ToString(), firstName, lastName}); + } + else + { + d = m_Database.Get( + new string[] {"FirstName", "LastName"}, + new string[] {firstName, lastName}); + } if (d.Length < 1) return null; -- cgit v1.1 From 3507005d9decdbf579fb2b7b9928a7d97bd6cf5b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 01:16:16 +0000 Subject: Remove CreateUserAccount. Rename SetUserAccount to StoreUserAccount. Implement the fetch operations fully. Rename one last UserService file to UserAccountService --- .../UserAccountService/UserAccountService.cs | 82 ++++++++++++++++++---- 1 file changed, 67 insertions(+), 15 deletions(-) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 0270f9d..706da84 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -62,33 +62,85 @@ namespace OpenSim.Services.UserAccountService if (d.Length < 1) return null; + return MakeUserAccount(d[0]); + } + + private UserAccount MakeUserAccount(UserAccountData d) + { UserAccount u = new UserAccount(); - u.FirstName = d[0].FirstName; - u.LastName = d[0].LastName; - u.PrincipalID = d[0].PrincipalID; - u.ScopeID = d[0].ScopeID; - u.Email = d[0].Data["Email"].ToString(); - u.Created = Convert.ToInt32(d[0].Data["Created"].ToString()); + u.FirstName = d.FirstName; + u.LastName = d.LastName; + u.PrincipalID = d.PrincipalID; + u.ScopeID = d.ScopeID; + u.Email = d.Data["Email"].ToString(); + u.Created = Convert.ToInt32(d.Data["Created"].ToString()); - return null; + string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '}); + u.ServiceURLs = new Dictionary(); + + foreach(string url in URLs) + { + string[] parts = url.Split(new char[] {'='}); + + if (parts.Length != 2) + continue; + + string name = System.Web.HttpUtility.UrlDecode(parts[0]); + string val = System.Web.HttpUtility.UrlDecode(parts[1]); + + u.ServiceURLs[name] = val; + } + + return u; } public UserAccount GetUserAccount(UUID scopeID, string email) { - return null; + UserAccountData[] d; + + if (scopeID != UUID.Zero) + { + d = m_Database.Get( + new string[] {"ScopeID", "Email"}, + new string[] {scopeID.ToString(), email}); + } + else + { + d = m_Database.Get( + new string[] {"Email"}, + new string[] {email}); + } + + if (d.Length < 1) + return null; + + return MakeUserAccount(d[0]); } - public UserAccount GetUserAccount(UUID scopeID, UUID userID) + public UserAccount GetUserAccount(UUID scopeID, UUID principalID) { - return null; - } + UserAccountData[] d; - public bool SetUserAccount(UserAccount data) - { - return false; + if (scopeID != UUID.Zero) + { + d = m_Database.Get( + new string[] {"ScopeID", "PrincipalID"}, + new string[] {scopeID.ToString(), principalID.ToString()}); + } + else + { + d = m_Database.Get( + new string[] {"PrincipalID"}, + new string[] {principalID.ToString()}); + } + + if (d.Length < 1) + return null; + + return MakeUserAccount(d[0]); } - public bool CreateUserAccount(UserAccount data) + public bool StoreUserAccount(UserAccount data) { return false; } -- cgit v1.1 From 99ad7aac7f854eaae075e93880c39796183ba7e4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 01:34:03 +0000 Subject: Implement saving user account data --- .../UserAccountService/UserAccountService.cs | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 706da84..2954589 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -142,7 +142,28 @@ namespace OpenSim.Services.UserAccountService public bool StoreUserAccount(UserAccount data) { - return false; + UserAccountData d = new UserAccountData(); + + d.FirstName = data.FirstName; + d.LastName = data.LastName; + d.PrincipalID = data.PrincipalID; + d.ScopeID = data.ScopeID; + d.Data = new Dictionary(); + d.Data["Email"] = data.Email; + d.Data["Created"] = data.Created.ToString(); + + List parts = new List(); + + foreach (KeyValuePair kvp in data.ServiceURLs) + { + string key = System.Web.HttpUtility.UrlEncode(kvp.Key); + string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); + parts.Add(key + "=" + val); + } + + d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray()); + + return m_Database.Store(d); } public List GetUserAccounts(UUID scopeID, string query) -- cgit v1.1 From 01f6aee020eddb46893cbfbcf3b1e114a85ac261 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 02:26:00 +0000 Subject: Implement avatar picker queries --- OpenSim/Services/UserAccountService/UserAccountService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 2954589..c14651d 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -168,7 +168,17 @@ namespace OpenSim.Services.UserAccountService public List GetUserAccounts(UUID scopeID, string query) { - return null; + UserAccountData[] d = m_Database.GetUsers(scopeID, query); + + if (d == null) + return new List(); + + List ret = new List(); + + foreach (UserAccountData data in d) + ret.Add(MakeUserAccount(data)); + + return ret; } } } -- cgit v1.1 From 25fdbd6cbcfc857c444042745d7d4fa8e495a982 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 9 Jan 2010 09:09:32 -0800 Subject: Less refs to UserProfileCacheService. Compiles but likely doesn't run. --- .../UserAccountService/UserAccountService.cs | 107 +++++++++++++++++---- 1 file changed, 88 insertions(+), 19 deletions(-) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index c14651d..dacfa51 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -29,6 +29,7 @@ using System; using System.Reflection; using Nini.Config; using OpenSim.Data; +using OpenSim.Framework.Console; using OpenSim.Services.Interfaces; using System.Collections.Generic; using OpenMetaverse; @@ -37,10 +38,17 @@ namespace OpenSim.Services.UserAccountService { public class UserAccountService : UserAccountServiceBase, IUserAccountService { - public UserAccountService(IConfigSource config) : base(config) + public UserAccountService(IConfigSource config) + : base(config) { + MainConsole.Instance.Commands.AddCommand("UserService", false, + "create user", + "create user [ [ [ [ []]]]]", + "Create a new user", HandleCreateUser); } + #region IUserAccountService + public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) { @@ -49,14 +57,14 @@ namespace OpenSim.Services.UserAccountService if (scopeID != UUID.Zero) { d = m_Database.Get( - new string[] {"ScopeID", "FirstName", "LastName"}, - new string[] {scopeID.ToString(), firstName, lastName}); + new string[] { "ScopeID", "FirstName", "LastName" }, + new string[] { scopeID.ToString(), firstName, lastName }); } else { d = m_Database.Get( - new string[] {"FirstName", "LastName"}, - new string[] {firstName, lastName}); + new string[] { "FirstName", "LastName" }, + new string[] { firstName, lastName }); } if (d.Length < 1) @@ -75,12 +83,12 @@ namespace OpenSim.Services.UserAccountService u.Email = d.Data["Email"].ToString(); u.Created = Convert.ToInt32(d.Data["Created"].ToString()); - string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '}); + string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' }); u.ServiceURLs = new Dictionary(); - foreach(string url in URLs) + foreach (string url in URLs) { - string[] parts = url.Split(new char[] {'='}); + string[] parts = url.Split(new char[] { '=' }); if (parts.Length != 2) continue; @@ -101,14 +109,14 @@ namespace OpenSim.Services.UserAccountService if (scopeID != UUID.Zero) { d = m_Database.Get( - new string[] {"ScopeID", "Email"}, - new string[] {scopeID.ToString(), email}); + new string[] { "ScopeID", "Email" }, + new string[] { scopeID.ToString(), email }); } else { d = m_Database.Get( - new string[] {"Email"}, - new string[] {email}); + new string[] { "Email" }, + new string[] { email }); } if (d.Length < 1) @@ -116,7 +124,7 @@ namespace OpenSim.Services.UserAccountService return MakeUserAccount(d[0]); } - + public UserAccount GetUserAccount(UUID scopeID, UUID principalID) { UserAccountData[] d; @@ -124,14 +132,14 @@ namespace OpenSim.Services.UserAccountService if (scopeID != UUID.Zero) { d = m_Database.Get( - new string[] {"ScopeID", "PrincipalID"}, - new string[] {scopeID.ToString(), principalID.ToString()}); + new string[] { "ScopeID", "PrincipalID" }, + new string[] { scopeID.ToString(), principalID.ToString() }); } else { d = m_Database.Get( - new string[] {"PrincipalID"}, - new string[] {principalID.ToString()}); + new string[] { "PrincipalID" }, + new string[] { principalID.ToString() }); } if (d.Length < 1) @@ -148,13 +156,13 @@ namespace OpenSim.Services.UserAccountService d.LastName = data.LastName; d.PrincipalID = data.PrincipalID; d.ScopeID = data.ScopeID; - d.Data = new Dictionary(); + d.Data = new Dictionary(); d.Data["Email"] = data.Email; d.Data["Created"] = data.Created.ToString(); List parts = new List(); - foreach (KeyValuePair kvp in data.ServiceURLs) + foreach (KeyValuePair kvp in data.ServiceURLs) { string key = System.Web.HttpUtility.UrlEncode(kvp.Key); string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); @@ -180,5 +188,66 @@ namespace OpenSim.Services.UserAccountService return ret; } + + #endregion + + #region Console commands + /// + /// Create a new user + /// + /// string array with parameters: firstname, lastname, password, locationX, locationY, email + protected void HandleCreateUser(string module, string[] cmdparams) + { + string firstName; + string lastName; + string password; + string email; + uint regX = 1000; + uint regY = 1000; + + // IConfig standalone; + // if ((standalone = m_config.Source.Configs["StandAlone"]) != null) + // { + // regX = (uint)standalone.GetInt("default_location_x", (int)regX); + // regY = (uint)standalone.GetInt("default_location_y", (int)regY); + // } + + + // if (cmdparams.Length < 3) + // firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); + // else firstName = cmdparams[2]; + + // if (cmdparams.Length < 4) + // lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); + // else lastName = cmdparams[3]; + + // if (cmdparams.Length < 5) + // password = MainConsole.Instance.PasswdPrompt("Password"); + // else password = cmdparams[4]; + + // if (cmdparams.Length < 6) + // regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); + // else regX = Convert.ToUInt32(cmdparams[5]); + + // if (cmdparams.Length < 7) + // regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); + // else regY = Convert.ToUInt32(cmdparams[6]); + + // if (cmdparams.Length < 8) + // email = MainConsole.Instance.CmdPrompt("Email", ""); + // else email = cmdparams[7]; + + // if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName)) + // { + // m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY); + // } + // else + // { + // m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName); + // } + //} + + } + #endregion } } -- cgit v1.1 From 96ecdcf9c5ba35e589a599ad37cc6ce1a83f46f1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 9 Jan 2010 18:04:50 -0800 Subject: * Added SetPassword to IAuthenticationService. * Added create user command to UserAccountService. Works. * Deleted create user command from OpenSim. --- .../UserAccountService/UserAccountService.cs | 145 ++++++++++++++------- 1 file changed, 95 insertions(+), 50 deletions(-) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index dacfa51..8f78813 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -26,25 +26,58 @@ */ using System; +using System.Collections.Generic; using System.Reflection; using Nini.Config; using OpenSim.Data; -using OpenSim.Framework.Console; using OpenSim.Services.Interfaces; -using System.Collections.Generic; +using OpenSim.Framework.Console; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + using OpenMetaverse; +using log4net; namespace OpenSim.Services.UserAccountService { public class UserAccountService : UserAccountServiceBase, IUserAccountService { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static UserAccountService m_RootInstance; + + protected IGridService m_GridService; + protected IAuthenticationService m_AuthenticationService; + protected IPresenceService m_PresenceService; + public UserAccountService(IConfigSource config) : base(config) { - MainConsole.Instance.Commands.AddCommand("UserService", false, - "create user", - "create user [ [ [ [ []]]]]", - "Create a new user", HandleCreateUser); + IConfig userConfig = config.Configs["UserAccountService"]; + if (userConfig == null) + throw new Exception("No UserAccountService configuration"); + + // In case there are several instances of this class in the same process, + // the console commands are only registered for the root instance + if (m_RootInstance == null) + { + m_RootInstance = this; + string gridServiceDll = userConfig.GetString("GridService", string.Empty); + if (gridServiceDll != string.Empty) + m_GridService = LoadPlugin(gridServiceDll, new Object[] { config }); + + string authServiceDll = userConfig.GetString("AuthenticationService", string.Empty); + if (authServiceDll != string.Empty) + m_AuthenticationService = LoadPlugin(authServiceDll, new Object[] { config }); + + string presenceServiceDll = userConfig.GetString("PresenceService", string.Empty); + if (presenceServiceDll != string.Empty) + m_PresenceService = LoadPlugin(presenceServiceDll, new Object[] { config }); + + MainConsole.Instance.Commands.AddCommand("UserService", false, + "create user", + "create user [ [ [ []]]]", + "Create a new user", HandleCreateUser); + } + } #region IUserAccountService @@ -202,52 +235,64 @@ namespace OpenSim.Services.UserAccountService string lastName; string password; string email; - uint regX = 1000; - uint regY = 1000; - - // IConfig standalone; - // if ((standalone = m_config.Source.Configs["StandAlone"]) != null) - // { - // regX = (uint)standalone.GetInt("default_location_x", (int)regX); - // regY = (uint)standalone.GetInt("default_location_y", (int)regY); - // } - - - // if (cmdparams.Length < 3) - // firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); - // else firstName = cmdparams[2]; - - // if (cmdparams.Length < 4) - // lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); - // else lastName = cmdparams[3]; - - // if (cmdparams.Length < 5) - // password = MainConsole.Instance.PasswdPrompt("Password"); - // else password = cmdparams[4]; - - // if (cmdparams.Length < 6) - // regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); - // else regX = Convert.ToUInt32(cmdparams[5]); - - // if (cmdparams.Length < 7) - // regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); - // else regY = Convert.ToUInt32(cmdparams[6]); - - // if (cmdparams.Length < 8) - // email = MainConsole.Instance.CmdPrompt("Email", ""); - // else email = cmdparams[7]; - - // if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName)) - // { - // m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY); - // } - // else - // { - // m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName); - // } - //} + + if (cmdparams.Length < 3) + firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); + else firstName = cmdparams[2]; + + if (cmdparams.Length < 4) + lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); + else lastName = cmdparams[3]; + + if (cmdparams.Length < 5) + password = MainConsole.Instance.PasswdPrompt("Password"); + else password = cmdparams[4]; + + if (cmdparams.Length < 6) + email = MainConsole.Instance.CmdPrompt("Email", ""); + else email = cmdparams[5]; + + UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); + if (null == account) + { + account = new UserAccount(UUID.Zero, firstName, lastName, email); + if (StoreUserAccount(account)) + { + bool success = false; + if (m_AuthenticationService != null) + success = m_AuthenticationService.SetPassword(account.PrincipalID, password); + if (!success) + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", + firstName, lastName); + + GridRegion home = null; + if (m_GridService != null) + { + List defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero); + if (defaultRegions != null && defaultRegions.Count >= 1) + home = defaultRegions[0]; + + if (m_PresenceService != null && home != null) + m_PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + else + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", + firstName, lastName); + + } + else + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", + firstName, lastName); + + m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); + } + } + else + { + m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); + } } #endregion + } } -- cgit v1.1 From 7cb66de2e022d1013eacb43dc0186a575a19a5c6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 9 Jan 2010 18:16:14 -0800 Subject: * Moved command reset password from OpenSim to UserAccountService. --- .../UserAccountService/UserAccountService.cs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 8f78813..90077d8 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -76,6 +76,10 @@ namespace OpenSim.Services.UserAccountService "create user", "create user [ [ [ []]]]", "Create a new user", HandleCreateUser); + MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password", + "reset user password [ [ []]]", + "Reset a user password", HandleResetUserPassword); + } } @@ -292,6 +296,39 @@ namespace OpenSim.Services.UserAccountService } } + + protected void HandleResetUserPassword(string module, string[] cmdparams) + { + string firstName; + string lastName; + string newPassword; + + if (cmdparams.Length < 4) + firstName = MainConsole.Instance.CmdPrompt("First name"); + else firstName = cmdparams[3]; + + if (cmdparams.Length < 5) + lastName = MainConsole.Instance.CmdPrompt("Last name"); + else lastName = cmdparams[4]; + + if (cmdparams.Length < 6) + newPassword = MainConsole.Instance.PasswdPrompt("New password"); + else newPassword = cmdparams[5]; + + UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); + if (account == null) + m_log.ErrorFormat("[USER ACCOUNT SERVICE]: No such user"); + + bool success = false; + if (m_AuthenticationService != null) + success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword); + if (!success) + m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Unable to reset password for account {0} {1}.", + firstName, lastName); + else + m_log.InfoFormat("[USER ACCOUNT SERVICE]: Password reset for user {0} {1}", firstName, lastName); + } + #endregion } -- cgit v1.1 From 7356860b487febd12c2e0de2f009a6df9ea0aeec Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 09:17:30 -0800 Subject: Several more buglets removed. --- OpenSim/Services/UserAccountService/UserAccountService.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 90077d8..a1dbb1e 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -119,6 +119,10 @@ namespace OpenSim.Services.UserAccountService u.ScopeID = d.ScopeID; u.Email = d.Data["Email"].ToString(); u.Created = Convert.ToInt32(d.Data["Created"].ToString()); + if (d.Data["UserTitle"] != null) + u.UserTitle = d.Data["UserTitle"].ToString(); + else + u.UserTitle = string.Empty; string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' }); u.ServiceURLs = new Dictionary(); -- cgit v1.1 From d939668d6a54bb25cbc56ec840058c08992fe536 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 10:15:14 -0800 Subject: Bug fix in create user: create inventory was missing. --- OpenSim/Services/UserAccountService/UserAccountService.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index a1dbb1e..c55013f 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -47,6 +47,7 @@ namespace OpenSim.Services.UserAccountService protected IGridService m_GridService; protected IAuthenticationService m_AuthenticationService; protected IPresenceService m_PresenceService; + protected IInventoryService m_InventoryService; public UserAccountService(IConfigSource config) : base(config) @@ -72,6 +73,10 @@ namespace OpenSim.Services.UserAccountService if (presenceServiceDll != string.Empty) m_PresenceService = LoadPlugin(presenceServiceDll, new Object[] { config }); + string invServiceDll = userConfig.GetString("InventoryService", string.Empty); + if (invServiceDll != string.Empty) + m_InventoryService = LoadPlugin(invServiceDll, new Object[] { config }); + MainConsole.Instance.Commands.AddCommand("UserService", false, "create user", "create user [ [ [ []]]]", @@ -291,6 +296,13 @@ namespace OpenSim.Services.UserAccountService m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", firstName, lastName); + if (m_InventoryService != null) + success = m_InventoryService.CreateUserInventory(account.PrincipalID); + if (!success) + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", + firstName, lastName); + + m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); } } -- cgit v1.1 From 24ab3e2d5ff913a2f35c320f3a3092052bd80e0d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 14:16:05 -0800 Subject: Fixed mixed-case use in UserAccounts table. Plus some more sanity checks on filling out the UserAccount data. --- .../UserAccountService/UserAccountService.cs | 32 ++++++++++++++-------- .../UserAccountService/UserAccountServiceBase.cs | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index c55013f..ffb9cca 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -122,28 +122,36 @@ namespace OpenSim.Services.UserAccountService u.LastName = d.LastName; u.PrincipalID = d.PrincipalID; u.ScopeID = d.ScopeID; - u.Email = d.Data["Email"].ToString(); + if (d.Data.ContainsKey("Email") && d.Data["Email"] != null) + u.Email = d.Data["Email"].ToString(); + else + u.Email = string.Empty; u.Created = Convert.ToInt32(d.Data["Created"].ToString()); - if (d.Data["UserTitle"] != null) + if (d.Data.ContainsKey("UserTitle") && d.Data["UserTitle"] != null) u.UserTitle = d.Data["UserTitle"].ToString(); else u.UserTitle = string.Empty; - string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' }); - u.ServiceURLs = new Dictionary(); - - foreach (string url in URLs) + if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null) { - string[] parts = url.Split(new char[] { '=' }); + string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' }); + u.ServiceURLs = new Dictionary(); + + foreach (string url in URLs) + { + string[] parts = url.Split(new char[] { '=' }); - if (parts.Length != 2) - continue; + if (parts.Length != 2) + continue; - string name = System.Web.HttpUtility.UrlDecode(parts[0]); - string val = System.Web.HttpUtility.UrlDecode(parts[1]); + string name = System.Web.HttpUtility.UrlDecode(parts[0]); + string val = System.Web.HttpUtility.UrlDecode(parts[1]); - u.ServiceURLs[name] = val; + u.ServiceURLs[name] = val; + } } + else + u.ServiceURLs = new Dictionary(); return u; } diff --git a/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs index 70ed594..c1a7b76 100644 --- a/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs +++ b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs @@ -42,7 +42,7 @@ namespace OpenSim.Services.UserAccountService { string dllName = String.Empty; string connString = String.Empty; - string realm = "useraccounts"; + string realm = "UserAccounts"; IConfig dbConfig = config.Configs["DatabaseService"]; if (dbConfig != null) -- cgit v1.1 From 2e7aa387f7a705079df4b534978c0f134591eea9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Feb 2010 19:11:48 -0800 Subject: One more test running. --- .../Services/UserAccountService/UserAccountService.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index ffb9cca..e498bd5 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -77,13 +77,16 @@ namespace OpenSim.Services.UserAccountService if (invServiceDll != string.Empty) m_InventoryService = LoadPlugin(invServiceDll, new Object[] { config }); - MainConsole.Instance.Commands.AddCommand("UserService", false, - "create user", - "create user [ [ [ []]]]", - "Create a new user", HandleCreateUser); - MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password", - "reset user password [ [ []]]", - "Reset a user password", HandleResetUserPassword); + if (MainConsole.Instance != null) + { + MainConsole.Instance.Commands.AddCommand("UserService", false, + "create user", + "create user [ [ [ []]]]", + "Create a new user", HandleCreateUser); + MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password", + "reset user password [ [ []]]", + "Reset a user password", HandleResetUserPassword); + } } -- cgit v1.1