Fix longstanding annoyance with proxy subscriber access control checking. If

we're proxying for a client, we now have to give up our ClientObject to anyone
who wants it, so that they can do access control checks.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5593 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-12-11 01:11:04 +00:00
parent df5f5ace27
commit f2b30890f9
3 changed files with 21 additions and 7 deletions
@@ -21,6 +21,8 @@
package com.threerings.presents.dobj;
import com.threerings.presents.data.ClientObject;
/**
* Defines a special kind of subscriber that proxies events for a subordinate distributed object
* manager. All events dispatched on objects with which this subscriber is registered are passed
@@ -36,4 +38,9 @@ public interface ProxySubscriber extends Subscriber<DObject>
* @param event The event that was dispatched on the object.
*/
void eventReceived (DEvent event);
/**
* Returns the client object that represents the subscriber for whom we are proxying.
*/
ClientObject getClientObject ();
}
@@ -28,6 +28,7 @@ import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.InvocationRequestEvent;
import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.dobj.NamedEvent;
import com.threerings.presents.dobj.ProxySubscriber;
import com.threerings.presents.dobj.Subscriber;
import static com.threerings.presents.Log.log;
@@ -72,17 +73,17 @@ public class PresentsObjectAccess
// documentation inherited from interface
public boolean allowSubscribe (DObject object, Subscriber<?> sub)
{
boolean allowed = true;
// if the subscriber is a client, ensure that they are this same user
if (PresentsSession.class.isInstance(sub)) {
PresentsSession client = PresentsSession.class.cast(sub);
allowed = (client.getClientObject() == object);
if (!allowed) {
if (ProxySubscriber.class.isInstance(sub)) {
ProxySubscriber proxy = ProxySubscriber.class.cast(sub);
if (proxy.getClientObject() != object) {
log.warning("Refusing ClientObject subscription request " +
"[obj=" + ((ClientObject)object).who() + ", sub=" + sub + "].");
"[obj=" + ((ClientObject)object).who() +
", sub=" + proxy.getClientObject().who() + "].");
return false;
}
}
return allowed;
return true;
}
// documentation inherited from interface
@@ -960,6 +960,12 @@ public class PresentsSession
postMessage(new EventNotification(event));
}
// from interface ProxySubscriber
public ClientObject getClientObject ()
{
return PresentsSession.this.getClientObject();
}
protected long _firstEventId;
}