aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-10-18 22:51:40 +0100
committerJustin Clark-Casey (justincc)2011-10-18 22:51:40 +0100
commitc85a780583cb36bac95f69c5d704f60a758d56bb (patch)
tree9ccd6c377ca205125020a9708038b32985ccdd13
parentTemporarily put in log lines to record time taken to set terrain in OdeScene. (diff)
downloadopensim-SC_OLD-c85a780583cb36bac95f69c5d704f60a758d56bb.zip
opensim-SC_OLD-c85a780583cb36bac95f69c5d704f60a758d56bb.tar.gz
opensim-SC_OLD-c85a780583cb36bac95f69c5d704f60a758d56bb.tar.bz2
opensim-SC_OLD-c85a780583cb36bac95f69c5d704f60a758d56bb.tar.xz
Provide an option to allow remote calls to the CreateUser method on the UserAccountService
Default is false, as before. Enabling AllowCreateUser in [UserAccountService] for ROBUST allows avatars to be created via an http call, with viewer 2 appropriate bits and pieces. Only Ruths can be created at present. Please don't rely on the config since at some point CreateUser will be moved to a separate co-ordinating service.
-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
-rw-r--r--bin/Robust.HG.ini.example7
-rw-r--r--bin/Robust.ini.example6
-rw-r--r--prebuild.xml1
6 files changed, 84 insertions, 10 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 {
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example
index 7f2636c..962c2f4 100644
--- a/bin/Robust.HG.ini.example
+++ b/bin/Robust.HG.ini.example
@@ -166,14 +166,17 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
166 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" 166 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
167 GridService = "OpenSim.Services.GridService.dll:GridService" 167 GridService = "OpenSim.Services.GridService.dll:GridService"
168 InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" 168 InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService"
169 ; AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" 169 AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService"
170 170
171 ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 171 ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2
172 ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. 172 ;; to show a default "Ruth" avatar rather than a cloud for a newly created user.
173 ;; Default is false 173 ;; Default is false
174 ;; If you enable this you will also need to uncomment the AvatarService line above
175 ; CreateDefaultAvatarEntries = false 174 ; CreateDefaultAvatarEntries = false
176 175
176 ;; Allow the service to process HTTP create user calls.
177 ;; Default is false.
178 ; AllowCreateUser = false
179
177 180
178[GridUserService] 181[GridUserService]
179 ; for the server connector 182 ; for the server connector
diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example
index a299a73..661a15e 100644
--- a/bin/Robust.ini.example
+++ b/bin/Robust.ini.example
@@ -149,7 +149,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
149 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" 149 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
150 GridService = "OpenSim.Services.GridService.dll:GridService" 150 GridService = "OpenSim.Services.GridService.dll:GridService"
151 InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" 151 InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService"
152 ; AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" 152 AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService"
153 153
154 ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 154 ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2
155 ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. 155 ;; 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
157 ;; If you enable this you will also need to uncomment the AvatarService line above 157 ;; If you enable this you will also need to uncomment the AvatarService line above
158 ; CreateDefaultAvatarEntries = false 158 ; CreateDefaultAvatarEntries = false
159 159
160 ;; Allow the service to process HTTP create user calls.
161 ;; Default is false.
162 ; AllowCreateUser = false
163
160 164
161[GridUserService] 165[GridUserService]
162 ; for the server connector 166 ; for the server connector
diff --git a/prebuild.xml b/prebuild.xml
index 8a45156..d6db614 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1326,6 +1326,7 @@
1326 <Reference name="OpenSim.Server.Base"/> 1326 <Reference name="OpenSim.Server.Base"/>
1327 <Reference name="OpenSim.Services.Base"/> 1327 <Reference name="OpenSim.Services.Base"/>
1328 <Reference name="OpenSim.Services.Interfaces"/> 1328 <Reference name="OpenSim.Services.Interfaces"/>
1329 <Reference name="OpenSim.Services.UserAccountService"/>
1329 <Reference name="XMLRPC" path="../../../bin/"/> 1330 <Reference name="XMLRPC" path="../../../bin/"/>
1330 <Reference name="Nini" path="../../../bin/"/> 1331 <Reference name="Nini" path="../../../bin/"/>
1331 <Reference name="log4net" path="../../../bin/"/> 1332 <Reference name="log4net" path="../../../bin/"/>