Java Reference
In-Depth Information
Bibliography
[API 2013]
Class
SecurityManager
Class
AccessControlContext
Class
AccessController
[Gong 2003]
§6.1, “Security Manager”
[Pistoia 2004]
§7.4, “The Security Manager”
[Policy 2010]
Default Policy Implementation and Policy File Syntax
[SecuritySpec 2010]
§6.2, “
SecurityManager
versus
AccessController
”
21. Do not let untrusted code misuse privileges of callback methods
Callbacks provide a means to register a method to be invoked (or
called back
) when an
interesting event occurs. Java uses callbacks forapplet andservlet life-cycle events, AWT
andSwingeventnotificationssuchasbuttonclicks,asynchronousreadsandwritestostor-
age, and even in
Runnable.run()
wherein a new thread automatically executes the spe-
cified
run()
method.
In Java, callbacks are typically implemented using interfaces. The general structure of
a callback is as follows:
public interface CallBack {
void callMethod();
}
class CallBackImpl implements CallBack {
public void callMethod() {
System.out.println("CallBack invoked");
}
}