public void check(AccessResource checkedAccess, AccessResource ownedAccess) {
        PlainAccessResource checkedPlainAccess = (PlainAccessResource) checkedAccess;
        PlainAccessResource ownedPlainAccess = (PlainAccessResource) ownedAccess;

        if (ownedPlainAccess.isAdmin()) {
            // admin user don't need verification
            return;
        }
        if (Permission.needAdminPerm(checkedPlainAccess.getRequestCode())) {
            throw new AclException(String.format("Need admin permission for request code=%d, but accessKey=%s is not", checkedPlainAccess.getRequestCode(), ownedPlainAccess.getAccessKey()));
        }

        Map<String, Byte> needCheckedPermMap = checkedPlainAccess.getResourcePermMap();
        Map<String, Byte> ownedPermMap = ownedPlainAccess.getResourcePermMap();

        if (needCheckedPermMap == null) {
            // If the needCheckedPermMap is null,then return
            return;
        }

        for (Map.Entry<String, Byte> needCheckedEntry : needCheckedPermMap.entrySet()) {
            String resource = needCheckedEntry.getKey();
            Byte neededPerm = needCheckedEntry.getValue();
            boolean isGroup = PlainAccessResource.isRetryTopic(resource);

            if (ownedPermMap == null || !ownedPermMap.containsKey(resource)) {
                // Check the default perm
                byte ownedPerm = isGroup ? ownedPlainAccess.getDefaultGroupPerm() :
                    ownedPlainAccess.getDefaultTopicPerm();
                if (!Permission.checkPermission(neededPerm, ownedPerm)) {
                    throw new AclException(String.format("No default permission for %s", PlainAccessResource.printStr(resource, isGroup)));
                }
                continue;
            }
            if (!Permission.checkPermission(neededPerm, ownedPermMap.get(resource))) {
                throw new AclException(String.format("No permission for %s", PlainAccessResource.printStr(resource, isGroup)));
            }
        }
    }
@Test(expected = AclException.class)
    public void testCheck_withoutPermission_shouldThrowAclException() {
        PlainAccessResource checkedAccess = new PlainAccessResource();
        checkedAccess.setRequestCode(Permission.SUB);
        checkedAccess.addResourceAndPerm("topic1", Permission.PUB);
        PlainAccessResource ownedAccess = new PlainAccessResource();
        ownedAccess.setAccessKey("nonAdminUser");
        ownedAccess.setAdmin(false);
        ownedAccess.setDefaultTopicPerm(Permission.SUB);
        permissionChecker.check(checkedAccess, ownedAccess);
    }