The SecurityManager
class contains many methods with
names that begin with the word check
. These methods
are called by various methods in the Java libraries before those
methods perform certain potentially sensitive operations. The
invocation of such a check method typically looks like this:
SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkXXX
(argument, . . . ); }
The security manager is thereby given an opportunity to prevent
completion of the operation by throwing an exception. A security
manager routine simply returns if the operation is permitted, but
throws a SecurityException
if the operation is not
permitted. The only exception to this convention is
checkTopLevelWindow
, which returns a
boolean
value.
The current security manager is set by the
setSecurityManager
method in class
System
. The current security manager is obtained
by the getSecurityManager
method.
The default implementation of each of the
check
XXX methods is to assume that the caller
does not have permission to perform the requested operation.
package java.lang; import java.io.FileDescriptor; import java.util.Hashtable; import java.net.InetAddress; import java.lang.reflect.Member; (>JDK1.0)public abstract class SecurityManager { // Champs protégé (>JDK1.0) protected boolean inCheck; // Constructeur Protégé (>JDK1.0) protected SecurityManager(); // Méthodes d'instances protégés (>JDK1.0) protected native int classDepth(String name); (>JDK1.0) protected native int classLoaderDepth(); (>JDK1.0) protected native ClassLoader currentClassLoader(); (>JDK1.1) protected Class currentLoadedClass(); (>JDK1.0) protected native Class[] getClassContext(); (>JDK1.0) protected boolean inClass(String name); (>JDK1.0) protected boolean inClassLoader(); // Méthodes d'instance publiques (>JDK1.0) public void checkAccept(String host, int port); (>JDK1.0) public void checkAccess(Thread g); (>JDK1.0) public void checkAccess(ThreadGroup g); (>JDK1.1) public void checkAwtEventQueueAccess(); (>JDK1.0) public void checkConnect(String host, int port); (>JDK1.0) public void checkConnect(String host, int port, Object context); (>JDK1.0) public void checkCreateClassLoader(); (>JDK1.0) public void checkDelete(String file); (>JDK1.0) public void checkExec(String cmd); (>JDK1.0) public void checkExit(int status); (>JDK1.0) public void checkLink(String lib); (>JDK1.0) public void checkListen(int port); (>JDK1.1) public void checkMemberAccess(Class clazz, int which); (>JDK1.1) public void checkMulticast(InetAddress maddr); (>JDK1.1) public void checkMulticast(InetAddress maddr, byte ttl); (>JDK1.0) public void checkPackageAccess(String pkg); (>JDK1.0) public void checkPackageDefinition(String pkg); (>JDK1.1) public void checkPrintJobAccess(); (>JDK1.0) public void checkPropertiesAccess(); (>JDK1.0) public void checkPropertyAccess(String key); (>JDK1.0) public void checkRead(FileDescriptor fd); (>JDK1.0) public void checkRead(String file); (>JDK1.0) public void checkRead(String file, Object context); (>JDK1.1) public void checkSecurityAccess(String action); (>JDK1.0) public void checkSetFactory(); (>JDK1.1) public void checkSystemClipboardAccess(); (>JDK1.0) public boolean checkTopLevelWindow(Object window); (>JDK1.0) public void checkWrite(FileDescriptor fd); (>JDK1.0) public void checkWrite(String file); (>JDK1.0) public boolean getInCheck(); (>JDK1.0) public Object getSecurityContext(); (>JDK1.1) public ThreadGroup getThreadGroup(); } |
Christophe Merlet redfox@redfoxcenter.org | ©Tous droits réservés
11 septembre 1998 |