All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.lang.SecurityManager
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 checkXXX methods is to assume that the caller does not have permission to perform the requested operation.
true if there is a security check in progress; false otherwise. SecurityManager. SecurityException if the calling thread is not permitted to accept a socket connection from the specified host and port number. SecurityException if the calling thread is not allowed to modify the thread argument. SecurityException if the calling thread is not allowed to modify the thread group argument. SecurityException if the calling thread is not allowed to open a socket connection to the specified host and port number. SecurityException if the specified security context is not allowed to open a socket connection to the specified host and port number. SecurityException if the calling thread is not allowed to create a new class loader. SecurityException if the calling thread is not allowed to delete the specified file. SecurityException if the calling thread is not allowed to create a subprocess. SecurityException if the calling thread is not allowed to cause the Java Virtual Machine to halt with the specified status code. SecurityException if the calling thread is not allowed to dynamic link the library code specified by the string argument file. SecurityException if the calling thread is not allowed to wait for a connection request on the specified local port number. SecurityException if the calling thread is not allowed to access the package specified by the argument. SecurityException if the calling thread is not allowed to define classes in the package specified by the argument. SecurityException if the calling thread is not allowed to access or modify the system properties. SecurityException if the calling thread is not allowed to access the system property with the specified key name. SecurityException if the calling thread is not allowed to read from the specified file descriptor. SecurityException if the calling thread is not allowed to read the file specified by the string argument. SecurityException if the specified security context is not allowed to read the file specified by the string argument. SecurityException if the calling thread is not allowed to set the socket factory used by ServerSocket or Socket, or the stream handler factory used by URL. false if the calling thread is not trusted to bring up the top-level window indicated by the window argument. SecurityException if the calling thread is not allowed to write to the specified file descriptor. SecurityException if the calling thread is not allowed to write to the file specified by the string argument. null. protected boolean inCheck
true if there is a security check in progress; false otherwise.protected SecurityManager()
SecurityManager. An application is not allowed to create a new security manager if there is already a current security manager. public boolean getInCheck()
inCheck field. This field should contain true if a security check is in progress; false otherwise. protected native Class[] getClassContext()
The length of the array is the number of methods on the execution stack. The element at index 0 is the class of the currently executing method, the element at index 1 is the class of that method's caller, and so on.
protected native ClassLoader currentClassLoader()
null if there is no occurrence on the stack of a method from a class defined using a class loader. protected Class currentLoadedClass()
protected native int classDepth(String name)
-1 if such a frame cannot be found. protected native int classLoaderDepth()
-1 if there is no occurrence of a method from a class defined using a class loader. protected boolean inClass(String name)
true if a method from a class with the specified name is on the execution stack; false otherwise. protected boolean inClassLoader()
null. true if a method from a class defined using a class loader is on the execution stack. public Object getSecurityContext()
checkConnect method and by the two-argument checkRead method. These methods are needed because a trusted method may be called on to read a file or open a socket on behalf of another method. The trusted method needs to determine if the other (possibly untrusted) method would be allowed to perform the operation on its own.
public void checkCreateClassLoader()
SecurityException if the calling thread is not allowed to create a new class loader. The checkCreateClassLoader method for class SecurityManager always throws a SecurityException.
public void checkAccess(Thread g)
SecurityException if the calling thread is not allowed to modify the thread argument. This method is invoked for the current security manager by the stop, suspend, resume, setPriority, setName, and setDaemon methods of class Thread.
The checkAccess method for class SecurityManager always throws a SecurityException.
public void checkAccess(ThreadGroup g)
SecurityException if the calling thread is not allowed to modify the thread group argument. This method is invoked for the current security manager when a new child thread or child thread group is created, and by the setDaemon, setMaxPriority, stop, suspend, resume, and destroy methods of class ThreadGroup.
The checkAccess method for class SecurityManager always throws a SecurityException.
public void checkExit(int status)
SecurityException if the calling thread is not allowed to cause the Java Virtual Machine to halt with the specified status code. This method is invoked for the current security manager by the exit method of class Runtime. A status of 0 indicates success; other values indicate various errors.
The checkExit method for class SecurityManager always throws a SecurityException.
public void checkExec(String cmd)
SecurityException if the calling thread is not allowed to create a subprocess. This method is invoked for the current security manager by the exec methods of class Runtime.
The checkExec method for class SecurityManager always throws a SecurityException.
public void checkLink(String lib)
SecurityException if the calling thread is not allowed to dynamic link the library code specified by the string argument file. The argument is either a simple library name or a complete filename. This method is invoked for the current security manager by methods load and loadLibrary of class Runtime.
The checkLink method for class SecurityManager always throws a SecurityException.
public void checkRead(FileDescriptor fd)
SecurityException if the calling thread is not allowed to read from the specified file descriptor. The checkRead method for class SecurityManager always throws a SecurityException.
public void checkRead(String file)
SecurityException if the calling thread is not allowed to read the file specified by the string argument. The checkRead method for class SecurityManager always throws a SecurityException.
public void checkRead(String file, Object context)
SecurityException if the specified security context is not allowed to read the file specified by the string argument. The context must be a security context returned by a previous call to getSecurityContext. The checkRead method for class SecurityManager always throws a SecurityException.
public void checkWrite(FileDescriptor fd)
SecurityException if the calling thread is not allowed to write to the specified file descriptor. The checkWrite method for class SecurityManager always throws a SecurityException.
public void checkWrite(String file)
SecurityException if the calling thread is not allowed to write to the file specified by the string argument. The checkWrite method for class SecurityManager always throws a SecurityException.
public void checkDelete(String file)
SecurityException if the calling thread is not allowed to delete the specified file. This method is invoked for the current security manager by the delete method of class File.
The checkDelete method for class SecurityManager always throws a SecurityException.
public void checkConnect(String host,
int port)
SecurityException if the calling thread is not allowed to open a socket connection to the specified host and port number. A port number of -1 indicates that the calling method is attempting to determine the IP address of the specified host name.
The checkConnect method for class SecurityManager always throws a SecurityException.
host and port.
public void checkConnect(String host,
int port,
Object context)
SecurityException if the specified security context is not allowed to open a socket connection to the specified host and port number. A port number of -1 indicates that the calling method is attempting to determine the IP address of the specified host name.
The checkConnect method for class SecurityManager always throws a SecurityException.
host and port. public void checkListen(int port)
SecurityException if the calling thread is not allowed to wait for a connection request on the specified local port number. The checkListen method for class SecurityManager always throws a SecurityException.
public void checkAccept(String host,
int port)
SecurityException if the calling thread is not permitted to accept a socket connection from the specified host and port number. This method is invoked for the current security manager by the accept method of class ServerSocket.
The checkAccept method for class SecurityManager always throws a SecurityException.
public void checkMulticast(InetAddress maddr)
public void checkMulticast(InetAddress maddr,
byte ttl)
public void checkPropertiesAccess()
SecurityException if the calling thread is not allowed to access or modify the system properties. This method is used by the getProperties and setProperties methods of class System.
The checkPropertiesAccess method for class SecurityManager always throws a SecurityException.
public void checkPropertyAccess(String key)
SecurityException if the calling thread is not allowed to access the system property with the specified key name. This method is used by the getProperty method of class System.
The checkPropertiesAccess method for class SecurityManager always throws a SecurityException.
public boolean checkTopLevelWindow(Object window)
false if the calling thread is not trusted to bring up the top-level window indicated by the window argument. In this case, the caller can still decide to show the window, but the window should include some sort of visual warning. If the method returns true, then the window can be shown without any special restrictions. See class Window for more information on trusted and untrusted windows.
The checkSetFactory method for class SecurityManager always returns false.
true if the caller is trusted to put up top-level windows; false otherwise. public void checkPrintJobAccess()
public void checkSystemClipboardAccess()
public void checkAwtEventQueueAccess()
public void checkPackageAccess(String pkg)
SecurityException if the calling thread is not allowed to access the package specified by the argument. This method is used by the loadClass method of class loaders.
The checkPackageAccess method for class SecurityManager always throws a SecurityException.
public void checkPackageDefinition(String pkg)
SecurityException if the calling thread is not allowed to define classes in the package specified by the argument. This method is used by the loadClass method of some class loaders.
The checkPackageDefinition method for class SecurityManager always throws a SecurityException.
public void checkSetFactory()
SecurityException if the calling thread is not allowed to set the socket factory used by ServerSocket or Socket, or the stream handler factory used by URL. The checkSetFactory method for class SecurityManager always throws a SecurityException.
public void checkMemberAccess(Class clazz,
int which)
public void checkSecurityAccess(String action)
public ThreadGroup getThreadGroup()
All Packages Class Hierarchy This Package Previous Next Index