Inching ahead... This compiles, but very likely does not run.

slimupdates
Diva Canto 2010-01-08 10:43:34 -08:00
parent f11a97f12d
commit b63405c1a7
20 changed files with 670 additions and 1047 deletions

View File

@ -85,10 +85,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
MainServer.Instance = m_httpServer;
InitialiseCommsManager(openSim);
if (m_commsManager != null)
{
m_openSim.ApplicationRegistry.RegisterInterface<IUserService>(m_commsManager.UserService);
}
}
public void PostInitialise()
@ -107,10 +103,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
private void RegionCreated(IScene scene)
{
if (m_commsManager != null)
{
scene.RegisterModuleInterface<IUserService>(m_commsManager.UserService);
}
}
protected void InitialiseCommsManager(OpenSimBase openSim)

View File

@ -49,6 +49,8 @@ using OpenSim.Region.CoreModules.World.Terrain;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.ApplicationPlugins.RemoteController
{
@ -1032,30 +1034,37 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (requestData.Contains("user_email"))
email = (string)requestData["user_email"];
CachedUserInfo userInfo =
m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(firstname, lastname);
UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
if (null != userInfo)
throw new Exception(String.Format("Avatar {0} {1} already exists", firstname, lastname));
UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstname, lastname);
UUID userID =
m_app.CommunicationsManager.UserAdminService.AddUser(firstname, lastname,
passwd, email, regX, regY);
if (null != account)
throw new Exception(String.Format("Account {0} {1} already exists", firstname, lastname));
if (userID == UUID.Zero)
account = new UserAccount(scopeID, firstname, lastname, email);
// REFACTORING PROBLEM: no method to set the password!
bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account);
if (!success)
throw new Exception(String.Format("failed to create new user {0} {1}",
firstname, lastname));
GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID,
(int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize));
if (home == null)
m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstname, lastname);
// Establish the avatar's initial appearance
updateUserAppearance(responseData, requestData, userID);
updateUserAppearance(responseData, requestData, account.PrincipalID);
responseData["success"] = true;
responseData["avatar_uuid"] = userID.ToString();
responseData["avatar_uuid"] = account.PrincipalID.ToString();
response.Value = responseData;
m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID);
m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, account.PrincipalID);
}
catch (Exception e)
{
@ -1124,21 +1133,27 @@ namespace OpenSim.ApplicationPlugins.RemoteController
string firstname = (string) requestData["user_firstname"];
string lastname = (string) requestData["user_lastname"];
CachedUserInfo userInfo
= m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(firstname, lastname);
responseData["user_firstname"] = firstname;
responseData["user_lastname"] = lastname;
if (null == userInfo)
UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstname, lastname);
if (null == account)
{
responseData["success"] = false;
responseData["lastlogin"] = 0;
}
else
{
PresenceInfo[] pinfos = m_app.SceneManager.CurrentOrFirstScene.PresenceService.GetAgents(new string[] { account.PrincipalID.ToString() });
if (pinfos != null && pinfos.Length >= 1)
responseData["lastlogin"] = pinfos[0].Login;
else
responseData["lastlogin"] = 0;
responseData["success"] = true;
responseData["lastlogin"] = userInfo.UserProfile.LastLogin;
}
response.Value = responseData;
@ -1200,117 +1215,118 @@ namespace OpenSim.ApplicationPlugins.RemoteController
public XmlRpcResponse XmlRpcUpdateUserAccountMethod(XmlRpcRequest request, IPEndPoint remoteClient)
{
m_log.Info("[RADMIN]: UpdateUserAccount: new request");
m_log.Warn("[RADMIN]: This method needs update for 0.7");
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
lock (rslock)
{
try
{
Hashtable requestData = (Hashtable) request.Params[0];
//lock (rslock)
//{
// try
// {
// Hashtable requestData = (Hashtable) request.Params[0];
// check completeness
checkStringParameters(request, new string[] {
"password", "user_firstname",
"user_lastname"});
// // check completeness
// checkStringParameters(request, new string[] {
// "password", "user_firstname",
// "user_lastname"});
// check password
if (!String.IsNullOrEmpty(m_requiredPassword) &&
(string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");
// // check password
// if (!String.IsNullOrEmpty(m_requiredPassword) &&
// (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");
// do the job
string firstname = (string) requestData["user_firstname"];
string lastname = (string) requestData["user_lastname"];
// // do the job
// string firstname = (string) requestData["user_firstname"];
// string lastname = (string) requestData["user_lastname"];
string passwd = String.Empty;
uint? regX = null;
uint? regY = null;
uint? ulaX = null;
uint? ulaY = null;
uint? ulaZ = null;
uint? usaX = null;
uint? usaY = null;
uint? usaZ = null;
string aboutFirstLive = String.Empty;
string aboutAvatar = String.Empty;
// string passwd = String.Empty;
// uint? regX = null;
// uint? regY = null;
// uint? ulaX = null;
// uint? ulaY = null;
// uint? ulaZ = null;
// uint? usaX = null;
// uint? usaY = null;
// uint? usaZ = null;
// string aboutFirstLive = String.Empty;
// string aboutAvatar = String.Empty;
if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"];
if (requestData.ContainsKey("start_region_x"))
regX = Convert.ToUInt32((Int32) requestData["start_region_x"]);
if (requestData.ContainsKey("start_region_y"))
regY = Convert.ToUInt32((Int32) requestData["start_region_y"]);
// if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"];
// if (requestData.ContainsKey("start_region_x"))
// regX = Convert.ToUInt32((Int32) requestData["start_region_x"]);
// if (requestData.ContainsKey("start_region_y"))
// regY = Convert.ToUInt32((Int32) requestData["start_region_y"]);
if (requestData.ContainsKey("start_lookat_x"))
ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]);
if (requestData.ContainsKey("start_lookat_y"))
ulaY = Convert.ToUInt32((Int32) requestData["start_lookat_y"]);
if (requestData.ContainsKey("start_lookat_z"))
ulaZ = Convert.ToUInt32((Int32) requestData["start_lookat_z"]);
// if (requestData.ContainsKey("start_lookat_x"))
// ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]);
// if (requestData.ContainsKey("start_lookat_y"))
// ulaY = Convert.ToUInt32((Int32) requestData["start_lookat_y"]);
// if (requestData.ContainsKey("start_lookat_z"))
// ulaZ = Convert.ToUInt32((Int32) requestData["start_lookat_z"]);
if (requestData.ContainsKey("start_standat_x"))
usaX = Convert.ToUInt32((Int32) requestData["start_standat_x"]);
if (requestData.ContainsKey("start_standat_y"))
usaY = Convert.ToUInt32((Int32) requestData["start_standat_y"]);
if (requestData.ContainsKey("start_standat_z"))
usaZ = Convert.ToUInt32((Int32) requestData["start_standat_z"]);
if (requestData.ContainsKey("about_real_world"))
aboutFirstLive = (string)requestData["about_real_world"];
if (requestData.ContainsKey("about_virtual_world"))
aboutAvatar = (string)requestData["about_virtual_world"];
// if (requestData.ContainsKey("start_standat_x"))
// usaX = Convert.ToUInt32((Int32) requestData["start_standat_x"]);
// if (requestData.ContainsKey("start_standat_y"))
// usaY = Convert.ToUInt32((Int32) requestData["start_standat_y"]);
// if (requestData.ContainsKey("start_standat_z"))
// usaZ = Convert.ToUInt32((Int32) requestData["start_standat_z"]);
// if (requestData.ContainsKey("about_real_world"))
// aboutFirstLive = (string)requestData["about_real_world"];
// if (requestData.ContainsKey("about_virtual_world"))
// aboutAvatar = (string)requestData["about_virtual_world"];
UserProfileData userProfile
= m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
// UserProfileData userProfile
// = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
if (null == userProfile)
throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname));
// if (null == userProfile)
// throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname));
if (!String.IsNullOrEmpty(passwd))
{
m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty);
userProfile.PasswordHash = md5PasswdHash;
}
// if (!String.IsNullOrEmpty(passwd))
// {
// m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname);
// string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty);
// userProfile.PasswordHash = md5PasswdHash;
// }
if (null != regX) userProfile.HomeRegionX = (uint) regX;
if (null != regY) userProfile.HomeRegionY = (uint) regY;
// if (null != regX) userProfile.HomeRegionX = (uint) regX;
// if (null != regY) userProfile.HomeRegionY = (uint) regY;
if (null != usaX) userProfile.HomeLocationX = (uint) usaX;
if (null != usaY) userProfile.HomeLocationY = (uint) usaY;
if (null != usaZ) userProfile.HomeLocationZ = (uint) usaZ;
// if (null != usaX) userProfile.HomeLocationX = (uint) usaX;
// if (null != usaY) userProfile.HomeLocationY = (uint) usaY;
// if (null != usaZ) userProfile.HomeLocationZ = (uint) usaZ;
if (null != ulaX) userProfile.HomeLookAtX = (uint) ulaX;
if (null != ulaY) userProfile.HomeLookAtY = (uint) ulaY;
if (null != ulaZ) userProfile.HomeLookAtZ = (uint) ulaZ;
// if (null != ulaX) userProfile.HomeLookAtX = (uint) ulaX;
// if (null != ulaY) userProfile.HomeLookAtY = (uint) ulaY;
// if (null != ulaZ) userProfile.HomeLookAtZ = (uint) ulaZ;
if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive;
if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar;
// if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive;
// if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar;
// User has been created. Now establish gender and appearance.
// // User has been created. Now establish gender and appearance.
updateUserAppearance(responseData, requestData, userProfile.ID);
// updateUserAppearance(responseData, requestData, userProfile.ID);
if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile))
throw new Exception("did not manage to update user profile");
// if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile))
// throw new Exception("did not manage to update user profile");
responseData["success"] = true;
// responseData["success"] = true;
response.Value = responseData;
// response.Value = responseData;
m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}",
firstname, lastname,
userProfile.ID);
}
catch (Exception e)
{
m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
// m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}",
// firstname, lastname,
// userProfile.ID);
// }
// catch (Exception e)
// {
// m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
// m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
responseData["success"] = false;
responseData["error"] = e.Message;
// responseData["success"] = false;
// responseData["error"] = e.Message;
response.Value = responseData;
}
}
// response.Value = responseData;
// }
//}
m_log.Info("[RADMIN]: UpdateUserAccount: request complete");
return response;
@ -1327,72 +1343,73 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid)
{
m_log.DebugFormat("[RADMIN] updateUserAppearance");
m_log.Warn("[RADMIN]: This method needs update for 0.7");
string dmale = m_config.GetString("default_male", "Default Male");
string dfemale = m_config.GetString("default_female", "Default Female");
string dneut = m_config.GetString("default_female", "Default Default");
//string dmale = m_config.GetString("default_male", "Default Male");
//string dfemale = m_config.GetString("default_female", "Default Female");
//string dneut = m_config.GetString("default_female", "Default Default");
string model = String.Empty;
// Has a gender preference been supplied?
//// Has a gender preference been supplied?
if (requestData.Contains("gender"))
{
switch ((string)requestData["gender"])
{
case "m" :
model = dmale;
break;
case "f" :
model = dfemale;
break;
case "n" :
default :
model = dneut;
break;
}
}
//if (requestData.Contains("gender"))
//{
// switch ((string)requestData["gender"])
// {
// case "m" :
// model = dmale;
// break;
// case "f" :
// model = dfemale;
// break;
// case "n" :
// default :
// model = dneut;
// break;
// }
//}
// Has an explicit model been specified?
//// Has an explicit model been specified?
if (requestData.Contains("model"))
{
model = (string)requestData["model"];
}
//if (requestData.Contains("model"))
//{
// model = (string)requestData["model"];
//}
// No appearance attributes were set
//// No appearance attributes were set
if (model == String.Empty)
{
m_log.DebugFormat("[RADMIN] Appearance update not requested");
return;
}
//if (model == String.Empty)
//{
// m_log.DebugFormat("[RADMIN] Appearance update not requested");
// return;
//}
m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model);
//m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model);
string[] nomens = model.Split();
if (nomens.Length != 2)
{
m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model);
// nomens = dmodel.Split();
return;
}
//string[] nomens = model.Split();
//if (nomens.Length != 2)
//{
// m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model);
// // nomens = dmodel.Split();
// return;
//}
UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]);
//UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]);
// Is this the first time one of the default models has been used? Create it if that is the case
// otherwise default to male.
//// Is this the first time one of the default models has been used? Create it if that is the case
//// otherwise default to male.
if (mprof == null)
{
m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model);
return;
}
//if (mprof == null)
//{
// m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model);
// return;
//}
// Set current user's appearance. This bit is easy. The appearance structure is populated with
// actual asset ids, however to complete the magic we need to populate the inventory with the
// assets in question.
//// Set current user's appearance. This bit is easy. The appearance structure is populated with
//// actual asset ids, however to complete the magic we need to populate the inventory with the
//// assets in question.
establishAppearance(userid, mprof.ID);
//establishAppearance(userid, mprof.ID);
m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}",
userid, model);
@ -1604,20 +1621,27 @@ namespace OpenSim.ApplicationPlugins.RemoteController
passwd = GetStringAttribute(avatar,"password",passwd);
string[] nomens = name.Split();
UI = m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(nomens[0], nomens[1]);
if (null == UI)
UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]);
if (null == account)
{
ID = m_app.CommunicationsManager.UserAdminService.AddUser(nomens[0], nomens[1],
passwd, email, regX, regY);
if (ID == UUID.Zero)
account = new UserAccount(scopeID, nomens[0], nomens[1], email);
bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account);
if (!success)
{
m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]);
return false;
}
// !!! REFACTORING PROBLEM: need to set the password
GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID,
(int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize));
if (home != null)
m_app.SceneManager.CurrentOrFirstScene.PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
}
else
{
ID = UI.UserProfile.ID;
ID = account.PrincipalID;
}
m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID);
@ -2391,17 +2415,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (requestData.Contains("users"))
{
UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService;
UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
IUserAccountService userService = m_app.SceneManager.CurrentOrFirstScene.UserAccountService;
Scene s = m_app.SceneManager.CurrentScene;
Hashtable users = (Hashtable) requestData["users"];
List<UUID> uuids = new List<UUID>();
foreach (string name in users.Values)
{
string[] parts = name.Split();
CachedUserInfo udata = ups.GetUserDetails(parts[0],parts[1]);
if (udata != null)
UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]);
if (account != null)
{
uuids.Add(udata.UserProfile.ID);
uuids.Add(account.PrincipalID);
m_log.DebugFormat("[RADMIN] adding \"{0}\" to ACL for \"{1}\"", name, s.RegionInfo.RegionName);
}
}
@ -2477,21 +2502,23 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (requestData.Contains("users"))
{
UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService;
UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
IUserAccountService userService = m_app.SceneManager.CurrentOrFirstScene.UserAccountService;
//UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService;
Scene s = m_app.SceneManager.CurrentScene;
Hashtable users = (Hashtable) requestData["users"];
List<UUID> uuids = new List<UUID>();
foreach (string name in users.Values)
foreach (string name in users.Values)
{
string[] parts = name.Split();
CachedUserInfo udata = ups.GetUserDetails(parts[0],parts[1]);
if (udata != null)
UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]);
if (account != null)
{
uuids.Add(udata.UserProfile.ID);
uuids.Add(account.PrincipalID);
}
}
List<UUID> acl = new List<UUID>(s.RegionInfo.EstateSettings.EstateAccess);
foreach (UUID uuid in uuids)
foreach (UUID uuid in uuids)
{
if (acl.Contains(uuid))
{

View File

@ -35,6 +35,9 @@ using System.Xml;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
namespace OpenSim.ApplicationPlugins.Rest.Inventory
{
@ -658,7 +661,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
{
int x;
string HA1;
string first;
string last;
@ -675,17 +677,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
last = String.Empty;
}
UserProfileData udata = Rest.UserServices.GetUserProfile(first, last);
UserAccount account = Rest.UserServices.GetUserAccount(UUID.Zero, first, last);
// If we don't recognize the user id, perhaps it is god?
if (udata == null)
if (account == null)
return pass == Rest.GodKey;
HA1 = HashToString(pass);
HA1 = HashToString(String.Format("{0}:{1}",HA1,udata.PasswordSalt));
return (0 == sc.Compare(HA1, udata.PasswordHash));
return (Rest.AuthServices.Authenticate(account.PrincipalID, pass, 1) != string.Empty);
}
@ -897,11 +895,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
last = String.Empty;
}
UserProfileData udata = Rest.UserServices.GetUserProfile(first, last);
UserAccount account = Rest.UserServices.GetUserAccount(UUID.Zero, first, last);
// If we don;t recognize the user id, perhaps it is god?
if (udata == null)
if (account == null)
{
Rest.Log.DebugFormat("{0} Administrator", MsgId);
return Rest.GodKey;
@ -909,7 +906,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
else
{
Rest.Log.DebugFormat("{0} Normal User {1}", MsgId, user);
return udata.PasswordHash;
// !!! REFACTORING PROBLEM
// This is what it was. It doesn't work in 0.7
// Nothing retrieves the password from the authentication service, there's only authentication.
//return udata.PasswordHash;
return string.Empty;
}
}

View File

@ -103,11 +103,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
get { return main.SceneManager.CurrentOrFirstScene.InventoryService; }
}
internal static IUserService UserServices
internal static IUserAccountService UserServices
{
get { return Comms.UserService; }
get { return main.SceneManager.CurrentOrFirstScene.UserAccountService; }
}
internal static IAuthenticationService AuthServices
{
get { return main.SceneManager.CurrentOrFirstScene.AuthenticationService; }
}
internal static IAvatarService AvatarServices
{
get { return Comms.AvatarService; }

View File

@ -135,152 +135,153 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void DoAppearance(RequestData hdata)
{
// !!! REFACTORIMG PROBLEM. This needs rewriting for 0.7
AppearanceRequestData rdata = (AppearanceRequestData) hdata;
//AppearanceRequestData rdata = (AppearanceRequestData) hdata;
Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
//Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
// If we're disabled, do nothing.
//// If we're disabled, do nothing.
if (!enabled)
{
return;
}
//if (!enabled)
//{
// return;
//}
// Now that we know this is a serious attempt to
// access inventory data, we should find out who
// is asking, and make sure they are authorized
// to do so. We need to validate the caller's
// identity before revealing anything about the
// status quo. Authenticate throws an exception
// via Fail if no identity information is present.
//
// With the present HTTP server we can't use the
// builtin authentication mechanisms because they
// would be enforced for all in-bound requests.
// Instead we look at the headers ourselves and
// handle authentication directly.
//// Now that we know this is a serious attempt to
//// access inventory data, we should find out who
//// is asking, and make sure they are authorized
//// to do so. We need to validate the caller's
//// identity before revealing anything about the
//// status quo. Authenticate throws an exception
//// via Fail if no identity information is present.
////
//// With the present HTTP server we can't use the
//// builtin authentication mechanisms because they
//// would be enforced for all in-bound requests.
//// Instead we look at the headers ourselves and
//// handle authentication directly.
try
{
if (!rdata.IsAuthenticated)
{
rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
}
}
catch (RestException e)
{
if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
{
Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
}
else
{
Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
}
throw (e);
}
//try
//{
// if (!rdata.IsAuthenticated)
// {
// rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
// }
//}
//catch (RestException e)
//{
// if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
// {
// Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
// Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
// }
// else
// {
// Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
// Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
// }
// throw (e);
//}
Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
//Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
// We can only get here if we are authorized
//
// The requestor may have specified an UUID or
// a conjoined FirstName LastName string. We'll
// try both. If we fail with the first, UUID,
// attempt, we try the other. As an example, the
// URI for a valid inventory request might be:
//
// http://<host>:<port>/admin/inventory/Arthur Dent
//
// Indicating that this is an inventory request for
// an avatar named Arthur Dent. This is ALL that is
// required to designate a GET for an entire
// inventory.
//
//// We can only get here if we are authorized
////
//// The requestor may have specified an UUID or
//// a conjoined FirstName LastName string. We'll
//// try both. If we fail with the first, UUID,
//// attempt, we try the other. As an example, the
//// URI for a valid inventory request might be:
////
//// http://<host>:<port>/admin/inventory/Arthur Dent
////
//// Indicating that this is an inventory request for
//// an avatar named Arthur Dent. This is ALL that is
//// required to designate a GET for an entire
//// inventory.
////
// Do we have at least a user agent name?
//// Do we have at least a user agent name?
if (rdata.Parameters.Length < 1)
{
Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId);
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
}
//if (rdata.Parameters.Length < 1)
//{
// Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId);
// rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
//}
// The first parameter MUST be the agent identification, either an UUID
// or a space-separated First-name Last-Name specification. We check for
// an UUID first, if anyone names their character using a valid UUID
// that identifies another existing avatar will cause this a problem...
//// The first parameter MUST be the agent identification, either an UUID
//// or a space-separated First-name Last-Name specification. We check for
//// an UUID first, if anyone names their character using a valid UUID
//// that identifies another existing avatar will cause this a problem...
try
{
rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
}
catch
{
string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
if (names.Length == 2)
{
Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
}
else
{
Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
}
}
//try
//{
// rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
// Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
// rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
//}
//catch
//{
// string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
// if (names.Length == 2)
// {
// Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
// rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
// }
// else
// {
// Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
// rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
// }
//}
// If the user profile is null then either the server is broken, or the
// user is not known. We always assume the latter case.
//// If the user profile is null then either the server is broken, or the
//// user is not known. We always assume the latter case.
if (rdata.userProfile != null)
{
Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
}
else
{
Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path);
rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
}
//if (rdata.userProfile != null)
//{
// Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}",
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
//}
//else
//{
// Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path);
// rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
//}
// If we get to here, then we have effectively validated the user's
//// If we get to here, then we have effectively validated the user's
switch (rdata.method)
{
case Rest.HEAD : // Do the processing, set the status code, suppress entity
DoGet(rdata);
rdata.buffer = null;
break;
//switch (rdata.method)
//{
// case Rest.HEAD : // Do the processing, set the status code, suppress entity
// DoGet(rdata);
// rdata.buffer = null;
// break;
case Rest.GET : // Do the processing, set the status code, return entity
DoGet(rdata);
break;
// case Rest.GET : // Do the processing, set the status code, return entity
// DoGet(rdata);
// break;
case Rest.PUT : // Update named element
DoUpdate(rdata);
break;
// case Rest.PUT : // Update named element
// DoUpdate(rdata);
// break;
case Rest.POST : // Add new information to identified context.
DoExtend(rdata);
break;
// case Rest.POST : // Add new information to identified context.
// DoExtend(rdata);
// break;
case Rest.DELETE : // Delete information
DoDelete(rdata);
break;
// case Rest.DELETE : // Delete information
// DoDelete(rdata);
// break;
default :
Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
MsgId, rdata.method, rdata.path);
rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
String.Format("{0} not supported", rdata.method));
break;
}
// default :
// Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
// MsgId, rdata.method, rdata.path);
// rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
// String.Format("{0} not supported", rdata.method));
// break;
//}
}
#endregion Interface
@ -391,37 +392,39 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
private void DoUpdate(AppearanceRequestData rdata)
{
bool created = false;
bool modified = false;
// REFACTORING PROBLEM This was commented out. It doesn't work for 0.7
//bool created = false;
//bool modified = false;
rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
//rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
// If the user exists then this is considered a modification regardless
// of what may, or may not be, specified in the payload.
//// If the user exists then this is considered a modification regardless
//// of what may, or may not be, specified in the payload.
if (rdata.userAppearance != null)
{
modified = true;
Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
Rest.UserServices.UpdateUserProfile(rdata.userProfile);
}
//if (rdata.userAppearance != null)
//{
// modified = true;
// Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
// Rest.UserServices.UpdateUserProfile(rdata.userProfile);
//}
if (created)
{
rdata.Complete(Rest.HttpStatusCodeCreated);
}
else
{
if (modified)
{
rdata.Complete(Rest.HttpStatusCodeOK);
}
else
{
rdata.Complete(Rest.HttpStatusCodeNoContent);
}
}
//if (created)
//{
// rdata.Complete(Rest.HttpStatusCodeCreated);
//}
//else
//{
// if (modified)
// {
// rdata.Complete(Rest.HttpStatusCodeOK);
// }
// else
// {
// rdata.Complete(Rest.HttpStatusCodeNoContent);
// }
//}
rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));

View File

@ -143,203 +143,205 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
Rest.Log.DebugFormat("{0} DoInventory ENTRY", MsgId);
// If we're disabled, do nothing.
// !!! REFACTORING PROBLEM
if (!enabled)
{
return;
}
//// If we're disabled, do nothing.
// Now that we know this is a serious attempt to
// access inventory data, we should find out who
// is asking, and make sure they are authorized
// to do so. We need to validate the caller's
// identity before revealing anything about the
// status quo. Authenticate throws an exception
// via Fail if no identity information is present.
//
// With the present HTTP server we can't use the
// builtin authentication mechanisms because they
// would be enforced for all in-bound requests.
// Instead we look at the headers ourselves and
// handle authentication directly.
//if (!enabled)
//{
// return;
//}
try
{
if (!rdata.IsAuthenticated)
{
rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
}
}
catch (RestException e)
{
if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
{
Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
}
else
{
Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
}
throw (e);
}
//// Now that we know this is a serious attempt to
//// access inventory data, we should find out who
//// is asking, and make sure they are authorized
//// to do so. We need to validate the caller's
//// identity before revealing anything about the
//// status quo. Authenticate throws an exception
//// via Fail if no identity information is present.
////
//// With the present HTTP server we can't use the
//// builtin authentication mechanisms because they
//// would be enforced for all in-bound requests.
//// Instead we look at the headers ourselves and
//// handle authentication directly.
Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
//try
//{
// if (!rdata.IsAuthenticated)
// {
// rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
// }
//}
//catch (RestException e)
//{
// if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
// {
// Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
// Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
// }
// else
// {
// Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
// Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
// }
// throw (e);
//}
// We can only get here if we are authorized
//
// The requestor may have specified an UUID or
// a conjoined FirstName LastName string. We'll
// try both. If we fail with the first, UUID,
// attempt, we try the other. As an example, the
// URI for a valid inventory request might be:
//
// http://<host>:<port>/admin/inventory/Arthur Dent
//
// Indicating that this is an inventory request for
// an avatar named Arthur Dent. This is ALL that is
// required to designate a GET for an entire
// inventory.
//
//Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
//// We can only get here if we are authorized
////
//// The requestor may have specified an UUID or
//// a conjoined FirstName LastName string. We'll
//// try both. If we fail with the first, UUID,
//// attempt, we try the other. As an example, the
//// URI for a valid inventory request might be:
////
//// http://<host>:<port>/admin/inventory/Arthur Dent
////
//// Indicating that this is an inventory request for
//// an avatar named Arthur Dent. This is ALL that is
//// required to designate a GET for an entire
//// inventory.
////
// Do we have at least a user agent name?
//// Do we have at least a user agent name?
if (rdata.Parameters.Length < 1)
{
Rest.Log.WarnFormat("{0} Inventory: No user agent identifier specified", MsgId);
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
}
//if (rdata.Parameters.Length < 1)
//{
// Rest.Log.WarnFormat("{0} Inventory: No user agent identifier specified", MsgId);
// rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
//}
// The first parameter MUST be the agent identification, either an UUID
// or a space-separated First-name Last-Name specification. We check for
// an UUID first, if anyone names their character using a valid UUID
// that identifies another existing avatar will cause this a problem...
//// The first parameter MUST be the agent identification, either an UUID
//// or a space-separated First-name Last-Name specification. We check for
//// an UUID first, if anyone names their character using a valid UUID
//// that identifies another existing avatar will cause this a problem...
try
{
rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
}
catch
{
string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
if (names.Length == 2)
{
Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
}
else
{
Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
}
}
//try
//{
// rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
// Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
// rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
//}
//catch
//{
// string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
// if (names.Length == 2)
// {
// Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
// rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
// }
// else
// {
// Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
// rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
// }
//}
// If the user profile is null then either the server is broken, or the
// user is not known. We always assume the latter case.
//// If the user profile is null then either the server is broken, or the
//// user is not known. We always assume the latter case.
if (rdata.userProfile != null)
{
Rest.Log.DebugFormat("{0} Profile obtained for agent {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
}
else
{
Rest.Log.WarnFormat("{0} No profile for {1}", MsgId, rdata.path);
rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
}
//if (rdata.userProfile != null)
//{
// Rest.Log.DebugFormat("{0} Profile obtained for agent {1} {2}",
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
//}
//else
//{
// Rest.Log.WarnFormat("{0} No profile for {1}", MsgId, rdata.path);
// rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
//}
// If we get to here, then we have effectively validated the user's
// identity. Now we need to get the inventory. If the server does not
// have the inventory, we reject the request with an appropriate explanation.
//
// Note that inventory retrieval is an asynchronous event, we use the rdata
// class instance as the basis for our synchronization.
//
//// If we get to here, then we have effectively validated the user's
//// identity. Now we need to get the inventory. If the server does not
//// have the inventory, we reject the request with an appropriate explanation.
////
//// Note that inventory retrieval is an asynchronous event, we use the rdata
//// class instance as the basis for our synchronization.
////
rdata.uuid = rdata.userProfile.ID;
//rdata.uuid = rdata.userProfile.ID;
if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid))
{
rdata.root = Rest.InventoryServices.GetRootFolder(rdata.uuid);
//if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid))
//{
// rdata.root = Rest.InventoryServices.GetRootFolder(rdata.uuid);
Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
// Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}",
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
Rest.InventoryServices.GetUserInventory(rdata.uuid, rdata.GetUserInventory);
// Rest.InventoryServices.GetUserInventory(rdata.uuid, rdata.GetUserInventory);
Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
// Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}",
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
lock (rdata)
{
if (!rdata.HaveInventory)
{
rdata.startWD(1000);
rdata.timeout = false;
Monitor.Wait(rdata);
}
}
// lock (rdata)
// {
// if (!rdata.HaveInventory)
// {
// rdata.startWD(1000);
// rdata.timeout = false;
// Monitor.Wait(rdata);
// }
// }
if (rdata.timeout)
{
Rest.Log.WarnFormat("{0} Inventory not available for {1} {2}. No response from service.",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
rdata.Fail(Rest.HttpStatusCodeServerError, "inventory server not responding");
}
// if (rdata.timeout)
// {
// Rest.Log.WarnFormat("{0} Inventory not available for {1} {2}. No response from service.",
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
// rdata.Fail(Rest.HttpStatusCodeServerError, "inventory server not responding");
// }
if (rdata.root == null)
{
Rest.Log.WarnFormat("{0} Inventory is not available [1] for agent {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
rdata.Fail(Rest.HttpStatusCodeServerError, "inventory retrieval failed");
}
// if (rdata.root == null)
// {
// Rest.Log.WarnFormat("{0} Inventory is not available [1] for agent {1} {2}",
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
// rdata.Fail(Rest.HttpStatusCodeServerError, "inventory retrieval failed");
// }
}
else
{
Rest.Log.WarnFormat("{0} Inventory is not locally available for agent {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
rdata.Fail(Rest.HttpStatusCodeNotFound, "no local inventory for user");
}
//}
//else
//{
// Rest.Log.WarnFormat("{0} Inventory is not locally available for agent {1} {2}",
// MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
// rdata.Fail(Rest.HttpStatusCodeNotFound, "no local inventory for user");
//}
// If we get here, then we have successfully retrieved the user's information
// and inventory information is now available locally.
//// If we get here, then we have successfully retrieved the user's information
//// and inventory information is now available locally.
switch (rdata.method)
{
case Rest.HEAD : // Do the processing, set the status code, suppress entity
DoGet(rdata);
rdata.buffer = null;
break;
//switch (rdata.method)
//{
// case Rest.HEAD : // Do the processing, set the status code, suppress entity
// DoGet(rdata);
// rdata.buffer = null;
// break;
case Rest.GET : // Do the processing, set the status code, return entity
DoGet(rdata);
break;
// case Rest.GET : // Do the processing, set the status code, return entity
// DoGet(rdata);
// break;
case Rest.PUT : // Update named element
DoUpdate(rdata);
break;
// case Rest.PUT : // Update named element
// DoUpdate(rdata);
// break;
case Rest.POST : // Add new information to identified context.
DoExtend(rdata);
break;
// case Rest.POST : // Add new information to identified context.
// DoExtend(rdata);
// break;
case Rest.DELETE : // Delete information
DoDelete(rdata);
break;
// case Rest.DELETE : // Delete information
// DoDelete(rdata);
// break;
default :
Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
MsgId, rdata.method, rdata.path);
rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
String.Format("{0} not supported", rdata.method));
break;
}
// default :
// Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
// MsgId, rdata.method, rdata.path);
// rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
// String.Format("{0} not supported", rdata.method));
// break;
//}
}
#endregion Interface

View File

@ -41,6 +41,7 @@ using OpenSim.Client.MXP.ClientStack;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Framework.Communications;
using OpenSim.Services.Interfaces;
using System.Security.Cryptography;
namespace OpenSim.Client.MXP.PacketHandler
@ -295,13 +296,11 @@ namespace OpenSim.Client.MXP.PacketHandler
regionExists = false;
}
UserProfileData user = null;
UUID userId = UUID.Zero;
string firstName = null;
string lastName = null;
UserAccount account = null;
bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName,
joinRequestMessage.ParticipantPassphrase,
new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName, out user)
new UUID(joinRequestMessage.BubbleId), out account)
: false;
if (authorized)
@ -316,10 +315,11 @@ namespace OpenSim.Client.MXP.PacketHandler
session.RemoteEndPoint.Port + ")");
m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile...");
AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user);
UUID secureSession = UUID.Zero;
AttachUserAgentToUserProfile(account, session, mxpSessionID, sceneId, out secureSession);
m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile.");
m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection...");
if (!PrepareSceneForConnection(mxpSessionID, sceneId, user, out reason))
if (!PrepareSceneForConnection(mxpSessionID, secureSession, sceneId, account, out reason))
{
m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason);
DeclineConnection(session, joinRequestMessage);
@ -332,7 +332,7 @@ namespace OpenSim.Client.MXP.PacketHandler
m_log.Info("[MXP ClientStack]: Accepted connection.");
m_log.Debug("[MXP ClientStack]: Creating ClientView....");
MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, firstName, lastName);
MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, account.FirstName, account.LastName);
m_clients.Add(client);
m_log.Debug("[MXP ClientStack]: Created ClientView.");
@ -489,12 +489,12 @@ namespace OpenSim.Client.MXP.PacketHandler
session.SetStateDisconnected();
}
public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UUID userId, out string firstName, out string lastName, out UserProfileData userProfile)
public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UserAccount account)
{
userId = UUID.Zero;
firstName = "";
lastName = "";
userProfile = null;
UUID userId = UUID.Zero;
string firstName = "";
string lastName = "";
account = null;
string[] nameParts = participantName.Split(' ');
if (nameParts.Length != 2)
@ -505,103 +505,38 @@ namespace OpenSim.Client.MXP.PacketHandler
firstName = nameParts[0];
lastName = nameParts[1];
userProfile = m_scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName);
account = m_scenes[sceneId].UserAccountService.GetUserAccount(m_scenes[sceneId].RegionInfo.ScopeID, firstName, lastName);
if (account != null)
return (m_scenes[sceneId].AuthenticationService.Authenticate(account.PrincipalID, password, 1) != string.Empty);
if (userProfile == null && !m_accountsAuthenticate)
{
userId = ((UserManagerBase)m_scenes[sceneId].CommsManager.UserService).AddUser(firstName, lastName, "test", "", 1000, 1000);
}
else
{
if (userProfile == null)
{
m_log.Error("[MXP ClientStack]: Login failed as user was not found: " + participantName);
return false;
}
userId = userProfile.ID;
}
if (m_accountsAuthenticate)
{
if (!password.StartsWith("$1$"))
{
password = "$1$" + Util.Md5Hash(password);
}
password = password.Remove(0, 3); //remove $1$
string s = Util.Md5Hash(password + ":" + userProfile.PasswordSalt);
return (userProfile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
|| userProfile.PasswordHash.Equals(password, StringComparison.InvariantCulture));
}
else
{
return true;
}
return false;
}
private void AttachUserAgentToUserProfile(Session session, UUID sessionId, UUID sceneId, UserProfileData userProfile)
private void AttachUserAgentToUserProfile(UserAccount account, Session session, UUID sessionId, UUID sceneId, out UUID secureSessionId)
{
//Scene scene = m_scenes[sceneId];
CommunicationsManager commsManager = m_scenes[sceneId].CommsManager;
IUserService userService = (IUserService)commsManager.UserService;
UserAgentData agent = new UserAgentData();
// User connection
agent.AgentOnline = true;
agent.AgentIP = session.RemoteEndPoint.Address.ToString();
agent.AgentPort = (uint)session.RemoteEndPoint.Port;
agent.SecureSessionID = UUID.Random();
agent.SessionID = sessionId;
// Profile UUID
agent.ProfileID = userProfile.ID;
// Current location/position/alignment
if (userProfile.CurrentAgent != null)
{
agent.Region = userProfile.CurrentAgent.Region;
agent.Handle = userProfile.CurrentAgent.Handle;
agent.Position = userProfile.CurrentAgent.Position;
agent.LookAt = userProfile.CurrentAgent.LookAt;
}
else
{
agent.Region = userProfile.HomeRegionID;
agent.Handle = userProfile.HomeRegion;
agent.Position = userProfile.HomeLocation;
agent.LookAt = userProfile.HomeLookAt;
}
// What time did the user login?
agent.LoginTime = Util.UnixTimeSinceEpoch();
agent.LogoutTime = 0;
userProfile.CurrentAgent = agent;
userService.UpdateUserProfile(userProfile);
//userService.CommitAgent(ref userProfile);
secureSessionId = UUID.Random();
Scene scene = m_scenes[sceneId];
scene.PresenceService.LoginAgent(account.PrincipalID.ToString(), sessionId, secureSessionId);
}
private bool PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile, out string reason)
private bool PrepareSceneForConnection(UUID sessionId, UUID secureSessionId, UUID sceneId, UserAccount account, out string reason)
{
Scene scene = m_scenes[sceneId];
CommunicationsManager commsManager = m_scenes[sceneId].CommsManager;
UserManagerBase userService = (UserManagerBase)commsManager.UserService;
AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = userProfile.ID;
agent.firstname = userProfile.FirstName;
agent.lastname = userProfile.SurName;
agent.AgentID = account.PrincipalID;
agent.firstname = account.FirstName;
agent.lastname = account.LastName;
agent.SessionID = sessionId;
agent.SecureSessionID = userProfile.CurrentAgent.SecureSessionID;
agent.SecureSessionID = secureSessionId;
agent.circuitcode = sessionId.CRC();
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position
agent.CapsPath = "http://localhost/";
agent.Appearance = userService.GetUserAppearance(userProfile.ID);
AvatarData avatar = scene.AvatarService.GetAvatar(account.PrincipalID);
if (avatar != null)
agent.Appearance = avatar.ToAvatarAppearance(); //userService.GetUserAppearance(userProfile.ID);
if (agent.Appearance == null)
{

View File

@ -1,345 +0,0 @@
/*
* 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 NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using System.Threading;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Communications.Local;
using OpenSim.Tests.Common.Mock;
using OpenSim.Tests.Common.Setup;
using OpenSim.Tests.Common;
namespace OpenSim.Framework.Communications.Tests
{
[TestFixture]
public class UserProfileCacheServiceTests
{
/// <value>Used by tests to indicate whether an async operation timed out</value>
private bool timedOut;
private void InventoryReceived(UUID userId)
{
lock (this)
{
timedOut = false;
Monitor.PulseAll(this);
}
}
[Test]
public void TestGetUserDetails()
{
TestHelper.InMethod();
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002");
string firstName = "Bill";
string lastName = "Bailey";
CachedUserInfo nonExistingUserInfo;
TestCommunicationsManager commsManager = new TestCommunicationsManager();
// Scene myScene = SceneSetupHelpers.SetupScene(commsManager, "");
// Check we can't retrieve info before it exists by uuid
nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation");
// Check we can't retrieve info before it exists by name
nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation");
LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
CachedUserInfo existingUserInfo;
// Check we can retrieve info by uuid
existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid");
// Check we can retrieve info by name
existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name");
}
/**
* Disabled as not fully implemented
[Test]
public void TestUpdateProfile()
{
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292");
string firstName = "Inspector";
string originalLastName = "Morse";
string newLastName = "Gadget";
UserProfileData newProfile = new UserProfileData();
newProfile.ID = userId;
newProfile.FirstName = firstName;
newProfile.SurName = newLastName;
TestCommunicationsManager commsManager = new TestCommunicationsManager();
UserProfileCacheService userCacheService = commsManager.UserProfileCacheService;
IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin;
// Check that we can't update info before it exists
Assert.That(userCacheService.StoreProfile(newProfile), Is.False);
Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null);
// Check that we can update a profile once it exists
LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId);
Assert.That(userCacheService.StoreProfile(newProfile), Is.True);
UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile;
Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName));
Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName));
}
*/
[Test]
public void TestFetchInventory()
{
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
timedOut = true;
lock (this)
{
UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
Assert.That(timedOut, Is.False, "Timed out");
}
[Test]
public void TestGetChildFolder()
{
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID);
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null);
}
[Test]
public void TestCreateFolder()
{
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
// 1: Try a folder create that should fail because the parent id given does not exist
UUID missingFolderId = UUID.Random();
InventoryFolderBase myFolder = new InventoryFolderBase();
myFolder.ID = folderId;
Assert.That(
userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False);
Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null);
Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False);
Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null);
// 2: Try a folder create that should work
Assert.That(
userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True);
Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null);
Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True);
}
//[Test]
public void TestUpdateFolder()
{
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
InventoryFolderImpl rootFolder = userInfo.RootFolder;
InventoryFolderBase myFolder = new InventoryFolderBase();
myFolder.ID = folder1Id;
userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
// 1: Test updates that don't involve moving the folder
{
string newFolderName1 = "newFolderName1";
ushort folderType1 = (ushort)AssetType.Texture;
userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID);
InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id);
Assert.That(newFolderName1, Is.EqualTo(folder1.Name));
Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type));
InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder);
Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name));
Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type));
}
// 2: Test an update that also involves moving the folder
{
UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000061");
userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID);
InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id);
InventoryFolderBase myFolder2 = new InventoryFolderBase();
myFolder2.ID = folder2Id;
string newFolderName2 = "newFolderName2";
ushort folderType2 = (ushort)AssetType.Bodypart;
userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id);
InventoryFolderImpl folder1 = folder2.GetChildFolder(folder1Id);
Assert.That(newFolderName2, Is.EqualTo(folder1.Name));
Assert.That(folderType2, Is.EqualTo((ushort)folder1.Type));
Assert.That(folder2Id, Is.EqualTo(folder1.ParentID));
Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True);
Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False);
InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder2);
Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name));
Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type));
Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID));
}
}
[Test]
public void TestMoveFolder()
{
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030");
InventoryFolderImpl rootFolder = userInfo.RootFolder;
userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id);
userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID);
InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id);
// Check folder is currently in folder1
userInfo.CreateFolder("folderToMove", folderToMoveId, (ushort)AssetType.Animation, folder1Id);
Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.True);
userInfo.MoveFolder(folderToMoveId, folder2Id);
// Check folder is now in folder2 and no trace remains in folder1
InventoryFolderBase myFolder = new InventoryFolderBase();
myFolder.ID = folderToMoveId;
Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True);
Assert.That(myScene.InventoryService.GetFolder(myFolder).ParentID, Is.EqualTo(folder2Id));
Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False);
}
[Test]
public void TestPurgeFolder()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
InventoryFolderImpl rootFolder = userInfo.RootFolder;
InventoryFolderBase myFolder = new InventoryFolderBase();
myFolder.ID = folder1Id;
userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null);
// Test purge
userInfo.PurgeFolder(rootFolder.ID);
Assert.That(rootFolder.RequestListOfFolders(), Is.Empty);
Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null);
}
[TearDown]
public void TearDown()
{
try
{
if (MainServer.Instance != null) MainServer.Instance.Stop();
}
catch (System.NullReferenceException)
{ }
}
}
}

View File

@ -534,26 +534,28 @@ namespace OpenSim.Region.CoreModules.InterGrid
userProfile.WantDoMask = 0;
userProfile.WebLoginKey = UUID.Random();
// Do caps registration
// get seed capagentData.firstname = FirstName;agentData.lastname = LastName;
if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode)
{
homeScene.CommsManager.UserAdminService.AddUser(
agentData.firstname, agentData.lastname, CreateRandomStr(7), "",
homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID);
// !!! REFACTORING PROBLEM. This needs to be changed for 0.7
//
//// Do caps registration
//// get seed capagentData.firstname = FirstName;agentData.lastname = LastName;
//if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode)
//{
// homeScene.CommsManager.UserAdminService.AddUser(
// agentData.firstname, agentData.lastname, CreateRandomStr(7), "",
// homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID);
UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID);
if (userProfile2 != null)
{
userProfile = userProfile2;
userProfile.AboutText = "OGP USER";
userProfile.FirstLifeAboutText = "OGP USER";
homeScene.CommsManager.UserService.UpdateUserProfile(userProfile);
}
}
// UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID);
// if (userProfile2 != null)
// {
// userProfile = userProfile2;
// userProfile.AboutText = "OGP USER";
// userProfile.FirstLifeAboutText = "OGP USER";
// homeScene.CommsManager.UserService.UpdateUserProfile(userProfile);
// }
//}
// Stick our data in the cache so the region will know something about us
homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile);
//// Stick our data in the cache so the region will know something about us
//homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile);
// Call 'new user' event handler
string reason;

View File

@ -161,7 +161,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService;
// ugh!
m_UserProfileService.SetInventoryService(this);
scene.CommsManager.UserService.SetInventoryService(this);
m_Initialized = true;
}

View File

@ -133,7 +133,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
// ugh!
scene.CommsManager.UserProfileCacheService.SetInventoryService(this);
scene.CommsManager.UserService.SetInventoryService(this);
m_Initialized = true;
}

View File

@ -116,7 +116,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
// ugh!
scene.CommsManager.UserProfileCacheService.SetInventoryService(this);
scene.CommsManager.UserService.SetInventoryService(this);
m_Initialized = true;
}

View File

@ -296,6 +296,17 @@ namespace OpenSim.Region.Framework.Scenes
}
}
protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService;
public OpenSim.Services.Interfaces.IAvatarService AvatarService
{
get
{
if (m_AvatarService == null)
m_AvatarService = RequestModuleInterface<OpenSim.Services.Interfaces.IAvatarService>();
return m_AvatarService;
}
}
protected IXMLRPC m_xmlrpcModule;
protected IWorldComm m_worldCommModule;
protected IAvatarFactory m_AvatarFactory;
@ -2975,21 +2986,11 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="client">The IClientAPI for the client</param>
public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
{
UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
if (UserProfile != null)
OpenSim.Services.Interfaces.PresenceInfo pinfo = PresenceService.GetAgent(client.SessionId);
if (pinfo != null)
{
GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
if (regionInfo == null)
{
uint x = 0, y = 0;
Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regionInfo != null) // home region can be away temporarily, too
{
UserProfile.HomeRegionID = regionInfo.RegionID;
CommsManager.UserService.UpdateUserProfile(UserProfile);
}
}
GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID);
if (regionInfo == null)
{
// can't find the Home region: Tell viewer and abort
@ -2997,7 +2998,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
RequestTeleportLocation(
client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt,
(uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
}
}
@ -3089,7 +3090,7 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
/// Sets the Home Point. The GridService uses this to know where to put a user when they log-in
/// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="regionHandle"></param>
@ -3098,27 +3099,11 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="flags"></param>
public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
{
UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId);
if (UserProfile != null)
{
// I know I'm ignoring the regionHandle provided by the teleport location request.
// reusing the TeleportLocationRequest delegate, so regionHandle isn't valid
UserProfile.HomeRegionID = RegionInfo.RegionID;
// TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
// TODO: The HomeRegion property can be removed then, too
UserProfile.HomeRegion = RegionInfo.RegionHandle;
UserProfile.HomeLocation = position;
UserProfile.HomeLookAt = lookAt;
CommsManager.UserService.UpdateUserProfile(UserProfile);
if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
// FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
}
else
{
m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed.");
}
}
/// <summary>
@ -3254,12 +3239,6 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
}
// Remove client agent from profile, so new logins will work
if (!childagentYN)
{
m_sceneGridService.ClearUserAgent(agentID);
}
m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
//m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));

View File

@ -1455,11 +1455,6 @@ namespace OpenSim.Region.Framework.Scenes
m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
}
public void ClearUserAgent(UUID avatarID)
{
m_commsProvider.UserService.ClearUserAgent(avatarID);
}
public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
{
m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);

View File

@ -43,6 +43,8 @@ using OpenSim.Region.CoreModules.Framework.EventQueue;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags;
@ -507,10 +509,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{
if (m_debugEnabled)
{
UserProfileData targetUserProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(member.AgentID);
if (targetUserProfile != null)
UserAccount targetUser = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, member.AgentID);
if (targetUser != null)
{
m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUserProfile.Name, member.AcceptNotices);
m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices);
}
else
{
@ -990,9 +992,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true);
GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID);
if ((groupInfo == null) || (userProfile == null))
UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID);
if ((groupInfo == null) || (account == null))
{
return;
}
@ -1032,9 +1033,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg.toAgentID = remoteClient.AgentId.Guid;
msg.timestamp = 0;
msg.fromAgentName = remoteClient.Name;
if (userProfile != null)
if (account != null)
{
msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, userProfile.Name);
msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, account.FirstName + " " + account.LastName);
}
else
{
@ -1147,8 +1148,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
info.RequestID.AgentID = client.AgentId;
info.RequestID.SessionID = client.SessionId;
UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
if (userProfile == null)
//UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
if (account == null)
{
// This should be impossible. If I've been passed a reference to a client
// that client should be registered with the UserService. So something
@ -1160,16 +1162,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
}
else if (userProfile is ForeignUserProfileData)
{
// They aren't from around here
ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
info.RequestID.UserServiceURL = fupd.UserServerURI;
}
else
{
string domain = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
if (account.ServiceURLs["HomeURI"] != null)
domain = account.ServiceURLs["HomeURI"].ToString();
// They're a local user, use this:
info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
info.RequestID.UserServiceURL = domain;
}
m_clientRequestIDInfo.Add(client.AgentId, info);
@ -1342,12 +1341,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
// TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(dataForAgentID);
UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID);
string firstname, lastname;
if (userProfile != null)
if (account != null)
{
firstname = userProfile.FirstName;
lastname = userProfile.SurName;
firstname = account.FirstName;
lastname = account.LastName;
}
else
{

View File

@ -52,8 +52,9 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
using AssetLandmark = OpenSim.Framework.AssetLandmark;
@ -3842,13 +3843,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID uuid = (UUID)id;
UserProfileData userProfile =
World.CommsManager.UserService.GetUserProfile(uuid);
UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
UserAgentData userAgent =
World.CommsManager.UserService.GetAgentByUUID(uuid);
PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
PresenceInfo pinfo = PresenceInfo.GetOnlinePresence(pinfos);
if (userProfile == null || userAgent == null)
if (pinfo == null)
return UUID.Zero.ToString();
string reply = String.Empty;
@ -3857,17 +3857,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
case 1: // DATA_ONLINE (0|1)
// TODO: implement fetching of this information
if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline)
if (pinfo != null)
reply = "1";
else
else
reply = "0";
break;
case 2: // DATA_NAME (First Last)
reply = userProfile.FirstName + " " + userProfile.SurName;
reply = account.FirstName + " " + account.LastName;
break;
case 3: // DATA_BORN (YYYY-MM-DD)
DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
born = born.AddSeconds(userProfile.Created);
born = born.AddSeconds(account.Created);
reply = born.ToString("yyyy-MM-dd");
break;
case 4: // DATA_RATING (0,0,0,0,0,0)

View File

@ -90,6 +90,26 @@ namespace OpenSim.Services.Interfaces
return result;
}
public static PresenceInfo[] GetOnlinePresences(PresenceInfo[] pinfos)
{
if (pinfos == null)
return null;
List<PresenceInfo> lst = new List<PresenceInfo>(pinfos);
lst = lst.FindAll(delegate(PresenceInfo each) { return each.Online; });
return lst.ToArray();
}
public static PresenceInfo GetOnlinePresence(PresenceInfo[] pinfos)
{
pinfos = GetOnlinePresences(pinfos);
if (pinfos != null && pinfos.Length >= 1)
return pinfos[0];
return null;
}
}
public interface IPresenceService

View File

@ -42,6 +42,17 @@ namespace OpenSim.Services.Interfaces
PrincipalID = principalID;
}
public UserAccount(UUID scopeID, string firstName, string lastName, string email)
{
PrincipalID = UUID.Random();
ScopeID = scopeID;
FirstName = firstName;
LastName = lastName;
Email = email;
ServiceURLs = new Dictionary<string, object>();
// Created = ???
}
public string FirstName;
public string LastName;
public string Email;

View File

@ -194,8 +194,6 @@ namespace OpenSim.Tests.Common.Setup
m_inventoryService.PostInitialise();
m_assetService.PostInitialise();
testScene.CommsManager.UserService.SetInventoryService(testScene.InventoryService);
testScene.SetModuleInterfaces();
testScene.LandChannel = new TestLandChannel(testScene);

View File

@ -2365,6 +2365,7 @@
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="Nini.dll" />
<Reference name="log4net.dll"/>
<Reference name="protobuf-net"/>