Put out a more comprehensible message when user authentication fails than the current NullReferenceException based one

afrisby
Justin Clarke Casey 2007-12-15 21:58:07 +00:00
parent 0047522859
commit 019d662606
8 changed files with 40 additions and 118 deletions

View File

@ -37,6 +37,9 @@ using OpenSim.Framework.Console;
namespace OpenSim.Framework.UserManagement
{
/// <summary>
/// Base class for user management (create, read, etc)
/// </summary>
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
/// </summary>
/// <param name="uuid">The target UUID</param>
/// <returns>A user profile</returns>
/// <returns>A user profile. Returns null if no user profile is found.</returns>
public UserProfileData GetUserProfile(LLUUID uuid)
{
foreach (KeyValuePair<string, IUserData> 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;
}
/// <summary>
/// Loads a user profile by name
/// </summary>
/// <param name="name">The target name</param>
/// <returns>A user profile</returns>
public UserProfileData GetUserProfile(string name)
{
foreach (KeyValuePair<string, IUserData> 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;
}
/// <summary>
/// Loads a user profile by name
/// </summary>
/// <param name="fname">First name</param>
/// <param name="lname">Last name</param>
/// <returns>A user profile</returns>
/// <returns>A user profile. Returns null if no profile is found</returns>
public UserProfileData GetUserProfile(string fname, string lname)
{
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
{
try
UserProfileData profile = plugin.Value.GetUserByName(fname, lname);
if (profile != null)
{
UserProfileData profile = plugin.Value.GetUserByName(fname, lname);
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;
}

View File

@ -61,16 +61,6 @@ namespace OpenSim.Framework.Data.MSSQL
database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword);
}
/// <summary>
/// Searches the database for a specified user profile
/// </summary>
/// <param name="name">The account name of the user</param>
/// <returns>A user profile</returns>
public UserProfileData GetUserByName(string name)
{
return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]);
}
/// <summary>
/// Searches the database for a specified user profile by name components
/// </summary>
@ -188,11 +178,7 @@ namespace OpenSim.Framework.Data.MSSQL
return returnlist;
}
/// <summary>
/// Searches the database for a specified user profile by UUID
/// </summary>
/// <param name="uuid">The account ID</param>
/// <returns>The users profile</returns>
// See IUserData
public UserProfileData GetUserByUUID(LLUUID uuid)
{
try

View File

@ -113,23 +113,8 @@ namespace OpenSim.Framework.Data.MySQL
}
#endregion
/// <summary>
/// Searches the database for a specified user profile
/// </summary>
/// <param name="name">The account name of the user</param>
/// <returns>A user profile</returns>
public UserProfileData GetUserByName(string name)
{
return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]);
}
/// <summary>
/// Searches the database for a specified user profile by name components
/// </summary>
/// <param name="user">The first part of the account name</param>
/// <param name="last">The second part of the account name</param>
/// <returns>A user profile</returns>
// see IUserData
public UserProfileData GetUserByName(string user, string last)
{
try
@ -244,11 +229,7 @@ namespace OpenSim.Framework.Data.MySQL
return returnlist;
}
/// <summary>
/// Searches the database for a specified user profile by UUID
/// </summary>
/// <param name="uuid">The account ID</param>
/// <returns>The users profile</returns>
// see IUserData
public UserProfileData GetUserByUUID(LLUUID uuid)
{
try

View File

@ -72,11 +72,7 @@ namespace OpenSim.Framework.Data.SQLite
return;
}
/// <summary>
/// Loads a specified user profile from a UUID
/// </summary>
/// <param name="uuid">The user's UUID</param>
/// <returns>A user profile</returns>
// see IUserData
public UserProfileData GetUserByUUID(LLUUID uuid)
{
lock (ds)
@ -99,22 +95,7 @@ namespace OpenSim.Framework.Data.SQLite
}
}
/// <summary>
/// Returns a user by searching for its name
/// </summary>
/// <param name="name">The user's account name</param>
/// <returns>A matching user profile</returns>
public UserProfileData GetUserByName(string name)
{
return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]);
}
/// <summary>
/// Returns a user by searching for its name
/// </summary>
/// <param name="fname">The first part of the user's account name</param>
/// <param name="lname">The second part of the user's account name</param>
/// <returns>A matching user profile</returns>
// see IUserData
public UserProfileData GetUserByName(string fname, string lname)
{
string select = "surname = '" + lname + "' and username = '" + fname + "'";

View File

@ -38,17 +38,10 @@ namespace OpenSim.Framework
/// <summary>
/// Returns a user profile from a database via their UUID
/// </summary>
/// <param name="user">The accounts UUID</param>
/// <returns>The user data profile</returns>
/// <param name="user">The user's UUID</param>
/// <returns>The user data profile. Returns null if no user is found</returns>
UserProfileData GetUserByUUID(LLUUID user);
/// <summary>
/// Returns a users profile by searching their username
/// </summary>
/// <param name="name">The users username</param>
/// <returns>The user data profile</returns>
UserProfileData GetUserByName(string name);
/// <summary>
/// Returns a users profile by searching their username parts
/// </summary>

View File

@ -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<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query);

View File

@ -31,6 +31,7 @@ using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.UserManagement;
using InventoryFolder=OpenSim.Framework.InventoryFolder;
@ -72,7 +73,8 @@ namespace OpenSim.Region.Communications.Local
if (!authUsers)
{
//no current user account so make one
Console.WriteLine("No User account found so creating a new one ");
MainLog.Instance.Notice("LOGIN", "No user account found so creating a new one.");
m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
profile = m_userManager.GetUserProfile(firstname, lastname);
@ -91,12 +93,14 @@ namespace OpenSim.Region.Communications.Local
if (!authUsers)
{
//for now we will accept any password in sandbox mode
Console.WriteLine("authorising user");
MainLog.Instance.Notice("LOGIN", "Authorising user (no actual password check)");
return true;
}
else
{
Console.WriteLine("Authenticating " + profile.username + " " + profile.surname);
MainLog.Instance.Notice(
"LOGIN", "Authenticating " + profile.username + " " + profile.surname);
password = password.Remove(0, 3); //remove $1$
@ -153,7 +157,7 @@ namespace OpenSim.Region.Communications.Local
}
else
{
Console.WriteLine("not found region " + currentRegion);
MainLog.Instance.Warn("LOGIN", "Not found region " + currentRegion);
}
}

View File

@ -1,7 +1,7 @@
[mysqlconnection]
hostname=localhost
database=database
username=username
password=password
database=opensim
username=root
password=passw0rd
pooling=false
port=3306
port=3306