public static boolean checkPermission(byte neededPerm, byte ownedPerm) {
        if ((ownedPerm & DENY) > 0) {
            return false;
        }
        if ((neededPerm & ANY) > 0) {
            return (ownedPerm & PUB) > 0 || (ownedPerm & SUB) > 0;
        }
        return (neededPerm & ownedPerm) > 0;
    }
@Test
    public void checkPermissionTest() {
        boolean boo = Permission.checkPermission(Permission.DENY, Permission.DENY);
        Assert.assertFalse(boo);

        boo = Permission.checkPermission(Permission.PUB, Permission.PUB);
        Assert.assertTrue(boo);

        boo = Permission.checkPermission(Permission.SUB, Permission.SUB);
        Assert.assertTrue(boo);

        boo = Permission.checkPermission(Permission.PUB, (byte) (Permission.PUB | Permission.SUB));
        Assert.assertTrue(boo);

        boo = Permission.checkPermission(Permission.SUB, (byte) (Permission.PUB | Permission.SUB));
        Assert.assertTrue(boo);

        boo = Permission.checkPermission(Permission.ANY, (byte) (Permission.PUB | Permission.SUB));
        Assert.assertTrue(boo);

        boo = Permission.checkPermission(Permission.ANY, Permission.SUB);
        Assert.assertTrue(boo);

        boo = Permission.checkPermission(Permission.ANY, Permission.PUB);
        Assert.assertTrue(boo);

        boo = Permission.checkPermission(Permission.DENY, Permission.ANY);
        Assert.assertFalse(boo);

        boo = Permission.checkPermission(Permission.DENY, Permission.PUB);
        Assert.assertFalse(boo);

        boo = Permission.checkPermission(Permission.DENY, Permission.SUB);
        Assert.assertFalse(boo);

    }