class CredentialsCacheBean {

    @GET
    @Path("/listDNs")
    @Produces({"text/plain", "application/xml", "text/xml", "application/json", "text/html"})
    @JmxManaged
    public DnList listDNs(@QueryParam("localOnly") boolean localOnly) {
        DnList result;
        if (!cachedDatawaveUserServiceInstance.isUnsatisfied() && !localOnly) {
            result = new DnList(cachedDatawaveUserServiceInstance.get().listAll());
        } else {
            // @formatter:off
            Set<DatawaveUserInfo> userList = authManager.getCachedKeys().parallelStream()
                    .filter(p -> p instanceof DatawavePrincipal)
                    .flatMap(p -> ((DatawavePrincipal) p).getProxiedUsers().stream())
                    .map(DatawaveUserInfo::new)
                    .collect(Collectors.toSet());
            // @formatter:on
            result = new DnList(userList);
        }
        return result;
    }

}