< prev index next >

test/sun/management/PlatformMBeanProviderConstructorCheck.java

Print this page




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.security.AccessControlException;
  25 import java.security.Permission;
  26 import java.security.Policy;
  27 import java.security.ProtectionDomain;
  28 import java.util.List;
  29 
  30 /*
  31  * @test
  32  * @bug     8042901
  33  * @summary Check permission for PlatformMBeanProvider Constructor

  34  * @author  Shanliang Jiang
  35  */
  36 public class PlatformMBeanProviderConstructorCheck {
  37     public static void main(String[] args) throws Exception {
  38         Policy origPolicy = Policy.getPolicy();
  39         SecurityManager origSM = System.getSecurityManager();
  40         try {
  41             System.out.println("---PlatformMBeanProviderConstructorCheck starting...");
  42 
  43             Policy.setPolicy(new MyPolicy());
  44             System.setSecurityManager(new SecurityManager());
  45 
  46             System.out.println("---PlatformMBeanProviderConstructorCheck Testing without permission...");
  47             try {
  48                 new MyProvider();
  49                 throw new RuntimeException("Does not get expected AccessControlException!");
  50             } catch (AccessControlException ace) {
  51                 System.out.println("---PlatformMBeanProviderConstructorCheck got the expected exception: "
  52                         + ace);
  53             }




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.security.AccessControlException;
  25 import java.security.Permission;
  26 import java.security.Policy;
  27 import java.security.ProtectionDomain;
  28 import java.util.List;
  29 
  30 /*
  31  * @test
  32  * @bug     8042901
  33  * @summary Check permission for PlatformMBeanProvider Constructor
  34  * @modules java.management/sun.management.spi
  35  * @author  Shanliang Jiang
  36  */
  37 public class PlatformMBeanProviderConstructorCheck {
  38     public static void main(String[] args) throws Exception {
  39         Policy origPolicy = Policy.getPolicy();
  40         SecurityManager origSM = System.getSecurityManager();
  41         try {
  42             System.out.println("---PlatformMBeanProviderConstructorCheck starting...");
  43 
  44             Policy.setPolicy(new MyPolicy());
  45             System.setSecurityManager(new SecurityManager());
  46 
  47             System.out.println("---PlatformMBeanProviderConstructorCheck Testing without permission...");
  48             try {
  49                 new MyProvider();
  50                 throw new RuntimeException("Does not get expected AccessControlException!");
  51             } catch (AccessControlException ace) {
  52                 System.out.println("---PlatformMBeanProviderConstructorCheck got the expected exception: "
  53                         + ace);
  54             }


< prev index next >