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

Print this page




 383      *
 384      *   <li> A call to <code>checkPermission</code> with
 385      *   <code>java.security.AllPermission</code> does not
 386      *   result in a SecurityException.
 387      *
 388      * </ol>
 389      *
 390      * @return  the class  of the most recent occurrence on the stack
 391      *          of a method from a class defined using a non-system class
 392      *          loader.
 393      *
 394      * @deprecated This type of security checking is not recommended.
 395      *  It is recommended that the <code>checkPermission</code>
 396      *  call be used instead.
 397      *
 398      * @see  java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
 399      * @see  #checkPermission(java.security.Permission) checkPermission
 400      */
 401     @Deprecated
 402     protected Class<?> currentLoadedClass() {
 403         Class c = currentLoadedClass0();
 404         if ((c != null) && hasAllPermission())
 405             c = null;
 406         return c;
 407     }
 408 
 409     /**
 410      * Returns the stack depth of the specified class.
 411      *
 412      * @param   name   the fully qualified name of the class to search for.
 413      * @return  the depth on the stack frame of the first occurrence of a
 414      *          method from a class with the specified name;
 415      *          <code>-1</code> if such a frame cannot be found.
 416      * @deprecated This type of security checking is not recommended.
 417      *  It is recommended that the <code>checkPermission</code>
 418      *  call be used instead.
 419      *
 420      */
 421     @Deprecated
 422     protected native int classDepth(String name);
 423 


1698      *
1699      * <p> If you override this method, then you should make a call to
1700      * <code>super.checkSecurityAccess</code>
1701      * at the point the overridden method would normally throw an
1702      * exception.
1703      *
1704      * @param target the target name of the <code>SecurityPermission</code>.
1705      *
1706      * @exception SecurityException if the calling thread does not have
1707      * permission for the requested access.
1708      * @exception NullPointerException if <code>target</code> is null.
1709      * @exception IllegalArgumentException if <code>target</code> is empty.
1710      *
1711      * @since   JDK1.1
1712      * @see        #checkPermission(java.security.Permission) checkPermission
1713      */
1714     public void checkSecurityAccess(String target) {
1715         checkPermission(new SecurityPermission(target));
1716     }
1717 
1718     private native Class currentLoadedClass0();
1719 
1720     /**
1721      * Returns the thread group into which to instantiate any new
1722      * thread being created at the time this is being called.
1723      * By default, it returns the thread group of the current
1724      * thread. This should be overridden by a specific security
1725      * manager to return the appropriate thread group.
1726      *
1727      * @return  ThreadGroup that new threads are instantiated into
1728      * @since   JDK1.1
1729      * @see     java.lang.ThreadGroup
1730      */
1731     public ThreadGroup getThreadGroup() {
1732         return Thread.currentThread().getThreadGroup();
1733     }
1734 
1735 }


 383      *
 384      *   <li> A call to <code>checkPermission</code> with
 385      *   <code>java.security.AllPermission</code> does not
 386      *   result in a SecurityException.
 387      *
 388      * </ol>
 389      *
 390      * @return  the class  of the most recent occurrence on the stack
 391      *          of a method from a class defined using a non-system class
 392      *          loader.
 393      *
 394      * @deprecated This type of security checking is not recommended.
 395      *  It is recommended that the <code>checkPermission</code>
 396      *  call be used instead.
 397      *
 398      * @see  java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
 399      * @see  #checkPermission(java.security.Permission) checkPermission
 400      */
 401     @Deprecated
 402     protected Class<?> currentLoadedClass() {
 403         Class<?> c = currentLoadedClass0();
 404         if ((c != null) && hasAllPermission())
 405             c = null;
 406         return c;
 407     }
 408 
 409     /**
 410      * Returns the stack depth of the specified class.
 411      *
 412      * @param   name   the fully qualified name of the class to search for.
 413      * @return  the depth on the stack frame of the first occurrence of a
 414      *          method from a class with the specified name;
 415      *          <code>-1</code> if such a frame cannot be found.
 416      * @deprecated This type of security checking is not recommended.
 417      *  It is recommended that the <code>checkPermission</code>
 418      *  call be used instead.
 419      *
 420      */
 421     @Deprecated
 422     protected native int classDepth(String name);
 423 


1698      *
1699      * <p> If you override this method, then you should make a call to
1700      * <code>super.checkSecurityAccess</code>
1701      * at the point the overridden method would normally throw an
1702      * exception.
1703      *
1704      * @param target the target name of the <code>SecurityPermission</code>.
1705      *
1706      * @exception SecurityException if the calling thread does not have
1707      * permission for the requested access.
1708      * @exception NullPointerException if <code>target</code> is null.
1709      * @exception IllegalArgumentException if <code>target</code> is empty.
1710      *
1711      * @since   JDK1.1
1712      * @see        #checkPermission(java.security.Permission) checkPermission
1713      */
1714     public void checkSecurityAccess(String target) {
1715         checkPermission(new SecurityPermission(target));
1716     }
1717 
1718     private native Class<?> currentLoadedClass0();
1719 
1720     /**
1721      * Returns the thread group into which to instantiate any new
1722      * thread being created at the time this is being called.
1723      * By default, it returns the thread group of the current
1724      * thread. This should be overridden by a specific security
1725      * manager to return the appropriate thread group.
1726      *
1727      * @return  ThreadGroup that new threads are instantiated into
1728      * @since   JDK1.1
1729      * @see     java.lang.ThreadGroup
1730      */
1731     public ThreadGroup getThreadGroup() {
1732         return Thread.currentThread().getThreadGroup();
1733     }
1734 
1735 }