2007-03-22 10:11:15 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using libsecondlife;
|
|
|
|
using OpenSim.Framework.Utilities;
|
|
|
|
using OpenSim.Framework.Inventory;
|
|
|
|
|
|
|
|
namespace OpenSim.Framework.User
|
|
|
|
{
|
|
|
|
public class UserProfileManagerBase
|
|
|
|
{
|
|
|
|
|
|
|
|
public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
|
|
|
|
|
|
|
|
public UserProfileManagerBase()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void InitUserProfiles()
|
|
|
|
{
|
|
|
|
// TODO: need to load from database
|
|
|
|
}
|
|
|
|
|
|
|
|
public UserProfile GetProfileByName(string firstname, string lastname)
|
|
|
|
{
|
|
|
|
foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
|
|
|
|
{
|
|
|
|
if ((UserProfiles[UUID].firstname == firstname) && (UserProfiles[UUID].lastname == lastname))
|
|
|
|
{
|
|
|
|
return UserProfiles[UUID];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID)
|
|
|
|
{
|
|
|
|
return UserProfiles[ProfileLLUUID];
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual bool AuthenticateUser(string firstname, string lastname, string passwd)
|
|
|
|
{
|
|
|
|
UserProfile TheUser = GetProfileByName(firstname, lastname);
|
2007-03-28 18:10:52 +00:00
|
|
|
passwd = passwd.Remove(0, 3); //remove $1$
|
2007-03-22 10:11:15 +00:00
|
|
|
if (TheUser != null)
|
|
|
|
{
|
|
|
|
if (TheUser.MD5passwd == passwd)
|
|
|
|
{
|
2007-03-28 18:10:52 +00:00
|
|
|
Console.WriteLine("UserProfile - authorised ");
|
2007-03-22 10:11:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-28 18:10:52 +00:00
|
|
|
Console.WriteLine("UserProfile - not authorised, password not match "+ TheUser.MD5passwd +" and "+ passwd);
|
2007-03-22 10:11:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-28 18:10:52 +00:00
|
|
|
Console.WriteLine("UserProfile - not authorised , unkown: "+ firstname +" , " + lastname);
|
2007-03-22 10:11:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetGod(LLUUID GodID)
|
|
|
|
{
|
|
|
|
this.UserProfiles[GodID].IsGridGod = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd)
|
|
|
|
{
|
2007-03-28 18:10:52 +00:00
|
|
|
Console.WriteLine("creating new profile for : " + firstname + " , " + lastname);
|
2007-03-22 10:11:15 +00:00
|
|
|
UserProfile newprofile = new UserProfile();
|
|
|
|
newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
|
|
|
|
newprofile.firstname = firstname;
|
|
|
|
newprofile.lastname = lastname;
|
|
|
|
newprofile.MD5passwd = MD5passwd;
|
|
|
|
newprofile.UUID = LLUUID.Random();
|
2007-03-28 18:10:52 +00:00
|
|
|
newprofile.Inventory.CreateRootFolder(newprofile.UUID, true);
|
2007-03-22 10:11:15 +00:00
|
|
|
this.UserProfiles.Add(newprofile.UUID, newprofile);
|
|
|
|
return newprofile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual AgentInventory GetUsersInventory(LLUUID agentID)
|
|
|
|
{
|
|
|
|
UserProfile user = this.GetProfileByLLUUID(agentID);
|
|
|
|
if (user != null)
|
|
|
|
{
|
|
|
|
return user.Inventory;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|