From 019d6626068920283b700440e780c86c162ca7c6 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 15 Dec 2007 21:58:07 +0000 Subject: Put out a more comprehensible message when user authentication fails than the current NullReferenceException based one --- .../Framework/Communications/UserManagerBase.cs | 63 +++++++--------------- OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | 16 +----- OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 23 +------- OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 23 +------- OpenSim/Framework/IUserData.cs | 11 +--- OpenSim/Framework/IUserService.cs | 2 +- 6 files changed, 28 insertions(+), 110 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 0e5e782..a82a58d 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -37,6 +37,9 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.UserManagement { + /// + /// Base class for user management (create, read, etc) + /// public abstract class UserManagerBase : IUserService { public UserConfig _config; @@ -84,22 +87,23 @@ namespace OpenSim.Framework.UserManagement /// Loads a user profile from a database by UUID /// /// The target UUID - /// A user profile + /// A user profile. Returns null if no user profile is found. public UserProfileData GetUserProfile(LLUUID uuid) { foreach (KeyValuePair plugin in _plugins) { - try + UserProfileData profile = plugin.Value.GetUserByUUID(uuid); + + if (null != profile) { - UserProfileData profile = plugin.Value.GetUserByUUID(uuid); profile.currentAgent = getUserAgent(profile.UUID); return profile; - } - catch (Exception e) - { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } + } } + + MainLog.Instance.Notice( + "USERSTORAGE", + "Could not find user " + uuid.ToStringHyphenated() + " in persistent storage."); return null; } @@ -123,55 +127,28 @@ namespace OpenSim.Framework.UserManagement return pickerlist; } - - /// - /// Loads a user profile by name - /// - /// The target name - /// A user profile - public UserProfileData GetUserProfile(string name) - { - foreach (KeyValuePair plugin in _plugins) - { - try - { - UserProfileData profile = plugin.Value.GetUserByName(name); - profile.currentAgent = getUserAgent(profile.UUID); - return profile; - } - catch (Exception e) - { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } - } - - return null; - } - /// /// Loads a user profile by name /// /// First name /// Last name - /// A user profile + /// A user profile. Returns null if no profile is found public UserProfileData GetUserProfile(string fname, string lname) { foreach (KeyValuePair plugin in _plugins) { - try - { - UserProfileData profile = plugin.Value.GetUserByName(fname, lname); + UserProfileData profile = plugin.Value.GetUserByName(fname, lname); + if (profile != null) + { profile.currentAgent = getUserAgent(profile.UUID); - return profile; } - catch (Exception e) - { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); - } } - + + MainLog.Instance.Notice( + "USERSTORAGE", "Could not find user " + fname + " " + lname + " in persistent storage."); + return null; } diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs index c235e96..80b65c1 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs @@ -62,16 +62,6 @@ namespace OpenSim.Framework.Data.MSSQL } /// - /// Searches the database for a specified user profile - /// - /// The account name of the user - /// A user profile - public UserProfileData GetUserByName(string name) - { - return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]); - } - - /// /// Searches the database for a specified user profile by name components /// /// The first part of the account name @@ -188,11 +178,7 @@ namespace OpenSim.Framework.Data.MSSQL return returnlist; } - /// - /// Searches the database for a specified user profile by UUID - /// - /// The account ID - /// The users profile + // See IUserData public UserProfileData GetUserByUUID(LLUUID uuid) { try diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index e5cbe45..6a7cf49 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -113,23 +113,8 @@ namespace OpenSim.Framework.Data.MySQL } #endregion - - /// - /// Searches the database for a specified user profile - /// - /// The account name of the user - /// A user profile - public UserProfileData GetUserByName(string name) - { - return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]); - } - /// - /// Searches the database for a specified user profile by name components - /// - /// The first part of the account name - /// The second part of the account name - /// A user profile + // see IUserData public UserProfileData GetUserByName(string user, string last) { try @@ -244,11 +229,7 @@ namespace OpenSim.Framework.Data.MySQL return returnlist; } - /// - /// Searches the database for a specified user profile by UUID - /// - /// The account ID - /// The users profile + // see IUserData public UserProfileData GetUserByUUID(LLUUID uuid) { try diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index da27277..346febc 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs @@ -72,11 +72,7 @@ namespace OpenSim.Framework.Data.SQLite return; } - /// - /// Loads a specified user profile from a UUID - /// - /// The user's UUID - /// A user profile + // see IUserData public UserProfileData GetUserByUUID(LLUUID uuid) { lock (ds) @@ -99,22 +95,7 @@ namespace OpenSim.Framework.Data.SQLite } } - /// - /// Returns a user by searching for its name - /// - /// The user's account name - /// A matching user profile - public UserProfileData GetUserByName(string name) - { - return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]); - } - - /// - /// Returns a user by searching for its name - /// - /// The first part of the user's account name - /// The second part of the user's account name - /// A matching user profile + // see IUserData public UserProfileData GetUserByName(string fname, string lname) { string select = "surname = '" + lname + "' and username = '" + fname + "'"; diff --git a/OpenSim/Framework/IUserData.cs b/OpenSim/Framework/IUserData.cs index a32bf6c..0679a68 100644 --- a/OpenSim/Framework/IUserData.cs +++ b/OpenSim/Framework/IUserData.cs @@ -38,18 +38,11 @@ namespace OpenSim.Framework /// /// Returns a user profile from a database via their UUID /// - /// The accounts UUID - /// The user data profile + /// The user's UUID + /// The user data profile. Returns null if no user is found UserProfileData GetUserByUUID(LLUUID user); /// - /// Returns a users profile by searching their username - /// - /// The users username - /// The user data profile - UserProfileData GetUserByName(string name); - - /// /// Returns a users profile by searching their username parts /// /// Account firstname diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs index 298bde5..3440e30 100644 --- a/OpenSim/Framework/IUserService.cs +++ b/OpenSim/Framework/IUserService.cs @@ -33,7 +33,7 @@ namespace OpenSim.Framework public interface IUserService { UserProfileData GetUserProfile(string firstName, string lastName); - UserProfileData GetUserProfile(string name); + //UserProfileData GetUserProfile(string name); UserProfileData GetUserProfile(LLUUID userId); void clearUserAgent(LLUUID avatarID); List GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query); -- cgit v1.1