aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs (renamed from OpenSim/Services/Connectors/User/UserServiceConnector.cs)94
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs28
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserServiceConnector.cs287
-rw-r--r--OpenSim/Services/Interfaces/IUserService.cs4
4 files changed, 349 insertions, 64 deletions
diff --git a/OpenSim/Services/Connectors/User/UserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs
index 0de8c1d..0b72080 100644
--- a/OpenSim/Services/Connectors/User/UserServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs
@@ -25,90 +25,90 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using log4net;
29using System; 28using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config; 29using Nini.Config;
34using OpenSim.Framework; 30using log4net;
35using OpenSim.Framework.Communications; 31using System.Reflection;
36using OpenSim.Framework.Servers.HttpServer; 32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
38using OpenMetaverse; 35using OpenSim.Services.Connectors;
39 36
40namespace OpenSim.Services.Connectors 37namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User
41{ 38{
42 public class UserServicesConnector : IUserAccountService 39 public class RemoteUserAccountServicesConnector : UserAccountServicesConnector,
40 ISharedRegionModule, IUserAccountService
43 { 41 {
44 private static readonly ILog m_log = 42 private static readonly ILog m_log =
45 LogManager.GetLogger( 43 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
47 45
48// private string m_ServerURI = String.Empty; 46 private bool m_Enabled = false;
49
50 public UserServicesConnector()
51 {
52 }
53 47
54 public UserServicesConnector(string serverURI) 48 public Type ReplaceableInterface
55 { 49 {
56// m_ServerURI = serverURI.TrimEnd('/'); 50 get { return null; }
57 } 51 }
58 52
59 public UserServicesConnector(IConfigSource source) 53 public string Name
60 { 54 {
61 Initialise(source); 55 get { return "RemoteUserAccountServicesConnector"; }
62 } 56 }
63 57
64 public virtual void Initialise(IConfigSource source) 58 public override void Initialise(IConfigSource source)
65 { 59 {
66 IConfig assetConfig = source.Configs["UserService"]; 60 IConfig moduleConfig = source.Configs["Modules"];
67 if (assetConfig == null) 61 if (moduleConfig != null)
68 { 62 {
69 m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); 63 string name = moduleConfig.GetString("UserServices", "");
70 throw new Exception("User connector init error"); 64 if (name == Name)
71 } 65 {
66 IConfig userConfig = source.Configs["UserService"];
67 if (userConfig == null)
68 {
69 m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini");
70 return;
71 }
72 72
73 string serviceURI = assetConfig.GetString("UserServerURI", 73 m_Enabled = true;
74 String.Empty);
75 74
76 if (serviceURI == String.Empty) 75 base.Initialise(source);
77 { 76
78 m_log.Error("[USER CONNECTOR]: No Server URI named in section UserService"); 77 m_log.Info("[USER CONNECTOR]: Remote users enabled");
79 throw new Exception("User connector init error"); 78 }
80 } 79 }
81 //m_ServerURI = serviceURI;
82 } 80 }
83 81
84 public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) 82 public void PostInitialise()
85 { 83 {
86 return null; 84 if (!m_Enabled)
85 return;
87 } 86 }
88 87
89 public UserAccount GetUserAccount(UUID scopeID, string email) 88 public void Close()
90 { 89 {
91 return null; 90 if (!m_Enabled)
92 } 91 return;
93
94 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
95 {
96 return null;
97 } 92 }
98 93
99 public bool SetUserAccount(UserAccount data) 94 public void AddRegion(Scene scene)
100 { 95 {
101 return false; 96 if (!m_Enabled)
97 return;
98
99 scene.RegisterModuleInterface<IUserAccountService>(this);
102 } 100 }
103 101
104 public bool CreateUserAccount(UserAccount data) 102 public void RemoveRegion(Scene scene)
105 { 103 {
106 return false; 104 if (!m_Enabled)
105 return;
107 } 106 }
108 107
109 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 108 public void RegionLoaded(Scene scene)
110 { 109 {
111 return null; 110 if (!m_Enabled)
111 return;
112 } 112 }
113 } 113 }
114} 114}
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
index 482862d..29cfd6e 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
@@ -109,9 +109,9 @@ namespace OpenSim.Services.Connectors
109 { 109 {
110 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 110 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
111 111
112 if (replyData.ContainsKey("Result")) 112 if (replyData.ContainsKey("result"))
113 { 113 {
114 if (replyData["Result"].ToString().ToLower() == "success") 114 if (replyData["result"].ToString().ToLower() == "success")
115 return true; 115 return true;
116 else 116 else
117 return false; 117 return false;
@@ -153,9 +153,9 @@ namespace OpenSim.Services.Connectors
153 { 153 {
154 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 154 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
155 155
156 if (replyData.ContainsKey("Result")) 156 if (replyData.ContainsKey("result"))
157 { 157 {
158 if (replyData["Result"].ToString().ToLower() == "success") 158 if (replyData["result"].ToString().ToLower() == "success")
159 return true; 159 return true;
160 else 160 else
161 return false; 161 return false;
@@ -196,9 +196,9 @@ namespace OpenSim.Services.Connectors
196 { 196 {
197 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 197 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
198 198
199 if (replyData.ContainsKey("Result")) 199 if (replyData.ContainsKey("result"))
200 { 200 {
201 if (replyData["Result"].ToString().ToLower() == "success") 201 if (replyData["result"].ToString().ToLower() == "success")
202 return true; 202 return true;
203 else 203 else
204 return false; 204 return false;
@@ -242,9 +242,9 @@ namespace OpenSim.Services.Connectors
242 { 242 {
243 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 243 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
244 244
245 if (replyData.ContainsKey("Result")) 245 if (replyData.ContainsKey("result"))
246 { 246 {
247 if (replyData["Result"].ToString().ToLower() == "success") 247 if (replyData["result"].ToString().ToLower() == "success")
248 return true; 248 return true;
249 else 249 else
250 return false; 250 return false;
@@ -296,11 +296,8 @@ namespace OpenSim.Services.Connectors
296 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 296 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
297 PresenceInfo pinfo = null; 297 PresenceInfo pinfo = null;
298 298
299 if ((replyData != null) && (replyData["result"] != null)) 299 if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
300 { 300 {
301 if (replyData["result"].ToString() == "null")
302 return null;
303
304 if (replyData["result"] is Dictionary<string, object>) 301 if (replyData["result"] is Dictionary<string, object>)
305 { 302 {
306 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); 303 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
@@ -345,7 +342,8 @@ namespace OpenSim.Services.Connectors
345 342
346 if (replyData != null) 343 if (replyData != null)
347 { 344 {
348 if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null") 345 if (replyData.ContainsKey("result") &&
346 (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
349 { 347 {
350 return new PresenceInfo[0]; 348 return new PresenceInfo[0];
351 } 349 }
@@ -395,9 +393,9 @@ namespace OpenSim.Services.Connectors
395 { 393 {
396 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 394 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
397 395
398 if (replyData.ContainsKey("Result")) 396 if (replyData.ContainsKey("result"))
399 { 397 {
400 if (replyData["Result"].ToString().ToLower() == "success") 398 if (replyData["result"].ToString().ToLower() == "success")
401 return true; 399 return true;
402 else 400 else
403 return false; 401 return false;
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserServiceConnector.cs
new file mode 100644
index 0000000..d4b906a
--- /dev/null
+++ b/OpenSim/Services/Connectors/UserAccounts/UserServiceConnector.cs
@@ -0,0 +1,287 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Server.Base;
38using OpenSim.Services.Interfaces;
39using OpenMetaverse;
40
41namespace OpenSim.Services.Connectors
42{
43 public class UserAccountServicesConnector : IUserAccountService
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(
47 MethodBase.GetCurrentMethod().DeclaringType);
48
49 private string m_ServerURI = String.Empty;
50
51 public UserAccountServicesConnector()
52 {
53 }
54
55 public UserAccountServicesConnector(string serverURI)
56 {
57 m_ServerURI = serverURI.TrimEnd('/');
58 }
59
60 public UserAccountServicesConnector(IConfigSource source)
61 {
62 Initialise(source);
63 }
64
65 public virtual void Initialise(IConfigSource source)
66 {
67 IConfig assetConfig = source.Configs["UserAccountService"];
68 if (assetConfig == null)
69 {
70 m_log.Error("[ACCOUNT CONNECTOR]: UserAccountService missing from OpenSim.ini");
71 throw new Exception("User account connector init error");
72 }
73
74 string serviceURI = assetConfig.GetString("UserAccountServerURI",
75 String.Empty);
76
77 if (serviceURI == String.Empty)
78 {
79 m_log.Error("[ACCOUNT CONNECTOR]: No Server URI named in section UserAccountService");
80 throw new Exception("User account connector init error");
81 }
82 m_ServerURI = serviceURI;
83 }
84
85 public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
86 {
87 Dictionary<string, object> sendData = new Dictionary<string, object>();
88 //sendData["SCOPEID"] = scopeID.ToString();
89 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
90 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
91 sendData["METHOD"] = "getaccount";
92
93 sendData["ScopeID"] = scopeID;
94 sendData["FirstName"] = firstName.ToString();
95 sendData["LastName"] = lastName.ToString();
96
97 return SendAndGetReply(sendData);
98 }
99
100 public UserAccount GetUserAccount(UUID scopeID, string email)
101 {
102 Dictionary<string, object> sendData = new Dictionary<string, object>();
103 //sendData["SCOPEID"] = scopeID.ToString();
104 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
105 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
106 sendData["METHOD"] = "getaccount";
107
108 sendData["ScopeID"] = scopeID;
109 sendData["Email"] = email;
110
111 return SendAndGetReply(sendData);
112 }
113
114 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
115 {
116 Dictionary<string, object> sendData = new Dictionary<string, object>();
117 //sendData["SCOPEID"] = scopeID.ToString();
118 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
119 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
120 sendData["METHOD"] = "getaccount";
121
122 sendData["ScopeID"] = scopeID;
123 sendData["UserID"] = userID.ToString();
124
125 return SendAndGetReply(sendData);
126 }
127
128 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
129 {
130 Dictionary<string, object> sendData = new Dictionary<string, object>();
131 //sendData["SCOPEID"] = scopeID.ToString();
132 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
133 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
134 sendData["METHOD"] = "getagents";
135
136 sendData["ScopeID"] = scopeID.ToString();
137 sendData["query"] = query;
138
139 string reply = string.Empty;
140 string reqString = ServerUtils.BuildQueryString(sendData);
141 // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
142 try
143 {
144 reply = SynchronousRestFormsRequester.MakeRequest("POST",
145 m_ServerURI + "/accounts",
146 reqString);
147 if (reply == null || (reply != null && reply == string.Empty))
148 {
149 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply");
150 return null;
151 }
152 }
153 catch (Exception e)
154 {
155 m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting accounts server: {0}", e.Message);
156 }
157
158 List<UserAccount> accounts = new List<UserAccount>();
159
160 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
161
162 if (replyData != null)
163 {
164 if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null")
165 {
166 return accounts;
167 }
168
169 Dictionary<string, object>.ValueCollection accountList = replyData.Values;
170 //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
171 foreach (object acc in accountList)
172 {
173 if (acc is Dictionary<string, object>)
174 {
175 UserAccount pinfo = new UserAccount((Dictionary<string, object>)acc);
176 accounts.Add(pinfo);
177 }
178 else
179 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received invalid response type {0}",
180 acc.GetType());
181 }
182 }
183 else
184 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetUserAccounts received null response");
185
186 return accounts;
187 }
188
189 public bool SetUserAccount(UserAccount data)
190 {
191 Dictionary<string, object> sendData = new Dictionary<string, object>();
192 //sendData["SCOPEID"] = scopeID.ToString();
193 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
194 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
195 sendData["METHOD"] = "setaccount";
196
197 sendData["account"] = data.ToKeyValuePairs();
198
199 return SendAndGetBoolReply(sendData);
200 }
201
202 public bool CreateUserAccount(UserAccount data)
203 {
204 Dictionary<string, object> sendData = new Dictionary<string, object>();
205 //sendData["SCOPEID"] = scopeID.ToString();
206 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
207 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
208 sendData["METHOD"] = "createaccount";
209
210 sendData["account"] = data.ToKeyValuePairs();
211
212 return SendAndGetBoolReply(sendData);
213 }
214
215 private UserAccount SendAndGetReply(Dictionary<string, object> sendData)
216 {
217 string reply = string.Empty;
218 string reqString = ServerUtils.BuildQueryString(sendData);
219 // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
220 try
221 {
222 reply = SynchronousRestFormsRequester.MakeRequest("POST",
223 m_ServerURI + "/accounts",
224 reqString);
225 if (reply == null || (reply != null && reply == string.Empty))
226 {
227 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply");
228 return null;
229 }
230 }
231 catch (Exception e)
232 {
233 m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user account server: {0}", e.Message);
234 }
235
236 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
237 UserAccount account = null;
238
239 if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
240 {
241 if (replyData["result"] is Dictionary<string, object>)
242 {
243 account = new UserAccount((Dictionary<string, object>)replyData["result"]);
244 }
245 }
246
247 return account;
248
249 }
250
251 private bool SendAndGetBoolReply(Dictionary<string, object> sendData)
252 {
253 string reqString = ServerUtils.BuildQueryString(sendData);
254 // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
255 try
256 {
257 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
258 m_ServerURI + "/accounts",
259 reqString);
260 if (reply != string.Empty)
261 {
262 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
263
264 if (replyData.ContainsKey("result"))
265 {
266 if (replyData["result"].ToString().ToLower() == "success")
267 return true;
268 else
269 return false;
270 }
271 else
272 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount reply data does not contain result field");
273
274 }
275 else
276 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount received empty reply");
277 }
278 catch (Exception e)
279 {
280 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Exception when contacting user account server: {0}", e.Message);
281 }
282
283 return false;
284 }
285
286 }
287}
diff --git a/OpenSim/Services/Interfaces/IUserService.cs b/OpenSim/Services/Interfaces/IUserService.cs
index 1089c6c..e4e4bec 100644
--- a/OpenSim/Services/Interfaces/IUserService.cs
+++ b/OpenSim/Services/Interfaces/IUserService.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Services.Interfaces
48 public UUID UserID; 48 public UUID UserID;
49 public UUID ScopeID; 49 public UUID ScopeID;
50 50
51 public Dictionary<string, string> ServiceURLs; 51 public Dictionary<string, object> ServiceURLs;
52 52
53 public DateTime Created; 53 public DateTime Created;
54 54
@@ -67,7 +67,7 @@ namespace OpenSim.Services.Interfaces
67 if (kvp.ContainsKey("Created")) 67 if (kvp.ContainsKey("Created"))
68 DateTime.TryParse(kvp["Created"].ToString(), out Created); 68 DateTime.TryParse(kvp["Created"].ToString(), out Created);
69 if (kvp.ContainsKey("ServiceURLs") && kvp["ServiceURLs"] != null && (kvp["ServiceURLs"] is Dictionary<string, string>)) 69 if (kvp.ContainsKey("ServiceURLs") && kvp["ServiceURLs"] != null && (kvp["ServiceURLs"] is Dictionary<string, string>))
70 ServiceURLs = (Dictionary<string, string>)kvp["ServiceURLs"]; 70 ServiceURLs = (Dictionary<string, object>)kvp["ServiceURLs"];
71 } 71 }
72 72
73 public Dictionary<string, object> ToKeyValuePairs() 73 public Dictionary<string, object> ToKeyValuePairs()