public class AuthorizationInterceptor extends Interceptor {
public Object execute(Command command) {
Environment environment = Environment.getCurrent();
if (environment==null) {
throw new PvmException("no environment for verifying authorization");
}
AuthorizationSession authorizationSession = environment.get(AuthorizationSession.class);
if (authorizationSession==null) {
throw new PvmException("no AuthorizationSession in environment for verifying authorization");
}
authorizationSession.checkPermission(command, environment);
// if the authorization check succeeded, proceed
return next.execute(command);
}