Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 2b4681d

Browse files
SynapticloopSynapticloop
authored andcommitted
added in debugging of post data with redacted
1 parent 55a7f10 commit 2b4681d

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/synapticloop/b2/request/BaseB2Request.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ protected String convertPostData() throws B2ApiException {
239239
JSONObject jsonObject = new JSONObject();
240240
for(final String key : requestBodyData.keySet()) {
241241
try {
242-
LOGGER.debug("Setting key '{}' to value '{}'", key, obfuscateData(requestBodyData.get(key)));
242+
LOGGER.debug("Setting key '{}' to value '{}'", key, obfuscateData(key, requestBodyData.get(key)));
243243
jsonObject.put(key, requestBodyData.get(key));
244244
} catch(JSONException ex) {
245245
throw new B2ApiException(ex);
@@ -307,8 +307,13 @@ protected CloseableHttpResponse execute(final HttpUriRequest request) throws IOE
307307
*
308308
* @return the obfuscated data
309309
*/
310-
private String obfuscateData(Object data) {
311-
return(data.toString().replaceAll("\"accountId\":\".*\"", "\"accountId\":\"[redacted]\""));
310+
private Object obfuscateData(String key, Object data) {
311+
if(LOGGER.isDebugEnabled()) {
312+
if("accountId".equals(key)) {
313+
return("[redacted]");
314+
}
315+
}
316+
return(data);
312317
}
313318

314319
}

0 commit comments

Comments
 (0)