Slap the CommunicationAuthorizer code in such that we block all user

communication if the user is not authorized.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2715 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Eric Lundberg
2003-07-18 01:58:38 +00:00
parent c2a5e8966b
commit 957faac149
3 changed files with 58 additions and 3 deletions
@@ -1,5 +1,5 @@
// //
// $Id: ChatProvider.java,v 1.23 2003/07/01 21:53:02 mdb Exp $ // $Id: ChatProvider.java,v 1.24 2003/07/18 01:58:38 eric Exp $
package com.threerings.crowd.chat.server; package com.threerings.crowd.chat.server;
@@ -57,6 +57,16 @@ public class ChatProvider
_autoRespond = autoRespond; _autoRespond = autoRespond;
} }
/**
* Set the authorizer we will use to see if the user is allowed to
* perform various chatting actions.
*/
public static void setCommunicationAuthorizer (
CommunicationAuthorizer comAuth)
{
_comAuth = comAuth;
}
/** /**
* Initializes the chat services and registers a chat provider with * Initializes the chat services and registers a chat provider with
* the invocation manager. * the invocation manager.
@@ -78,6 +88,11 @@ public class ChatProvider
TellListener listener) TellListener listener)
throws InvocationException throws InvocationException
{ {
// make sure the caller is authorized to perform this action
if ((_comAuth != null) && (!_comAuth.authorized(caller))) {
return;
}
// make sure the target user is online // make sure the target user is online
BodyObject tobj = CrowdServer.lookupBody(target); BodyObject tobj = CrowdServer.lookupBody(target);
if (tobj == null) { if (tobj == null) {
@@ -165,4 +180,7 @@ public class ChatProvider
/** Reference to our auto responder object. */ /** Reference to our auto responder object. */
protected static TellAutoResponder _autoRespond; protected static TellAutoResponder _autoRespond;
/** The entity that will authorize our chatters. */
protected static CommunicationAuthorizer _comAuth;
} }
@@ -1,5 +1,5 @@
// //
// $Id: SpeakProvider.java,v 1.14 2003/07/14 23:46:03 ray Exp $ // $Id: SpeakProvider.java,v 1.15 2003/07/18 01:58:38 eric Exp $
package com.threerings.crowd.chat.server; package com.threerings.crowd.chat.server;
@@ -62,11 +62,26 @@ public class SpeakProvider
_validator = validator; _validator = validator;
} }
/**
* Set the authorizer we will use to see if the user is allowed to
* perform various speaking actions.
*/
public static void setCommunicationAuthorizer (
CommunicationAuthorizer comAuth)
{
_comAuth = comAuth;
}
/** /**
* Handles a {@link SpeakService#speak} request. * Handles a {@link SpeakService#speak} request.
*/ */
public void speak (ClientObject caller, String message, byte mode) public void speak (ClientObject caller, String message, byte mode)
{ {
// make sure the caller is authorized to perform this action
if ((_comAuth != null) && (!_comAuth.authorized(caller))) {
return;
}
// ensure that the speaker is valid // ensure that the speaker is valid
// TODO: broadcast should be handled more like a system message // TODO: broadcast should be handled more like a system message
// rather than as a mode for a user message so that we don't // rather than as a mode for a user message so that we don't
@@ -327,6 +342,9 @@ public class SpeakProvider
/** The entity that will validate our speakers. */ /** The entity that will validate our speakers. */
protected SpeakerValidator _validator; protected SpeakerValidator _validator;
/** The entity that will authorize our speakers. */
protected static CommunicationAuthorizer _comAuth;
/** Recent chat history for the server. */ /** Recent chat history for the server. */
protected static HashMap _histories = new HashMap(); protected static HashMap _histories = new HashMap();
@@ -1,5 +1,5 @@
// //
// $Id: SpotProvider.java,v 1.18 2003/04/17 19:17:07 mdb Exp $ // $Id: SpotProvider.java,v 1.19 2003/07/18 01:58:38 eric Exp $
package com.threerings.whirled.spot.server; package com.threerings.whirled.spot.server;
@@ -11,6 +11,7 @@ import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager; import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider; import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.chat.server.CommunicationAuthorizer;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
@@ -48,6 +49,16 @@ public class SpotProvider
_omgr = omgr; _omgr = omgr;
} }
/**
* Set the authorizer we will use to see if the user is allowed to
* perform various chatting actions.
*/
public static void setCommunicationAuthorizer (
CommunicationAuthorizer comAuth)
{
_comAuth = comAuth;
}
/** /**
* Processes a {@link SpotService#traversePortal} request. * Processes a {@link SpotService#traversePortal} request.
*/ */
@@ -201,6 +212,11 @@ public class SpotProvider
public void clusterSpeak (ClientObject caller, String message, byte mode) public void clusterSpeak (ClientObject caller, String message, byte mode)
throws InvocationException throws InvocationException
{ {
// make sure the caller is authorized to perform this action
if ((_comAuth != null) && (!_comAuth.authorized(caller))) {
return;
}
BodyObject source = (BodyObject)caller; BodyObject source = (BodyObject)caller;
sendClusterChatMessage(getCallerSceneId(caller), source.getOid(), sendClusterChatMessage(getCallerSceneId(caller), source.getOid(),
source.username, null, message, mode); source.username, null, message, mode);
@@ -269,4 +285,7 @@ public class SpotProvider
/** The object manager we use to do dobject stuff. */ /** The object manager we use to do dobject stuff. */
protected RootDObjectManager _omgr; protected RootDObjectManager _omgr;
/** The entity that will authorize our speaker. */
protected static CommunicationAuthorizer _comAuth;
} }