aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs8
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs433
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs26
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs11
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs347
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs396
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs121
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs345
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs38
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs57
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs20
-rw-r--r--OpenSim/Services/Interfaces/IPresenceService.cs20
-rw-r--r--OpenSim/Services/Interfaces/IUserAccountService.cs11
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs2
19 files changed, 753 insertions, 1131 deletions
diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
index 0f827b0..02ee025 100644
--- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
@@ -85,10 +85,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
85 MainServer.Instance = m_httpServer; 85 MainServer.Instance = m_httpServer;
86 86
87 InitialiseCommsManager(openSim); 87 InitialiseCommsManager(openSim);
88 if (m_commsManager != null)
89 {
90 m_openSim.ApplicationRegistry.RegisterInterface<IUserService>(m_commsManager.UserService);
91 }
92 } 88 }
93 89
94 public void PostInitialise() 90 public void PostInitialise()
@@ -107,10 +103,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
107 103
108 private void RegionCreated(IScene scene) 104 private void RegionCreated(IScene scene)
109 { 105 {
110 if (m_commsManager != null)
111 {
112 scene.RegisterModuleInterface<IUserService>(m_commsManager.UserService);
113 }
114 } 106 }
115 107
116 protected void InitialiseCommsManager(OpenSimBase openSim) 108 protected void InitialiseCommsManager(OpenSimBase openSim)
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 9400788..d6d5700 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -49,6 +49,8 @@ using OpenSim.Region.CoreModules.World.Terrain;
49using OpenSim.Region.Framework.Interfaces; 49using OpenSim.Region.Framework.Interfaces;
50using OpenSim.Region.Framework.Scenes; 50using OpenSim.Region.Framework.Scenes;
51using OpenSim.Services.Interfaces; 51using OpenSim.Services.Interfaces;
52using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
52 54
53namespace OpenSim.ApplicationPlugins.RemoteController 55namespace OpenSim.ApplicationPlugins.RemoteController
54{ 56{
@@ -1032,30 +1034,37 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1032 if (requestData.Contains("user_email")) 1034 if (requestData.Contains("user_email"))
1033 email = (string)requestData["user_email"]; 1035 email = (string)requestData["user_email"];
1034 1036
1035 CachedUserInfo userInfo = 1037 UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
1036 m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(firstname, lastname);
1037 1038
1038 if (null != userInfo) 1039 UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstname, lastname);
1039 throw new Exception(String.Format("Avatar {0} {1} already exists", firstname, lastname));
1040 1040
1041 UUID userID = 1041 if (null != account)
1042 m_app.CommunicationsManager.UserAdminService.AddUser(firstname, lastname, 1042 throw new Exception(String.Format("Account {0} {1} already exists", firstname, lastname));
1043 passwd, email, regX, regY);
1044 1043
1045 if (userID == UUID.Zero) 1044 account = new UserAccount(scopeID, firstname, lastname, email);
1045 // REFACTORING PROBLEM: no method to set the password!
1046
1047 bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account);
1048
1049 if (!success)
1046 throw new Exception(String.Format("failed to create new user {0} {1}", 1050 throw new Exception(String.Format("failed to create new user {0} {1}",
1047 firstname, lastname)); 1051 firstname, lastname));
1048 1052
1053 GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID,
1054 (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize));
1055 if (home == null)
1056 m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstname, lastname);
1057
1049 // Establish the avatar's initial appearance 1058 // Establish the avatar's initial appearance
1050 1059
1051 updateUserAppearance(responseData, requestData, userID); 1060 updateUserAppearance(responseData, requestData, account.PrincipalID);
1052 1061
1053 responseData["success"] = true; 1062 responseData["success"] = true;
1054 responseData["avatar_uuid"] = userID.ToString(); 1063 responseData["avatar_uuid"] = account.PrincipalID.ToString();
1055 1064
1056 response.Value = responseData; 1065 response.Value = responseData;
1057 1066
1058 m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); 1067 m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, account.PrincipalID);
1059 } 1068 }
1060 catch (Exception e) 1069 catch (Exception e)
1061 { 1070 {
@@ -1124,21 +1133,27 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1124 string firstname = (string) requestData["user_firstname"]; 1133 string firstname = (string) requestData["user_firstname"];
1125 string lastname = (string) requestData["user_lastname"]; 1134 string lastname = (string) requestData["user_lastname"];
1126 1135
1127 CachedUserInfo userInfo
1128 = m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(firstname, lastname);
1129
1130 responseData["user_firstname"] = firstname; 1136 responseData["user_firstname"] = firstname;
1131 responseData["user_lastname"] = lastname; 1137 responseData["user_lastname"] = lastname;
1132 1138
1133 if (null == userInfo) 1139 UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
1140
1141 UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstname, lastname);
1142
1143 if (null == account)
1134 { 1144 {
1135 responseData["success"] = false; 1145 responseData["success"] = false;
1136 responseData["lastlogin"] = 0; 1146 responseData["lastlogin"] = 0;
1137 } 1147 }
1138 else 1148 else
1139 { 1149 {
1150 PresenceInfo[] pinfos = m_app.SceneManager.CurrentOrFirstScene.PresenceService.GetAgents(new string[] { account.PrincipalID.ToString() });
1151 if (pinfos != null && pinfos.Length >= 1)
1152 responseData["lastlogin"] = pinfos[0].Login;
1153 else
1154 responseData["lastlogin"] = 0;
1155
1140 responseData["success"] = true; 1156 responseData["success"] = true;
1141 responseData["lastlogin"] = userInfo.UserProfile.LastLogin;
1142 } 1157 }
1143 1158
1144 response.Value = responseData; 1159 response.Value = responseData;
@@ -1200,117 +1215,118 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1200 public XmlRpcResponse XmlRpcUpdateUserAccountMethod(XmlRpcRequest request, IPEndPoint remoteClient) 1215 public XmlRpcResponse XmlRpcUpdateUserAccountMethod(XmlRpcRequest request, IPEndPoint remoteClient)
1201 { 1216 {
1202 m_log.Info("[RADMIN]: UpdateUserAccount: new request"); 1217 m_log.Info("[RADMIN]: UpdateUserAccount: new request");
1218 m_log.Warn("[RADMIN]: This method needs update for 0.7");
1203 XmlRpcResponse response = new XmlRpcResponse(); 1219 XmlRpcResponse response = new XmlRpcResponse();
1204 Hashtable responseData = new Hashtable(); 1220 Hashtable responseData = new Hashtable();
1205 1221
1206 lock (rslock) 1222 //lock (rslock)
1207 { 1223 //{
1208 try 1224 // try
1209 { 1225 // {
1210 Hashtable requestData = (Hashtable) request.Params[0]; 1226 // Hashtable requestData = (Hashtable) request.Params[0];
1211 1227
1212 // check completeness 1228 // // check completeness
1213 checkStringParameters(request, new string[] { 1229 // checkStringParameters(request, new string[] {
1214 "password", "user_firstname", 1230 // "password", "user_firstname",
1215 "user_lastname"}); 1231 // "user_lastname"});
1216 1232
1217 // check password 1233 // // check password
1218 if (!String.IsNullOrEmpty(m_requiredPassword) && 1234 // if (!String.IsNullOrEmpty(m_requiredPassword) &&
1219 (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password"); 1235 // (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");
1220 1236
1221 // do the job 1237 // // do the job
1222 string firstname = (string) requestData["user_firstname"]; 1238 // string firstname = (string) requestData["user_firstname"];
1223 string lastname = (string) requestData["user_lastname"]; 1239 // string lastname = (string) requestData["user_lastname"];
1224 1240
1225 string passwd = String.Empty; 1241 // string passwd = String.Empty;
1226 uint? regX = null; 1242 // uint? regX = null;
1227 uint? regY = null; 1243 // uint? regY = null;
1228 uint? ulaX = null; 1244 // uint? ulaX = null;
1229 uint? ulaY = null; 1245 // uint? ulaY = null;
1230 uint? ulaZ = null; 1246 // uint? ulaZ = null;
1231 uint? usaX = null; 1247 // uint? usaX = null;
1232 uint? usaY = null; 1248 // uint? usaY = null;
1233 uint? usaZ = null; 1249 // uint? usaZ = null;
1234 string aboutFirstLive = String.Empty; 1250 // string aboutFirstLive = String.Empty;
1235 string aboutAvatar = String.Empty; 1251 // string aboutAvatar = String.Empty;
1236 1252
1237 if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; 1253 // if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"];
1238 if (requestData.ContainsKey("start_region_x")) 1254 // if (requestData.ContainsKey("start_region_x"))
1239 regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); 1255 // regX = Convert.ToUInt32((Int32) requestData["start_region_x"]);
1240 if (requestData.ContainsKey("start_region_y")) 1256 // if (requestData.ContainsKey("start_region_y"))
1241 regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); 1257 // regY = Convert.ToUInt32((Int32) requestData["start_region_y"]);
1242 1258
1243 if (requestData.ContainsKey("start_lookat_x")) 1259 // if (requestData.ContainsKey("start_lookat_x"))
1244 ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]); 1260 // ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]);
1245 if (requestData.ContainsKey("start_lookat_y")) 1261 // if (requestData.ContainsKey("start_lookat_y"))
1246 ulaY = Convert.ToUInt32((Int32) requestData["start_lookat_y"]); 1262 // ulaY = Convert.ToUInt32((Int32) requestData["start_lookat_y"]);
1247 if (requestData.ContainsKey("start_lookat_z")) 1263 // if (requestData.ContainsKey("start_lookat_z"))
1248 ulaZ = Convert.ToUInt32((Int32) requestData["start_lookat_z"]); 1264 // ulaZ = Convert.ToUInt32((Int32) requestData["start_lookat_z"]);
1249 1265
1250 if (requestData.ContainsKey("start_standat_x")) 1266 // if (requestData.ContainsKey("start_standat_x"))
1251 usaX = Convert.ToUInt32((Int32) requestData["start_standat_x"]); 1267 // usaX = Convert.ToUInt32((Int32) requestData["start_standat_x"]);
1252 if (requestData.ContainsKey("start_standat_y")) 1268 // if (requestData.ContainsKey("start_standat_y"))
1253 usaY = Convert.ToUInt32((Int32) requestData["start_standat_y"]); 1269 // usaY = Convert.ToUInt32((Int32) requestData["start_standat_y"]);
1254 if (requestData.ContainsKey("start_standat_z")) 1270 // if (requestData.ContainsKey("start_standat_z"))
1255 usaZ = Convert.ToUInt32((Int32) requestData["start_standat_z"]); 1271 // usaZ = Convert.ToUInt32((Int32) requestData["start_standat_z"]);
1256 if (requestData.ContainsKey("about_real_world")) 1272 // if (requestData.ContainsKey("about_real_world"))
1257 aboutFirstLive = (string)requestData["about_real_world"]; 1273 // aboutFirstLive = (string)requestData["about_real_world"];
1258 if (requestData.ContainsKey("about_virtual_world")) 1274 // if (requestData.ContainsKey("about_virtual_world"))
1259 aboutAvatar = (string)requestData["about_virtual_world"]; 1275 // aboutAvatar = (string)requestData["about_virtual_world"];
1260 1276
1261 UserProfileData userProfile 1277 // UserProfileData userProfile
1262 = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); 1278 // = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
1263 1279
1264 if (null == userProfile) 1280 // if (null == userProfile)
1265 throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname)); 1281 // throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname));
1266 1282
1267 if (!String.IsNullOrEmpty(passwd)) 1283 // if (!String.IsNullOrEmpty(passwd))
1268 { 1284 // {
1269 m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname); 1285 // m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname);
1270 string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty); 1286 // string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty);
1271 userProfile.PasswordHash = md5PasswdHash; 1287 // userProfile.PasswordHash = md5PasswdHash;
1272 } 1288 // }
1273 1289
1274 if (null != regX) userProfile.HomeRegionX = (uint) regX; 1290 // if (null != regX) userProfile.HomeRegionX = (uint) regX;
1275 if (null != regY) userProfile.HomeRegionY = (uint) regY; 1291 // if (null != regY) userProfile.HomeRegionY = (uint) regY;
1276 1292
1277 if (null != usaX) userProfile.HomeLocationX = (uint) usaX; 1293 // if (null != usaX) userProfile.HomeLocationX = (uint) usaX;
1278 if (null != usaY) userProfile.HomeLocationY = (uint) usaY; 1294 // if (null != usaY) userProfile.HomeLocationY = (uint) usaY;
1279 if (null != usaZ) userProfile.HomeLocationZ = (uint) usaZ; 1295 // if (null != usaZ) userProfile.HomeLocationZ = (uint) usaZ;
1280 1296
1281 if (null != ulaX) userProfile.HomeLookAtX = (uint) ulaX; 1297 // if (null != ulaX) userProfile.HomeLookAtX = (uint) ulaX;
1282 if (null != ulaY) userProfile.HomeLookAtY = (uint) ulaY; 1298 // if (null != ulaY) userProfile.HomeLookAtY = (uint) ulaY;
1283 if (null != ulaZ) userProfile.HomeLookAtZ = (uint) ulaZ; 1299 // if (null != ulaZ) userProfile.HomeLookAtZ = (uint) ulaZ;
1284 1300
1285 if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive; 1301 // if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive;
1286 if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar; 1302 // if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar;
1287 1303
1288 // User has been created. Now establish gender and appearance. 1304 // // User has been created. Now establish gender and appearance.
1289 1305
1290 updateUserAppearance(responseData, requestData, userProfile.ID); 1306 // updateUserAppearance(responseData, requestData, userProfile.ID);
1291 1307
1292 if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) 1308 // if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile))
1293 throw new Exception("did not manage to update user profile"); 1309 // throw new Exception("did not manage to update user profile");
1294 1310
1295 responseData["success"] = true; 1311 // responseData["success"] = true;
1296 1312
1297 response.Value = responseData; 1313 // response.Value = responseData;
1298 1314
1299 m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", 1315 // m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}",
1300 firstname, lastname, 1316 // firstname, lastname,
1301 userProfile.ID); 1317 // userProfile.ID);
1302 } 1318 // }
1303 catch (Exception e) 1319 // catch (Exception e)
1304 { 1320 // {
1305 m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message); 1321 // m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
1306 m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString()); 1322 // m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
1307 1323
1308 responseData["success"] = false; 1324 // responseData["success"] = false;
1309 responseData["error"] = e.Message; 1325 // responseData["error"] = e.Message;
1310 1326
1311 response.Value = responseData; 1327 // response.Value = responseData;
1312 } 1328 // }
1313 } 1329 //}
1314 1330
1315 m_log.Info("[RADMIN]: UpdateUserAccount: request complete"); 1331 m_log.Info("[RADMIN]: UpdateUserAccount: request complete");
1316 return response; 1332 return response;
@@ -1327,72 +1343,73 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1327 private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid) 1343 private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid)
1328 { 1344 {
1329 m_log.DebugFormat("[RADMIN] updateUserAppearance"); 1345 m_log.DebugFormat("[RADMIN] updateUserAppearance");
1346 m_log.Warn("[RADMIN]: This method needs update for 0.7");
1330 1347
1331 string dmale = m_config.GetString("default_male", "Default Male"); 1348 //string dmale = m_config.GetString("default_male", "Default Male");
1332 string dfemale = m_config.GetString("default_female", "Default Female"); 1349 //string dfemale = m_config.GetString("default_female", "Default Female");
1333 string dneut = m_config.GetString("default_female", "Default Default"); 1350 //string dneut = m_config.GetString("default_female", "Default Default");
1334 string model = String.Empty; 1351 string model = String.Empty;
1335 1352
1336 // Has a gender preference been supplied? 1353 //// Has a gender preference been supplied?
1337 1354
1338 if (requestData.Contains("gender")) 1355 //if (requestData.Contains("gender"))
1339 { 1356 //{
1340 switch ((string)requestData["gender"]) 1357 // switch ((string)requestData["gender"])
1341 { 1358 // {
1342 case "m" : 1359 // case "m" :
1343 model = dmale; 1360 // model = dmale;
1344 break; 1361 // break;
1345 case "f" : 1362 // case "f" :
1346 model = dfemale; 1363 // model = dfemale;
1347 break; 1364 // break;
1348 case "n" : 1365 // case "n" :
1349 default : 1366 // default :
1350 model = dneut; 1367 // model = dneut;
1351 break; 1368 // break;
1352 } 1369 // }
1353 } 1370 //}
1354 1371
1355 // Has an explicit model been specified? 1372 //// Has an explicit model been specified?
1356 1373
1357 if (requestData.Contains("model")) 1374 //if (requestData.Contains("model"))
1358 { 1375 //{
1359 model = (string)requestData["model"]; 1376 // model = (string)requestData["model"];
1360 } 1377 //}
1361 1378
1362 // No appearance attributes were set 1379 //// No appearance attributes were set
1363 1380
1364 if (model == String.Empty) 1381 //if (model == String.Empty)
1365 { 1382 //{
1366 m_log.DebugFormat("[RADMIN] Appearance update not requested"); 1383 // m_log.DebugFormat("[RADMIN] Appearance update not requested");
1367 return; 1384 // return;
1368 } 1385 //}
1369 1386
1370 m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model); 1387 //m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model);
1371 1388
1372 string[] nomens = model.Split(); 1389 //string[] nomens = model.Split();
1373 if (nomens.Length != 2) 1390 //if (nomens.Length != 2)
1374 { 1391 //{
1375 m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model); 1392 // m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model);
1376 // nomens = dmodel.Split(); 1393 // // nomens = dmodel.Split();
1377 return; 1394 // return;
1378 } 1395 //}
1379 1396
1380 UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]); 1397 //UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]);
1381 1398
1382 // Is this the first time one of the default models has been used? Create it if that is the case 1399 //// Is this the first time one of the default models has been used? Create it if that is the case
1383 // otherwise default to male. 1400 //// otherwise default to male.
1384 1401
1385 if (mprof == null) 1402 //if (mprof == null)
1386 { 1403 //{
1387 m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model); 1404 // m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model);
1388 return; 1405 // return;
1389 } 1406 //}
1390 1407
1391 // Set current user's appearance. This bit is easy. The appearance structure is populated with 1408 //// Set current user's appearance. This bit is easy. The appearance structure is populated with
1392 // actual asset ids, however to complete the magic we need to populate the inventory with the 1409 //// actual asset ids, however to complete the magic we need to populate the inventory with the
1393 // assets in question. 1410 //// assets in question.
1394 1411
1395 establishAppearance(userid, mprof.ID); 1412 //establishAppearance(userid, mprof.ID);
1396 1413
1397 m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}", 1414 m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}",
1398 userid, model); 1415 userid, model);
@@ -1604,20 +1621,27 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1604 passwd = GetStringAttribute(avatar,"password",passwd); 1621 passwd = GetStringAttribute(avatar,"password",passwd);
1605 1622
1606 string[] nomens = name.Split(); 1623 string[] nomens = name.Split();
1607 UI = m_app.CommunicationsManager.UserProfileCacheService.GetUserDetails(nomens[0], nomens[1]); 1624 UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
1608 if (null == UI) 1625 UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]);
1626 if (null == account)
1609 { 1627 {
1610 ID = m_app.CommunicationsManager.UserAdminService.AddUser(nomens[0], nomens[1], 1628 account = new UserAccount(scopeID, nomens[0], nomens[1], email);
1611 passwd, email, regX, regY); 1629 bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account);
1612 if (ID == UUID.Zero) 1630 if (!success)
1613 { 1631 {
1614 m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]); 1632 m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]);
1615 return false; 1633 return false;
1616 } 1634 }
1635 // !!! REFACTORING PROBLEM: need to set the password
1636
1637 GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID,
1638 (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize));
1639 if (home != null)
1640 m_app.SceneManager.CurrentOrFirstScene.PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1617 } 1641 }
1618 else 1642 else
1619 { 1643 {
1620 ID = UI.UserProfile.ID; 1644 ID = account.PrincipalID;
1621 } 1645 }
1622 1646
1623 m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID); 1647 m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID);
@@ -2391,17 +2415,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2391 2415
2392 if (requestData.Contains("users")) 2416 if (requestData.Contains("users"))
2393 { 2417 {
2394 UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService; 2418 UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
2419 IUserAccountService userService = m_app.SceneManager.CurrentOrFirstScene.UserAccountService;
2395 Scene s = m_app.SceneManager.CurrentScene; 2420 Scene s = m_app.SceneManager.CurrentScene;
2396 Hashtable users = (Hashtable) requestData["users"]; 2421 Hashtable users = (Hashtable) requestData["users"];
2397 List<UUID> uuids = new List<UUID>(); 2422 List<UUID> uuids = new List<UUID>();
2398 foreach (string name in users.Values) 2423 foreach (string name in users.Values)
2399 { 2424 {
2400 string[] parts = name.Split(); 2425 string[] parts = name.Split();
2401 CachedUserInfo udata = ups.GetUserDetails(parts[0],parts[1]); 2426 UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]);
2402 if (udata != null) 2427 if (account != null)
2403 { 2428 {
2404 uuids.Add(udata.UserProfile.ID); 2429 uuids.Add(account.PrincipalID);
2405 m_log.DebugFormat("[RADMIN] adding \"{0}\" to ACL for \"{1}\"", name, s.RegionInfo.RegionName); 2430 m_log.DebugFormat("[RADMIN] adding \"{0}\" to ACL for \"{1}\"", name, s.RegionInfo.RegionName);
2406 } 2431 }
2407 } 2432 }
@@ -2477,21 +2502,23 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2477 2502
2478 if (requestData.Contains("users")) 2503 if (requestData.Contains("users"))
2479 { 2504 {
2480 UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService; 2505 UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
2506 IUserAccountService userService = m_app.SceneManager.CurrentOrFirstScene.UserAccountService;
2507 //UserProfileCacheService ups = m_app.CommunicationsManager.UserProfileCacheService;
2481 Scene s = m_app.SceneManager.CurrentScene; 2508 Scene s = m_app.SceneManager.CurrentScene;
2482 Hashtable users = (Hashtable) requestData["users"]; 2509 Hashtable users = (Hashtable) requestData["users"];
2483 List<UUID> uuids = new List<UUID>(); 2510 List<UUID> uuids = new List<UUID>();
2484 foreach (string name in users.Values) 2511 foreach (string name in users.Values)
2485 { 2512 {
2486 string[] parts = name.Split(); 2513 string[] parts = name.Split();
2487 CachedUserInfo udata = ups.GetUserDetails(parts[0],parts[1]); 2514 UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]);
2488 if (udata != null) 2515 if (account != null)
2489 { 2516 {
2490 uuids.Add(udata.UserProfile.ID); 2517 uuids.Add(account.PrincipalID);
2491 } 2518 }
2492 } 2519 }
2493 List<UUID> acl = new List<UUID>(s.RegionInfo.EstateSettings.EstateAccess); 2520 List<UUID> acl = new List<UUID>(s.RegionInfo.EstateSettings.EstateAccess);
2494 foreach (UUID uuid in uuids) 2521 foreach (UUID uuid in uuids)
2495 { 2522 {
2496 if (acl.Contains(uuid)) 2523 if (acl.Contains(uuid))
2497 { 2524 {
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
index d3a7e64..10f1a6e 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
@@ -35,6 +35,9 @@ using System.Xml;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37using OpenSim.Framework.Servers.HttpServer; 37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Services.Interfaces;
39
40using OpenMetaverse;
38 41
39namespace OpenSim.ApplicationPlugins.Rest.Inventory 42namespace OpenSim.ApplicationPlugins.Rest.Inventory
40{ 43{
@@ -658,7 +661,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
658 { 661 {
659 662
660 int x; 663 int x;
661 string HA1;
662 string first; 664 string first;
663 string last; 665 string last;
664 666
@@ -675,17 +677,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
675 last = String.Empty; 677 last = String.Empty;
676 } 678 }
677 679
678 UserProfileData udata = Rest.UserServices.GetUserProfile(first, last); 680 UserAccount account = Rest.UserServices.GetUserAccount(UUID.Zero, first, last);
679 681
680 // If we don't recognize the user id, perhaps it is god? 682 // If we don't recognize the user id, perhaps it is god?
681 683 if (account == null)
682 if (udata == null)
683 return pass == Rest.GodKey; 684 return pass == Rest.GodKey;
684 685
685 HA1 = HashToString(pass); 686 return (Rest.AuthServices.Authenticate(account.PrincipalID, pass, 1) != string.Empty);
686 HA1 = HashToString(String.Format("{0}:{1}",HA1,udata.PasswordSalt));
687
688 return (0 == sc.Compare(HA1, udata.PasswordHash));
689 687
690 } 688 }
691 689
@@ -897,11 +895,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
897 last = String.Empty; 895 last = String.Empty;
898 } 896 }
899 897
900 UserProfileData udata = Rest.UserServices.GetUserProfile(first, last); 898 UserAccount account = Rest.UserServices.GetUserAccount(UUID.Zero, first, last);
901
902 // If we don;t recognize the user id, perhaps it is god? 899 // If we don;t recognize the user id, perhaps it is god?
903 900
904 if (udata == null) 901 if (account == null)
905 { 902 {
906 Rest.Log.DebugFormat("{0} Administrator", MsgId); 903 Rest.Log.DebugFormat("{0} Administrator", MsgId);
907 return Rest.GodKey; 904 return Rest.GodKey;
@@ -909,7 +906,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
909 else 906 else
910 { 907 {
911 Rest.Log.DebugFormat("{0} Normal User {1}", MsgId, user); 908 Rest.Log.DebugFormat("{0} Normal User {1}", MsgId, user);
912 return udata.PasswordHash; 909
910 // !!! REFACTORING PROBLEM
911 // This is what it was. It doesn't work in 0.7
912 // Nothing retrieves the password from the authentication service, there's only authentication.
913 //return udata.PasswordHash;
914 return string.Empty;
913 } 915 }
914 916
915 } 917 }
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs
index 8d62423..791cfcd 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs
@@ -103,11 +103,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
103 get { return main.SceneManager.CurrentOrFirstScene.InventoryService; } 103 get { return main.SceneManager.CurrentOrFirstScene.InventoryService; }
104 } 104 }
105 105
106 internal static IUserService UserServices 106 internal static IUserAccountService UserServices
107 { 107 {
108 get { return Comms.UserService; } 108 get { return main.SceneManager.CurrentOrFirstScene.UserAccountService; }
109 } 109 }
110 110
111 internal static IAuthenticationService AuthServices
112 {
113 get { return main.SceneManager.CurrentOrFirstScene.AuthenticationService; }
114 }
115
111 internal static IAvatarService AvatarServices 116 internal static IAvatarService AvatarServices
112 { 117 {
113 get { return Comms.AvatarService; } 118 get { return Comms.AvatarService; }
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
index b2b4aa7..0a45eff 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
@@ -135,152 +135,153 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
135 135
136 private void DoAppearance(RequestData hdata) 136 private void DoAppearance(RequestData hdata)
137 { 137 {
138 138 // !!! REFACTORIMG PROBLEM. This needs rewriting for 0.7
139 AppearanceRequestData rdata = (AppearanceRequestData) hdata; 139
140 140 //AppearanceRequestData rdata = (AppearanceRequestData) hdata;
141 Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId); 141
142 142 //Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
143 // If we're disabled, do nothing. 143
144 144 //// If we're disabled, do nothing.
145 if (!enabled) 145
146 { 146 //if (!enabled)
147 return; 147 //{
148 } 148 // return;
149 149 //}
150 // Now that we know this is a serious attempt to 150
151 // access inventory data, we should find out who 151 //// Now that we know this is a serious attempt to
152 // is asking, and make sure they are authorized 152 //// access inventory data, we should find out who
153 // to do so. We need to validate the caller's 153 //// is asking, and make sure they are authorized
154 // identity before revealing anything about the 154 //// to do so. We need to validate the caller's
155 // status quo. Authenticate throws an exception 155 //// identity before revealing anything about the
156 // via Fail if no identity information is present. 156 //// status quo. Authenticate throws an exception
157 // 157 //// via Fail if no identity information is present.
158 // With the present HTTP server we can't use the 158 ////
159 // builtin authentication mechanisms because they 159 //// With the present HTTP server we can't use the
160 // would be enforced for all in-bound requests. 160 //// builtin authentication mechanisms because they
161 // Instead we look at the headers ourselves and 161 //// would be enforced for all in-bound requests.
162 // handle authentication directly. 162 //// Instead we look at the headers ourselves and
163 163 //// handle authentication directly.
164 try 164
165 { 165 //try
166 if (!rdata.IsAuthenticated) 166 //{
167 { 167 // if (!rdata.IsAuthenticated)
168 rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName)); 168 // {
169 } 169 // rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
170 } 170 // }
171 catch (RestException e) 171 //}
172 { 172 //catch (RestException e)
173 if (e.statusCode == Rest.HttpStatusCodeNotAuthorized) 173 //{
174 { 174 // if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
175 Rest.Log.WarnFormat("{0} User not authenticated", MsgId); 175 // {
176 Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization")); 176 // Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
177 } 177 // Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
178 else 178 // }
179 { 179 // else
180 Rest.Log.ErrorFormat("{0} User authentication failed", MsgId); 180 // {
181 Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization")); 181 // Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
182 } 182 // Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
183 throw (e); 183 // }
184 } 184 // throw (e);
185 185 //}
186 Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName); 186
187 187 //Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
188 // We can only get here if we are authorized 188
189 // 189 //// We can only get here if we are authorized
190 // The requestor may have specified an UUID or 190 ////
191 // a conjoined FirstName LastName string. We'll 191 //// The requestor may have specified an UUID or
192 // try both. If we fail with the first, UUID, 192 //// a conjoined FirstName LastName string. We'll
193 // attempt, we try the other. As an example, the 193 //// try both. If we fail with the first, UUID,
194 // URI for a valid inventory request might be: 194 //// attempt, we try the other. As an example, the
195 // 195 //// URI for a valid inventory request might be:
196 // http://<host>:<port>/admin/inventory/Arthur Dent 196 ////
197 // 197 //// http://<host>:<port>/admin/inventory/Arthur Dent
198 // Indicating that this is an inventory request for 198 ////
199 // an avatar named Arthur Dent. This is ALL that is 199 //// Indicating that this is an inventory request for
200 // required to designate a GET for an entire 200 //// an avatar named Arthur Dent. This is ALL that is
201 // inventory. 201 //// required to designate a GET for an entire
202 // 202 //// inventory.
203 203 ////
204 // Do we have at least a user agent name? 204
205 205 //// Do we have at least a user agent name?
206 if (rdata.Parameters.Length < 1) 206
207 { 207 //if (rdata.Parameters.Length < 1)
208 Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId); 208 //{
209 rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified"); 209 // Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId);
210 } 210 // rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
211 211 //}
212 // The first parameter MUST be the agent identification, either an UUID 212
213 // or a space-separated First-name Last-Name specification. We check for 213 //// The first parameter MUST be the agent identification, either an UUID
214 // an UUID first, if anyone names their character using a valid UUID 214 //// or a space-separated First-name Last-Name specification. We check for
215 // that identifies another existing avatar will cause this a problem... 215 //// an UUID first, if anyone names their character using a valid UUID
216 216 //// that identifies another existing avatar will cause this a problem...
217 try 217
218 { 218 //try
219 rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]); 219 //{
220 Rest.Log.DebugFormat("{0} UUID supplied", MsgId); 220 // rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
221 rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid); 221 // Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
222 } 222 // rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
223 catch 223 //}
224 { 224 //catch
225 string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE); 225 //{
226 if (names.Length == 2) 226 // string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
227 { 227 // if (names.Length == 2)
228 Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId); 228 // {
229 rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]); 229 // Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
230 } 230 // rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
231 else 231 // }
232 { 232 // else
233 Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId); 233 // {
234 rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity"); 234 // Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
235 } 235 // rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
236 } 236 // }
237 237 //}
238 // If the user profile is null then either the server is broken, or the 238
239 // user is not known. We always assume the latter case. 239 //// If the user profile is null then either the server is broken, or the
240 240 //// user is not known. We always assume the latter case.
241 if (rdata.userProfile != null) 241
242 { 242 //if (rdata.userProfile != null)
243 Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}", 243 //{
244 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 244 // Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}",
245 } 245 // MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
246 else 246 //}
247 { 247 //else
248 Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path); 248 //{
249 rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity"); 249 // Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path);
250 } 250 // rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
251 251 //}
252 // If we get to here, then we have effectively validated the user's 252
253 253 //// If we get to here, then we have effectively validated the user's
254 switch (rdata.method) 254
255 { 255 //switch (rdata.method)
256 case Rest.HEAD : // Do the processing, set the status code, suppress entity 256 //{
257 DoGet(rdata); 257 // case Rest.HEAD : // Do the processing, set the status code, suppress entity
258 rdata.buffer = null; 258 // DoGet(rdata);
259 break; 259 // rdata.buffer = null;
260 260 // break;
261 case Rest.GET : // Do the processing, set the status code, return entity 261
262 DoGet(rdata); 262 // case Rest.GET : // Do the processing, set the status code, return entity
263 break; 263 // DoGet(rdata);
264 264 // break;
265 case Rest.PUT : // Update named element 265
266 DoUpdate(rdata); 266 // case Rest.PUT : // Update named element
267 break; 267 // DoUpdate(rdata);
268 268 // break;
269 case Rest.POST : // Add new information to identified context. 269
270 DoExtend(rdata); 270 // case Rest.POST : // Add new information to identified context.
271 break; 271 // DoExtend(rdata);
272 272 // break;
273 case Rest.DELETE : // Delete information 273
274 DoDelete(rdata); 274 // case Rest.DELETE : // Delete information
275 break; 275 // DoDelete(rdata);
276 276 // break;
277 default : 277
278 Rest.Log.WarnFormat("{0} Method {1} not supported for {2}", 278 // default :
279 MsgId, rdata.method, rdata.path); 279 // Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
280 rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed, 280 // MsgId, rdata.method, rdata.path);
281 String.Format("{0} not supported", rdata.method)); 281 // rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
282 break; 282 // String.Format("{0} not supported", rdata.method));
283 } 283 // break;
284 //}
284 } 285 }
285 286
286 #endregion Interface 287 #endregion Interface
@@ -391,37 +392,39 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
391 private void DoUpdate(AppearanceRequestData rdata) 392 private void DoUpdate(AppearanceRequestData rdata)
392 { 393 {
393 394
394 bool created = false; 395 // REFACTORING PROBLEM This was commented out. It doesn't work for 0.7
395 bool modified = false;
396 396
397 //bool created = false;
398 //bool modified = false;
397 399
398 rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
399 400
400 // If the user exists then this is considered a modification regardless 401 //rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
401 // of what may, or may not be, specified in the payload.
402 402
403 if (rdata.userAppearance != null) 403 //// If the user exists then this is considered a modification regardless
404 { 404 //// of what may, or may not be, specified in the payload.
405 modified = true;
406 Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
407 Rest.UserServices.UpdateUserProfile(rdata.userProfile);
408 }
409 405
410 if (created) 406 //if (rdata.userAppearance != null)
411 { 407 //{
412 rdata.Complete(Rest.HttpStatusCodeCreated); 408 // modified = true;
413 } 409 // Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
414 else 410 // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
415 { 411 //}
416 if (modified) 412
417 { 413 //if (created)
418 rdata.Complete(Rest.HttpStatusCodeOK); 414 //{
419 } 415 // rdata.Complete(Rest.HttpStatusCodeCreated);
420 else 416 //}
421 { 417 //else
422 rdata.Complete(Rest.HttpStatusCodeNoContent); 418 //{
423 } 419 // if (modified)
424 } 420 // {
421 // rdata.Complete(Rest.HttpStatusCodeOK);
422 // }
423 // else
424 // {
425 // rdata.Complete(Rest.HttpStatusCodeNoContent);
426 // }
427 //}
425 428
426 rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); 429 rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
427 430
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index 01bfe00..098c54d 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -143,203 +143,205 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
143 143
144 Rest.Log.DebugFormat("{0} DoInventory ENTRY", MsgId); 144 Rest.Log.DebugFormat("{0} DoInventory ENTRY", MsgId);
145 145
146 // If we're disabled, do nothing. 146 // !!! REFACTORING PROBLEM
147 147
148 if (!enabled) 148 //// If we're disabled, do nothing.
149 { 149
150 return; 150 //if (!enabled)
151 } 151 //{
152 152 // return;
153 // Now that we know this is a serious attempt to 153 //}
154 // access inventory data, we should find out who 154
155 // is asking, and make sure they are authorized 155 //// Now that we know this is a serious attempt to
156 // to do so. We need to validate the caller's 156 //// access inventory data, we should find out who
157 // identity before revealing anything about the 157 //// is asking, and make sure they are authorized
158 // status quo. Authenticate throws an exception 158 //// to do so. We need to validate the caller's
159 // via Fail if no identity information is present. 159 //// identity before revealing anything about the
160 // 160 //// status quo. Authenticate throws an exception
161 // With the present HTTP server we can't use the 161 //// via Fail if no identity information is present.
162 // builtin authentication mechanisms because they 162 ////
163 // would be enforced for all in-bound requests. 163 //// With the present HTTP server we can't use the
164 // Instead we look at the headers ourselves and 164 //// builtin authentication mechanisms because they
165 // handle authentication directly. 165 //// would be enforced for all in-bound requests.
166 166 //// Instead we look at the headers ourselves and
167 try 167 //// handle authentication directly.
168 { 168
169 if (!rdata.IsAuthenticated) 169 //try
170 { 170 //{
171 rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName)); 171 // if (!rdata.IsAuthenticated)
172 } 172 // {
173 } 173 // rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName));
174 catch (RestException e) 174 // }
175 { 175 //}
176 if (e.statusCode == Rest.HttpStatusCodeNotAuthorized) 176 //catch (RestException e)
177 { 177 //{
178 Rest.Log.WarnFormat("{0} User not authenticated", MsgId); 178 // if (e.statusCode == Rest.HttpStatusCodeNotAuthorized)
179 Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization")); 179 // {
180 } 180 // Rest.Log.WarnFormat("{0} User not authenticated", MsgId);
181 else 181 // Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
182 { 182 // }
183 Rest.Log.ErrorFormat("{0} User authentication failed", MsgId); 183 // else
184 Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization")); 184 // {
185 } 185 // Rest.Log.ErrorFormat("{0} User authentication failed", MsgId);
186 throw (e); 186 // Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization"));
187 } 187 // }
188 188 // throw (e);
189 Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName); 189 //}
190 190
191 // We can only get here if we are authorized 191 //Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName);
192 // 192
193 // The requestor may have specified an UUID or 193 //// We can only get here if we are authorized
194 // a conjoined FirstName LastName string. We'll 194 ////
195 // try both. If we fail with the first, UUID, 195 //// The requestor may have specified an UUID or
196 // attempt, we try the other. As an example, the 196 //// a conjoined FirstName LastName string. We'll
197 // URI for a valid inventory request might be: 197 //// try both. If we fail with the first, UUID,
198 // 198 //// attempt, we try the other. As an example, the
199 // http://<host>:<port>/admin/inventory/Arthur Dent 199 //// URI for a valid inventory request might be:
200 // 200 ////
201 // Indicating that this is an inventory request for 201 //// http://<host>:<port>/admin/inventory/Arthur Dent
202 // an avatar named Arthur Dent. This is ALL that is 202 ////
203 // required to designate a GET for an entire 203 //// Indicating that this is an inventory request for
204 // inventory. 204 //// an avatar named Arthur Dent. This is ALL that is
205 // 205 //// required to designate a GET for an entire
206 206 //// inventory.
207 207 ////
208 // Do we have at least a user agent name? 208
209 209
210 if (rdata.Parameters.Length < 1) 210 //// Do we have at least a user agent name?
211 { 211
212 Rest.Log.WarnFormat("{0} Inventory: No user agent identifier specified", MsgId); 212 //if (rdata.Parameters.Length < 1)
213 rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified"); 213 //{
214 } 214 // Rest.Log.WarnFormat("{0} Inventory: No user agent identifier specified", MsgId);
215 215 // rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified");
216 // The first parameter MUST be the agent identification, either an UUID 216 //}
217 // or a space-separated First-name Last-Name specification. We check for 217
218 // an UUID first, if anyone names their character using a valid UUID 218 //// The first parameter MUST be the agent identification, either an UUID
219 // that identifies another existing avatar will cause this a problem... 219 //// or a space-separated First-name Last-Name specification. We check for
220 220 //// an UUID first, if anyone names their character using a valid UUID
221 try 221 //// that identifies another existing avatar will cause this a problem...
222 { 222
223 rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]); 223 //try
224 Rest.Log.DebugFormat("{0} UUID supplied", MsgId); 224 //{
225 rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid); 225 // rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]);
226 } 226 // Rest.Log.DebugFormat("{0} UUID supplied", MsgId);
227 catch 227 // rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid);
228 { 228 //}
229 string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE); 229 //catch
230 if (names.Length == 2) 230 //{
231 { 231 // string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE);
232 Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId); 232 // if (names.Length == 2)
233 rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]); 233 // {
234 } 234 // Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId);
235 else 235 // rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]);
236 { 236 // }
237 Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId); 237 // else
238 rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity"); 238 // {
239 } 239 // Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId);
240 } 240 // rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity");
241 241 // }
242 // If the user profile is null then either the server is broken, or the 242 //}
243 // user is not known. We always assume the latter case. 243
244 244 //// If the user profile is null then either the server is broken, or the
245 if (rdata.userProfile != null) 245 //// user is not known. We always assume the latter case.
246 { 246
247 Rest.Log.DebugFormat("{0} Profile obtained for agent {1} {2}", 247 //if (rdata.userProfile != null)
248 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 248 //{
249 } 249 // Rest.Log.DebugFormat("{0} Profile obtained for agent {1} {2}",
250 else 250 // MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
251 { 251 //}
252 Rest.Log.WarnFormat("{0} No profile for {1}", MsgId, rdata.path); 252 //else
253 rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity"); 253 //{
254 } 254 // Rest.Log.WarnFormat("{0} No profile for {1}", MsgId, rdata.path);
255 255 // rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity");
256 // If we get to here, then we have effectively validated the user's 256 //}
257 // identity. Now we need to get the inventory. If the server does not 257
258 // have the inventory, we reject the request with an appropriate explanation. 258 //// If we get to here, then we have effectively validated the user's
259 // 259 //// identity. Now we need to get the inventory. If the server does not
260 // Note that inventory retrieval is an asynchronous event, we use the rdata 260 //// have the inventory, we reject the request with an appropriate explanation.
261 // class instance as the basis for our synchronization. 261 ////
262 // 262 //// Note that inventory retrieval is an asynchronous event, we use the rdata
263 263 //// class instance as the basis for our synchronization.
264 rdata.uuid = rdata.userProfile.ID; 264 ////
265 265
266 if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid)) 266 //rdata.uuid = rdata.userProfile.ID;
267 { 267
268 rdata.root = Rest.InventoryServices.GetRootFolder(rdata.uuid); 268 //if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid))
269 269 //{
270 Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}", 270 // rdata.root = Rest.InventoryServices.GetRootFolder(rdata.uuid);
271 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 271
272 272 // Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}",
273 Rest.InventoryServices.GetUserInventory(rdata.uuid, rdata.GetUserInventory); 273 // MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
274 274
275 Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}", 275 // Rest.InventoryServices.GetUserInventory(rdata.uuid, rdata.GetUserInventory);
276 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 276
277 277 // Rest.Log.DebugFormat("{0} Inventory catalog requested for {1} {2}",
278 lock (rdata) 278 // MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
279 { 279
280 if (!rdata.HaveInventory) 280 // lock (rdata)
281 { 281 // {
282 rdata.startWD(1000); 282 // if (!rdata.HaveInventory)
283 rdata.timeout = false; 283 // {
284 Monitor.Wait(rdata); 284 // rdata.startWD(1000);
285 } 285 // rdata.timeout = false;
286 } 286 // Monitor.Wait(rdata);
287 287 // }
288 if (rdata.timeout) 288 // }
289 { 289
290 Rest.Log.WarnFormat("{0} Inventory not available for {1} {2}. No response from service.", 290 // if (rdata.timeout)
291 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 291 // {
292 rdata.Fail(Rest.HttpStatusCodeServerError, "inventory server not responding"); 292 // Rest.Log.WarnFormat("{0} Inventory not available for {1} {2}. No response from service.",
293 } 293 // MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
294 294 // rdata.Fail(Rest.HttpStatusCodeServerError, "inventory server not responding");
295 if (rdata.root == null) 295 // }
296 { 296
297 Rest.Log.WarnFormat("{0} Inventory is not available [1] for agent {1} {2}", 297 // if (rdata.root == null)
298 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 298 // {
299 rdata.Fail(Rest.HttpStatusCodeServerError, "inventory retrieval failed"); 299 // Rest.Log.WarnFormat("{0} Inventory is not available [1] for agent {1} {2}",
300 } 300 // MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
301 301 // rdata.Fail(Rest.HttpStatusCodeServerError, "inventory retrieval failed");
302 } 302 // }
303 else 303
304 { 304 //}
305 Rest.Log.WarnFormat("{0} Inventory is not locally available for agent {1} {2}", 305 //else
306 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 306 //{
307 rdata.Fail(Rest.HttpStatusCodeNotFound, "no local inventory for user"); 307 // Rest.Log.WarnFormat("{0} Inventory is not locally available for agent {1} {2}",
308 } 308 // MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
309 309 // rdata.Fail(Rest.HttpStatusCodeNotFound, "no local inventory for user");
310 // If we get here, then we have successfully retrieved the user's information 310 //}
311 // and inventory information is now available locally. 311
312 312 //// If we get here, then we have successfully retrieved the user's information
313 switch (rdata.method) 313 //// and inventory information is now available locally.
314 { 314
315 case Rest.HEAD : // Do the processing, set the status code, suppress entity 315 //switch (rdata.method)
316 DoGet(rdata); 316 //{
317 rdata.buffer = null; 317 // case Rest.HEAD : // Do the processing, set the status code, suppress entity
318 break; 318 // DoGet(rdata);
319 319 // rdata.buffer = null;
320 case Rest.GET : // Do the processing, set the status code, return entity 320 // break;
321 DoGet(rdata); 321
322 break; 322 // case Rest.GET : // Do the processing, set the status code, return entity
323 323 // DoGet(rdata);
324 case Rest.PUT : // Update named element 324 // break;
325 DoUpdate(rdata); 325
326 break; 326 // case Rest.PUT : // Update named element
327 327 // DoUpdate(rdata);
328 case Rest.POST : // Add new information to identified context. 328 // break;
329 DoExtend(rdata); 329
330 break; 330 // case Rest.POST : // Add new information to identified context.
331 331 // DoExtend(rdata);
332 case Rest.DELETE : // Delete information 332 // break;
333 DoDelete(rdata); 333
334 break; 334 // case Rest.DELETE : // Delete information
335 335 // DoDelete(rdata);
336 default : 336 // break;
337 Rest.Log.WarnFormat("{0} Method {1} not supported for {2}", 337
338 MsgId, rdata.method, rdata.path); 338 // default :
339 rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed, 339 // Rest.Log.WarnFormat("{0} Method {1} not supported for {2}",
340 String.Format("{0} not supported", rdata.method)); 340 // MsgId, rdata.method, rdata.path);
341 break; 341 // rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed,
342 } 342 // String.Format("{0} not supported", rdata.method));
343 // break;
344 //}
343 } 345 }
344 346
345 #endregion Interface 347 #endregion Interface
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
index 7d71f18..c4b3dda 100644
--- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
+++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
@@ -41,6 +41,7 @@ using OpenSim.Client.MXP.ClientStack;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Framework.Communications; 43using OpenSim.Framework.Communications;
44using OpenSim.Services.Interfaces;
44using System.Security.Cryptography; 45using System.Security.Cryptography;
45 46
46namespace OpenSim.Client.MXP.PacketHandler 47namespace OpenSim.Client.MXP.PacketHandler
@@ -295,13 +296,11 @@ namespace OpenSim.Client.MXP.PacketHandler
295 regionExists = false; 296 regionExists = false;
296 } 297 }
297 298
298 UserProfileData user = null;
299 UUID userId = UUID.Zero; 299 UUID userId = UUID.Zero;
300 string firstName = null; 300 UserAccount account = null;
301 string lastName = null;
302 bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName, 301 bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName,
303 joinRequestMessage.ParticipantPassphrase, 302 joinRequestMessage.ParticipantPassphrase,
304 new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName, out user) 303 new UUID(joinRequestMessage.BubbleId), out account)
305 : false; 304 : false;
306 305
307 if (authorized) 306 if (authorized)
@@ -316,10 +315,11 @@ namespace OpenSim.Client.MXP.PacketHandler
316 session.RemoteEndPoint.Port + ")"); 315 session.RemoteEndPoint.Port + ")");
317 316
318 m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile..."); 317 m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile...");
319 AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user); 318 UUID secureSession = UUID.Zero;
319 AttachUserAgentToUserProfile(account, session, mxpSessionID, sceneId, out secureSession);
320 m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile."); 320 m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile.");
321 m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection..."); 321 m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection...");
322 if (!PrepareSceneForConnection(mxpSessionID, sceneId, user, out reason)) 322 if (!PrepareSceneForConnection(mxpSessionID, secureSession, sceneId, account, out reason))
323 { 323 {
324 m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason); 324 m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason);
325 DeclineConnection(session, joinRequestMessage); 325 DeclineConnection(session, joinRequestMessage);
@@ -332,7 +332,7 @@ namespace OpenSim.Client.MXP.PacketHandler
332 m_log.Info("[MXP ClientStack]: Accepted connection."); 332 m_log.Info("[MXP ClientStack]: Accepted connection.");
333 333
334 m_log.Debug("[MXP ClientStack]: Creating ClientView...."); 334 m_log.Debug("[MXP ClientStack]: Creating ClientView....");
335 MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, firstName, lastName); 335 MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, account.FirstName, account.LastName);
336 m_clients.Add(client); 336 m_clients.Add(client);
337 m_log.Debug("[MXP ClientStack]: Created ClientView."); 337 m_log.Debug("[MXP ClientStack]: Created ClientView.");
338 338
@@ -489,12 +489,12 @@ namespace OpenSim.Client.MXP.PacketHandler
489 session.SetStateDisconnected(); 489 session.SetStateDisconnected();
490 } 490 }
491 491
492 public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UUID userId, out string firstName, out string lastName, out UserProfileData userProfile) 492 public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UserAccount account)
493 { 493 {
494 userId = UUID.Zero; 494 UUID userId = UUID.Zero;
495 firstName = ""; 495 string firstName = "";
496 lastName = ""; 496 string lastName = "";
497 userProfile = null; 497 account = null;
498 498
499 string[] nameParts = participantName.Split(' '); 499 string[] nameParts = participantName.Split(' ');
500 if (nameParts.Length != 2) 500 if (nameParts.Length != 2)
@@ -505,103 +505,38 @@ namespace OpenSim.Client.MXP.PacketHandler
505 firstName = nameParts[0]; 505 firstName = nameParts[0];
506 lastName = nameParts[1]; 506 lastName = nameParts[1];
507 507
508 userProfile = m_scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName); 508 account = m_scenes[sceneId].UserAccountService.GetUserAccount(m_scenes[sceneId].RegionInfo.ScopeID, firstName, lastName);
509 if (account != null)
510 return (m_scenes[sceneId].AuthenticationService.Authenticate(account.PrincipalID, password, 1) != string.Empty);
509 511
510 if (userProfile == null && !m_accountsAuthenticate) 512 return false;
511 {
512 userId = ((UserManagerBase)m_scenes[sceneId].CommsManager.UserService).AddUser(firstName, lastName, "test", "", 1000, 1000);
513 }
514 else
515 {
516 if (userProfile == null)
517 {
518 m_log.Error("[MXP ClientStack]: Login failed as user was not found: " + participantName);
519 return false;
520 }
521 userId = userProfile.ID;
522 }
523
524 if (m_accountsAuthenticate)
525 {
526 if (!password.StartsWith("$1$"))
527 {
528 password = "$1$" + Util.Md5Hash(password);
529 }
530 password = password.Remove(0, 3); //remove $1$
531 string s = Util.Md5Hash(password + ":" + userProfile.PasswordSalt);
532 return (userProfile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
533 || userProfile.PasswordHash.Equals(password, StringComparison.InvariantCulture));
534 }
535 else
536 {
537 return true;
538 }
539 } 513 }
540 514
541 private void AttachUserAgentToUserProfile(Session session, UUID sessionId, UUID sceneId, UserProfileData userProfile) 515 private void AttachUserAgentToUserProfile(UserAccount account, Session session, UUID sessionId, UUID sceneId, out UUID secureSessionId)
542 { 516 {
543 //Scene scene = m_scenes[sceneId]; 517 secureSessionId = UUID.Random();
544 CommunicationsManager commsManager = m_scenes[sceneId].CommsManager; 518 Scene scene = m_scenes[sceneId];
545 IUserService userService = (IUserService)commsManager.UserService; 519 scene.PresenceService.LoginAgent(account.PrincipalID.ToString(), sessionId, secureSessionId);
546
547 UserAgentData agent = new UserAgentData();
548
549 // User connection
550 agent.AgentOnline = true;
551 agent.AgentIP = session.RemoteEndPoint.Address.ToString();
552 agent.AgentPort = (uint)session.RemoteEndPoint.Port;
553
554 agent.SecureSessionID = UUID.Random();
555 agent.SessionID = sessionId;
556
557 // Profile UUID
558 agent.ProfileID = userProfile.ID;
559
560 // Current location/position/alignment
561 if (userProfile.CurrentAgent != null)
562 {
563 agent.Region = userProfile.CurrentAgent.Region;
564 agent.Handle = userProfile.CurrentAgent.Handle;
565 agent.Position = userProfile.CurrentAgent.Position;
566 agent.LookAt = userProfile.CurrentAgent.LookAt;
567 }
568 else
569 {
570 agent.Region = userProfile.HomeRegionID;
571 agent.Handle = userProfile.HomeRegion;
572 agent.Position = userProfile.HomeLocation;
573 agent.LookAt = userProfile.HomeLookAt;
574 }
575
576 // What time did the user login?
577 agent.LoginTime = Util.UnixTimeSinceEpoch();
578 agent.LogoutTime = 0;
579
580 userProfile.CurrentAgent = agent;
581
582
583 userService.UpdateUserProfile(userProfile);
584 //userService.CommitAgent(ref userProfile);
585 } 520 }
586 521
587 private bool PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile, out string reason) 522 private bool PrepareSceneForConnection(UUID sessionId, UUID secureSessionId, UUID sceneId, UserAccount account, out string reason)
588 { 523 {
589 Scene scene = m_scenes[sceneId]; 524 Scene scene = m_scenes[sceneId];
590 CommunicationsManager commsManager = m_scenes[sceneId].CommsManager;
591 UserManagerBase userService = (UserManagerBase)commsManager.UserService;
592 525
593 AgentCircuitData agent = new AgentCircuitData(); 526 AgentCircuitData agent = new AgentCircuitData();
594 agent.AgentID = userProfile.ID; 527 agent.AgentID = account.PrincipalID;
595 agent.firstname = userProfile.FirstName; 528 agent.firstname = account.FirstName;
596 agent.lastname = userProfile.SurName; 529 agent.lastname = account.LastName;
597 agent.SessionID = sessionId; 530 agent.SessionID = sessionId;
598 agent.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; 531 agent.SecureSessionID = secureSessionId;
599 agent.circuitcode = sessionId.CRC(); 532 agent.circuitcode = sessionId.CRC();
600 agent.BaseFolder = UUID.Zero; 533 agent.BaseFolder = UUID.Zero;
601 agent.InventoryFolder = UUID.Zero; 534 agent.InventoryFolder = UUID.Zero;
602 agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position 535 agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position
603 agent.CapsPath = "http://localhost/"; 536 agent.CapsPath = "http://localhost/";
604 agent.Appearance = userService.GetUserAppearance(userProfile.ID); 537 AvatarData avatar = scene.AvatarService.GetAvatar(account.PrincipalID);
538 if (avatar != null)
539 agent.Appearance = avatar.ToAvatarAppearance(); //userService.GetUserAppearance(userProfile.ID);
605 540
606 if (agent.Appearance == null) 541 if (agent.Appearance == null)
607 { 542 {
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
deleted file mode 100644
index 830c877..0000000
--- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
+++ /dev/null
@@ -1,345 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using NUnit.Framework;
29using NUnit.Framework.SyntaxHelpers;
30using System.Threading;
31using OpenMetaverse;
32using OpenSim.Data;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Communications.Local;
37using OpenSim.Tests.Common.Mock;
38using OpenSim.Tests.Common.Setup;
39using OpenSim.Tests.Common;
40
41namespace OpenSim.Framework.Communications.Tests
42{
43 [TestFixture]
44 public class UserProfileCacheServiceTests
45 {
46 /// <value>Used by tests to indicate whether an async operation timed out</value>
47 private bool timedOut;
48
49 private void InventoryReceived(UUID userId)
50 {
51 lock (this)
52 {
53 timedOut = false;
54 Monitor.PulseAll(this);
55 }
56 }
57
58 [Test]
59 public void TestGetUserDetails()
60 {
61 TestHelper.InMethod();
62
63 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002");
64 string firstName = "Bill";
65 string lastName = "Bailey";
66 CachedUserInfo nonExistingUserInfo;
67
68 TestCommunicationsManager commsManager = new TestCommunicationsManager();
69 // Scene myScene = SceneSetupHelpers.SetupScene(commsManager, "");
70
71 // Check we can't retrieve info before it exists by uuid
72 nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
73 Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation");
74
75 // Check we can't retrieve info before it exists by name
76 nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
77 Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation");
78
79 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
80 lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
81
82 CachedUserInfo existingUserInfo;
83
84 // Check we can retrieve info by uuid
85 existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
86 Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid");
87
88 // Check we can retrieve info by name
89 existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
90 Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name");
91 }
92
93 /**
94 * Disabled as not fully implemented
95 [Test]
96 public void TestUpdateProfile()
97 {
98 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292");
99 string firstName = "Inspector";
100 string originalLastName = "Morse";
101 string newLastName = "Gadget";
102
103 UserProfileData newProfile = new UserProfileData();
104 newProfile.ID = userId;
105 newProfile.FirstName = firstName;
106 newProfile.SurName = newLastName;
107
108 TestCommunicationsManager commsManager = new TestCommunicationsManager();
109 UserProfileCacheService userCacheService = commsManager.UserProfileCacheService;
110 IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin;
111
112 // Check that we can't update info before it exists
113 Assert.That(userCacheService.StoreProfile(newProfile), Is.False);
114 Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null);
115
116 // Check that we can update a profile once it exists
117 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
118 lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId);
119
120 Assert.That(userCacheService.StoreProfile(newProfile), Is.True);
121 UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile;
122 Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName));
123 Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName));
124 }
125 */
126
127 [Test]
128 public void TestFetchInventory()
129 {
130 TestHelper.InMethod();
131
132 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
133
134 timedOut = true;
135 lock (this)
136 {
137 UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
138 Monitor.Wait(this, 60000);
139 }
140
141 Assert.That(timedOut, Is.False, "Timed out");
142 }
143
144 [Test]
145 public void TestGetChildFolder()
146 {
147 TestHelper.InMethod();
148
149 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
150 CachedUserInfo userInfo;
151
152 lock (this)
153 {
154 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
155 Monitor.Wait(this, 60000);
156 }
157
158 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
159 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
160 userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID);
161
162 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null);
163 }
164
165 [Test]
166 public void TestCreateFolder()
167 {
168 TestHelper.InMethod();
169
170 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
171 CachedUserInfo userInfo;
172
173 lock (this)
174 {
175 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
176 Monitor.Wait(this, 60000);
177 }
178
179 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
180 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
181
182 // 1: Try a folder create that should fail because the parent id given does not exist
183 UUID missingFolderId = UUID.Random();
184 InventoryFolderBase myFolder = new InventoryFolderBase();
185 myFolder.ID = folderId;
186
187 Assert.That(
188 userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False);
189 Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null);
190 Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False);
191 Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null);
192
193 // 2: Try a folder create that should work
194 Assert.That(
195 userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True);
196 Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null);
197 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True);
198 }
199
200 //[Test]
201 public void TestUpdateFolder()
202 {
203 TestHelper.InMethod();
204
205 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
206 CachedUserInfo userInfo;
207
208 lock (this)
209 {
210 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
211 Monitor.Wait(this, 60000);
212 }
213
214 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
215 InventoryFolderImpl rootFolder = userInfo.RootFolder;
216 InventoryFolderBase myFolder = new InventoryFolderBase();
217 myFolder.ID = folder1Id;
218
219 userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
220
221 // 1: Test updates that don't involve moving the folder
222 {
223 string newFolderName1 = "newFolderName1";
224 ushort folderType1 = (ushort)AssetType.Texture;
225 userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID);
226
227 InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id);
228 Assert.That(newFolderName1, Is.EqualTo(folder1.Name));
229 Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type));
230
231 InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder);
232 Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name));
233 Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type));
234 }
235
236 // 2: Test an update that also involves moving the folder
237 {
238 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000061");
239 userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID);
240 InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id);
241
242 InventoryFolderBase myFolder2 = new InventoryFolderBase();
243 myFolder2.ID = folder2Id;
244
245 string newFolderName2 = "newFolderName2";
246 ushort folderType2 = (ushort)AssetType.Bodypart;
247 userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id);
248
249 InventoryFolderImpl folder1 = folder2.GetChildFolder(folder1Id);
250 Assert.That(newFolderName2, Is.EqualTo(folder1.Name));
251 Assert.That(folderType2, Is.EqualTo((ushort)folder1.Type));
252 Assert.That(folder2Id, Is.EqualTo(folder1.ParentID));
253
254 Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True);
255 Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False);
256
257 InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder2);
258 Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name));
259 Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type));
260 Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID));
261 }
262
263 }
264
265 [Test]
266 public void TestMoveFolder()
267 {
268 TestHelper.InMethod();
269
270 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
271 CachedUserInfo userInfo;
272
273 lock (this)
274 {
275 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
276 Monitor.Wait(this, 60000);
277 }
278
279 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
280 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
281 UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030");
282 InventoryFolderImpl rootFolder = userInfo.RootFolder;
283
284 userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
285 InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id);
286 userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID);
287 InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id);
288
289 // Check folder is currently in folder1
290 userInfo.CreateFolder("folderToMove", folderToMoveId, (ushort)AssetType.Animation, folder1Id);
291 Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.True);
292
293 userInfo.MoveFolder(folderToMoveId, folder2Id);
294
295 // Check folder is now in folder2 and no trace remains in folder1
296 InventoryFolderBase myFolder = new InventoryFolderBase();
297 myFolder.ID = folderToMoveId;
298 Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True);
299 Assert.That(myScene.InventoryService.GetFolder(myFolder).ParentID, Is.EqualTo(folder2Id));
300
301 Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False);
302 }
303
304 [Test]
305 public void TestPurgeFolder()
306 {
307 TestHelper.InMethod();
308 //log4net.Config.XmlConfigurator.Configure();
309
310 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
311 CachedUserInfo userInfo;
312
313 lock (this)
314 {
315 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
316 Monitor.Wait(this, 60000);
317 }
318
319 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
320 InventoryFolderImpl rootFolder = userInfo.RootFolder;
321 InventoryFolderBase myFolder = new InventoryFolderBase();
322 myFolder.ID = folder1Id;
323
324 userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
325 Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null);
326
327 // Test purge
328 userInfo.PurgeFolder(rootFolder.ID);
329
330 Assert.That(rootFolder.RequestListOfFolders(), Is.Empty);
331 Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null);
332 }
333
334 [TearDown]
335 public void TearDown()
336 {
337 try
338 {
339 if (MainServer.Instance != null) MainServer.Instance.Stop();
340 }
341 catch (System.NullReferenceException)
342 { }
343 }
344 }
345} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index 10a3232..cf7bcef 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -534,26 +534,28 @@ namespace OpenSim.Region.CoreModules.InterGrid
534 userProfile.WantDoMask = 0; 534 userProfile.WantDoMask = 0;
535 userProfile.WebLoginKey = UUID.Random(); 535 userProfile.WebLoginKey = UUID.Random();
536 536
537 // Do caps registration 537 // !!! REFACTORING PROBLEM. This needs to be changed for 0.7
538 // get seed capagentData.firstname = FirstName;agentData.lastname = LastName; 538 //
539 if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode) 539 //// Do caps registration
540 { 540 //// get seed capagentData.firstname = FirstName;agentData.lastname = LastName;
541 homeScene.CommsManager.UserAdminService.AddUser( 541 //if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode)
542 agentData.firstname, agentData.lastname, CreateRandomStr(7), "", 542 //{
543 homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID); 543 // homeScene.CommsManager.UserAdminService.AddUser(
544 // agentData.firstname, agentData.lastname, CreateRandomStr(7), "",
545 // homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID);
544 546
545 UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID); 547 // UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID);
546 if (userProfile2 != null) 548 // if (userProfile2 != null)
547 { 549 // {
548 userProfile = userProfile2; 550 // userProfile = userProfile2;
549 userProfile.AboutText = "OGP USER"; 551 // userProfile.AboutText = "OGP USER";
550 userProfile.FirstLifeAboutText = "OGP USER"; 552 // userProfile.FirstLifeAboutText = "OGP USER";
551 homeScene.CommsManager.UserService.UpdateUserProfile(userProfile); 553 // homeScene.CommsManager.UserService.UpdateUserProfile(userProfile);
552 } 554 // }
553 } 555 //}
554 556
555 // Stick our data in the cache so the region will know something about us 557 //// Stick our data in the cache so the region will know something about us
556 homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile); 558 //homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile);
557 559
558 // Call 'new user' event handler 560 // Call 'new user' event handler
559 string reason; 561 string reason;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 1fdf1ef..7584dd8 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -161,7 +161,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
161 m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService; 161 m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService;
162 // ugh! 162 // ugh!
163 m_UserProfileService.SetInventoryService(this); 163 m_UserProfileService.SetInventoryService(this);
164 scene.CommsManager.UserService.SetInventoryService(this);
165 164
166 m_Initialized = true; 165 m_Initialized = true;
167 } 166 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index 66d11dd..f2e344f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -133,7 +133,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
133 { 133 {
134 // ugh! 134 // ugh!
135 scene.CommsManager.UserProfileCacheService.SetInventoryService(this); 135 scene.CommsManager.UserProfileCacheService.SetInventoryService(this);
136 scene.CommsManager.UserService.SetInventoryService(this);
137 m_Initialized = true; 136 m_Initialized = true;
138 } 137 }
139 138
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
index 69504df..3580c27 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
@@ -116,7 +116,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
116 { 116 {
117 // ugh! 117 // ugh!
118 scene.CommsManager.UserProfileCacheService.SetInventoryService(this); 118 scene.CommsManager.UserProfileCacheService.SetInventoryService(this);
119 scene.CommsManager.UserService.SetInventoryService(this);
120 m_Initialized = true; 119 m_Initialized = true;
121 } 120 }
122 121
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d8874b2..e22dd2d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -296,6 +296,17 @@ namespace OpenSim.Region.Framework.Scenes
296 } 296 }
297 } 297 }
298 298
299 protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService;
300 public OpenSim.Services.Interfaces.IAvatarService AvatarService
301 {
302 get
303 {
304 if (m_AvatarService == null)
305 m_AvatarService = RequestModuleInterface<OpenSim.Services.Interfaces.IAvatarService>();
306 return m_AvatarService;
307 }
308 }
309
299 protected IXMLRPC m_xmlrpcModule; 310 protected IXMLRPC m_xmlrpcModule;
300 protected IWorldComm m_worldCommModule; 311 protected IWorldComm m_worldCommModule;
301 protected IAvatarFactory m_AvatarFactory; 312 protected IAvatarFactory m_AvatarFactory;
@@ -2975,21 +2986,11 @@ namespace OpenSim.Region.Framework.Scenes
2975 /// <param name="client">The IClientAPI for the client</param> 2986 /// <param name="client">The IClientAPI for the client</param>
2976 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2987 public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
2977 { 2988 {
2978 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2989 OpenSim.Services.Interfaces.PresenceInfo pinfo = PresenceService.GetAgent(client.SessionId);
2979 if (UserProfile != null) 2990
2991 if (pinfo != null)
2980 { 2992 {
2981 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); 2993 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID);
2982 if (regionInfo == null)
2983 {
2984 uint x = 0, y = 0;
2985 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2986 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2987 if (regionInfo != null) // home region can be away temporarily, too
2988 {
2989 UserProfile.HomeRegionID = regionInfo.RegionID;
2990 CommsManager.UserService.UpdateUserProfile(UserProfile);
2991 }
2992 }
2993 if (regionInfo == null) 2994 if (regionInfo == null)
2994 { 2995 {
2995 // can't find the Home region: Tell viewer and abort 2996 // can't find the Home region: Tell viewer and abort
@@ -2997,7 +2998,7 @@ namespace OpenSim.Region.Framework.Scenes
2997 return; 2998 return;
2998 } 2999 }
2999 RequestTeleportLocation( 3000 RequestTeleportLocation(
3000 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt, 3001 client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt,
3001 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome)); 3002 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
3002 } 3003 }
3003 } 3004 }
@@ -3089,7 +3090,7 @@ namespace OpenSim.Region.Framework.Scenes
3089 } 3090 }
3090 3091
3091 /// <summary> 3092 /// <summary>
3092 /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in 3093 /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
3093 /// </summary> 3094 /// </summary>
3094 /// <param name="remoteClient"></param> 3095 /// <param name="remoteClient"></param>
3095 /// <param name="regionHandle"></param> 3096 /// <param name="regionHandle"></param>
@@ -3098,27 +3099,11 @@ namespace OpenSim.Region.Framework.Scenes
3098 /// <param name="flags"></param> 3099 /// <param name="flags"></param>
3099 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3100 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3100 { 3101 {
3101 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 3102 if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3102 if (UserProfile != null)
3103 {
3104 // I know I'm ignoring the regionHandle provided by the teleport location request.
3105 // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid
3106 UserProfile.HomeRegionID = RegionInfo.RegionID;
3107 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
3108 // TODO: The HomeRegion property can be removed then, too
3109 UserProfile.HomeRegion = RegionInfo.RegionHandle;
3110
3111 UserProfile.HomeLocation = position;
3112 UserProfile.HomeLookAt = lookAt;
3113 CommsManager.UserService.UpdateUserProfile(UserProfile);
3114
3115 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3103 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3116 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3104 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
3117 }
3118 else 3105 else
3119 {
3120 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); 3106 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed.");
3121 }
3122 } 3107 }
3123 3108
3124 /// <summary> 3109 /// <summary>
@@ -3254,12 +3239,6 @@ namespace OpenSim.Region.Framework.Scenes
3254 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3239 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3255 } 3240 }
3256 3241
3257 // Remove client agent from profile, so new logins will work
3258 if (!childagentYN)
3259 {
3260 m_sceneGridService.ClearUserAgent(agentID);
3261 }
3262
3263 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3242 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3264 3243
3265 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3244 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index f612d17..53693e4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -1455,11 +1455,6 @@ namespace OpenSim.Region.Framework.Scenes
1455 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); 1455 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
1456 } 1456 }
1457 1457
1458 public void ClearUserAgent(UUID avatarID)
1459 {
1460 m_commsProvider.UserService.ClearUserAgent(avatarID);
1461 }
1462
1463 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) 1458 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
1464 { 1459 {
1465 m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms); 1460 m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 8d32e66..c8a10b5 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -43,6 +43,8 @@ using OpenSim.Region.CoreModules.Framework.EventQueue;
43using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
45 45
46using OpenSim.Services.Interfaces;
47
46using Caps = OpenSim.Framework.Capabilities.Caps; 48using Caps = OpenSim.Framework.Capabilities.Caps;
47using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; 49using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags;
48 50
@@ -507,10 +509,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
507 { 509 {
508 if (m_debugEnabled) 510 if (m_debugEnabled)
509 { 511 {
510 UserProfileData targetUserProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(member.AgentID); 512 UserAccount targetUser = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, member.AgentID);
511 if (targetUserProfile != null) 513 if (targetUser != null)
512 { 514 {
513 m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUserProfile.Name, member.AcceptNotices); 515 m_log.DebugFormat("[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices);
514 } 516 }
515 else 517 else
516 { 518 {
@@ -990,9 +992,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
990 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 992 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true);
991 993
992 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); 994 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
993 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); 995 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID);
994 996 if ((groupInfo == null) || (account == null))
995 if ((groupInfo == null) || (userProfile == null))
996 { 997 {
997 return; 998 return;
998 } 999 }
@@ -1032,9 +1033,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1032 msg.toAgentID = remoteClient.AgentId.Guid; 1033 msg.toAgentID = remoteClient.AgentId.Guid;
1033 msg.timestamp = 0; 1034 msg.timestamp = 0;
1034 msg.fromAgentName = remoteClient.Name; 1035 msg.fromAgentName = remoteClient.Name;
1035 if (userProfile != null) 1036 if (account != null)
1036 { 1037 {
1037 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, userProfile.Name); 1038 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, account.FirstName + " " + account.LastName);
1038 } 1039 }
1039 else 1040 else
1040 { 1041 {
@@ -1147,8 +1148,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1147 info.RequestID.AgentID = client.AgentId; 1148 info.RequestID.AgentID = client.AgentId;
1148 info.RequestID.SessionID = client.SessionId; 1149 info.RequestID.SessionID = client.SessionId;
1149 1150
1150 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId); 1151 //UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1151 if (userProfile == null) 1152 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
1153 if (account == null)
1152 { 1154 {
1153 // This should be impossible. If I've been passed a reference to a client 1155 // This should be impossible. If I've been passed a reference to a client
1154 // that client should be registered with the UserService. So something 1156 // that client should be registered with the UserService. So something
@@ -1160,16 +1162,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1160 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; 1162 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1161 1163
1162 } 1164 }
1163 else if (userProfile is ForeignUserProfileData)
1164 {
1165 // They aren't from around here
1166 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1167 info.RequestID.UserServiceURL = fupd.UserServerURI;
1168 }
1169 else 1165 else
1170 { 1166 {
1167 string domain = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1168 if (account.ServiceURLs["HomeURI"] != null)
1169 domain = account.ServiceURLs["HomeURI"].ToString();
1171 // They're a local user, use this: 1170 // They're a local user, use this:
1172 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; 1171 info.RequestID.UserServiceURL = domain;
1173 } 1172 }
1174 1173
1175 m_clientRequestIDInfo.Add(client.AgentId, info); 1174 m_clientRequestIDInfo.Add(client.AgentId, info);
@@ -1342,12 +1341,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1342 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1341 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1343 1342
1344 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1343 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1345 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(dataForAgentID); 1344 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID);
1346 string firstname, lastname; 1345 string firstname, lastname;
1347 if (userProfile != null) 1346 if (account != null)
1348 { 1347 {
1349 firstname = userProfile.FirstName; 1348 firstname = account.FirstName;
1350 lastname = userProfile.SurName; 1349 lastname = account.LastName;
1351 } 1350 }
1352 else 1351 else
1353 { 1352 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 39b597e..2bfd3fb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -52,8 +52,9 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
52using OpenSim.Region.ScriptEngine.Interfaces; 52using OpenSim.Region.ScriptEngine.Interfaces;
53using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 53using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
54using OpenSim.Services.Interfaces; 54using OpenSim.Services.Interfaces;
55 55using OpenSim.Services.Interfaces;
56using GridRegion = OpenSim.Services.Interfaces.GridRegion; 56using GridRegion = OpenSim.Services.Interfaces.GridRegion;
57using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
57 58
58using AssetLandmark = OpenSim.Framework.AssetLandmark; 59using AssetLandmark = OpenSim.Framework.AssetLandmark;
59 60
@@ -3842,13 +3843,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3842 3843
3843 UUID uuid = (UUID)id; 3844 UUID uuid = (UUID)id;
3844 3845
3845 UserProfileData userProfile = 3846 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
3846 World.CommsManager.UserService.GetUserProfile(uuid);
3847 3847
3848 UserAgentData userAgent = 3848 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3849 World.CommsManager.UserService.GetAgentByUUID(uuid); 3849 PresenceInfo pinfo = PresenceInfo.GetOnlinePresence(pinfos);
3850 3850
3851 if (userProfile == null || userAgent == null) 3851 if (pinfo == null)
3852 return UUID.Zero.ToString(); 3852 return UUID.Zero.ToString();
3853 3853
3854 string reply = String.Empty; 3854 string reply = String.Empty;
@@ -3857,17 +3857,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3857 { 3857 {
3858 case 1: // DATA_ONLINE (0|1) 3858 case 1: // DATA_ONLINE (0|1)
3859 // TODO: implement fetching of this information 3859 // TODO: implement fetching of this information
3860 if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline) 3860 if (pinfo != null)
3861 reply = "1"; 3861 reply = "1";
3862 else 3862 else
3863 reply = "0"; 3863 reply = "0";
3864 break; 3864 break;
3865 case 2: // DATA_NAME (First Last) 3865 case 2: // DATA_NAME (First Last)
3866 reply = userProfile.FirstName + " " + userProfile.SurName; 3866 reply = account.FirstName + " " + account.LastName;
3867 break; 3867 break;
3868 case 3: // DATA_BORN (YYYY-MM-DD) 3868 case 3: // DATA_BORN (YYYY-MM-DD)
3869 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); 3869 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
3870 born = born.AddSeconds(userProfile.Created); 3870 born = born.AddSeconds(account.Created);
3871 reply = born.ToString("yyyy-MM-dd"); 3871 reply = born.ToString("yyyy-MM-dd");
3872 break; 3872 break;
3873 case 4: // DATA_RATING (0,0,0,0,0,0) 3873 case 4: // DATA_RATING (0,0,0,0,0,0)
diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs
index 2dad7e6..a010611 100644
--- a/OpenSim/Services/Interfaces/IPresenceService.cs
+++ b/OpenSim/Services/Interfaces/IPresenceService.cs
@@ -90,6 +90,26 @@ namespace OpenSim.Services.Interfaces
90 90
91 return result; 91 return result;
92 } 92 }
93
94 public static PresenceInfo[] GetOnlinePresences(PresenceInfo[] pinfos)
95 {
96 if (pinfos == null)
97 return null;
98
99 List<PresenceInfo> lst = new List<PresenceInfo>(pinfos);
100 lst = lst.FindAll(delegate(PresenceInfo each) { return each.Online; });
101
102 return lst.ToArray();
103 }
104
105 public static PresenceInfo GetOnlinePresence(PresenceInfo[] pinfos)
106 {
107 pinfos = GetOnlinePresences(pinfos);
108 if (pinfos != null && pinfos.Length >= 1)
109 return pinfos[0];
110
111 return null;
112 }
93 } 113 }
94 114
95 public interface IPresenceService 115 public interface IPresenceService
diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs
index 87f0e6c..b1be64b 100644
--- a/OpenSim/Services/Interfaces/IUserAccountService.cs
+++ b/OpenSim/Services/Interfaces/IUserAccountService.cs
@@ -42,6 +42,17 @@ namespace OpenSim.Services.Interfaces
42 PrincipalID = principalID; 42 PrincipalID = principalID;
43 } 43 }
44 44
45 public UserAccount(UUID scopeID, string firstName, string lastName, string email)
46 {
47 PrincipalID = UUID.Random();
48 ScopeID = scopeID;
49 FirstName = firstName;
50 LastName = lastName;
51 Email = email;
52 ServiceURLs = new Dictionary<string, object>();
53 // Created = ???
54 }
55
45 public string FirstName; 56 public string FirstName;
46 public string LastName; 57 public string LastName;
47 public string Email; 58 public string Email;
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index b13e8dd..dbb8fd4 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -194,8 +194,6 @@ namespace OpenSim.Tests.Common.Setup
194 m_inventoryService.PostInitialise(); 194 m_inventoryService.PostInitialise();
195 m_assetService.PostInitialise(); 195 m_assetService.PostInitialise();
196 196
197 testScene.CommsManager.UserService.SetInventoryService(testScene.InventoryService);
198
199 testScene.SetModuleInterfaces(); 197 testScene.SetModuleInterfaces();
200 198
201 testScene.LandChannel = new TestLandChannel(testScene); 199 testScene.LandChannel = new TestLandChannel(testScene);