diff --git a/src/java/com/threerings/crowd/chat/server/ChatProvider.java b/src/java/com/threerings/crowd/chat/server/ChatProvider.java index 5b0078bea..1a789a36b 100644 --- a/src/java/com/threerings/crowd/chat/server/ChatProvider.java +++ b/src/java/com/threerings/crowd/chat/server/ChatProvider.java @@ -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; @@ -57,6 +57,16 @@ public class ChatProvider _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 * the invocation manager. @@ -78,6 +88,11 @@ public class ChatProvider TellListener listener) 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 BodyObject tobj = CrowdServer.lookupBody(target); if (tobj == null) { @@ -165,4 +180,7 @@ public class ChatProvider /** Reference to our auto responder object. */ protected static TellAutoResponder _autoRespond; + + /** The entity that will authorize our chatters. */ + protected static CommunicationAuthorizer _comAuth; } diff --git a/src/java/com/threerings/crowd/chat/server/SpeakProvider.java b/src/java/com/threerings/crowd/chat/server/SpeakProvider.java index d202399ec..9e38efaa5 100644 --- a/src/java/com/threerings/crowd/chat/server/SpeakProvider.java +++ b/src/java/com/threerings/crowd/chat/server/SpeakProvider.java @@ -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; @@ -62,11 +62,26 @@ public class SpeakProvider _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. */ 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 // TODO: broadcast should be handled more like a system message // 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. */ protected SpeakerValidator _validator; + /** The entity that will authorize our speakers. */ + protected static CommunicationAuthorizer _comAuth; + /** Recent chat history for the server. */ protected static HashMap _histories = new HashMap(); diff --git a/src/java/com/threerings/whirled/spot/server/SpotProvider.java b/src/java/com/threerings/whirled/spot/server/SpotProvider.java index 268775d63..614236495 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotProvider.java +++ b/src/java/com/threerings/whirled/spot/server/SpotProvider.java @@ -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; @@ -11,6 +11,7 @@ import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationManager; import com.threerings.presents.server.InvocationProvider; +import com.threerings.crowd.chat.server.CommunicationAuthorizer; import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceObject; @@ -48,6 +49,16 @@ public class SpotProvider _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. */ @@ -201,6 +212,11 @@ public class SpotProvider public void clusterSpeak (ClientObject caller, String message, byte mode) throws InvocationException { + // make sure the caller is authorized to perform this action + if ((_comAuth != null) && (!_comAuth.authorized(caller))) { + return; + } + BodyObject source = (BodyObject)caller; sendClusterChatMessage(getCallerSceneId(caller), source.getOid(), source.username, null, message, mode); @@ -269,4 +285,7 @@ public class SpotProvider /** The object manager we use to do dobject stuff. */ protected RootDObjectManager _omgr; + + /** The entity that will authorize our speaker. */ + protected static CommunicationAuthorizer _comAuth; }