public static void maskPasswords(final Map<String, Object> map) {
        map.entrySet().forEach(entry -> {
            String key = entry.getKey();
            if (entry.getValue() instanceof String) {
                if (key.toLowerCase().contains("password")) {
                    LOGGER.debug("Masking entry with key {}", key);
                    map.put(key, "****");
                } else if (key.toLowerCase().contains("apikey") || key.toLowerCase().contains("token")) {
                    LOGGER.debug("Masking entry with key {}", key);
                    String oldValue = (String) entry.getValue();
                    if (oldValue.length() <= 8) {
                        map.put(key, "****");
                    } else {
                        String newValue = oldValue.substring(0, 4) + "****" + oldValue.substring(oldValue.length() - 4);
                        map.put(key, newValue);
                    }
                }
            } else if (entry.getValue() instanceof Map) {
                maskPasswords((Map<String, Object>) entry.getValue());
            } else if (entry.getValue() instanceof List) {
                for (Object item : (List<Object>) entry.getValue()) {
                    if (item instanceof Map) {
                        maskPasswords((Map<String, Object>) item);
                    }
                }
            }
        });
    }
Replaces any values with '***' if the key is a string and contains 'password' or 'apikey' or 'token'
stroom-util/src/main/java/stroom/util/HealthCheckUtils.java