class DBService implements RolesProvider {

    List<RoleMember> getDelegatedRoleMembers(ObjectStoreConnection con, final String domainName,
                                             final String trustDomain, final String roleName) {
        
        // verify that the domain and trust domain are not the same
        
        if (domainName.equals(trustDomain)) {
            return null;
        }
        
        // retrieve our trust domain
        
        AthenzDomain domain = null;
        try {
            domain = getAthenzDomain(con, trustDomain);
        } catch (ResourceException ex) {
            LOG.error("unable to fetch domain {}: {}", trustDomain, ex.getMessage());
        }
        
        if (domain == null) {
            return null;
        }
        
        // we need to use a set since we might be matching
        // multiple assertions and we want to automatically
        // skip any duplicate members
        
        Map<String, RoleMember> roleMembers = new HashMap<>();
        
        // generate our full role name
        
        String fullRoleName = ZMSUtils.roleResourceName(domainName, roleName);
        
        // iterate through all policies to see which one has the
        // assume_role assertion for the given role
        
        for (Policy policy : domain.getPolicies()) {
            
            List<Assertion> assertions = policy.getAssertions();
            if (assertions == null) {
                continue;
            }
            
            for (Assertion assertion : assertions) {
                
                if (!AuthzHelper.assumeRoleResourceMatch(fullRoleName, assertion)) {
                    continue;
                }
                
                String rolePattern = StringUtils.patternFromGlob(assertion.getRole());
                for (Role role : domain.getRoles()) {
                    
                    // make sure we have members before trying to match the name
                    
                    List<RoleMember> members = role.getRoleMembers();
                    if (members == null || members.isEmpty()) {
                        continue;
                    }
                    
                    if (!role.getName().matches(rolePattern)) {
                        continue;
                    }
                    
                    for (RoleMember member : members) {
                        String memberName = member.getMemberName();
                        if (!roleMembers.containsKey(memberName)) {
                            roleMembers.put(memberName, member);
                        }
                    }
                }
            }
        }

        return new ArrayList<>(roleMembers.values());
    }

    public  DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator);

}