diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins')
6 files changed, 626 insertions, 595 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; | |||
49 | using OpenSim.Region.Framework.Interfaces; | 49 | using OpenSim.Region.Framework.Interfaces; |
50 | using OpenSim.Region.Framework.Scenes; | 50 | using OpenSim.Region.Framework.Scenes; |
51 | using OpenSim.Services.Interfaces; | 51 | using OpenSim.Services.Interfaces; |
52 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
53 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
52 | 54 | ||
53 | namespace OpenSim.ApplicationPlugins.RemoteController | 55 | namespace 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; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Servers; | 36 | using OpenSim.Framework.Servers; |
37 | using OpenSim.Framework.Servers.HttpServer; | 37 | using OpenSim.Framework.Servers.HttpServer; |
38 | using OpenSim.Services.Interfaces; | ||
39 | |||
40 | using OpenMetaverse; | ||
38 | 41 | ||
39 | namespace OpenSim.ApplicationPlugins.Rest.Inventory | 42 | namespace 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 |