Implementing a SecurityManager is probably the best way to go. You would have to override checkPermission. That method would look at the Permission object passed to it, and determine if a certain action is dangerous. This way you can allow some permissions and disallow other permissions.
Can you describe the custom SecurityManager you used?