jdk/src/java.base/share/classes/java/lang/SecurityManager.java
changeset 37521 b6e0f285c998
parent 37363 329dba26ffd2
child 37894 3acc9608c162
equal deleted inserted replaced
37520:f308aaf25d07 37521:b6e0f285c998
   227      *
   227      *
   228      * @deprecated This type of security checking is not recommended.
   228      * @deprecated This type of security checking is not recommended.
   229      *  It is recommended that the <code>checkPermission</code>
   229      *  It is recommended that the <code>checkPermission</code>
   230      *  call be used instead.
   230      *  call be used instead.
   231      */
   231      */
   232     @Deprecated
   232     @Deprecated(since="1.2")
   233     protected boolean inCheck;
   233     protected boolean inCheck;
   234 
   234 
   235     /*
   235     /*
   236      * Have we been initialized. Effective against finalizer attacks.
   236      * Have we been initialized. Effective against finalizer attacks.
   237      */
   237      */
   260      * @see     java.lang.SecurityManager#inCheck
   260      * @see     java.lang.SecurityManager#inCheck
   261      * @deprecated This type of security checking is not recommended.
   261      * @deprecated This type of security checking is not recommended.
   262      *  It is recommended that the <code>checkPermission</code>
   262      *  It is recommended that the <code>checkPermission</code>
   263      *  call be used instead.
   263      *  call be used instead.
   264      */
   264      */
   265     @Deprecated
   265     @Deprecated(since="1.2")
   266     public boolean getInCheck() {
   266     public boolean getInCheck() {
   267         return inCheck;
   267         return inCheck;
   268     }
   268     }
   269 
   269 
   270     /**
   270     /**
   343      *  call be used instead.
   343      *  call be used instead.
   344      *
   344      *
   345      * @see  java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
   345      * @see  java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
   346      * @see  #checkPermission(java.security.Permission) checkPermission
   346      * @see  #checkPermission(java.security.Permission) checkPermission
   347      */
   347      */
   348     @Deprecated
   348     @Deprecated(since="1.2")
   349     protected ClassLoader currentClassLoader() {
   349     protected ClassLoader currentClassLoader() {
   350         ClassLoader cl = currentClassLoader0();
   350         ClassLoader cl = currentClassLoader0();
   351         if ((cl != null) && hasAllPermission())
   351         if ((cl != null) && hasAllPermission())
   352             cl = null;
   352             cl = null;
   353         return cl;
   353         return cl;
   389      *  call be used instead.
   389      *  call be used instead.
   390      *
   390      *
   391      * @see  java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
   391      * @see  java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
   392      * @see  #checkPermission(java.security.Permission) checkPermission
   392      * @see  #checkPermission(java.security.Permission) checkPermission
   393      */
   393      */
   394     @Deprecated
   394     @Deprecated(since="1.2")
   395     protected Class<?> currentLoadedClass() {
   395     protected Class<?> currentLoadedClass() {
   396         Class<?> c = currentLoadedClass0();
   396         Class<?> c = currentLoadedClass0();
   397         if ((c != null) && hasAllPermission())
   397         if ((c != null) && hasAllPermission())
   398             c = null;
   398             c = null;
   399         return c;
   399         return c;
   409      * @deprecated This type of security checking is not recommended.
   409      * @deprecated This type of security checking is not recommended.
   410      *  It is recommended that the <code>checkPermission</code>
   410      *  It is recommended that the <code>checkPermission</code>
   411      *  call be used instead.
   411      *  call be used instead.
   412      *
   412      *
   413      */
   413      */
   414     @Deprecated
   414     @Deprecated(since="1.2")
   415     protected native int classDepth(String name);
   415     protected native int classDepth(String name);
   416 
   416 
   417     /**
   417     /**
   418      * Returns the stack depth of the most recently executing method
   418      * Returns the stack depth of the most recently executing method
   419      * from a class defined using a non-system class loader.  A non-system
   419      * from a class defined using a non-system class loader.  A non-system
   447      *  call be used instead.
   447      *  call be used instead.
   448      *
   448      *
   449      * @see   java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
   449      * @see   java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
   450      * @see   #checkPermission(java.security.Permission) checkPermission
   450      * @see   #checkPermission(java.security.Permission) checkPermission
   451      */
   451      */
   452     @Deprecated
   452     @Deprecated(since="1.2")
   453     protected int classLoaderDepth() {
   453     protected int classLoaderDepth() {
   454         int depth = classLoaderDepth0();
   454         int depth = classLoaderDepth0();
   455         if (depth != -1) {
   455         if (depth != -1) {
   456             if (hasAllPermission())
   456             if (hasAllPermission())
   457                 depth = -1;
   457                 depth = -1;
   472      *         name is on the execution stack; <code>false</code> otherwise.
   472      *         name is on the execution stack; <code>false</code> otherwise.
   473      * @deprecated This type of security checking is not recommended.
   473      * @deprecated This type of security checking is not recommended.
   474      *  It is recommended that the <code>checkPermission</code>
   474      *  It is recommended that the <code>checkPermission</code>
   475      *  call be used instead.
   475      *  call be used instead.
   476      */
   476      */
   477     @Deprecated
   477     @Deprecated(since="1.2")
   478     protected boolean inClass(String name) {
   478     protected boolean inClass(String name) {
   479         return classDepth(name) >= 0;
   479         return classDepth(name) >= 0;
   480     }
   480     }
   481 
   481 
   482     /**
   482     /**
   489      * @deprecated This type of security checking is not recommended.
   489      * @deprecated This type of security checking is not recommended.
   490      *  It is recommended that the <code>checkPermission</code>
   490      *  It is recommended that the <code>checkPermission</code>
   491      *  call be used instead.
   491      *  call be used instead.
   492      * @see        #currentClassLoader() currentClassLoader
   492      * @see        #currentClassLoader() currentClassLoader
   493      */
   493      */
   494     @Deprecated
   494     @Deprecated(since="1.2")
   495     protected boolean inClassLoader() {
   495     protected boolean inClassLoader() {
   496         return currentClassLoader() != null;
   496         return currentClassLoader() != null;
   497     }
   497     }
   498 
   498 
   499     /**
   499     /**
  1215      *             <code>null</code>.
  1215      *             <code>null</code>.
  1216      * @since      1.1
  1216      * @since      1.1
  1217      * @deprecated Use #checkPermission(java.security.Permission) instead
  1217      * @deprecated Use #checkPermission(java.security.Permission) instead
  1218      * @see        #checkPermission(java.security.Permission) checkPermission
  1218      * @see        #checkPermission(java.security.Permission) checkPermission
  1219      */
  1219      */
  1220     @Deprecated
  1220     @Deprecated(since="1.4")
  1221     public void checkMulticast(InetAddress maddr, byte ttl) {
  1221     public void checkMulticast(InetAddress maddr, byte ttl) {
  1222         String host = maddr.getHostAddress();
  1222         String host = maddr.getHostAddress();
  1223         if (!host.startsWith("[") && host.indexOf(':') != -1) {
  1223         if (!host.startsWith("[") && host.indexOf(':') != -1) {
  1224             host = "[" + host + "]";
  1224             host = "[" + host + "]";
  1225         }
  1225         }
  1295      *             {@code null}.
  1295      *             {@code null}.
  1296      * @deprecated This method was originally used to check if the calling thread
  1296      * @deprecated This method was originally used to check if the calling thread
  1297      *             was trusted to bring up a top-level window. The method has been
  1297      *             was trusted to bring up a top-level window. The method has been
  1298      *             obsoleted and code should instead use {@link #checkPermission}
  1298      *             obsoleted and code should instead use {@link #checkPermission}
  1299      *             to check {@code AWTPermission("showWindowWithoutWarningBanner")}.
  1299      *             to check {@code AWTPermission("showWindowWithoutWarningBanner")}.
  1300      * @see        #checkPermission(java.security.Permission) checkPermission
  1300      *             This method is subject to removal in a future version of Java SE.
  1301      */
  1301      * @see        #checkPermission(java.security.Permission) checkPermission
  1302     @Deprecated
  1302      */
       
  1303     @Deprecated(since="1.8", forRemoval=true)
  1303     public boolean checkTopLevelWindow(Object window) {
  1304     public boolean checkTopLevelWindow(Object window) {
  1304         if (window == null) {
  1305         if (window == null) {
  1305             throw new NullPointerException("window can't be null");
  1306             throw new NullPointerException("window can't be null");
  1306         }
  1307         }
  1307         return hasAllPermission();
  1308         return hasAllPermission();
  1338      *             {@code AllPermission}
  1339      *             {@code AllPermission}
  1339      * @deprecated This method was originally used to check if the calling
  1340      * @deprecated This method was originally used to check if the calling
  1340      *             thread could access the system clipboard. The method has been
  1341      *             thread could access the system clipboard. The method has been
  1341      *             obsoleted and code should instead use {@link #checkPermission}
  1342      *             obsoleted and code should instead use {@link #checkPermission}
  1342      *             to check {@code AWTPermission("accessClipboard")}.
  1343      *             to check {@code AWTPermission("accessClipboard")}.
  1343      * @see        #checkPermission(java.security.Permission) checkPermission
  1344      *             This method is subject to removal in a future version of Java SE.
  1344      */
  1345      * @see        #checkPermission(java.security.Permission) checkPermission
  1345     @Deprecated
  1346      */
       
  1347     @Deprecated(since="1.8", forRemoval=true)
  1346     public void checkSystemClipboardAccess() {
  1348     public void checkSystemClipboardAccess() {
  1347         checkPermission(SecurityConstants.ALL_PERMISSION);
  1349         checkPermission(SecurityConstants.ALL_PERMISSION);
  1348     }
  1350     }
  1349 
  1351 
  1350     /**
  1352     /**
  1356      *             {@code AllPermission}
  1358      *             {@code AllPermission}
  1357      * @deprecated This method was originally used to check if the calling
  1359      * @deprecated This method was originally used to check if the calling
  1358      *             thread could access the AWT event queue. The method has been
  1360      *             thread could access the AWT event queue. The method has been
  1359      *             obsoleted and code should instead use {@link #checkPermission}
  1361      *             obsoleted and code should instead use {@link #checkPermission}
  1360      *             to check {@code AWTPermission("accessEventQueue")}.
  1362      *             to check {@code AWTPermission("accessEventQueue")}.
  1361      * @see        #checkPermission(java.security.Permission) checkPermission
  1363      *             This method is subject to removal in a future version of Java SE.
  1362      */
  1364      * @see        #checkPermission(java.security.Permission) checkPermission
  1363     @Deprecated
  1365      */
       
  1366     @Deprecated(since="1.8", forRemoval=true)
  1364     public void checkAwtEventQueueAccess() {
  1367     public void checkAwtEventQueueAccess() {
  1365         checkPermission(SecurityConstants.ALL_PERMISSION);
  1368         checkPermission(SecurityConstants.ALL_PERMISSION);
  1366     }
  1369     }
  1367 
  1370 
  1368     /*
  1371     /*
  1624      * @deprecated This method relies on the caller being at a stack depth
  1627      * @deprecated This method relies on the caller being at a stack depth
  1625      *             of 4 which is error-prone and cannot be enforced by the runtime.
  1628      *             of 4 which is error-prone and cannot be enforced by the runtime.
  1626      *             Users of this method should instead invoke {@link #checkPermission}
  1629      *             Users of this method should instead invoke {@link #checkPermission}
  1627      *             directly.  This method will be changed in a future release
  1630      *             directly.  This method will be changed in a future release
  1628      *             to check the permission {@code java.security.AllPermission}.
  1631      *             to check the permission {@code java.security.AllPermission}.
       
  1632      *             This method is subject to removal in a future version of Java SE.
  1629      *
  1633      *
  1630      * @see java.lang.reflect.Member
  1634      * @see java.lang.reflect.Member
  1631      * @since 1.1
  1635      * @since 1.1
  1632      * @see        #checkPermission(java.security.Permission) checkPermission
  1636      * @see        #checkPermission(java.security.Permission) checkPermission
  1633      */
  1637      */
  1634     @Deprecated
  1638     @Deprecated(since="1.8", forRemoval=true)
  1635     @CallerSensitive
  1639     @CallerSensitive
  1636     public void checkMemberAccess(Class<?> clazz, int which) {
  1640     public void checkMemberAccess(Class<?> clazz, int which) {
  1637         if (clazz == null) {
  1641         if (clazz == null) {
  1638             throw new NullPointerException("class can't be null");
  1642             throw new NullPointerException("class can't be null");
  1639         }
  1643         }