From ef9d140022b57b175f41602731ec73775bdf2d9c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 23 Apr 2009 18:24:39 +0000 Subject: [PATCH] * Add user data plugin to store temporary profiles (which are distinct from cached) * Plugin not yet used * Existing functionality should not be affected in any way --- .../Client/Linden/LLStandaloneLoginService.cs | 1 - .../Communications/Services/LoginService.cs | 2 +- .../TemporaryUserProfilePlugin.cs | 88 +++++++++++++++++++ .../Communications/Tests/LoginServiceTests.cs | 7 +- .../Communications/UserManagerBase.cs | 40 +++++---- .../Hypergrid/HGCommunicationsGridMode.cs | 10 +-- .../Hypergrid/HGCommunicationsStandalone.cs | 3 +- .../Local/CommunicationsLocal.cs | 1 + .../Communications/OGS1/CommunicationsOGS1.cs | 4 +- .../Common/Mock/TestCommunicationsManager.cs | 8 +- 10 files changed, 130 insertions(+), 34 deletions(-) create mode 100644 OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs diff --git a/OpenSim/Client/Linden/LLStandaloneLoginService.cs b/OpenSim/Client/Linden/LLStandaloneLoginService.cs index 5e286e2007..731658777d 100644 --- a/OpenSim/Client/Linden/LLStandaloneLoginService.cs +++ b/OpenSim/Client/Linden/LLStandaloneLoginService.cs @@ -57,7 +57,6 @@ namespace OpenSim.Client.Linden /// protected ILoginServiceToRegionsConnector m_regionsConnector; - public LLStandaloneLoginService( UserManagerBase userManager, string welcomeMess, IInterServiceInventoryServices interServiceInventoryService, diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 1b7136792c..168f7a6157 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -182,7 +182,7 @@ namespace OpenSim.Framework.Communications.Services // Reject the login m_log.InfoFormat( - "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", + "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", firstname, lastname); return logResponse.CreateAlreadyLoggedInResponse(); diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs new file mode 100644 index 0000000000..1cfeaf1fc2 --- /dev/null +++ b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs @@ -0,0 +1,88 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Data; + +namespace OpenSim.Framework.Communications +{ + /// + /// Plugin for managing temporary user profiles. + /// + public class TemporaryUserProfilePlugin : IUserDataPlugin + { + protected Dictionary m_profiles = new Dictionary(); + + public string Name { get { return "TemporaryUserProfilePlugin"; } } + public string Version { get { return "0.1"; } } + public void Initialise() {} + public void Initialise(string connect) {} + public void Dispose() {} + + public UserProfileData GetUserByUUID(UUID user) + { + lock (m_profiles) + { + if (m_profiles.ContainsKey(user)) + return m_profiles[user]; + else + return null; + } + } + + public UserProfileData GetUserByName(string fname, string lname) + { + // We deliberately don't look up a temporary profile by name so that we don't obscure non-temporary + // profiles. + + return null; + } + + public UserProfileData GetUserByUri(Uri uri) { return null; } + public List GeneratePickerResults(UUID queryID, string query) { return null; } + public UserAgentData GetAgentByUUID(UUID user) { return null; } + public UserAgentData GetAgentByName(string name) { return null; } + public UserAgentData GetAgentByName(string fname, string lname) { return null; } + public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {} + public void AddNewUserProfile(UserProfileData user) {} + public bool UpdateUserProfile(UserProfileData user) { return false; } + public void AddNewUserAgent(UserAgentData agent) {} + public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) {} + public void RemoveUserFriend(UUID friendlistowner, UUID friend) {} + public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) {} + public List GetUserFriendList(UUID friendlistowner) { return null; } + public Dictionary GetFriendRegionInfos(List uuids) { return null; } + public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; } + public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; } + public AvatarAppearance GetUserAppearance(UUID user) { return null; } + public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {} + public void ResetAttachments(UUID userID) {} + public void LogoutUsers(UUID regionID) {} + } +} diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index e7dbf2d475..42fdea5fc0 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -280,6 +280,9 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void T023_TestAuthenticatedLoginAlreadyLoggedIn() { + Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); + log4net.Config.XmlConfigurator.Configure(); + string error_already_logged = "You appear to be already logged in. " + "If this is not the case please wait for your session to timeout. " + "If this takes longer than a few minutes please contact the grid owner. " + @@ -303,7 +306,6 @@ namespace OpenSim.Framework.Communications.Tests // Then we try again, this time expecting failure. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); @@ -314,11 +316,12 @@ namespace OpenSim.Framework.Communications.Tests response = m_loginService.XmlRpcLoginMethod(request); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); + + Console.WriteLine("Finished T023_TestAuthenticatedLoginAlreadyLoggedIn()"); } public class TestLoginToRegionConnector : ILoginServiceToRegionsConnector { - private List m_regionsList = new List(); public void AddRegion(RegionInfo regionInfo) diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 9cd7658721..b6a736209a 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -208,7 +208,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.InfoFormat( + m_log.ErrorFormat( "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName, plugin.Name, e.ToString()); } @@ -239,7 +239,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -264,7 +264,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -290,7 +290,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -334,7 +334,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); } } @@ -351,7 +351,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -366,7 +366,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -381,7 +381,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -396,7 +396,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Name + "(" + e.ToString() + ")"); } } } @@ -707,24 +707,30 @@ namespace OpenSim.Framework.Communications public abstract UserProfileData SetupMasterUser(UUID uuid); /// - /// Add agent to DB + /// Add an agent using data plugins. /// /// The agent data to be added + /// + /// true if at least one plugin added the user agent. false if no plugin successfully added the agent + /// public virtual bool AddUserAgent(UserAgentData agentdata) { + bool result = false; + foreach (IUserDataPlugin plugin in m_plugins) { try { plugin.AddNewUserAgent(agentdata); - return true; + result = true; } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")"); + m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")"); } } - return false; + + return result; } /// @@ -745,7 +751,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); + m_log.ErrorFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } @@ -762,7 +768,7 @@ namespace OpenSim.Framework.Communications } catch (Exception e) { - m_log.InfoFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); + m_log.ErrorFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); } } } @@ -811,10 +817,10 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[USERAUTH]: Successfully generated new auth key for user {0}", userID); } else - m_log.Info("[USERAUTH]: Unauthorized key generation request. Denying new key."); + m_log.Warn("[USERAUTH]: Unauthorized key generation request. Denying new key."); } else - m_log.Info("[USERAUTH]: User not found."); + m_log.Warn("[USERAUTH]: User not found."); return url + newKey; } diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs index feacb2f6c5..799ec2ad02 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs @@ -69,15 +69,13 @@ namespace OpenSim.Region.Communications.Hypergrid m_log.Info("[HG]: Non-secureInventoryService."); HGUserServices userServices = new HGUserServices(this); - // This plugin arrangement could eventually be configurable rather than hardcoded here. - OGS1UserDataPlugin userDataPlugin = new OGS1UserDataPlugin(this); - userServices.AddPlugin(userDataPlugin); + // This plugin arrangement could eventually be configurable rather than hardcoded here. + userServices.AddPlugin(new TemporaryUserProfilePlugin()); + userServices.AddPlugin(new OGS1UserDataPlugin(this)); m_userService = userServices; m_messageService = userServices; - m_avatarService = (IAvatarService)m_userService; - + m_avatarService = userServices; } - } } diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs index 126f42b533..43cc16a403 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs @@ -62,7 +62,8 @@ namespace OpenSim.Region.Communications.Hypergrid m_inventoryServices = null; HGUserServices hgUserService = new HGUserServices(this, localUserService); - // This plugin arrangement could eventually be configurable rather than hardcoded here. + // This plugin arrangement could eventually be configurable rather than hardcoded here. + hgUserService.AddPlugin(new TemporaryUserProfilePlugin()); hgUserService.AddPlugin(new OGS1UserDataPlugin(this)); m_userService = hgUserService; diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index c17f799dde..1861d52318 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -52,6 +52,7 @@ namespace OpenSim.Region.Communications.Local LocalUserServices lus = new LocalUserServices( serversInfo.DefaultHomeLocX, serversInfo.DefaultHomeLocY, this); + lus.AddPlugin(new TemporaryUserProfilePlugin()); lus.AddPlugin(configSettings.StandaloneUserPlugin, configSettings.StandaloneUserSource); m_userService = lus; m_userAdminService = lus; diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index ee8562f274..de6bd61239 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -57,8 +57,8 @@ namespace OpenSim.Region.Communications.OGS1 // This plugin arrangement could eventually be configurable rather than hardcoded here. OGS1UserServices userServices = new OGS1UserServices(this); - OGS1UserDataPlugin userDataPlugin = new OGS1UserDataPlugin(this); - userServices.AddPlugin(userDataPlugin); + userServices.AddPlugin(new TemporaryUserProfilePlugin()); + userServices.AddPlugin(new OGS1UserDataPlugin(this)); m_userService = userServices; m_messageService = userServices; diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs index 4ade40d83b..9d28fc7287 100644 --- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs +++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs @@ -55,19 +55,19 @@ namespace OpenSim.Tests.Common.Mock public TestCommunicationsManager(NetworkServersInfo serversInfo) : base(serversInfo, new BaseHttpServer(666), null, false, null) - { - m_userDataPlugin = new TestUserDataPlugin(); - m_inventoryDataPlugin = new TestInventoryDataPlugin(); - + { SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin()); m_assetCache = new AssetCache(assetService); LocalInventoryService lis = new LocalInventoryService(); + m_inventoryDataPlugin = new TestInventoryDataPlugin(); lis.AddPlugin(m_inventoryDataPlugin); m_interServiceInventoryService = lis; AddInventoryService(lis); LocalUserServices lus = new LocalUserServices(991, 992, this); + lus.AddPlugin(new TemporaryUserProfilePlugin()); + m_userDataPlugin = new TestUserDataPlugin(); lus.AddPlugin(m_userDataPlugin); m_userService = lus; m_userAdminService = lus;