All Packages Class Hierarchy This Package Previous Next Index
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
check
XXX methods is to assume that the caller
does not have permission to perform the requested operation.
- Version:
- 1.50, 08/17/98
- Author:
- Arthur van Hoff
- Since:
- JDK1.0
- See Also:
- ClassLoader, SecurityException, checkTopLevelWindow(java.lang.Object), getSecurityManager(), setSecurityManager(java.lang.SecurityManager)
-
inCheck
- This field is
true
if there is a security check in
progress; false
otherwise.
-
java.lang.SecurityManager()
- Constructs a new
SecurityManager
.
-
checkAccept(String, int)
- Throws a
SecurityException
if the
calling thread is not permitted to accept a socket connection from
the specified host and port number.
-
checkAccess(Thread)
- Throws a
SecurityException
if the
calling thread is not allowed to modify the thread argument.
-
checkAccess(ThreadGroup)
- Throws a
SecurityException
if the
calling thread is not allowed to modify the thread group argument.
-
checkAwtEventQueueAccess()
- Tests if a client can get access to the AWT event queue.
-
checkConnect(String, int)
- Throws a
SecurityException
if the
calling thread is not allowed to open a socket connection to the
specified host and port number.
-
checkConnect(String, int, Object)
- Throws a
SecurityException
if the
specified security context is not allowed to open a socket
connection to the specified host and port number.
-
checkCreateClassLoader()
- Throws a
SecurityException
if the
calling thread is not allowed to create a new class loader.
-
checkDelete(String)
- Throws a
SecurityException
if the
calling thread is not allowed to delete the specified file.
-
checkExec(String)
- Throws a
SecurityException
if the
calling thread is not allowed to create a subprocess.
-
checkExit(int)
- Throws a
SecurityException
if the
calling thread is not allowed to cause the Java Virtual Machine to
halt with the specified status code.
-
checkLink(String)
- Throws a
SecurityException
if the
calling thread is not allowed to dynamic link the library code
specified by the string argument file.
-
checkListen(int)
- Throws a
SecurityException
if the
calling thread is not allowed to wait for a connection request on
the specified local port number.
-
checkMemberAccess(Class, int)
- Tests if a client is allowed to access members.
-
checkMulticast(InetAddress)
- Tests if current execution context is allowed to use
(join/leave/send/receive) IP multicast.
-
checkMulticast(InetAddress, byte)
- Tests to see if current execution context is allowed to use
(join/leave/send/receive) IP multicast.
-
checkPackageAccess(String)
- Throws a
SecurityException
if the
calling thread is not allowed to access the package specified by
the argument.
-
checkPackageDefinition(String)
- Throws a
SecurityException
if the
calling thread is not allowed to define classes in the package
specified by the argument.
-
checkPrintJobAccess()
- Tests if a client can initiate a print job request.
-
checkPropertiesAccess()
- Throws a
SecurityException
if the
calling thread is not allowed to access or modify the system
properties.
-
checkPropertyAccess(String)
- Throws a
SecurityException
if the
calling thread is not allowed to access the system property with
the specified key
name.
-
checkRead(FileDescriptor)
- Throws a
SecurityException
if the
calling thread is not allowed to read from the specified file
descriptor.
-
checkRead(String)
- Throws a
SecurityException
if the
calling thread is not allowed to read the file specified by the
string argument.
-
checkRead(String, Object)
- Throws a
SecurityException
if the
specified security context is not allowed to read the file
specified by the string argument.
-
checkSecurityAccess(String)
- Tests access to certain operations for a security API
action.
-
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
.
-
checkSystemClipboardAccess()
- Tests if a client can get access to the system clipboard.
-
checkTopLevelWindow(Object)
- Returns
false
if the calling
thread is not trusted to bring up the top-level window indicated
by the window
argument.
-
checkWrite(FileDescriptor)
- Throws a
SecurityException
if the
calling thread is not allowed to write to the specified file
descriptor.
-
checkWrite(String)
- Throws a
SecurityException
if the
calling thread is not allowed to write to the file specified by
the string argument.
-
classDepth(String)
- Returns the stack depth of the specified class.
-
classLoaderDepth()
- Returns the stack depth of the most recently executing method
from a class defined using a class loader.
-
currentClassLoader()
- Returns an object describing the most recent class loader executing
on the stack.
-
currentLoadedClass()
- Returns the current Class with a ClassLoader on the execution stack.
-
getClassContext()
- Returns the current execution stack as an array of classes.
-
getInCheck()
-
Tests if there is a security check in progress.
-
getSecurityContext()
- Creates an object that encapsulates the current execution
environment.
-
getThreadGroup()
- Returns the thread group into which to instantiate any new
thread being created at the time this is being called.
-
inClass(String)
- Tests if the specified String is in this Class.
-
inClassLoader()
- Tests if the current ClassLoader is equal to
null
.
inCheck
protected boolean inCheck
- This field is
true
if there is a security check in
progress; false
otherwise.
- Since:
JDK1.0
SecurityManager
protected 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.
- Since:
- JDK1.0
- See Also:
- getSecurityManager()
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
always throws a
SecurityException
.
- 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.
- Since:
- JDK1.0
- See Also:
- getSecurityManager(), accept()
checkAccess
public void checkAccess(Thread g)
- 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
always throws a
SecurityException
.
- Parameters:
- g - the thread to be checked.
- Throws: SecurityException
- if the caller does not have permission
to modify the thread.
- Since:
- JDK1.0
- See Also:
- getSecurityManager(), resume(), setDaemon(boolean), setName(java.lang.String), setPriority(int), stop(), 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
always throws a
SecurityException
.
- Parameters:
- g - the thread group to be checked.
- Throws: SecurityException
- if the caller does not have permission
to modify the thread group.
- Since:
- JDK1.0
- See Also:
- getSecurityManager(), destroy(), resume(), setDaemon(boolean), setMaxPriority(int), stop(), suspend()
checkAwtEventQueueAccess
public void checkAwtEventQueueAccess()
- Tests if a client can get access to the AWT event queue.
- Since:
- JDK1.1
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
always throws a
SecurityException
.
- 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
.
- Since:
- JDK1.0
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.
The checkConnect
method for class
SecurityManager
always throws a
SecurityException
.
- 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
.
- Since:
- JDK1.0
- 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
always throws a
SecurityException
.
- Throws: SecurityException
- if the caller does not have permission
to create a new class loader.
- Since:
- JDK1.0
- See Also:
- ClassLoader()
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
always throws a
SecurityException
.
- Parameters:
- file - the system-dependent filename.
- Throws: SecurityException
- if the caller does not have permission
to delete the file.
- Since:
- JDK1.0
- See Also:
- delete(), 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
always throws a
SecurityException
.
- Parameters:
- cmd - the specified system command.
- Throws: SecurityException
- if the caller does not have permission
to create a subprocess.
- Since:
- JDK1.0
- See Also:
- exec(java.lang.String), exec(java.lang.String, java.lang.String[]), exec(java.lang.String[]), exec(java.lang.String[], java.lang.String[]), getSecurityManager()
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
always throws a
SecurityException
.
- Parameters:
- status - the exit status.
- Throws: SecurityException
- if the caller does not have permission
to halt the Java Virtual Machine with the specified status.
- Since:
- JDK1.0
- See Also:
- exit(int), 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
always throws a
SecurityException
.
- Parameters:
- lib - the name of the library.
- Throws: SecurityException
- if the caller does not have permission
to dynamically link the library.
- Since:
- JDK1.0
- See Also:
- load(java.lang.String), loadLibrary(java.lang.String), getSecurityManager()
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.
The checkListen
method for class
SecurityManager
always throws a
SecurityException
.
- Parameters:
- port - the local port.
- Throws: SecurityException
- if the caller does not have permission
to listen on the specified port.
- Since:
- JDK1.0
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 deny all accesses.
- Since:
- JDK1.1
checkMulticast
public void checkMulticast(InetAddress maddr)
- Tests if current execution context is allowed to use
(join/leave/send/receive) IP multicast.
- Parameters:
- multicast - 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.
- Parameters:
- multicast - 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
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
always throws a
SecurityException
.
- Parameters:
- pkg - the package name.
- Throws: SecurityException
- if the caller does not have permission
to access the specified package.
- Since:
- JDK1.0
- See Also:
- 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
always throws a
SecurityException
.
- Parameters:
- pkg - the package name.
- Throws: SecurityException
- if the caller does not have permission
to define classes in the specified package.
- Since:
- JDK1.0
- See Also:
- loadClass(java.lang.String, boolean)
checkPrintJobAccess
public void checkPrintJobAccess()
- Tests if a client can initiate a print job request.
- 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
always throws a
SecurityException
.
- Throws: SecurityException
- if the caller does not have permission
to access or modify the system properties.
- Since:
- JDK1.0
- See Also:
- getProperties(), 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 checkPropertiesAccess
method for class
SecurityManager
always throws a
SecurityException
.
- Parameters:
- key - a system property key.
- Throws: SecurityException
- if the caller does not have permission
to access the specified system property.
- Since:
- JDK1.0
- See Also:
- getProperty(java.lang.String)
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
always throws a
SecurityException
.
- Parameters:
- fd - the system-dependent file descriptor.
- Throws: SecurityException
- if the caller does not have permission
to access the specified file descriptor.
- Since:
- JDK1.0
- 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
always throws a
SecurityException
.
- Parameters:
- file - the system-dependent file name.
- Throws: SecurityException
- if the caller does not have permission
to access the specified file.
- Since:
- JDK1.0
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
.
The checkRead
method for class
SecurityManager
always throws a
SecurityException
.
- 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.
- Since:
- JDK1.0
- See Also:
- getSecurityContext()
checkSecurityAccess
public void checkSecurityAccess(String action)
- Tests access to certain operations for a security API
action.
- Since:
- JDK1.1
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
always throws a
SecurityException
.
- Throws: SecurityException
- if the caller does not have permission
to specify a socket factory or a stream handler factory.
- Since:
- JDK1.0
- See Also:
- setSocketFactory(java.net.SocketImplFactory), setSocketImplFactory(java.net.SocketImplFactory), setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)
checkSystemClipboardAccess
public void checkSystemClipboardAccess()
- Tests if a client can get access to the system clipboard.
- Since:
- JDK1.1
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.
The checkSetFactory
method for class
SecurityManager
always 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.
- Since:
- JDK1.0
- See Also:
- Window
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
always throws a
SecurityException
.
- Parameters:
- fd - the system-dependent file descriptor.
- Throws: SecurityException
- if the caller does not have permission
to access the specified file descriptor.
- Since:
- JDK1.0
- 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
always throws a
SecurityException
.
- Parameters:
- file - the system-dependent filename.
- Throws: SecurityException
- if the caller does not have permission
to access the specified file.
- Since:
- JDK1.0
classDepth
protected native int classDepth(String name)
- 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.
- Since:
- JDK1.0
classLoaderDepth
protected native int classLoaderDepth()
- 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.
- Since:
- JDK1.0
currentClassLoader
protected native java.lang.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.
- Since:
- JDK1.0
currentLoadedClass
protected java.lang.Class currentLoadedClass()
- Returns the current Class with a ClassLoader on the execution stack.
- Since:
- JDK1.1
getClassContext
protected native java.lang.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.
- Since:
- JDK1.0
getInCheck
public boolean getInCheck()
- 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.
- Since:
- JDK1.0
- See Also:
- inCheck
getSecurityContext
public java.lang.Object getSecurityContext()
- Creates an object that encapsulates the current execution
environment. The result of this method is used by the
three-argument
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.
- Returns:
- an implementation-dependent object that encapsulates
sufficient information about the current execution environment
to perform some security checks later.
- Since:
- JDK1.0
- See Also:
- checkConnect(java.lang.String, int, java.lang.Object), checkRead(java.lang.String, java.lang.Object)
getThreadGroup
public java.lang.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 specific security
manager to return the appropriate thread group.
- Since:
- JDK1.1
inClass
protected boolean inClass(String name)
- Tests if the specified String is in this Class.
- 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.
- Since:
- JDK1.0
inClassLoader
protected boolean inClassLoader()
- Tests if the current ClassLoader is equal to
null
.
- Returns:
-
true
if a method from a class defined using a
class loader is on the execution stack.
- Since:
- JDK1.0
All Packages Class Hierarchy This Package Previous Next Index