aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2011-05-22 16:51:03 -0700
committerDiva Canto2011-05-22 16:51:03 -0700
commit336665e03532cf9d7a1ad65d5071e7050bf6ecd0 (patch)
tree45c7c1145de1b5af3ff198bcb29564a2547e4575 /OpenSim/Services
parentFile to be removed (diff)
downloadopensim-SC_OLD-336665e03532cf9d7a1ad65d5071e7050bf6ecd0.zip
opensim-SC_OLD-336665e03532cf9d7a1ad65d5071e7050bf6ecd0.tar.gz
opensim-SC_OLD-336665e03532cf9d7a1ad65d5071e7050bf6ecd0.tar.bz2
opensim-SC_OLD-336665e03532cf9d7a1ad65d5071e7050bf6ecd0.tar.xz
More on HG Friends. Added Delete(string, string) across the board. Added security to friendship identifiers so that they can safely be deleted across worlds. Had to change Get(string) to use LIKE because the secret in the identifier is not always known -- affects only HG visitors. BOTTOM LINE SO FAR: HG friendships established and deleted safely across grids, local rights working but not (yet?) being transmitted back.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs15
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs50
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs7
-rw-r--r--OpenSim/Services/Friends/FriendsService.cs7
-rw-r--r--OpenSim/Services/HypergridService/HGFriendsService.cs86
-rw-r--r--OpenSim/Services/Interfaces/IFriendsService.cs1
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs2
7 files changed, 79 insertions, 89 deletions
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
index d1afea2..08f1dc3 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
@@ -211,6 +211,16 @@ namespace OpenSim.Services.Connectors.Friends
211 211
212 } 212 }
213 213
214 public bool Delete(string PrincipalID, string Friend)
215 {
216 Dictionary<string, object> sendData = new Dictionary<string, object>();
217 sendData["PRINCIPALID"] = PrincipalID.ToString();
218 sendData["FRIEND"] = Friend;
219 sendData["METHOD"] = "deletefriend_string";
220
221 return Delete(sendData, PrincipalID, Friend);
222 }
223
214 public bool Delete(UUID PrincipalID, string Friend) 224 public bool Delete(UUID PrincipalID, string Friend)
215 { 225 {
216 Dictionary<string, object> sendData = new Dictionary<string, object>(); 226 Dictionary<string, object> sendData = new Dictionary<string, object>();
@@ -218,6 +228,11 @@ namespace OpenSim.Services.Connectors.Friends
218 sendData["FRIEND"] = Friend; 228 sendData["FRIEND"] = Friend;
219 sendData["METHOD"] = "deletefriend"; 229 sendData["METHOD"] = "deletefriend";
220 230
231 return Delete(sendData, PrincipalID.ToString(), Friend);
232 }
233
234 public bool Delete(Dictionary<string, object> sendData, string PrincipalID, string Friend)
235 {
221 string reply = string.Empty; 236 string reply = string.Empty;
222 try 237 try
223 { 238 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs
index f823889..d699f59 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs
@@ -54,6 +54,11 @@ namespace OpenSim.Services.Connectors.Hypergrid
54 { 54 {
55 } 55 }
56 56
57 public HGFriendsServicesConnector(string serverURI)
58 {
59 m_ServerURI = serverURI.TrimEnd('/');
60 }
61
57 public HGFriendsServicesConnector(string serverURI, UUID sessionID, string serviceKey) 62 public HGFriendsServicesConnector(string serverURI, UUID sessionID, string serviceKey)
58 { 63 {
59 m_ServerURI = serverURI.TrimEnd('/'); 64 m_ServerURI = serverURI.TrimEnd('/');
@@ -151,6 +156,51 @@ namespace OpenSim.Services.Connectors.Hypergrid
151 156
152 } 157 }
153 158
159 public bool DeleteFriendship(UUID PrincipalID, UUID Friend, string secret)
160 {
161 FriendInfo finfo = new FriendInfo();
162 finfo.PrincipalID = PrincipalID;
163 finfo.Friend = Friend.ToString();
164
165 Dictionary<string, object> sendData = finfo.ToKeyValuePairs();
166
167 sendData["METHOD"] = "deletefriendship";
168 sendData["SECRET"] = secret;
169
170 string reply = string.Empty;
171 try
172 {
173 reply = SynchronousRestFormsRequester.MakeRequest("POST",
174 m_ServerURI + "/hgfriends",
175 ServerUtils.BuildQueryString(sendData));
176 }
177 catch (Exception e)
178 {
179 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
180 return false;
181 }
182
183 if (reply != string.Empty)
184 {
185 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
186
187 if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
188 {
189 bool success = false;
190 Boolean.TryParse(replyData["Result"].ToString(), out success);
191 return success;
192 }
193 else
194 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Delete {0} {1} received null response",
195 PrincipalID, Friend);
196 }
197 else
198 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: DeleteFriend received null reply");
199
200 return false;
201
202 }
203
154 #endregion 204 #endregion
155 } 205 }
156} \ No newline at end of file 206} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
index b1c34dd..7422d94 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
@@ -103,7 +103,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
103 if (!UUID.TryParse(principalID, out friend.PrincipalID)) 103 if (!UUID.TryParse(principalID, out friend.PrincipalID))
104 { 104 {
105 string tmp = string.Empty; 105 string tmp = string.Empty;
106 if (!Util.ParseUniversalUserIdentifier(principalID, out friend.PrincipalID, out tmp, out tmp, out tmp)) 106 if (!Util.ParseUniversalUserIdentifier(principalID, out friend.PrincipalID, out tmp, out tmp, out tmp, out tmp))
107 // bad record. ignore this entry 107 // bad record. ignore this entry
108 continue; 108 continue;
109 } 109 }
@@ -164,6 +164,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
164 164
165 public bool Delete(UUID principalID, string friend) 165 public bool Delete(UUID principalID, string friend)
166 { 166 {
167 return Delete(principalID.ToString(), friend);
168 }
169
170 public bool Delete(string principalID, string friend)
171 {
167 if (String.IsNullOrEmpty(m_serverUrl)) 172 if (String.IsNullOrEmpty(m_serverUrl))
168 return true; 173 return true;
169 174
diff --git a/OpenSim/Services/Friends/FriendsService.cs b/OpenSim/Services/Friends/FriendsService.cs
index 4664cb3..e2033ac 100644
--- a/OpenSim/Services/Friends/FriendsService.cs
+++ b/OpenSim/Services/Friends/FriendsService.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Services.Friends
75 if (!UUID.TryParse(d.PrincipalID, out i.PrincipalID)) 75 if (!UUID.TryParse(d.PrincipalID, out i.PrincipalID))
76 { 76 {
77 string tmp = string.Empty; 77 string tmp = string.Empty;
78 if (!Util.ParseUniversalUserIdentifier(d.PrincipalID, out i.PrincipalID, out tmp, out tmp, out tmp)) 78 if (!Util.ParseUniversalUserIdentifier(d.PrincipalID, out i.PrincipalID, out tmp, out tmp, out tmp, out tmp))
79 // bad record. ignore this entry 79 // bad record. ignore this entry
80 continue; 80 continue;
81 } 81 }
@@ -101,6 +101,11 @@ namespace OpenSim.Services.Friends
101 return m_Database.Store(d); 101 return m_Database.Store(d);
102 } 102 }
103 103
104 public bool Delete(string principalID, string friend)
105 {
106 return m_Database.Delete(principalID, friend);
107 }
108
104 public virtual bool Delete(UUID PrincipalID, string Friend) 109 public virtual bool Delete(UUID PrincipalID, string Friend)
105 { 110 {
106 return m_Database.Delete(PrincipalID, Friend); 111 return m_Database.Delete(PrincipalID, Friend);
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
deleted file mode 100644
index 1829ae3..0000000
--- a/OpenSim/Services/HypergridService/HGFriendsService.cs
+++ /dev/null
@@ -1,86 +0,0 @@
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 OpenMetaverse;
29using OpenSim.Framework;
30using System;
31using System.Collections.Generic;
32using OpenSim.Services.Interfaces;
33using OpenSim.Services.Friends;
34using OpenSim.Data;
35using Nini.Config;
36using log4net;
37using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38
39namespace OpenSim.Services.HypergridService
40{
41 public class HGFriendsService : FriendsService, IFriendsService
42 {
43 public HGFriendsService(IConfigSource config) : base(config)
44 {
45 }
46
47 /// <summary>
48 /// Overrides base.
49 /// Storing new friendships from the outside is a tricky, sensitive operation, and it
50 /// needs to be done under certain restrictions.
51 /// First of all, if the friendship already exists, this is a no-op. In other words,
52 /// we cannot change just the flags, it needs to be a new friendship.
53 /// Second, we store it as flags=0 always, independent of what the caller sends. The
54 /// owner of the friendship needs to confirm when it gets back home.
55 /// </summary>
56 /// <param name="PrincipalID"></param>
57 /// <param name="Friend"></param>
58 /// <param name="flags"></param>
59 /// <returns></returns>
60 public override bool StoreFriend(string PrincipalID, string Friend, int flags)
61 {
62 UUID userID;
63 if (UUID.TryParse(PrincipalID, out userID))
64 {
65 FriendsData[] friendsData = m_Database.GetFriends(userID.ToString());
66 List<FriendsData> fList = new List<FriendsData>(friendsData);
67 if (fList.Find(delegate(FriendsData fdata)
68 {
69 return fdata.Friend == Friend;
70 }) != null)
71 return false;
72 }
73 else
74 return false;
75
76 FriendsData d = new FriendsData();
77 d.PrincipalID = PrincipalID;
78 d.Friend = Friend;
79 d.Data = new Dictionary<string, string>();
80 d.Data["Flags"] = "0";
81
82 return m_Database.Store(d);
83 }
84
85 }
86}
diff --git a/OpenSim/Services/Interfaces/IFriendsService.cs b/OpenSim/Services/Interfaces/IFriendsService.cs
index 0a8efad..1664f3b 100644
--- a/OpenSim/Services/Interfaces/IFriendsService.cs
+++ b/OpenSim/Services/Interfaces/IFriendsService.cs
@@ -77,5 +77,6 @@ namespace OpenSim.Services.Interfaces
77 FriendInfo[] GetFriends(string PrincipalID); 77 FriendInfo[] GetFriends(string PrincipalID);
78 bool StoreFriend(string PrincipalID, string Friend, int flags); 78 bool StoreFriend(string PrincipalID, string Friend, int flags);
79 bool Delete(UUID PrincipalID, string Friend); 79 bool Delete(UUID PrincipalID, string Friend);
80 bool Delete(string PrincipalID, string Friend);
80 } 81 }
81} 82}
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index 4fac951..f68c078 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -628,7 +628,7 @@ namespace OpenSim.Services.LLLoginService
628 else 628 else
629 { 629 {
630 string tmp; 630 string tmp;
631 if (Util.ParseUniversalUserIdentifier(finfo.Friend, out friendID, out tmp, out tmp, out tmp)) 631 if (Util.ParseUniversalUserIdentifier(finfo.Friend, out friendID, out tmp, out tmp, out tmp, out tmp))
632 buddyitem.BuddyID = friendID.ToString(); 632 buddyitem.BuddyID = friendID.ToString();
633 else 633 else
634 // junk entry 634 // junk entry