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:
@@ -23,11 +23,37 @@ package com.threerings.presents.server;
|
||||
|
||||
import com.threerings.util.MessageBundle;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.Permission;
|
||||
|
||||
/**
|
||||
* Used to report failures when executing service requests.
|
||||
*/
|
||||
public class InvocationException extends Exception
|
||||
{
|
||||
/**
|
||||
* Requires that the specified client have the specified permissions.
|
||||
*
|
||||
* @throws InvocationException if they do not.
|
||||
*/
|
||||
public static void requireAccess (ClientObject clobj, Permission perm, Object context)
|
||||
throws InvocationException
|
||||
{
|
||||
String errmsg = clobj.checkAccess(perm, context);
|
||||
if (errmsg != null) {
|
||||
throw new InvocationException(errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of {@link #requireAccess} that takes no context.
|
||||
*/
|
||||
public static void requireAccess (ClientObject clobj, Permission perm)
|
||||
throws InvocationException
|
||||
{
|
||||
requireAccess(clobj, perm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an invocation exception with the supplied cause code
|
||||
* string.
|
||||
|
||||
Reference in New Issue
Block a user