Code example for Permission

Methods: getName

0
        } 
 
        SecurityManager sm = new SecurityManager() { 
 
            public void checkPermission(Permission perm) { 
                if(perm.getName().equals("getenv.*")) { 
                    throw new SecurityException(); 
                } 
            } 
        }; 
 
        SecurityManager oldSm = System.getSecurityManager(); 
        System.setSecurityManager(sm); 
 
        try { 
            System.getenv(); 
            fail("SecurityException should be thrown."); 
        } catch (SecurityException e) { 
            // expected 
        } finally { 
            System.setSecurityManager(oldSm);