# Class SecurityManager

java.lang.Object
java.lang.SecurityManager

Direct Known Subclasses:
  `RMISecurityManager`

@Deprecated(since="17", forRemoval=true) public class SecurityManager extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
There is no replacement for this class.
SecurityManager was originally specified to allow an application implement a security policy. It allowed an application to determine, before performing a possibly unsafe or security sensitive operation, whether the operation was being attempted in a security context that allowed the operation. This feature no longer exists.

Since:
  1.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SecurityManager()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Constructs a new `SecurityManager`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `checkAccept(String host, int port)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkAccess(Thread t)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkAccess(ThreadGroup g)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkConnect(String host, int port)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkConnect(String host, int port, Object context)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkCreateClassLoader()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkDelete(String file)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkExec(String cmd)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkExit(int status)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkLink(String lib)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkListen(int port)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkMulticast(InetAddress maddr)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkMulticast(InetAddress maddr, byte ttl)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkPackageAccess(String pkg)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkPackageDefinition(String pkg)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkPermission(Permission perm)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkPermission(Permission perm, Object context)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkPrintJobAccess()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkPropertiesAccess()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkPropertyAccess(String key)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkRead(FileDescriptor fd)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkRead(String file)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkRead(String file, Object context)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkSecurityAccess(String target)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkSetFactory()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkWrite(FileDescriptor fd)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `void`
  `checkWrite(String file)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Throws `SecurityException`.
  `protected Class<?>[]`
  `getClassContext()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Returns the current execution stack as an array of classes.
  `Object`
  `getSecurityContext()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Returns an `AccessControlContext` where the `checkPermission` method always throws an `AccessControlException` and the `getDomainCombiner` method always returns `null`.
  `ThreadGroup`
  `getThreadGroup()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Returns the current Thread's `ThreadGroup`.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### SecurityManager

    public SecurityManager()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Constructs a new `SecurityManager`. Setting a security manager with `System.setSecurityManager(SecurityManager)` is not supported.

- ## Method Details

  - ### getClassContext

    protected Class<?>[] getClassContext()
    Deprecated, for removal: This API element is subject to removal in a future version.
    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.

    API Note:
      The `StackWalker` class can be used as a replacement for this method.
    Returns:
      the execution stack.

  - ### getSecurityContext

    public Object getSecurityContext()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns an `AccessControlContext` where the `checkPermission` method always throws an `AccessControlException` and the `getDomainCombiner` method always returns `null`.
    API Note:
      This method originally returned a snapshot of the current calling context, which included the current thread's access control context and any limited privilege scope. This method has been changed to always return an innocuous `AccessControlContext` that fails all permission checks. The Security Manager is no longer supported. There is no replacement for the Security Manager or this method.
    Returns:
      an `AccessControlContext` as specified above
    See Also:
      - `AccessControlContext`

  - ### checkPermission

    public void checkPermission(Permission perm)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `perm` - ignored
    Throws:
      `SecurityException` - always
    Since:
      1.2

  - ### checkPermission

    public void checkPermission(Permission perm, Object context)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `perm` - ignored
      `context` - ignored
    Throws:
      `SecurityException` - always
    Since:
      1.2

  - ### checkCreateClassLoader

    public void checkCreateClassLoader()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Throws:
      `SecurityException` - always

  - ### checkAccess

    public void checkAccess(Thread t)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `t` - ignored
    Throws:
      `SecurityException` - always

  - ### checkAccess

    public void checkAccess(ThreadGroup g)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `g` - ignored
    Throws:
      `SecurityException` - always

  - ### checkExit

    public void checkExit(int status)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `status` - ignored
    Throws:
      `SecurityException` - always

  - ### checkExec

    public void checkExec(String cmd)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `cmd` - ignored
    Throws:
      `SecurityException` - always

  - ### checkLink

    public void checkLink(String lib)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `lib` - ignored
    Throws:
      `SecurityException` - always

  - ### checkRead

    public void checkRead(FileDescriptor fd)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `fd` - the system-dependent file descriptor
    Throws:
      `SecurityException` - always

  - ### checkRead

    public void checkRead(String file)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `file` - ignored
    Throws:
      `SecurityException` - always

  - ### checkRead

    public void checkRead(String file, Object context)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `file` - ignored
      `context` - ignored
    Throws:
      `SecurityException` - always

  - ### checkWrite

    public void checkWrite(FileDescriptor fd)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `fd` - ignored
    Throws:
      `SecurityException` - always

  - ### checkWrite

    public void checkWrite(String file)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `file` - ignored
    Throws:
      `SecurityException` - always

  - ### checkDelete

    public void checkDelete(String file)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `file` - ignored
    Throws:
      `SecurityException` - always

  - ### checkConnect

    public void checkConnect(String host, int port)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `host` - ignored
      `port` - ignored
    Throws:
      `SecurityException` - always

  - ### checkConnect

    public void checkConnect(String host, int port, Object context)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `host` - ignored
      `port` - ignored
      `context` - ignored
    Throws:
      `SecurityException` - always

  - ### checkListen

    public void checkListen(int port)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `port` - ignored
    Throws:
      `SecurityException` - always

  - ### checkAccept

    public void checkAccept(String host, int port)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `host` - ignored
      `port` - ignored
    Throws:
      `SecurityException` - always

  - ### checkMulticast

    public void checkMulticast(InetAddress maddr)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `maddr` - ignored
    Throws:
      `SecurityException` - always
    Since:
      1.1

  - ### checkMulticast

    public void checkMulticast(InetAddress maddr, byte ttl)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `maddr` - ignored
      `ttl` - ignored
    Throws:
      `SecurityException` - always
    Since:
      1.1

  - ### checkPropertiesAccess

    public void checkPropertiesAccess()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Throws:
      `SecurityException` - always

  - ### checkPropertyAccess

    public void checkPropertyAccess(String key)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `key` - ignored
    Throws:
      `SecurityException` - always

  - ### checkPrintJobAccess

    public void checkPrintJobAccess()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Throws:
      `SecurityException` - always
    Since:
      1.1

  - ### checkPackageAccess

    public void checkPackageAccess(String pkg)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `pkg` - ignored
    Throws:
      `SecurityException` - always

  - ### checkPackageDefinition

    public void checkPackageDefinition(String pkg)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `pkg` - ignored
    Throws:
      `SecurityException` - always

  - ### checkSetFactory

    public void checkSetFactory()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Throws:
      `SecurityException` - always

  - ### checkSecurityAccess

    public void checkSecurityAccess(String target)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Throws `SecurityException`.
    Parameters:
      `target` - ignored
    Throws:
      `SecurityException` - always
    Since:
      1.1

  - ### getThreadGroup

    public ThreadGroup getThreadGroup()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the current Thread's `ThreadGroup`.
    Returns:
      the current Thread's `ThreadGroup`
    Since:
      1.1