class ZMSUtils {

    public static boolean isUserAuthorityFilterValid(Authority userAuthority, final String filterList, final String memberName) {

        // in most cases we're going to have a single filter configured
        // so we'll optimize for that case and not create an array

        if (filterList.indexOf(',') == -1) {
            if (!userAuthority.isAttributeSet(memberName, filterList)) {
                LOG.error("Principal {} does not satisfy user authority {} filter", memberName, filterList);
                return false;
            }
        } else {
            final String[] filterItems = filterList.split(",");
            for (String filterItem : filterItems) {
                if (!userAuthority.isAttributeSet(memberName, filterItem)) {
                    LOG.error("Principal {} does not satisfy user authority {} filter", memberName, filterItem);
                    return false;
                }
            }
        }
        return true;
    }

}