Put out a more comprehensible message when user authentication fails than the current NullReferenceException based one
parent
0047522859
commit
019d662606
|
@ -37,6 +37,9 @@ using OpenSim.Framework.Console;
|
||||||
|
|
||||||
namespace OpenSim.Framework.UserManagement
|
namespace OpenSim.Framework.UserManagement
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for user management (create, read, etc)
|
||||||
|
/// </summary>
|
||||||
public abstract class UserManagerBase : IUserService
|
public abstract class UserManagerBase : IUserService
|
||||||
{
|
{
|
||||||
public UserConfig _config;
|
public UserConfig _config;
|
||||||
|
@ -84,22 +87,23 @@ namespace OpenSim.Framework.UserManagement
|
||||||
/// Loads a user profile from a database by UUID
|
/// Loads a user profile from a database by UUID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">The target UUID</param>
|
/// <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)
|
public UserProfileData GetUserProfile(LLUUID uuid)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
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);
|
profile.currentAgent = getUserAgent(profile.UUID);
|
||||||
return profile;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -123,55 +127,28 @@ namespace OpenSim.Framework.UserManagement
|
||||||
return pickerlist;
|
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>
|
/// <summary>
|
||||||
/// Loads a user profile by name
|
/// Loads a user profile by name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fname">First name</param>
|
/// <param name="fname">First name</param>
|
||||||
/// <param name="lname">Last 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)
|
public UserProfileData GetUserProfile(string fname, string lname)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
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);
|
profile.currentAgent = getUserAgent(profile.UUID);
|
||||||
|
|
||||||
return profile;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,16 +61,6 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword);
|
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>
|
/// <summary>
|
||||||
/// Searches the database for a specified user profile by name components
|
/// Searches the database for a specified user profile by name components
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -188,11 +178,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
return returnlist;
|
return returnlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// See IUserData
|
||||||
/// Searches the database for a specified user profile by UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The account ID</param>
|
|
||||||
/// <returns>The users profile</returns>
|
|
||||||
public UserProfileData GetUserByUUID(LLUUID uuid)
|
public UserProfileData GetUserByUUID(LLUUID uuid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -113,23 +113,8 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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>
|
// see IUserData
|
||||||
/// 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>
|
|
||||||
public UserProfileData GetUserByName(string user, string last)
|
public UserProfileData GetUserByName(string user, string last)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -244,11 +229,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
return returnlist;
|
return returnlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// see IUserData
|
||||||
/// Searches the database for a specified user profile by UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The account ID</param>
|
|
||||||
/// <returns>The users profile</returns>
|
|
||||||
public UserProfileData GetUserByUUID(LLUUID uuid)
|
public UserProfileData GetUserByUUID(LLUUID uuid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -72,11 +72,7 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// see IUserData
|
||||||
/// Loads a specified user profile from a UUID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuid">The user's UUID</param>
|
|
||||||
/// <returns>A user profile</returns>
|
|
||||||
public UserProfileData GetUserByUUID(LLUUID uuid)
|
public UserProfileData GetUserByUUID(LLUUID uuid)
|
||||||
{
|
{
|
||||||
lock (ds)
|
lock (ds)
|
||||||
|
@ -99,22 +95,7 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// see IUserData
|
||||||
/// 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>
|
|
||||||
public UserProfileData GetUserByName(string fname, string lname)
|
public UserProfileData GetUserByName(string fname, string lname)
|
||||||
{
|
{
|
||||||
string select = "surname = '" + lname + "' and username = '" + fname + "'";
|
string select = "surname = '" + lname + "' and username = '" + fname + "'";
|
||||||
|
|
|
@ -38,17 +38,10 @@ namespace OpenSim.Framework
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a user profile from a database via their UUID
|
/// Returns a user profile from a database via their UUID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user">The accounts UUID</param>
|
/// <param name="user">The user's UUID</param>
|
||||||
/// <returns>The user data profile</returns>
|
/// <returns>The user data profile. Returns null if no user is found</returns>
|
||||||
UserProfileData GetUserByUUID(LLUUID user);
|
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>
|
/// <summary>
|
||||||
/// Returns a users profile by searching their username parts
|
/// Returns a users profile by searching their username parts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace OpenSim.Framework
|
||||||
public interface IUserService
|
public interface IUserService
|
||||||
{
|
{
|
||||||
UserProfileData GetUserProfile(string firstName, string lastName);
|
UserProfileData GetUserProfile(string firstName, string lastName);
|
||||||
UserProfileData GetUserProfile(string name);
|
//UserProfileData GetUserProfile(string name);
|
||||||
UserProfileData GetUserProfile(LLUUID userId);
|
UserProfileData GetUserProfile(LLUUID userId);
|
||||||
void clearUserAgent(LLUUID avatarID);
|
void clearUserAgent(LLUUID avatarID);
|
||||||
List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query);
|
List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query);
|
||||||
|
|
|
@ -31,6 +31,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.UserManagement;
|
using OpenSim.Framework.UserManagement;
|
||||||
using InventoryFolder=OpenSim.Framework.InventoryFolder;
|
using InventoryFolder=OpenSim.Framework.InventoryFolder;
|
||||||
|
|
||||||
|
@ -72,7 +73,8 @@ namespace OpenSim.Region.Communications.Local
|
||||||
if (!authUsers)
|
if (!authUsers)
|
||||||
{
|
{
|
||||||
//no current user account so make one
|
//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);
|
m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
|
||||||
|
|
||||||
profile = m_userManager.GetUserProfile(firstname, lastname);
|
profile = m_userManager.GetUserProfile(firstname, lastname);
|
||||||
|
@ -91,12 +93,14 @@ namespace OpenSim.Region.Communications.Local
|
||||||
if (!authUsers)
|
if (!authUsers)
|
||||||
{
|
{
|
||||||
//for now we will accept any password in sandbox mode
|
//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;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Authenticating " + profile.username + " " + profile.surname);
|
MainLog.Instance.Notice(
|
||||||
|
"LOGIN", "Authenticating " + profile.username + " " + profile.surname);
|
||||||
|
|
||||||
password = password.Remove(0, 3); //remove $1$
|
password = password.Remove(0, 3); //remove $1$
|
||||||
|
|
||||||
|
@ -153,7 +157,7 @@ namespace OpenSim.Region.Communications.Local
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("not found region " + currentRegion);
|
MainLog.Instance.Warn("LOGIN", "Not found region " + currentRegion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[mysqlconnection]
|
[mysqlconnection]
|
||||||
hostname=localhost
|
hostname=localhost
|
||||||
database=database
|
database=opensim
|
||||||
username=username
|
username=root
|
||||||
password=password
|
password=passw0rd
|
||||||
pooling=false
|
pooling=false
|
||||||
port=3306
|
port=3306
|
||||||
|
|
Loading…
Reference in New Issue