Merge commit 'c85a780583cb36bac95f69c5d704f60a758d56bb' into bigmerge
commit
f5e2bdebef
|
@ -55,7 +55,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
||||||
Object[] args = new Object[] { config };
|
Object[] args = new Object[] { config };
|
||||||
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(service, args);
|
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(service, args);
|
||||||
|
|
||||||
server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService));
|
server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService, serverConfig));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ using System.Xml.Serialization;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenSim.Server.Base;
|
using OpenSim.Server.Base;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
|
using OpenSim.Services.UserAccountService;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
@ -49,11 +50,18 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private IUserAccountService m_UserAccountService;
|
private IUserAccountService m_UserAccountService;
|
||||||
|
private bool m_AllowCreateUser = false;
|
||||||
|
|
||||||
public UserAccountServerPostHandler(IUserAccountService service) :
|
public UserAccountServerPostHandler(IUserAccountService service)
|
||||||
|
: this(service, null) {}
|
||||||
|
|
||||||
|
public UserAccountServerPostHandler(IUserAccountService service, IConfig config) :
|
||||||
base("POST", "/accounts")
|
base("POST", "/accounts")
|
||||||
{
|
{
|
||||||
m_UserAccountService = service;
|
m_UserAccountService = service;
|
||||||
|
|
||||||
|
if (config != null)
|
||||||
|
m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override byte[] Handle(string path, Stream requestData,
|
public override byte[] Handle(string path, Stream requestData,
|
||||||
|
@ -81,6 +89,11 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
||||||
|
|
||||||
switch (method)
|
switch (method)
|
||||||
{
|
{
|
||||||
|
case "createuser":
|
||||||
|
if (m_AllowCreateUser)
|
||||||
|
return CreateUser(request);
|
||||||
|
else
|
||||||
|
break;
|
||||||
case "getaccount":
|
case "getaccount":
|
||||||
return GetAccount(request);
|
return GetAccount(request);
|
||||||
case "getaccounts":
|
case "getaccounts":
|
||||||
|
@ -123,16 +136,20 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
||||||
if (UUID.TryParse(request["UserID"].ToString(), out userID))
|
if (UUID.TryParse(request["UserID"].ToString(), out userID))
|
||||||
account = m_UserAccountService.GetUserAccount(scopeID, userID);
|
account = m_UserAccountService.GetUserAccount(scopeID, userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (request.ContainsKey("Email") && request["Email"] != null)
|
else if (request.ContainsKey("Email") && request["Email"] != null)
|
||||||
|
{
|
||||||
account = m_UserAccountService.GetUserAccount(scopeID, request["Email"].ToString());
|
account = m_UserAccountService.GetUserAccount(scopeID, request["Email"].ToString());
|
||||||
|
}
|
||||||
else if (request.ContainsKey("FirstName") && request.ContainsKey("LastName") &&
|
else if (request.ContainsKey("FirstName") && request.ContainsKey("LastName") &&
|
||||||
request["FirstName"] != null && request["LastName"] != null)
|
request["FirstName"] != null && request["LastName"] != null)
|
||||||
|
{
|
||||||
account = m_UserAccountService.GetUserAccount(scopeID, request["FirstName"].ToString(), request["LastName"].ToString());
|
account = m_UserAccountService.GetUserAccount(scopeID, request["FirstName"].ToString(), request["LastName"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
if (account == null)
|
if (account == null)
|
||||||
|
{
|
||||||
result["result"] = "null";
|
result["result"] = "null";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result["result"] = account.ToKeyValuePairs();
|
result["result"] = account.ToKeyValuePairs();
|
||||||
|
@ -180,6 +197,47 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
||||||
return FailureResult();
|
return FailureResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] CreateUser(Dictionary<string, object> request)
|
||||||
|
{
|
||||||
|
if (!
|
||||||
|
request.ContainsKey("FirstName")
|
||||||
|
&& request.ContainsKey("LastName")
|
||||||
|
&& request.ContainsKey("Password"))
|
||||||
|
return FailureResult();
|
||||||
|
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
UUID scopeID = UUID.Zero;
|
||||||
|
if (request.ContainsKey("ScopeID") && !UUID.TryParse(request["ScopeID"].ToString(), out scopeID))
|
||||||
|
return FailureResult();
|
||||||
|
|
||||||
|
UUID principalID = UUID.Random();
|
||||||
|
if (request.ContainsKey("UserID") && !UUID.TryParse(request["UserID"].ToString(), out principalID))
|
||||||
|
return FailureResult();
|
||||||
|
|
||||||
|
string firstName = request["FirstName"].ToString();
|
||||||
|
string lastName = request["LastName"].ToString();
|
||||||
|
string password = request["Password"].ToString();
|
||||||
|
|
||||||
|
string email = "";
|
||||||
|
if (request.ContainsKey("Email"))
|
||||||
|
email = request["Email"].ToString();
|
||||||
|
|
||||||
|
UserAccount createdUserAccount = null;
|
||||||
|
|
||||||
|
if (m_UserAccountService is UserAccountService)
|
||||||
|
createdUserAccount
|
||||||
|
= ((UserAccountService)m_UserAccountService).CreateUser(
|
||||||
|
scopeID, principalID, firstName, lastName, password, email);
|
||||||
|
|
||||||
|
if (createdUserAccount == null)
|
||||||
|
return FailureResult();
|
||||||
|
|
||||||
|
result["result"] = createdUserAccount.ToKeyValuePairs();
|
||||||
|
|
||||||
|
return ResultToBytes(result);
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] SuccessResult()
|
private byte[] SuccessResult()
|
||||||
{
|
{
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
|
|
|
@ -524,8 +524,10 @@ namespace OpenSim.Services.UserAccountService
|
||||||
firstName, lastName);
|
firstName, lastName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
|
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
|
||||||
firstName, lastName);
|
firstName, lastName);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_InventoryService != null)
|
if (m_InventoryService != null)
|
||||||
{
|
{
|
||||||
|
@ -535,13 +537,19 @@ namespace OpenSim.Services.UserAccountService
|
||||||
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
|
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
|
||||||
firstName, lastName);
|
firstName, lastName);
|
||||||
}
|
}
|
||||||
else if (m_CreateDefaultAvatarEntries)
|
else
|
||||||
{
|
{
|
||||||
CreateDefaultAppearanceEntries(account.PrincipalID);
|
m_log.DebugFormat(
|
||||||
}
|
"[USER ACCOUNT SERVICE]; Created user inventory for {0} {1}", firstName, lastName);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName);
|
if (m_CreateDefaultAvatarEntries)
|
||||||
|
CreateDefaultAppearanceEntries(account.PrincipalID);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_log.InfoFormat(
|
||||||
|
"[USER ACCOUNT SERVICE]: Account {0} {1} {2} created successfully",
|
||||||
|
firstName, lastName, account.PrincipalID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,14 +166,17 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
||||||
GridService = "OpenSim.Services.GridService.dll:GridService"
|
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||||
InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService"
|
InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService"
|
||||||
; AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService"
|
AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService"
|
||||||
|
|
||||||
;; This switch creates the minimum set of body parts and avatar entries for a viewer 2
|
;; This switch creates the minimum set of body parts and avatar entries for a viewer 2
|
||||||
;; to show a default "Ruth" avatar rather than a cloud for a newly created user.
|
;; to show a default "Ruth" avatar rather than a cloud for a newly created user.
|
||||||
;; Default is false
|
;; Default is false
|
||||||
;; If you enable this you will also need to uncomment the AvatarService line above
|
|
||||||
; CreateDefaultAvatarEntries = false
|
; CreateDefaultAvatarEntries = false
|
||||||
|
|
||||||
|
;; Allow the service to process HTTP create user calls.
|
||||||
|
;; Default is false.
|
||||||
|
; AllowCreateUser = false
|
||||||
|
|
||||||
|
|
||||||
[GridUserService]
|
[GridUserService]
|
||||||
; for the server connector
|
; for the server connector
|
||||||
|
|
|
@ -149,7 +149,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
||||||
GridService = "OpenSim.Services.GridService.dll:GridService"
|
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||||
InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService"
|
InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService"
|
||||||
; AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService"
|
AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService"
|
||||||
|
|
||||||
;; This switch creates the minimum set of body parts and avatar entries for a viewer 2
|
;; This switch creates the minimum set of body parts and avatar entries for a viewer 2
|
||||||
;; to show a default "Ruth" avatar rather than a cloud for a newly created user.
|
;; to show a default "Ruth" avatar rather than a cloud for a newly created user.
|
||||||
|
@ -157,6 +157,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
;; If you enable this you will also need to uncomment the AvatarService line above
|
;; If you enable this you will also need to uncomment the AvatarService line above
|
||||||
; CreateDefaultAvatarEntries = false
|
; CreateDefaultAvatarEntries = false
|
||||||
|
|
||||||
|
;; Allow the service to process HTTP create user calls.
|
||||||
|
;; Default is false.
|
||||||
|
; AllowCreateUser = false
|
||||||
|
|
||||||
|
|
||||||
[GridUserService]
|
[GridUserService]
|
||||||
; for the server connector
|
; for the server connector
|
||||||
|
|
|
@ -1357,6 +1357,7 @@
|
||||||
<Reference name="OpenSim.Server.Base"/>
|
<Reference name="OpenSim.Server.Base"/>
|
||||||
<Reference name="OpenSim.Services.Base"/>
|
<Reference name="OpenSim.Services.Base"/>
|
||||||
<Reference name="OpenSim.Services.Interfaces"/>
|
<Reference name="OpenSim.Services.Interfaces"/>
|
||||||
|
<Reference name="OpenSim.Services.UserAccountService"/>
|
||||||
<Reference name="XMLRPC" path="../../../bin/"/>
|
<Reference name="XMLRPC" path="../../../bin/"/>
|
||||||
<Reference name="Nini" path="../../../bin/"/>
|
<Reference name="Nini" path="../../../bin/"/>
|
||||||
<Reference name="log4net" path="../../../bin/"/>
|
<Reference name="log4net" path="../../../bin/"/>
|
||||||
|
|
Loading…
Reference in New Issue