aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Hypergrid
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/Server/Handlers/Hypergrid
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/Server/Handlers/Hypergrid')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs43
1 files changed, 41 insertions, 2 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
index dde7875..a83d0e8 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
@@ -88,6 +88,8 @@ namespace OpenSim.Server.Handlers.Hypergrid
88 case "newfriendship": 88 case "newfriendship":
89 return NewFriendship(request); 89 return NewFriendship(request);
90 90
91 case "deletefriendship":
92 return DeleteFriendship(request);
91 } 93 }
92 m_log.DebugFormat("[HGFRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); 94 m_log.DebugFormat("[HGFRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method);
93 } 95 }
@@ -143,11 +145,21 @@ namespace OpenSim.Server.Handlers.Hypergrid
143 145
144 // OK, can proceed 146 // OK, can proceed
145 FriendInfo friend = new FriendInfo(request); 147 FriendInfo friend = new FriendInfo(request);
148 UUID friendID;
149 string tmp = string.Empty;
150 if (!Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out tmp, out tmp, out tmp, out tmp))
151 return FailureResult();
152
153 m_log.DebugFormat("[HGFRIENDS HANDLER]: New friendship {0} {1}", friend.PrincipalID, friend.Friend);
154
155 // If the friendship already exists, return fail
156 FriendInfo[] finfos = m_FriendsService.GetFriends(friend.PrincipalID);
157 foreach (FriendInfo finfo in finfos)
158 if (finfo.Friend.StartsWith(friendID.ToString()))
159 return FailureResult();
146 160
147 // the user needs to confirm when he gets home 161 // the user needs to confirm when he gets home
148 bool success = m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, 0); 162 bool success = m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, 0);
149 //if (success)
150 // m_FriendsService.StoreFriend(friend.Friend, friend.PrincipalID.ToString(), 1);
151 163
152 if (success) 164 if (success)
153 return SuccessResult(); 165 return SuccessResult();
@@ -155,6 +167,33 @@ namespace OpenSim.Server.Handlers.Hypergrid
155 return FailureResult(); 167 return FailureResult();
156 } 168 }
157 169
170 byte[] DeleteFriendship(Dictionary<string, object> request)
171 {
172 FriendInfo friend = new FriendInfo(request);
173 string secret = string.Empty;
174 if (request.ContainsKey("SECRET"))
175 secret = request["SECRET"].ToString();
176
177 if (secret == string.Empty)
178 return FailureResult();
179
180 FriendInfo[] finfos = m_FriendsService.GetFriends(friend.PrincipalID);
181 foreach (FriendInfo finfo in finfos)
182 {
183 // We check the secret here
184 if (finfo.Friend.StartsWith(friend.Friend) && finfo.Friend.EndsWith(secret))
185 {
186 m_log.DebugFormat("[HGFRIENDS HANDLER]: Delete friendship {0} {1}", friend.PrincipalID, friend.Friend);
187 m_FriendsService.Delete(friend.PrincipalID, finfo.Friend);
188 m_FriendsService.Delete(finfo.Friend, friend.PrincipalID.ToString());
189
190 return SuccessResult();
191 }
192 }
193
194 return FailureResult();
195 }
196
158 #endregion 197 #endregion
159 198
160 #region Misc 199 #region Misc