class CredentialsCacheBean {

    @GET
    @Path("/{dn}/evict")
    @Produces({"text/plain"})
    @JmxManaged
    public String evict(@PathParam("dn") String dn) {
        
        String result = "Evicted " + dn + " from the credentials cache.";
        if (!cachedDatawaveUserServiceInstance.isUnsatisfied()) {
            result = cachedDatawaveUserServiceInstance.get().evictMatching(dn);
        }
        // @formatter:off
        // Flush all principals from the Wildfly cache if the getName() of any of the contained DatawaveUser objects matches the supplied DN.
        authManager.getCachedKeys().parallelStream()
                .filter(p -> p instanceof DatawavePrincipal)
                .filter(p -> ((DatawavePrincipal) p).getProxiedUsers().stream().anyMatch(u -> u.getName().equals(dn)))
                .forEach(p -> {
                    log.debug("Evicting {} from the Wildfly authentication cache.", p);
                    authManager.flushCache(p);
                });
        // @formatter:on
        return result;
    }

}