This commit is contained in:
Phillip Webb
2013-12-16 11:03:06 -08:00
parent 85fb1cba0b
commit 513c6a1de2
12 changed files with 76 additions and 53 deletions

View File

@@ -57,7 +57,7 @@ public class ConfigurationPropertiesReportEndpoint extends
return this.keysToSanitize;
}
public void setKeysToSanitize(String[] keysToSanitize) {
public void setKeysToSanitize(String... keysToSanitize) {
Assert.notNull(keysToSanitize, "KeysToSanitize must not be null");
this.keysToSanitize = keysToSanitize;
}
@@ -69,10 +69,10 @@ public class ConfigurationPropertiesReportEndpoint extends
.getBeansWithAnnotation(ConfigurationProperties.class);
// Serialize beans into map structure and sanitize values
ObjectMapper mapper = new ObjectMapper();
for (Map.Entry<String, Object> entry : beans.entrySet()) {
ObjectMapper m = new ObjectMapper();
beans.put(entry.getKey(),
sanitize(m.convertValue(entry.getValue(), Map.class)));
Map<String, Object> value = mapper.convertValue(entry.getValue(), Map.class);
beans.put(entry.getKey(), sanitize(value));
}
return beans;
@@ -94,7 +94,7 @@ public class ConfigurationPropertiesReportEndpoint extends
private Object sanitize(String name, Object object) {
for (String keyToSanitize : this.keysToSanitize) {
if (name.toLowerCase().endsWith(keyToSanitize)) {
return object == null ? null : "******";
return (object == null ? null : "******");
}
}
return object;