Here is what the usage of privileged code looks like. Note the use of Java's inner classes capability:(If you are using an anonymous inner class, any local variables you access must be final to make JAVA language looks like having closures.) |
somemethod() { |
<normal code> |
AccessController.doPrivileged (new PrivilegedAction() |
{ |
public Object run() |
{ <insert dangerous code here> return null; } |
}); |
<more normal code> |
} |