Java Platform 1.2
Beta 4

Class java.lang.SecurityManager

java.lang.Object
  |
  +--java.lang.SecurityManager
Direct Known Subclasses:
RMISecurityManager

public class SecurityManager
extends Object
The security manager is a class that allows applications to implement a security policy. It allows an application to determine, before performing a possibly unsafe or sensitive operation, what the operation is and whether the operation is being performed by a class created via a class loader rather than installed locally. Classes loaded via a class loader (especially if they have been downloaded over a network) may be less trustworthy than classes from files installed locally. The application can allow or disallow the operation.

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.

As of JDK 1.2, the default implementation of each of the checkXXX methods is to use the AccessController to determine if the caller has permission to perform the requested operation.

The special method checkPermission(java.security.Permission) determines whether an access request indicated by a specified permission should be granted or denied. The default implementation calls

   AccessController.checkPermission(perm);
 

If a requested access is allowed, checkPermission returns quietly. If denied, a SecurityException is thrown.

Note that the checkPermission method with just a single permission argument always performs security checks within the context of the currently executing thread. Sometimes a security check that should be made within a given context will actually need to be done from within a different context (for example, from within a worker thread). The getSecurityContext() method and the checkPermission(java.security.Permission, java.lang.Object) method that includes a context argument are provided for this situation. The getSecurityContext method returns a "snapshot" of the current calling context. (The default implementation returns an AccessControlContext object.) A sample call is the following:

   Object context = null;
   SecurityManager sm = System.getSecurityManager();
   if (sm != null) context = sm.getSecurityContext(); 
 

The checkPermission method that takes a context object (in addition to a permission) makes access decisions based on that context, rather than that of the current execution thread. Code within a different context can thus call that method, passing the permission and the previously-saved context object. A sample call (using the SecurityManager sm obtained as in the previous example) is the following:

   if (sm != null) sm.checkPermission(permission, context);
 

Permissions fall into these categories: File, Socket, Net, Security, Runtime, Property, and AWT. The classes managing these various permission categories are java.io.FilePermission, java.net.SocketPermission, java.net.NetPermission, java.security.SecurityPermission, java.lang.RuntimePermission, java.util.PropertyPermission, and java.awt.AWTPermission.

All but the first two (FilePermission and SocketPermission) are subclasses of java.security.BasicPermission, which itself is an abstract subclass of the top-level class for permissions, which is java.security.Permission. BasicPermission defines the functionality needed for all permissions that contain a name that follows the hierarchical property naming convention (for example, "exitVM", "setFactory", "queuePrintJob", etc). An asterisk may appear at the end of the name, following a ".", or by itself, to signify a wildcard match. For example: "a.*" or "*" is valid, "*a" or "a*b" is not valid.

FilePermission and SocketPermission are subclasses of the top-level class for permissions (java.security.Permission). Classes like these that have a more complicated name syntax than that used by BasicPermission subclass directly from Permission rather than from BasicPermission. For example, for a java.io.FilePermission object, the permission name is the pathname of a file (or directory).

Some of the permission classes have an "actions" list that tells the actions that are permitted for the object. For example, for a java.io.FilePermission object, the actions list (such as "read, write") specifies which actions are granted for the specified file (or for files in the specified directory).

Other permission classes are for "named" permissions - ones that contain a name but no actions list; you either have the named permission or you don't.

Note: There is also a java.security.AllPermission permission that implies all permissions. It exists to simplify the work of system administrators who might need to perform multiple tasks that require all (or numerous) permissions.

The permission namespace is organized in the manner shown below. For each category, the category name is given, followed by an indented list of permission names (such as "createClassLoader" and "exitVM") and permission name types in braces (such as "{property name}" to represent an actual property name). Each permission name (or name type) is followed by the name in parentheses of the SecurityManager class(es) that handle that kind of permission.

 RuntimePermission
    createClassLoader  (checkCreateClassLoader)
    exit (checkExit)
    setFactory (checkSetFactory)
    setIO (java.lang.System.{setIn,setOut,SetErr})
    modifyThread (checkAccess(Thread))
    modifyThreadGroup (checkAccess(ThreadGroup))
    readFileDescriptor (checkRead(FileDescriptor))
    writeFileDescriptor (checkWrite(FileDescriptor))
    loadLibrary.{library name} (checkLink)
    accessClassInPackage.{package name}  (checkPackageAccess)
    defineClassInPackage.{package name} (checkPackageDefinition)
    accessDeclaredMembers (checkMemberAccess)
    queuePrintJob (checkPrintJobAccess)
 NetPermission
    setDefaultAuthenticator
    requestPasswordAuthentication
 PropertyPermission
    * (checkPropertiesAccess)
    {property name} (checkPropertyAccess)
 AWTPermission
    showWindowWithoutWarningBanner (checkTopLevelWindow)
    accessClipboard (checkSystemClipboardAccess)
    acccessEventQueue (checkAwtEventQueueAccess)
 SecurityPermission
    {action} (checkSecurityAccess)
 FilePermission
    {file or directory pathname} (checkExec, 
        checkRead(String), checkWrite(String), checkDelete}
 SocketPermission
    {host:port} {checkConnect, checkListen, checkAccept}
 

Since:
JDK1.0
See Also:
ClassLoader, SecurityException, checkTopLevelWindow(java.lang.Object), System.getSecurityManager(), System.setSecurityManager(java.lang.SecurityManager), AccessController, AccessControlContext, AccessControlException, Permission, BasicPermission, FilePermission, SocketPermission, PropertyPermission, RuntimePermission, AWTPermission, Policy, SecurityPermission, ProtectionDomain

Field Summary
protected  boolean inCheck
          Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
 
Constructor Summary
SecurityManager()
          Constructs a new SecurityManager.
 
Method Summary
 void checkAccept(String host, int port)
          Throws a SecurityException if the calling thread is not permitted to accept a socket connection from the specified host and port number.
 void checkAccess(Thread t)
          Throws a SecurityException if the calling thread is not allowed to modify the thread argument.
 void checkAccess(ThreadGroup g)
          Throws a SecurityException if the calling thread is not allowed to modify the thread group argument.
 void checkAwtEventQueueAccess()
          Tests if a client can get access to the AWT event queue.
 void checkConnect(String host, int port, Object context)
          Throws a SecurityException if the specified security context is not allowed to open a socket connection to the specified host and port number.
 void checkConnect(String host, int port)
          Throws a SecurityException if the calling thread is not allowed to open a socket connection to the specified host and port number.
 void checkCreateClassLoader()
          Throws a SecurityException if the calling thread is not allowed to create a new class loader.
 void checkDelete(String file)
          Throws a SecurityException if the calling thread is not allowed to delete the specified file.
 void checkExec(String cmd)
          Throws a SecurityException if the calling thread is not allowed to create a subprocess.
 void checkExit(int status)
          Throws a SecurityException if the calling thread is not allowed to cause the Java Virtual Machine to halt with the specified status code.
 void checkLink(String lib)
          Throws a SecurityException if the calling thread is not allowed to dynamic link the library code specified by the string argument file.
 void checkListen(int port)
          Throws a SecurityException if the calling thread is not allowed to wait for a connection request on the specified local port number.
 void checkMemberAccess(Class clazz, int which)
          Tests if a client is allowed to access members.
 void checkMulticast(InetAddress maddr, byte ttl)
          Tests to see if current execution context is allowed to use (join/leave/send/receive) IP multicast.
 void checkMulticast(InetAddress maddr)
          Tests if current execution context is allowed to use (join/leave/send/receive) IP multicast.
 void checkPackageAccess(String pkg)
          Throws a SecurityException if the calling thread is not allowed to access the package specified by the argument.
 void checkPackageDefinition(String pkg)
          Throws a SecurityException if the calling thread is not allowed to define classes in the package specified by the argument.
 void checkPermission(Permission perm, Object context)
          Throws a SecurityException if the specified security context is denied access to the resource specified by the given permission.
 void checkPermission(Permission perm)
          Throws a SecurityException if the requested access, specified by the given permission, is not permitted based on the security policy currently in effect.
 void checkPrintJobAccess()
          Tests if a client can initiate a print job request.
 void checkPropertiesAccess()
          Throws a SecurityException if the calling thread is not allowed to access or modify the system properties.
 void checkPropertyAccess(String key)
          Throws a SecurityException if the calling thread is not allowed to access the system property with the specified key name.
 void checkRead(FileDescriptor fd)
          Throws a SecurityException if the calling thread is not allowed to read from the specified file descriptor.
 void checkRead(String file, Object context)
          Throws a SecurityException if the specified security context is not allowed to read the file specified by the string argument.
 void checkRead(String file)
          Throws a SecurityException if the calling thread is not allowed to read the file specified by the string argument.
 void checkSecurityAccess(String action)
          Tests access to certain operations for a security API action.
 void checkSetFactory()
          Throws a 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.
 void checkSystemClipboardAccess()
          Tests if a client can get access to the system clipboard.
 boolean checkTopLevelWindow(Object window)
          Returns false if the calling thread is not trusted to bring up the top-level window indicated by the window argument.
 void checkWrite(FileDescriptor fd)
          Throws a SecurityException if the calling thread is not allowed to write to the specified file descriptor.
 void checkWrite(String file)
          Throws a SecurityException if the calling thread is not allowed to write to the file specified by the string argument.
protected  int classDepth(String name)
          Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
protected  int classLoaderDepth()
          Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
protected  ClassLoader currentClassLoader()
          Returns an object describing the most recent class loader executing on the stack.
protected  Class currentLoadedClass()
          Returns the current Class with a ClassLoader on the execution stack.
protected  Class[] getClassContext()
          Returns the current execution stack as an array of classes.
 boolean getInCheck()
          Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
 Object getSecurityContext()
          Creates an object that encapsulates the current execution environment.
 ThreadGroup getThreadGroup()
          Returns the thread group into which to instantiate any new thread being created at the time this is being called.
protected  boolean inClass(String name)
          Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
protected  boolean inClassLoader()
          Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Field Detail

inCheck

protected boolean inCheck
Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
This field is true if there is a security check in progress; false otherwise.
Constructor Detail

SecurityManager

public SecurityManager()
Constructs a new SecurityManager. An application is not allowed to create a new security manager if there is already a current security manager.
Throws:
SecurityException - if a security manager already exists.
See Also:
System.getSecurityManager()
Method Detail

getInCheck

public boolean getInCheck()
Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
Tests if there is a security check in progress.
Returns:
the value of the inCheck field. This field should contain true if a security check is in progress, false otherwise.
See Also:
inCheck

getClassContext

protected Class[] getClassContext()
Returns the current execution stack as an array of classes.

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.

Returns:
the execution stack.

currentClassLoader

protected ClassLoader currentClassLoader()
Returns an object describing the most recent class loader executing on the stack.
Returns:
the class loader of the most recent occurrence on the stack of a method from a class defined using a class loader; returns null if there is no occurrence on the stack of a method from a class defined using a class loader.

currentLoadedClass

protected Class currentLoadedClass()
Returns the current Class with a ClassLoader on the execution stack.
Since:
JDK1.1

classDepth

protected int classDepth(String name)
Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
Returns the stack depth of the specified class.
Parameters:
name - the fully qualified name of the class to search for.
Returns:
the depth on the stack frame of the first occurrence of a method from a class with the specified name; -1 if such a frame cannot be found.

classLoaderDepth

protected int classLoaderDepth()
Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
Returns the stack depth of the most recently executing method from a class defined using a class loader.
Returns:
the depth on the stack frame of the most recent occurrence of a method from a class defined using a class loader; returns -1 if there is no occurrence of a method from a class defined using a class loader.

inClass

protected boolean inClass(String name)
Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
Tests if a method from a class with the specified name is on the execution stack.
Parameters:
name - the fully qualified name of the class.
Returns:
true if a method from a class with the specified name is on the execution stack; false otherwise.

inClassLoader

protected boolean inClassLoader()
Deprecated. This type of security checking is not recommended. It is recommended that the checkPermission call be used instead.
Tests if a method from a class defined using a class loader is on the execution stack.
Returns:
true if a method from a class defined using a class loader is on the execution stack.

getSecurityContext

public Object getSecurityContext()
Creates an object that encapsulates the current execution environment. The result of this method is used, for example, by the three-argument checkConnect method and by the two-argument checkRead method.

The default implementation of this method is to return an AccessControlContext object.

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.

Returns:
an implementation-dependent object that encapsulates sufficient information about the current execution environment to perform some security checks later.
See Also:
checkConnect(java.lang.String, int, java.lang.Object), checkRead(java.lang.String, java.lang.Object)

checkPermission

public void checkPermission(Permission perm)
Throws a SecurityException if the requested access, specified by the given permission, is not permitted based on the security policy currently in effect.

The checkPermission method for class SecurityManager calls AccessController.checkPermission with the given permission.

Parameters:
perm - the requested permission
Throws:
SecurityException - if access is not permitted based on the current security policy.
Since:
JDK1.2

checkPermission

public void checkPermission(Permission perm,
                            Object context)
Throws a SecurityException if the specified security context is denied access to the resource specified by the given permission. The context must be a security context returned by a previous call to getSecurityContext and the access control decision is based upon the configured security policy for that security context.

If context is an instance of AccessControlContext then the AccessControlContext.checkPermission method will be invoked with the specified permission.

If context is not an instance of AccessControlContext then a SecurityException is thrown.

Parameters:
perm - the specified permission
context - a system-dependent security context.
Throws:
SecurityException - if the specified security context is denied access to the resource specified by the given permission.
Since:
JDK1.2
See Also:
getSecurityContext()

checkCreateClassLoader

public void checkCreateClassLoader()
Throws a SecurityException if the calling thread is not allowed to create a new class loader.

The checkCreateClassLoader method for class SecurityManager calls checkPermission with the RuntimePermission("createClassLoader") permission.

Throws:
SecurityException - if the caller does not have permission to create a new class loader.
See Also:
ClassLoader.ClassLoader()

checkAccess

public void checkAccess(Thread t)
Throws a 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 calls checkPermission with the RuntimePermission("modifyThread") permission.

Parameters:
t - the thread to be checked.
Throws:
SecurityException - if the caller does not have permission to modify the thread.
See Also:
System.getSecurityManager(), Thread.resume(), Thread.setDaemon(boolean), Thread.setName(java.lang.String), Thread.setPriority(int), Thread.stop(), Thread.suspend()

checkAccess

public void checkAccess(ThreadGroup g)
Throws a 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 calls checkPermission with the RuntimePermission("modifyThreadGroup") permission.

Parameters:
g - the thread group to be checked.
Throws:
SecurityException - if the caller does not have permission to modify the thread group.
See Also:
System.getSecurityManager(), ThreadGroup.destroy(), ThreadGroup.resume(), ThreadGroup.setDaemon(boolean), ThreadGroup.setMaxPriority(int), ThreadGroup.stop(), ThreadGroup.suspend()

checkExit

public void checkExit(int status)
Throws a 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 calls checkPermission with the RuntimePermission("exitVM") permission.

Parameters:
status - the exit status.
Throws:
SecurityException - if the caller does not have permission to halt the Java Virtual Machine with the specified status.
See Also:
Runtime.exit(int), System.getSecurityManager()

checkExec

public void checkExec(String cmd)
Throws a 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 calls checkPermission with the FilePermission(cmd,"execute") permission.

Parameters:
cmd - the specified system command.
Throws:
SecurityException - if the caller does not have permission to create a subprocess.
See Also:
Runtime.exec(java.lang.String), Runtime.exec(java.lang.String, java.lang.String[]), Runtime.exec(java.lang.String[]), Runtime.exec(java.lang.String[], java.lang.String[]), System.getSecurityManager()

checkLink

public void checkLink(String lib)
Throws a 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 calls checkPermission with the RuntimePermission("loadLibrary."+lib) permission.

Parameters:
lib - the name of the library.
Throws:
SecurityException - if the caller does not have permission to dynamically link the library.
See Also:
Runtime.load(java.lang.String), Runtime.loadLibrary(java.lang.String), System.getSecurityManager()

checkRead

public void checkRead(FileDescriptor fd)
Throws a SecurityException if the calling thread is not allowed to read from the specified file descriptor.

The checkRead method for class SecurityManager calls checkPermission with the RuntimePermission("readFileDescriptor") permission.

Parameters:
fd - the system-dependent file descriptor.
Throws:
SecurityException - if the caller does not have permission to access the specified file descriptor.
See Also:
FileDescriptor

checkRead

public void checkRead(String file)
Throws a SecurityException if the calling thread is not allowed to read the file specified by the string argument.

The checkRead method for class SecurityManager calls checkPermission with the FilePermission(file,"read") permission.

Parameters:
file - the system-dependent file name.
Throws:
SecurityException - if the caller does not have permission to access the specified file.

checkRead

public void checkRead(String file,
                      Object context)
Throws a 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.

If context is an instance of AccessControlContext then the AccessControlContext.checkPermission method will be invoked with the FilePermission(file,"read") permission.

If context is not an instance of AccessControlContext then a SecurityException is thrown.

Parameters:
file - the system-dependent filename.
context - a system-dependent security context.
Throws:
SecurityException - if the specified security context does not have permission to read the specified file.
See Also:
getSecurityContext()

checkWrite

public void checkWrite(FileDescriptor fd)
Throws a SecurityException if the calling thread is not allowed to write to the specified file descriptor.

The checkWrite method for class SecurityManager calls checkPermission with the RuntimePermission("writeFileDescriptor") permission.

Parameters:
fd - the system-dependent file descriptor.
Throws:
SecurityException - if the caller does not have permission to access the specified file descriptor.
See Also:
FileDescriptor

checkWrite

public void checkWrite(String file)
Throws a SecurityException if the calling thread is not allowed to write to the file specified by the string argument.

The checkWrite method for class SecurityManager calls checkPermission with the FilePermission(file,"write") permission.

Parameters:
file - the system-dependent filename.
Throws:
SecurityException - if the caller does not have permission to access the specified file.

checkDelete

public void checkDelete(String file)
Throws a 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 calls checkPermission with the FilePermission(file,"delete") permission.

Parameters:
file - the system-dependent filename.
Throws:
SecurityException - if the caller does not have permission to delete the file.
See Also:
File.delete(), System.getSecurityManager()

checkConnect

public void checkConnect(String host,
                         int port)
Throws a 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 calls checkPermission with the SocketPermission(host+":"+port,"connect") permission if the port is not equal to -1. If the port is equal to -1, then it calls checkPermission with the SocketPermission(host,"resolve") permission.

Parameters:
host - the host name port to connect to.
port - the protocol port to connect to.
Throws:
SecurityException - if the caller does not have permission to open a socket connection to the specified host and port.

checkConnect

public void checkConnect(String host,
                         int port,
                         Object context)
Throws a 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.

If context is an instance of AccessControlContext then the AccessControlContext.checkPermission method will be invoked with the SocketPermission(host+":"+port,"connect") permission if the port is not equal to -1. If the port is equal to -1, then it calls checkPermission with the SocketPermission(host,"resolve") permission.

If context is not an instance of AccessControlContext then a SecurityException is thrown.

Parameters:
host - the host name port to connect to.
port - the protocol port to connect to.
context - a system-dependent security context.
Throws:
SecurityException - if the specified security context does not have permission to open a socket connection to the specified host and port.
See Also:
getSecurityContext()

checkListen

public void checkListen(int port)
Throws a SecurityException if the calling thread is not allowed to wait for a connection request on the specified local port number.

If port is not 0, the checkListen method for class SecurityManager calls checkPermission with the SocketPermission("localhost:"+port,"listen"). If port is zero, calls checkPermission with SocketPermission("localhost:1024-","listen").

Parameters:
port - the local port.
Throws:
SecurityException - if the caller does not have permission to listen on the specified port.

checkAccept

public void checkAccept(String host,
                        int port)
Throws a 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 calls checkPermission with the SocketPermission(host+":"+port,"accept") permission.

Parameters:
host - the host name of the socket connection.
port - the port number of the socket connection.
Throws:
SecurityException - if the caller does not have permission to accept the connection.
See Also:
System.getSecurityManager(), ServerSocket.accept()

checkMulticast

public void checkMulticast(InetAddress maddr)
Tests if current execution context is allowed to use (join/leave/send/receive) IP multicast.

The checkMulticast method for class SecurityManager calls checkPermission with the java.net.SocketPermission(maddr.getHostAddress(),"accept,connect") permission.

Parameters:
maddr - Internet group address to be used.
Throws:
SecurityException - if a security error has occurred.
Since:
JDK1.1

checkMulticast

public void checkMulticast(InetAddress maddr,
                           byte ttl)
Tests to see if current execution context is allowed to use (join/leave/send/receive) IP multicast.

The checkMulticast method for class SecurityManager calls checkPermission with the java.net.SocketPermission(maddr.getHostAddress(),"accept,connect") permission.

Parameters:
maddr - Internet group address to be used.
ttl - value in use, if it is multicast send.
Throws:
SecurityException - if a security error has occurred.
Since:
JDK1.1

checkPropertiesAccess

public void checkPropertiesAccess()
Throws a 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 calls checkPermission with the PropertyPermission("*", "read,write") permission.

Throws:
SecurityException - if the caller does not have permission to access or modify the system properties.
See Also:
System.getProperties(), System.setProperties(java.util.Properties)

checkPropertyAccess

public void checkPropertyAccess(String key)
Throws a 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 checkPropertyAccess method for class SecurityManager calls checkPermission with the PropertyPermission(key, "read") permission.

Parameters:
key - a system property key.
Throws:
SecurityException - if the caller does not have permission to access the specified system property.
See Also:
System.getProperty(java.lang.String)

checkTopLevelWindow

public boolean checkTopLevelWindow(Object window)
Returns 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.

This method calls checkPermission with the AWTPermission("showWindowWithoutWarningBanner") permission, and returns true if an SecurityException is not thrown, otherwise it returns false.

Parameters:
window - the new window that is being created.
Returns:
true if the caller is trusted to put up top-level windows; false otherwise.
Throws:
SecurityException - if creation is disallowed entirely.
See Also:
Window

checkPrintJobAccess

public void checkPrintJobAccess()
Tests if a client can initiate a print job request. This method calls checkPermission with the RuntimePermission("queuePrintJob") permission.

Throws:
SecurityException - if the caller does not have permission to initiate a print job request.
Since:
JDK1.1

checkSystemClipboardAccess

public void checkSystemClipboardAccess()
Tests if a client can get access to the system clipboard.

This method calls checkPermission with the AWTPermission("accessClipboard") permission.

Throws:
SecurityException - if the caller does not have permission to accesss the system clipboard.
Since:
JDK1.1

checkAwtEventQueueAccess

public void checkAwtEventQueueAccess()
Tests if a client can get access to the AWT event queue.

This method calls checkPermission with the AWTPermission("accessEventQueue") permission.

Throws:
SecurityException - if the caller does not have permission to accesss the AWT event queue.
Since:
JDK1.1

checkPackageAccess

public void checkPackageAccess(String pkg)
Throws a 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 calls checkPermission with the RuntimePermission("accessClassInPackage."+pkg) permission.

Parameters:
pkg - the package name.
Throws:
SecurityException - if the caller does not have permission to access the specified package.
See Also:
ClassLoader.loadClass(java.lang.String, boolean)

checkPackageDefinition

public void checkPackageDefinition(String pkg)
Throws a 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 calls checkPermission with the RuntimePermission("defineClassInPackage."+pkg) permission.

Parameters:
pkg - the package name.
Throws:
SecurityException - if the caller does not have permission to define classes in the specified package.
See Also:
ClassLoader.loadClass(java.lang.String, boolean)

checkSetFactory

public void checkSetFactory()
Throws a 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 calls checkPermission with the RuntimePermission("setFactory") permission.

Throws:
SecurityException - if the caller does not have permission to specify a socket factory or a stream handler factory.
See Also:
ServerSocket.setSocketFactory(java.net.SocketImplFactory), Socket.setSocketImplFactory(java.net.SocketImplFactory), URL.setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)

checkMemberAccess

public void checkMemberAccess(Class clazz,
                              int which)
Tests if a client is allowed to access members. If access is denied, throw a SecurityException. The default policy is to allow access to PUBLIC members, as well as access to classes that have the same class loader as the caller. In all other cases call checkPermission with the RuntimePermission("accessDeclaredMembers") permission.
Parameters:
clazz - the class that reflection is to be performed on
which - type of access, PUBLIC or DECLARED
Throws:
SecurityException - if the caller does not have permission.
Since:
JDK1.1
See Also:
Member

checkSecurityAccess

public void checkSecurityAccess(String action)
Tests access to certain operations for a security API action.

This method calls checkPermission with the SecurityPermission(action) permission.

Parameters:
action - the security API action to check against.
Since:
JDK1.1

getThreadGroup

public ThreadGroup getThreadGroup()
Returns the thread group into which to instantiate any new thread being created at the time this is being called. By default, it returns the thread group of the current thread. This should be overriden by a specific security manager to return the appropriate thread group.
Since:
JDK1.1

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.