Give Bureaus their own client object subclass. It does nothing at the moment, but we need it to be a distinct type for access control purposes.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5600 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Par Winzell
2008-12-12 15:36:46 +00:00
parent 1052aa86ec
commit fb4a28b2ed
7 changed files with 103 additions and 8 deletions
@@ -6,13 +6,13 @@ import com.threerings.util.Log;
import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.ClientEvent;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.ObjectAccessError;
import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.dobj.SubscriberAdapter;
import com.threerings.presents.util.SafeSubscriber;
import com.threerings.bureau.data.AgentObject;
import com.threerings.bureau.data.BureauClientObject;
import com.threerings.bureau.data.BureauCodes;
import com.threerings.bureau.util.BureauContext;
@@ -22,6 +22,8 @@ import com.threerings.bureau.util.BureauContext;
*/
public class BureauDirector extends BasicDirector
{
BureauClientObject;
/**
* Creates a new BureauDirector.
*/
@@ -21,13 +21,12 @@
package com.threerings.bureau.data {
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.data.ClientObject;
/**
* Defines the fields available for the distributed part of a bureau.
* An object representing a Bureau connection. This is currently just a marker class.
*/
public class BureauClientObject extends DObject
public class BureauClientObject extends ClientObject
{
// TODO: add some fields
}
}
@@ -0,0 +1,36 @@
//
// $Id: $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.bureau.data;
import com.threerings.presents.data.ClientObject;
/**
* An object representing a Bureau connection. This is currently just a marker class.
*/
public class BureauClientObject extends ClientObject
{
@Override
public String toString ()
{
return "BUREAU_CLIENT_OBJECT(" + super.toString() + ")";
}
}
@@ -0,0 +1,39 @@
//
// $Id: $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.bureau.server;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.ClientResolver;
import com.threerings.bureau.data.BureauClientObject;
/**
* Used to configure crowd-specific client object data.
*/
public class BureauClientResolver extends ClientResolver
{
@Override // from ClientResolver
public ClientObject createClientObject ()
{
return new BureauClientObject();
}
}
@@ -58,10 +58,8 @@ public class BureauSessionFactory implements SessionFactory
// from interface SessionFactory
public Class<? extends ClientResolver> getClientResolverClass (Name username)
{
// Just give bureaus a vanilla ClientResolver for now.
// TODO: will bureaus need specific resolution?
if (BureauCredentials.isBureau(username)) {
return ClientResolver.class;
return BureauClientResolver.class;
} else {
return _delegate.getClientResolverClass(username);
}
@@ -29,6 +29,7 @@ import com.threerings.presents.dobj.ProxySubscriber;
import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.server.PresentsObjectAccess;
import com.threerings.bureau.data.BureauClientObject;
import com.threerings.crowd.data.PlaceObject;
/**
@@ -59,4 +60,23 @@ public class CrowdObjectAccess
return PresentsObjectAccess.DEFAULT.allowDispatch(object, event);
}
};
/**
* Extends the access control in {@link #PLACE} to allow Bureau clients to subscribe.
*/
public static AccessController BUREAU_ACCESS_PLACE = new AccessController() {
public boolean allowSubscribe (DObject object, Subscriber<?> sub) {
if (sub instanceof ProxySubscriber) {
ClientObject co = ((ProxySubscriber)sub).getClientObject();
if (co instanceof BureauClientObject) {
return true;
}
}
return PLACE.allowSubscribe(object, sub);
}
public boolean allowDispatch (DObject object, DEvent event) {
return PLACE.allowDispatch(object, event);
}
};
}
@@ -619,6 +619,7 @@ public class PresentsSession
protected void sessionWillStart ()
{
// configure a specific access controller for the client object
log.info("Setting access controller to PresentsObjectAccess.CLIENT");
_clobj.setAccessController(PresentsObjectAccess.CLIENT);
}