public boolean hasPermission(ModeledAuthenticatedUser user,
            ModeledPermissions<? extends EntityModel> targetEntity,
            SystemPermission.Type type, Set<String> effectiveGroups)
            throws GuacamoleException {

        // Retrieve permissions only if allowed
        if (canReadPermissions(user, targetEntity))
            return getPermissionMapper().selectOne(targetEntity.getModel(), type, effectiveGroups, getCaseSensitivity()) != null;

        // User cannot read this entity's permissions
        throw new GuacamoleSecurityException("Permission denied.");
        
    }
Retrieves whether the permission of the given type has been granted to
the given entity. Permission inheritance through group membership is
taken into account.

@param user
    The user retrieving the permission.

@param targetEntity
    The entity associated with the permission to be retrieved.

@param type
    The type of permission to retrieve.

@param effectiveGroups
    The identifiers of all groups that should be taken into account
    when determining the permissions effectively granted to the entity.
    If no groups are given, only permissions directly granted to the
    entity will be used.

@return
    true if permission of the given type has been granted to the given
    entity, false otherwise.

@throws GuacamoleException
    If an error occurs while retrieving the requested permission.
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/permission/SystemPermissionService.java