Name
SecurityManager
Synopsis
This class defines the methods necessary to
implement a security policy for the safe
execution of untrusted code. Before performing potentially sensitive
operations, Java calls methods of the
SecurityManager
object currently in effect to
determine whether the operations are permitted. These methods throw a
SecurityException
if the operation is not
permitted. Typical applications do not need to use or subclass
SecurityManager
. It is typically used only by web
browsers, applet viewers, and other programs that need to run
untrusted code in a controlled environment.
Prior to Java 1.2, this class
is abstract
, and the default implementation of
each check( )
method throws a
SecurityException
unconditionally. The Java
security mechanism has been overhauled as of Java 1.2. As part of the
overhaul, this class is no longer abstract
and its
methods have useful default implementations, so there is rarely a
need to subclass it. checkPermission( )
operates
by invoking the checkPermission( )
method of the
system java.security.AccessController
object. In
Java 1.2 and later, all other check( )
methods of
SecurityManager
are now implemented on top of
checkPermission( )
.
public class SecurityManager { // Public Constructors public SecurityManager( ); // Public Instance Methods public void checkAccept(String host, int port); public void checkAccess(ThreadGroup g); public void checkAccess(Thread t); 1.1 public void checkAwtEventQueueAccess( ); public void checkConnect(String ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.