Code example for SocketPermission

0
    @SuppressWarnings("nls") 
    public void test_checkListen_int() { 
        // enable all but one check 
        mutableSM.addPermission(new AllPermission());
        mutableSM
                .denyPermission(new SocketPermission("localhost:80", "listen"));
 
        try { 
            mutableSM.checkListen(80);
            fail("This should throw a SecurityException.");
        } catch (SecurityException e) {
            // expected 
        } 
        mutableSM.addPermission(new AllPermission());
        mutableSM.denyPermission(new SocketPermission("localhost:1024-",
                "listen")); 
        try { 
            mutableSM.checkListen(0);
            fail("This should throw a SecurityException.");
        } catch (SecurityException e) {
            // expected