GeezerVison is showing docs.oracle.com — SecurityManager (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.lang
Class SecurityManager
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
protected boolean |
inCheck |
Deprecated.
This type of security checking is not recommended.
It is recommended that the checkPermission
call be used instead.
|
-
Constructor Summary
Constructors
| Constructor |
Description |
SecurityManager() |
Constructs a new SecurityManager.
|
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods
| Modifier and Type |
Method |
Description |
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() |
Deprecated.
The dependency on AWTPermission creates an
impediment to future modularization of the Java platform.
Users of this method should instead invoke
checkPermission(java.security.Permission) directly.
This method will be changed in a future release to check
the permission java.security.AllPermission.
|
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 |
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 |
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) |
Deprecated.
This method relies on the caller being at a stack depth
of 4 which is error-prone and cannot be enforced by the runtime.
Users of this method should instead invoke checkPermission(java.security.Permission)
directly. This method will be changed in a future release
to check the permission java.security.AllPermission.
|
void |
checkMulticast(InetAddress maddr) |
Throws a SecurityException if the
calling thread is not allowed to use
(join/leave/send/receive) IP multicast.
|
void |
checkMulticast(InetAddress maddr,
byte ttl) |
Deprecated.
Use #checkPermission(java.security.Permission) instead
|
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) |
Throws a SecurityException if the requested
access, specified by the given permission, is not permitted based
on the security policy currently in effect.
|
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 |
checkPrintJobAccess() |
Throws a SecurityException if the
calling thread is not allowed to 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) |
Throws a SecurityException if the
calling thread is not allowed to read the file specified by the
string argument.
|
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 |
checkSecurityAccess(String target) |
Determines whether the permission with the specified permission target
name should be granted or denied.
|
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() |
Deprecated.
The dependency on AWTPermission creates an
impediment to future modularization of the Java platform.
Users of this method should instead invoke
checkPermission(java.security.Permission) directly.
This method will be changed in a future release to check
the permission java.security.AllPermission.
|
boolean |
checkTopLevelWindow(Object window) |
Deprecated.
The dependency on AWTPermission creates an
impediment to future modularization of the Java platform.
Users of this method should instead invoke
checkPermission(java.security.Permission) directly.
This method will be changed in a future release to check
the permission java.security.AllPermission.
|
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() |
Deprecated.
This type of security checking is not recommended.
It is recommended that the checkPermission
call be used instead.
|
protected Class<?> |
currentLoadedClass() |
Deprecated.
This type of security checking is not recommended.
It is recommended that the checkPermission
call be used instead.
|
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
@Deprecated
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.
If there is a security manager already installed, this method first
calls the security manager's checkPermission method
with the RuntimePermission("createSecurityManager")
permission to ensure the calling thread has permission to create a new
security manager.
This may result in throwing a SecurityException.
- Throws:
SecurityException - if a security manager already
exists and its checkPermission method
doesn't allow creation of a new security manager.
- See Also:
System.getSecurityManager(),
checkPermission,
RuntimePermission
-
Method Detail
-
getInCheck
@Deprecated
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
-
classDepth
@Deprecated
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.
-
inClass
@Deprecated
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
@Deprecated
protected boolean inClassLoader()
Deprecated. This type of security checking is not recommended.
It is recommended that the checkPermission
call be used instead.
Basically, tests if a method from a class defined using a
class loader is on the execution stack.
- Returns:
true if a call to currentClassLoader
has a non-null return value.
- See Also:
currentClassLoader
-
checkMulticast
@Deprecated
public void checkMulticast(InetAddress maddr,
byte ttl)
Deprecated. Use #checkPermission(java.security.Permission) instead
Throws a SecurityException if the
calling thread is not allowed to use
(join/leave/send/receive) IP multicast.
This method calls checkPermission with the
java.net.SocketPermission(maddr.getHostAddress(),
"accept,connect") permission.
If you override this method, then you should make a call to
super.checkMulticast
at the point the overridden method would normally throw an
exception.
- Parameters:
maddr - Internet group address to be used.
ttl - value in use, if it is multicast send.
Note: this particular implementation does not use the ttl
parameter.
- Throws:
SecurityException - if the calling thread is not allowed to
use (join/leave/send/receive) IP multicast.
NullPointerException - if the address argument is
null.
- Since:
- JDK1.1
- See Also:
checkPermission
-
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 overridden by a specific security
manager to return the appropriate thread group.
- Returns:
- ThreadGroup that new threads are instantiated into
- Since:
- JDK1.1
- See Also:
ThreadGroup
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|