Cleaned up the fine-grained permissions system a bit so that Yohoho can make
use of it in good conscience. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5117 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -25,6 +25,7 @@ import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
import com.threerings.presents.data.Permission;
|
||||
|
||||
import com.threerings.crowd.chat.data.ChatCodes;
|
||||
import com.threerings.crowd.chat.data.SpeakObject;
|
||||
@@ -87,27 +88,6 @@ public class BodyObject extends ClientObject
|
||||
return (location == null) ? -1 : location.placeOid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not this user has access to the specified feature. Currently used by the
|
||||
* chat system to regulate access to chat broadcasts but also forms the basis of an extensible
|
||||
* fine-grained permissions system.
|
||||
*
|
||||
* @return null if the user has access, a fully-qualified translatable message string
|
||||
* indicating the reason for denial of access (or just {@link InvocationCodes#ACCESS_DENIED} if
|
||||
* you don't want to be specific).
|
||||
*/
|
||||
public String checkAccess (String feature, Object context)
|
||||
{
|
||||
// our default access control policy; how quaint
|
||||
if (ChatCodes.BROADCAST_ACCESS.equals(feature)) {
|
||||
return getTokens().isAdmin() ? null : ChatCodes.ACCESS_DENIED;
|
||||
} else if (ChatCodes.CHAT_ACCESS.equals(feature)) {
|
||||
return null;
|
||||
} else {
|
||||
return InvocationCodes.ACCESS_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this user's access control tokens.
|
||||
*/
|
||||
@@ -157,6 +137,18 @@ public class BodyObject extends ClientObject
|
||||
setLocation(null);
|
||||
}
|
||||
|
||||
@Override // from ClientObject
|
||||
public String checkAccess (Permission perm, Object context)
|
||||
{
|
||||
if (perm == ChatCodes.BROADCAST_ACCESS) {
|
||||
return getTokens().isAdmin() ? null : ChatCodes.ACCESS_DENIED;
|
||||
} else if (perm == ChatCodes.CHAT_ACCESS) {
|
||||
return null;
|
||||
} else {
|
||||
return super.checkAccess(perm, context);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void applyToListeners (ListenerOp op)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user