📜  Java.lang.SecurityManager类

📅  最后修改于: 2020-11-15 03:05:04             🧑  作者: Mango


介绍

java.lang.SecurityManager类允许应用程序实现安全策略。它允许应用程序在执行可能不安全或敏感的操作之前确定该操作是什么以及是否在允许执行该操作的安全上下文中尝试该操作。应用程序可以允许或禁止该操作。

类声明

以下是java.lang.SecurityManager类的声明-

public class SecurityManager
   extends Object

类的构造函数

Sr.No. Constructor & Description
1

SecurityManager()

This constructs a new SecurityManager.

类方法

Sr.No. Method & Description
1 void checkAccept(String host, int port)

This method throws a SecurityException if the calling thread is not permitted to accept a socket connection from the specified host and port number.

2 void checkAccess(Thread t)

This method throws a SecurityException if the calling thread is not allowed to modify the thread argument.

3 void checkAccess(ThreadGroup g)

This method throws a SecurityException if the calling thread is not allowed to modify the thread group argument.

4 void checkAwtEventQueueAccess()

This method throws a SecurityException if the calling thread is not allowed to access the AWT event queue.

5 void checkConnect(String host, int port)

This method throws a SecurityException if the calling thread is not allowed to open a socket connection to the specified host and port number.

6 void checkConnect(String host, int port, Object context)

This method throws a SecurityException if the specified security context is not allowed to open a socket connection to the specified host and port number.

7 void checkCreateClassLoader()

This method throws a SecurityException if the calling thread is not allowed to create a new class loader.

8 void checkDelete(String file)

This method throws a SecurityException if the calling thread is not allowed to delete the specified file.

9 void checkExec(String cmd)

This method throws a SecurityException if the calling thread is not allowed to create a subprocess.

10 void checkExit(int status)

This method throws a SecurityException if the calling thread is not allowed to cause the Java Virtual Machine to halt with the specified status code.

11 void checkLink(String lib)

This method throws a SecurityException if the calling thread is not allowed to dynamic link the library code specified by the string argument file.

12 void checkListen(int port)

This method throws a SecurityException if the calling thread is not allowed to wait for a connection request on the specified local port number.

13 void checkMemberAccess(Class clazz, int which)

This method throws a SecurityException if the calling thread is not allowed to access members.

14 void checkMulticast(InetAddress maddr)

This method throws a SecurityException if the calling thread is not allowed to use (join/leave/send/receive) IP multicast.

15 void checkPackageAccess(String pkg)

This method throws a SecurityException if the calling thread is not allowed to access the package specified by the argument.

16 void checkPackageDefinition(String pkg)

This method throws a SecurityException if the calling thread is not allowed to define classes in the package specified by the argument.

17 void checkPermission(Permission perm)

This method throws a SecurityException if the requested access, specified by the given permission, is not permitted based on the security policy currently in effect.

18 void checkPermission(Permission perm, Object context)

This method throws a SecurityException if the specified security context is denied access to the resource specified by the given permission.

19 void checkPrintJobAccess()

This method throws a SecurityException if the calling thread is not allowed to initiate a print job request.

20 void checkPropertiesAccess()

This method throws a SecurityException if the calling thread is not allowed to access or modify the system properties.

21 void checkPropertyAccess(String key)

This method throws a SecurityException if the calling thread is not allowed to access the system property with the specified key name.

22 void checkRead(FileDescriptor fd)

This method throws a SecurityException if the calling thread is not allowed to read from the specified file descriptor.

23 void checkRead(String file)

This method throws a SecurityException if the calling thread is not allowed to read the file specified by the string argument.

24 void checkRead(String file, Object context)

This method throws a SecurityException if the specified security context is not allowed to read the file specified by the string argument.

25 void checkSecurityAccess(String target)

This method determines whether the permission with the specified permission target name should be granted or denied.

26 void checkSetFactory()

This method 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.

27 void checkSystemClipboardAccess()

This method throws a SecurityException if the calling thread is not allowed to access the system clipboard.

28 boolean checkTopLevelWindow(Object window)

This method returns false if the calling thread is not trusted to bring up the top-level window indicated by the window argument.

29 void checkWrite(FileDescriptor fd)

This method throws a SecurityException if the calling thread is not allowed to write to the specified file descriptor.

30 void checkWrite(String file)

This method throws a SecurityException if the calling thread is not allowed to write to the file specified by the string argument.

31 protected Class[] getClassContext()

This method returns the current execution stack as an array of classes.

32 Object getSecurityContext()

This method creates an object that encapsulates the current execution environment.

33 ThreadGroup getThreadGroup()

This method returns the thread group into which to instantiate any new thread being created at the time this is being called.

方法继承

此类从以下类继承方法-

  • java.lang.Object