aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs64
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs14
3 files changed, 73 insertions, 7 deletions
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs
index f17a8de..344b513 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
55 Object[] args = new Object[] { config }; 55 Object[] args = new Object[] { config };
56 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(service, args); 56 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(service, args);
57 57
58 server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService)); 58 server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService, serverConfig));
59 } 59 }
60 } 60 }
61} 61}
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index a1d4871..deadce2 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -38,6 +38,7 @@ using System.Xml.Serialization;
38using System.Collections.Generic; 38using System.Collections.Generic;
39using OpenSim.Server.Base; 39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using OpenSim.Services.UserAccountService;
41using OpenSim.Framework; 42using OpenSim.Framework;
42using OpenSim.Framework.Servers.HttpServer; 43using OpenSim.Framework.Servers.HttpServer;
43using OpenMetaverse; 44using OpenMetaverse;
@@ -49,11 +50,18 @@ namespace OpenSim.Server.Handlers.UserAccounts
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 51
51 private IUserAccountService m_UserAccountService; 52 private IUserAccountService m_UserAccountService;
53 private bool m_AllowCreateUser = false;
52 54
53 public UserAccountServerPostHandler(IUserAccountService service) : 55 public UserAccountServerPostHandler(IUserAccountService service)
56 : this(service, null) {}
57
58 public UserAccountServerPostHandler(IUserAccountService service, IConfig config) :
54 base("POST", "/accounts") 59 base("POST", "/accounts")
55 { 60 {
56 m_UserAccountService = service; 61 m_UserAccountService = service;
62
63 if (config != null)
64 m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser);
57 } 65 }
58 66
59 public override byte[] Handle(string path, Stream requestData, 67 public override byte[] Handle(string path, Stream requestData,
@@ -81,6 +89,11 @@ namespace OpenSim.Server.Handlers.UserAccounts
81 89
82 switch (method) 90 switch (method)
83 { 91 {
92 case "createuser":
93 if (m_AllowCreateUser)
94 return CreateUser(request);
95 else
96 break;
84 case "getaccount": 97 case "getaccount":
85 return GetAccount(request); 98 return GetAccount(request);
86 case "getaccounts": 99 case "getaccounts":
@@ -123,16 +136,20 @@ namespace OpenSim.Server.Handlers.UserAccounts
123 if (UUID.TryParse(request["UserID"].ToString(), out userID)) 136 if (UUID.TryParse(request["UserID"].ToString(), out userID))
124 account = m_UserAccountService.GetUserAccount(scopeID, userID); 137 account = m_UserAccountService.GetUserAccount(scopeID, userID);
125 } 138 }
126
127 else if (request.ContainsKey("Email") && request["Email"] != null) 139 else if (request.ContainsKey("Email") && request["Email"] != null)
140 {
128 account = m_UserAccountService.GetUserAccount(scopeID, request["Email"].ToString()); 141 account = m_UserAccountService.GetUserAccount(scopeID, request["Email"].ToString());
129 142 }
130 else if (request.ContainsKey("FirstName") && request.ContainsKey("LastName") && 143 else if (request.ContainsKey("FirstName") && request.ContainsKey("LastName") &&
131 request["FirstName"] != null && request["LastName"] != null) 144 request["FirstName"] != null && request["LastName"] != null)
145 {
132 account = m_UserAccountService.GetUserAccount(scopeID, request["FirstName"].ToString(), request["LastName"].ToString()); 146 account = m_UserAccountService.GetUserAccount(scopeID, request["FirstName"].ToString(), request["LastName"].ToString());
147 }
133 148
134 if (account == null) 149 if (account == null)
150 {
135 result["result"] = "null"; 151 result["result"] = "null";
152 }
136 else 153 else
137 { 154 {
138 result["result"] = account.ToKeyValuePairs(); 155 result["result"] = account.ToKeyValuePairs();
@@ -180,6 +197,47 @@ namespace OpenSim.Server.Handlers.UserAccounts
180 return FailureResult(); 197 return FailureResult();
181 } 198 }
182 199
200 byte[] CreateUser(Dictionary<string, object> request)
201 {
202 if (!
203 request.ContainsKey("FirstName")
204 && request.ContainsKey("LastName")
205 && request.ContainsKey("Password"))
206 return FailureResult();
207
208 Dictionary<string, object> result = new Dictionary<string, object>();
209
210 UUID scopeID = UUID.Zero;
211 if (request.ContainsKey("ScopeID") && !UUID.TryParse(request["ScopeID"].ToString(), out scopeID))
212 return FailureResult();
213
214 UUID principalID = UUID.Random();
215 if (request.ContainsKey("UserID") && !UUID.TryParse(request["UserID"].ToString(), out principalID))
216 return FailureResult();
217
218 string firstName = request["FirstName"].ToString();
219 string lastName = request["LastName"].ToString();
220 string password = request["Password"].ToString();
221
222 string email = "";
223 if (request.ContainsKey("Email"))
224 email = request["Email"].ToString();
225
226 UserAccount createdUserAccount = null;
227
228 if (m_UserAccountService is UserAccountService)
229 createdUserAccount
230 = ((UserAccountService)m_UserAccountService).CreateUser(
231 scopeID, principalID, firstName, lastName, password, email);
232
233 if (createdUserAccount == null)
234 return FailureResult();
235
236 result["result"] = createdUserAccount.ToKeyValuePairs();
237
238 return ResultToBytes(result);
239 }
240
183 private byte[] SuccessResult() 241 private byte[] SuccessResult()
184 { 242 {
185 XmlDocument doc = new XmlDocument(); 243 XmlDocument doc = new XmlDocument();
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 9425816..4a29690 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -505,8 +505,10 @@ namespace OpenSim.Services.UserAccountService
505 firstName, lastName); 505 firstName, lastName);
506 } 506 }
507 else 507 else
508 {
508 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", 509 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
509 firstName, lastName); 510 firstName, lastName);
511 }
510 512
511 if (m_InventoryService != null) 513 if (m_InventoryService != null)
512 { 514 {
@@ -516,13 +518,19 @@ namespace OpenSim.Services.UserAccountService
516 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", 518 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
517 firstName, lastName); 519 firstName, lastName);
518 } 520 }
519 else if (m_CreateDefaultAvatarEntries) 521 else
520 { 522 {
521 CreateDefaultAppearanceEntries(account.PrincipalID); 523 m_log.DebugFormat(
524 "[USER ACCOUNT SERVICE]; Created user inventory for {0} {1}", firstName, lastName);
522 } 525 }
526
527 if (m_CreateDefaultAvatarEntries)
528 CreateDefaultAppearanceEntries(account.PrincipalID);
523 } 529 }
524 530
525 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); 531 m_log.InfoFormat(
532 "[USER ACCOUNT SERVICE]: Account {0} {1} {2} created successfully",
533 firstName, lastName, account.PrincipalID);
526 } 534 }
527 else 535 else
528 { 536 {