
We can also extend the SecurityManager class and override the methods to
create our behavior. First, let’s look at what the methods in the SecurityManager do.
There are about 30 methods that all begin with “check,” such as checkWrite(),
checkRead(), and checkConnect(). If a SecurityManager is loaded, whenever one of
the hazardous operations is attempted, a check method will be invoked.The check
methods are invoked by other methods in the Java library. For example, before the
FileOutputStream class actually attempts to write to a file, it would invoke code that
looks like this:
SecurityManager security = System.getSecurityManager();
if (security != null) ...