aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Addons
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-05-06 17:22:47 +0100
committerJustin Clark-Casey (justincc)2014-05-06 17:22:47 +0100
commit95eeb4dde840a8b0d325dd0423dc7099aaed7dfa (patch)
tree139e7fd30e49d13cdb5c53ebcf82eb5cc22cc8e9 /OpenSim/Addons
parentminor: Comment out Cacheitems debug log lines for now (diff)
parentBetter error handling in AssetServerPostHandler. Invalid XML causes an Invali... (diff)
downloadopensim-SC_OLD-95eeb4dde840a8b0d325dd0423dc7099aaed7dfa.zip
opensim-SC_OLD-95eeb4dde840a8b0d325dd0423dc7099aaed7dfa.tar.gz
opensim-SC_OLD-95eeb4dde840a8b0d325dd0423dc7099aaed7dfa.tar.bz2
opensim-SC_OLD-95eeb4dde840a8b0d325dd0423dc7099aaed7dfa.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Addons')
-rw-r--r--OpenSim/Addons/Groups/GroupsModule.cs5
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs8
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs3
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs38
4 files changed, 47 insertions, 7 deletions
diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs
index f11606a..2831326 100644
--- a/OpenSim/Addons/Groups/GroupsModule.cs
+++ b/OpenSim/Addons/Groups/GroupsModule.cs
@@ -496,12 +496,13 @@ namespace OpenSim.Groups
496 Util.ParseUniversalUserIdentifier(notice.noticeData.AttachmentOwnerID, out giver, out tmp, out tmp, out tmp, out tmp); 496 Util.ParseUniversalUserIdentifier(notice.noticeData.AttachmentOwnerID, out giver, out tmp, out tmp, out tmp, out tmp);
497 497
498 m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); 498 m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId);
499 string message;
499 InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, 500 InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId,
500 giver, notice.noticeData.AttachmentItemID); 501 giver, notice.noticeData.AttachmentItemID, out message);
501 502
502 if (itemCopy == null) 503 if (itemCopy == null)
503 { 504 {
504 remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); 505 remoteClient.SendAgentAlertMessage(message, false);
505 return; 506 return;
506 } 507 }
507 508
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs
index 67402a2..1425a23 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs
@@ -44,15 +44,17 @@ namespace OpenSim.Groups
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private string m_ServerURI; 46 private string m_ServerURI;
47 private string m_SecretKey;
47 private object m_Lock = new object(); 48 private object m_Lock = new object();
48 49
49 public GroupsServiceRemoteConnector(string url) 50 public GroupsServiceRemoteConnector(string url, string secret)
50 { 51 {
51 m_ServerURI = url; 52 m_ServerURI = url;
52 if (!m_ServerURI.EndsWith("/")) 53 if (!m_ServerURI.EndsWith("/"))
53 m_ServerURI += "/"; 54 m_ServerURI += "/";
54 55
55 m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}", m_ServerURI); 56 m_SecretKey = secret;
57 m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, secret key {1}", m_ServerURI, m_SecretKey);
56 } 58 }
57 59
58 public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, 60 public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment,
@@ -654,6 +656,8 @@ namespace OpenSim.Groups
654 private Dictionary<string, object> MakeRequest(string method, Dictionary<string, object> sendData) 656 private Dictionary<string, object> MakeRequest(string method, Dictionary<string, object> sendData)
655 { 657 {
656 sendData["METHOD"] = method; 658 sendData["METHOD"] = method;
659 if (m_SecretKey != string.Empty)
660 sendData["KEY"] = m_SecretKey;
657 661
658 string reply = string.Empty; 662 string reply = string.Empty;
659 lock (m_Lock) 663 lock (m_Lock)
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs
index d3de0e8..5fb3c19 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs
@@ -77,7 +77,8 @@ namespace OpenSim.Groups
77 if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) 77 if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
78 throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); 78 throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url));
79 79
80 m_GroupsService = new GroupsServiceRemoteConnector(url); 80 string secret = groupsConfig.GetString("SecretKey", string.Empty);
81 m_GroupsService = new GroupsServiceRemoteConnector(url, secret);
81 m_Scenes = new List<Scene>(); 82 m_Scenes = new List<Scene>();
82 83
83 } 84 }
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
index 616afa9..828965f 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
@@ -52,14 +52,24 @@ namespace OpenSim.Groups
52 public GroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName) : 52 public GroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName) :
53 base(config, server, configName) 53 base(config, server, configName)
54 { 54 {
55 string key = string.Empty;
55 if (configName != String.Empty) 56 if (configName != String.Empty)
56 m_ConfigName = configName; 57 m_ConfigName = configName;
57 58
58 m_log.DebugFormat("[Groups.RobustConnector]: Starting with config name {0}", m_ConfigName); 59 m_log.DebugFormat("[Groups.RobustConnector]: Starting with config name {0}", m_ConfigName);
59 60
61 IConfig groupsConfig = config.Configs[m_ConfigName];
62 if (groupsConfig != null)
63 {
64 key = groupsConfig.GetString("SecretKey", string.Empty);
65 m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key);
66 }
67 else
68 m_log.WarnFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName);
69
60 m_GroupsService = new GroupsService(config); 70 m_GroupsService = new GroupsService(config);
61 71
62 server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService)); 72 server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, key));
63 } 73 }
64 } 74 }
65 75
@@ -68,11 +78,13 @@ namespace OpenSim.Groups
68 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 78 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
69 79
70 private GroupsService m_GroupsService; 80 private GroupsService m_GroupsService;
81 private string m_SecretKey = String.Empty;
71 82
72 public GroupsServicePostHandler(GroupsService service) : 83 public GroupsServicePostHandler(GroupsService service, string key) :
73 base("POST", "/groups") 84 base("POST", "/groups")
74 { 85 {
75 m_GroupsService = service; 86 m_GroupsService = service;
87 m_SecretKey = key;
76 } 88 }
77 89
78 protected override byte[] ProcessRequest(string path, Stream requestData, 90 protected override byte[] ProcessRequest(string path, Stream requestData,
@@ -96,6 +108,20 @@ namespace OpenSim.Groups
96 string method = request["METHOD"].ToString(); 108 string method = request["METHOD"].ToString();
97 request.Remove("METHOD"); 109 request.Remove("METHOD");
98 110
111 if (!String.IsNullOrEmpty(m_SecretKey)) // Verification required
112 {
113 // Sender didn't send key
114 if (!request.ContainsKey("KEY") || (request["KEY"] == null))
115 return FailureResult("This service requires a secret key");
116
117 // Sender sent wrong key
118 if (!m_SecretKey.Equals(request["KEY"]))
119 return FailureResult("Provided key does not match existing one");
120
121 // OK, key matches. Remove it.
122 request.Remove("KEY");
123 }
124
99 m_log.DebugFormat("[Groups.Handler]: {0}", method); 125 m_log.DebugFormat("[Groups.Handler]: {0}", method);
100 switch (method) 126 switch (method)
101 { 127 {
@@ -784,6 +810,14 @@ namespace OpenSim.Groups
784 string xmlString = ServerUtils.BuildXmlResponse(result); 810 string xmlString = ServerUtils.BuildXmlResponse(result);
785 return Util.UTF8NoBomEncoding.GetBytes(xmlString); 811 return Util.UTF8NoBomEncoding.GetBytes(xmlString);
786 } 812 }
813
814 private byte[] FailureResult(string reason)
815 {
816 Dictionary<string, object> result = new Dictionary<string, object>();
817 NullResult(result, reason);
818 string xmlString = ServerUtils.BuildXmlResponse(result);
819 return Util.UTF8NoBomEncoding.GetBytes(xmlString);
820 }
787 #endregion 821 #endregion
788 } 822 }
789} 823}