< prev index next >

## src/java.base/share/classes/java/lang/SecurityManager.java

Print this page

     296  *
     297  * @see     java.lang.ClassLoader
     298  * @see     java.lang.SecurityException
     299  * @see     java.lang.System#getSecurityManager() getSecurityManager
     300  * @see     java.lang.System#setSecurityManager(java.lang.SecurityManager)
     301  *  setSecurityManager
     302  * @see     java.security.AccessController AccessController
     303  * @see     java.security.AccessControlContext AccessControlContext
     304  * @see     java.security.AccessControlException AccessControlException
     305  * @see     java.security.Permission
     306  * @see     java.security.BasicPermission
     307  * @see     java.io.FilePermission
     308  * @see     java.net.SocketPermission
     309  * @see     java.util.PropertyPermission
     310  * @see     java.lang.RuntimePermission
     311  * @see     java.security.Policy Policy
     312  * @see     java.security.SecurityPermission SecurityPermission
     313  * @see     java.security.ProtectionDomain
     314  *
     315  * @since   1.0

     316  */

     317 public class SecurityManager {
     318
     319     /*
     320      * Have we been initialized. Effective against finalizer attacks.
     321      */
     322     private boolean initialized = false;
     323
     324     /**
     325      * Constructs a new {@code SecurityManager}.
     326      *
     327      * <p> If there is a security manager already installed, this method first
     328      * calls the security manager's {@code checkPermission} method
     329      * with the {@code RuntimePermission("createSecurityManager")}
     330      * permission to ensure the calling thread has permission to create a new
     331      * security manager.
     332      * This may result in throwing a {@code SecurityException}.
     333      *
     334      * @throws     java.lang.SecurityException if a security manager already
     335      *             exists and its {@code checkPermission} method
     336      *             doesn't allow creation of a new security manager.
    1067      * <code>java.net.SocketPermission(maddr.getHostAddress(),
    1068      * "accept,connect")</code> permission.
    1069      * <p>
    1070      * If you override this method, then you should make a call to
    1071      * {@code super.checkMulticast}
    1072      * at the point the overridden method would normally throw an
    1073      * exception.
    1074      *
    1075      * @param      maddr  Internet group address to be used.
    1076      * @param      ttl        value in use, if it is multicast send.
    1077      * Note: this particular implementation does not use the ttl
    1078      * parameter.
    1079      * @throws     SecurityException  if the calling thread is not allowed to
    1080      *  use (join/leave/send/receive) IP multicast.
    1081      * @throws     NullPointerException if the address argument is
    1082      *             {@code null}.
    1083      * @since      1.1
    1084      * @deprecated Use #checkPermission(java.security.Permission) instead
    1085      * @see        #checkPermission(java.security.Permission) checkPermission
    1086      */
    1087     @Deprecated(since="1.4")
    1088     public void checkMulticast(InetAddress maddr, byte ttl) {
    1089         String host = maddr.getHostAddress();
    1090         if (!host.startsWith("[") && host.indexOf(':') != -1) {
    1091             host = "[" + host + "]";
    1092         }
    1093         checkPermission(new SocketPermission(host,
    1094             SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
    1095     }
    1096
    1097     /**
    1098      * Throws a {@code SecurityException} if the
    1099      * calling thread is not allowed to access or modify the system
    1100      * properties.
    1101      * <p>
    1102      * This method is used by the {@code getProperties} and
    1103      * {@code setProperties} methods of class {@code System}.
    1104      * <p>
    1105      * This method calls {@code checkPermission} with the
    1106      * {@code PropertyPermission("*", "read,write")} permission.
    1107      * <p>
     296  *
     297  * @see     java.lang.ClassLoader
     298  * @see     java.lang.SecurityException
     299  * @see     java.lang.System#getSecurityManager() getSecurityManager
     300  * @see     java.lang.System#setSecurityManager(java.lang.SecurityManager)
     301  *  setSecurityManager
     302  * @see     java.security.AccessController AccessController
     303  * @see     java.security.AccessControlContext AccessControlContext
     304  * @see     java.security.AccessControlException AccessControlException
     305  * @see     java.security.Permission
     306  * @see     java.security.BasicPermission
     307  * @see     java.io.FilePermission
     308  * @see     java.net.SocketPermission
     309  * @see     java.util.PropertyPermission
     310  * @see     java.lang.RuntimePermission
     311  * @see     java.security.Policy Policy
     312  * @see     java.security.SecurityPermission SecurityPermission
     313  * @see     java.security.ProtectionDomain
     314  *
     315  * @since   1.0
     316  * @deprecated The Security Manager is deprecated and subject to removal in a
     317  *       future release. There is no replacement for the Security Manager.
     318  *       See <a href="https://openjdk.java.net/jeps/411">JEP 411</a> for
     319  *       discussion and alternatives.
     320  */
     321 @Deprecated(since="17", forRemoval=true)
     322 public class SecurityManager {
     323
     324     /*
     325      * Have we been initialized. Effective against finalizer attacks.
     326      */
     327     private boolean initialized = false;
     328
     329     /**
     330      * Constructs a new {@code SecurityManager}.
     331      *
     332      * <p> If there is a security manager already installed, this method first
     333      * calls the security manager's {@code checkPermission} method
     334      * with the {@code RuntimePermission("createSecurityManager")}
     335      * permission to ensure the calling thread has permission to create a new
     336      * security manager.
     337      * This may result in throwing a {@code SecurityException}.
     338      *
     339      * @throws     java.lang.SecurityException if a security manager already
     340      *             exists and its {@code checkPermission} method
     341      *             doesn't allow creation of a new security manager.
    1072      * <code>java.net.SocketPermission(maddr.getHostAddress(),
    1073      * "accept,connect")</code> permission.
    1074      * <p>
    1075      * If you override this method, then you should make a call to
    1076      * {@code super.checkMulticast}
    1077      * at the point the overridden method would normally throw an
    1078      * exception.
    1079      *
    1080      * @param      maddr  Internet group address to be used.
    1081      * @param      ttl        value in use, if it is multicast send.
    1082      * Note: this particular implementation does not use the ttl
    1083      * parameter.
    1084      * @throws     SecurityException  if the calling thread is not allowed to
    1085      *  use (join/leave/send/receive) IP multicast.
    1086      * @throws     NullPointerException if the address argument is
    1087      *             {@code null}.
    1088      * @since      1.1
    1089      * @deprecated Use #checkPermission(java.security.Permission) instead
    1090      * @see        #checkPermission(java.security.Permission) checkPermission
    1091      */
    1092     @Deprecated(since="1.4", forRemoval=true)
    1093     public void checkMulticast(InetAddress maddr, byte ttl) {
    1094         String host = maddr.getHostAddress();
    1095         if (!host.startsWith("[") && host.indexOf(':') != -1) {
    1096             host = "[" + host + "]";
    1097         }
    1098         checkPermission(new SocketPermission(host,
    1099             SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
    1100     }
    1101
    1102     /**
    1103      * Throws a {@code SecurityException} if the
    1104      * calling thread is not allowed to access or modify the system
    1105      * properties.
    1106      * <p>
    1107      * This method is used by the {@code getProperties} and
    1108      * {@code setProperties} methods of class {@code System}.
    1109      * <p>
    1110      * This method calls {@code checkPermission} with the
    1111      * {@code PropertyPermission("*", "read,write")} permission.
    1112      * <p>

< prev index next >