class DBService implements RolesProvider {

    List<String> listPrincipals(String domainName, boolean domainOnly) {
        
        try (ObjectStoreConnection con = store.getConnection(true, false)) {
            
            List<String> principals = con.listPrincipals(domainName);
            
            // if no further filtering is necessary, return the data
            // right away
            
            if (!domainOnly) {
                return principals;
            }
            
            // generate our return list
            
            List<String> users = new ArrayList<>();

            // if we're asked for domain only then we need to match
            // the domain name, if specified, and make sure the response
            // only includes a single period/domain separator
            // we need to skip an extra byte to accommodate for the
            // domain separator (e.g. <domainName>.<userName>)
            
            int prefixLength = 0;
            if (domainName != null) {
                prefixLength = domainName.length() + 1;
            }
                
            for (String principal : principals) {
                    
                // make sure the principal name doesn't have multiple
                // components - e.g. user.joe.test since it represents
                // a service or a sub-domain and we're only interested
                // in actual users
                
                if (prefixLength > 0) {
                    if (principal.substring(prefixLength).indexOf('.') == -1) {
                        users.add(principal);
                    }
                } else {
                    
                    // we have a single separator when the first index
                    // and the last index are the same
                    
                    if (principal.indexOf('.') == principal.lastIndexOf('.')) {
                        users.add(principal);
                    }
                }
            }
            
            return users;
        }
    }

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

}