From 0862627b341641ec0223bb4191dfee8d85724c9e Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 28 Nov 2008 15:34:30 +0000
Subject: * refactor: move CreateUser into UserServiceAdmin
---
.../Communications/CommunicationsManager.cs | 63 ++------------------
.../Framework/Communications/IUserServiceAdmin.cs | 30 +++++-----
.../Communications/InventoryServiceBase.cs | 1 -
.../Framework/Communications/UserManagerBase.cs | 68 +++++++++++++++-------
4 files changed, 66 insertions(+), 96 deletions(-)
(limited to 'OpenSim/Framework/Communications')
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index bcf9bed..a5ead3f 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -106,8 +106,12 @@ namespace OpenSim.Framework.Communications
protected NetworkServersInfo m_networkServersInfo;
///
- /// Interface to administrative user service calls.
+ /// Interface to user service for administrating users.
///
+ public IUserServiceAdmin UserServiceAdmin
+ {
+ get { return m_userServiceAdmin; }
+ }
protected IUserServiceAdmin m_userServiceAdmin;
public BaseHttpServer HttpServer
@@ -247,63 +251,6 @@ namespace OpenSim.Framework.Communications
}
#endregion
-
- ///
- /// Persistently adds a user to OpenSim.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- /// The UUID of the added user. Returns UUID.Zero if the add was unsuccessful
- public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY)
- {
- string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
-
- m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, email, regX, regY);
- UserProfileData userProf = UserService.GetUserProfile(firstName, lastName);
- if (userProf == null)
- {
- return UUID.Zero;
- }
- else
- {
- InterServiceInventoryService.CreateNewUserInventory(userProf.ID);
- m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName);
- return userProf.ID;
- }
- }
-
- ///
- /// Adds the user.
- ///
- /// The first name.
- /// The last name.
- /// The password.
- /// The email.
- /// The reg X.
- /// The reg Y.
- /// The set UUID.
- ///
- public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID)
- {
- string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
-
- m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, email, regX, regY, SetUUID);
- UserProfileData userProf = UserService.GetUserProfile(firstName, lastName);
- if (userProf == null)
- {
- return UUID.Zero;
- }
- else
- {
- InterServiceInventoryService.CreateNewUserInventory(userProf.ID);
- m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName);
- return userProf.ID;
- }
- }
///
/// Reset a user password
diff --git a/OpenSim/Framework/Communications/IUserServiceAdmin.cs b/OpenSim/Framework/Communications/IUserServiceAdmin.cs
index a120add..b1f974b 100644
--- a/OpenSim/Framework/Communications/IUserServiceAdmin.cs
+++ b/OpenSim/Framework/Communications/IUserServiceAdmin.cs
@@ -32,29 +32,29 @@ namespace OpenSim.Framework.Communications
public interface IUserServiceAdmin
{
///
- /// Add a new user profile
+ /// Add a new user
///
- /// The first name.
- /// The last name.
+ /// The first name
+ /// The last name
/// password of avatar
/// email of user
- /// region X.
- /// region Y.
- ///
- UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY);
+ /// region X
+ /// region Y
+ /// The UUID of the created user profile. On failure, returns UUID.Zero
+ UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY);
///
- /// Adds one for allowing setting of the UUID from modules.. SHOULD ONLY BE USED in very special circumstances!
+ /// Add a new user with a specified UUID. SHOULD ONLY BE USED in very special circumstances from modules!
///
- /// The first name.
- /// The last name.
+ /// The first name
+ /// The last name
/// password of avatar
/// email of user
- /// region X.
- /// region Y.
- /// The set UUID.
- ///
- UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID);
+ /// region X
+ /// region Y
+ /// The set UUID
+ /// The UUID of the created user profile. On failure, returns UUID.Zero
+ UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID);
///
/// Reset a user password
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index 777e15b..7a44420 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -82,7 +82,6 @@ namespace OpenSim.Framework.Communications
get { return "default"; }
}
- // See IInventoryServices
public List GetInventorySkeleton(UUID userId)
{
// m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId);
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index a5ca654..3946ea3 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -52,6 +52,17 @@ namespace OpenSim.Framework.Communications
/// List of plugins to search for user data
///
private List _plugins = new List();
+
+ private IInterServiceInventoryServices m_interServiceInventoryService;
+
+ ///
+ /// Constructor
+ ///
+ ///
+ public UserManagerBase(IInterServiceInventoryServices interServiceInventoryService)
+ {
+ m_interServiceInventoryService = interServiceInventoryService;
+ }
///
/// Add a new user data plugin - plugins will be requested in the order they were added.
@@ -80,7 +91,7 @@ namespace OpenSim.Framework.Communications
_plugins.AddRange(loader.Plugins);
}
- #region Get UserProfile
+ #region Get UserProfile
// see IUserService
public UserProfileData GetUserProfile(string fname, string lname)
@@ -586,39 +597,42 @@ namespace OpenSim.Framework.Communications
#endregion
///
- /// Add a new user profile
+ /// Add a new user
///
- /// first name.
- /// last name.
- /// password
- /// email.
- /// location X.
- /// location Y.
- ///
- public UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY)
+ /// first name
+ /// last name
+ /// password
+ /// email
+ /// location X
+ /// location Y
+ /// The UUID of the created user profile. On failure, returns UUID.Zero
+ public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY)
{
- return AddUserProfile(firstName, lastName, pass, email, regX, regY, UUID.Random());
+ return AddUser(firstName, lastName, password, email, regX, regY, UUID.Random());
}
///
- /// Adds the user profile.
+ /// Add a new user
///
- /// first name.
- /// last name.
- /// password
- /// email.
- /// location X.
- /// location Y.
+ /// first name
+ /// last name
+ /// password
+ /// email
+ /// location X
+ /// location Y
/// UUID of avatar.
- ///
- public UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID SetUUID)
+ /// The UUID of the created user profile. On failure, returns UUID.Zero
+ public UUID AddUser(
+ string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID)
{
+ string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
+
UserProfileData user = new UserProfileData();
user.HomeLocation = new Vector3(128, 128, 100);
user.ID = SetUUID;
user.FirstName = firstName;
user.SurName = lastName;
- user.PasswordHash = pass;
+ user.PasswordHash = md5PasswdHash;
user.PasswordSalt = String.Empty;
user.Created = Util.UnixTimeSinceEpoch();
user.HomeLookAt = new Vector3(100, 100, 100);
@@ -638,7 +652,17 @@ namespace OpenSim.Framework.Communications
}
}
- return user.ID;
+ UserProfileData userProf = GetUserProfile(firstName, lastName);
+ if (userProf == null)
+ {
+ return UUID.Zero;
+ }
+ else
+ {
+ m_interServiceInventoryService.CreateNewUserInventory(userProf.ID);
+
+ return userProf.ID;
+ }
}
///
--
cgit v1.1