|
15 | 15 | import com.fasterxml.jackson.annotation.JsonInclude; |
16 | 16 | import com.fasterxml.jackson.databind.JsonNode; |
17 | 17 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 18 | +import com.google.common.annotations.VisibleForTesting; |
18 | 19 | import com.google.common.base.Joiner; |
19 | 20 | import com.google.common.base.Splitter; |
20 | 21 | import com.wavefront.agent.api.APIContainer; |
@@ -50,6 +51,7 @@ public class ProxyConfig extends ProxyConfigDef { |
50 | 51 | static final int GRAPHITE_LISTENING_PORT = 2878; |
51 | 52 | private static final Logger logger = Logger.getLogger(ProxyConfig.class.getCanonicalName()); |
52 | 53 | private static final double MAX_RETRY_BACKOFF_BASE_SECONDS = 60.0; |
| 54 | + @VisibleForTesting public static final Integer NUMBER_OF_VISIBLE_DIGITS = 4; |
53 | 55 | private final List<Field> modifyByArgs = new ArrayList<>(); |
54 | 56 | private final List<Field> modifyByFile = new ArrayList<>(); |
55 | 57 |
|
@@ -1367,7 +1369,18 @@ public JsonNode getJsonConfig() { |
1367 | 1369 | data.order = parameter.get().order() == -1 ? 99999 : parameter.get().order(); |
1368 | 1370 | try { |
1369 | 1371 | Object val = field.get(this); |
1370 | | - data.value = val != null ? val.toString() : "null"; |
| 1372 | + if ((data.name.equals("token") |
| 1373 | + || data.name.equals("cspAPIToken") |
| 1374 | + || data.name.equals("cspAppId") |
| 1375 | + || data.name.equals("cspAppSecret")) |
| 1376 | + && val != null) { |
| 1377 | + String value = val.toString(); |
| 1378 | + data.value = |
| 1379 | + StringUtils.repeat("*", value.length() - NUMBER_OF_VISIBLE_DIGITS) |
| 1380 | + + value.substring(value.length() - NUMBER_OF_VISIBLE_DIGITS); |
| 1381 | + } else { |
| 1382 | + data.value = val != null ? val.toString() : "null"; |
| 1383 | + } |
1371 | 1384 | } catch (IllegalAccessException e) { |
1372 | 1385 | logger.severe(e.toString()); |
1373 | 1386 | } |
|
0 commit comments