class AuthzHelper {

    public static boolean matchDelegatedTrustAssertion(Assertion assertion, final String roleName, final String roleMember,
                                                       List<Role> roles, GroupMembersFetcher groupMembersFetcher) {

        if (!assumeRoleResourceMatch(roleName, assertion)) {
            return false;
        }

        String rolePattern = StringUtils.patternFromGlob(assertion.getRole());
        for (Role role : roles) {
            String name = role.getName();
            if (!name.matches(rolePattern)) {
                continue;
            }

            if (isMemberOfRole(role, roleMember, groupMembersFetcher)) {
                return true;
            }
        }

        return false;
    }

}