From 53f084f4c06a14851b6348ba52b98fbb620d85c8 Mon Sep 17 00:00:00 2001 From: Sumeet Phadnis Date: Tue, 16 Apr 2024 22:28:41 +0530 Subject: [PATCH] FSDProtectedLogListener now supports a parameter to optionally print ellipsis for truncated fields --- .../main/java/org/jpos/util/FSDProtectedLogListener.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jpos/src/main/java/org/jpos/util/FSDProtectedLogListener.java b/jpos/src/main/java/org/jpos/util/FSDProtectedLogListener.java index 88ffce65b3..77b2cbf350 100644 --- a/jpos/src/main/java/org/jpos/util/FSDProtectedLogListener.java +++ b/jpos/src/main/java/org/jpos/util/FSDProtectedLogListener.java @@ -22,7 +22,6 @@ import org.jpos.core.Configuration; import org.jpos.core.ConfigurationException; import org.jpos.iso.FSDISOMsg; -import org.jpos.iso.ISOException; import org.jpos.iso.ISOUtil; import java.util.List; @@ -68,6 +67,7 @@ public class FSDProtectedLogListener implements LogListener, Configurable String[] protectFields = null; String[] wipeFields = null; String[] truncateFields = null; + boolean truncateAddEllipsis = false; Configuration cfg = null; public static final String WIPED = "[WIPED]"; public static final byte[] BINARY_WIPED = ISOUtil.hex2byte ("AA55AA55"); @@ -94,6 +94,7 @@ public void setConfiguration (Configuration cfg) truncateFields = ISOUtil.toStringArray (cfg.get ("truncate", "")); protectFields = ISOUtil.toStringArray (cfg.get ("protect", "")); wipeFields = ISOUtil.toStringArray (cfg.get ("wipe", "")); + truncateAddEllipsis = cfg.getBoolean("truncate-add-ellipsis", false); } public synchronized LogEvent log (LogEvent ev) { synchronized (ev.getPayLoad()) { @@ -133,7 +134,7 @@ private void checkTruncated(FSDISOMsg m) { private void checkTruncated(FSDMsg m) { for (String truncateField : truncateFields) { - String truncate[] = truncateField.split(":"); + String [] truncate = truncateField.split(":"); if (truncate.length == 2) { String f = truncate[0]; int len = Integer.parseInt(truncate[1]); @@ -144,7 +145,7 @@ private void checkTruncated(FSDMsg m) { // NOPMD: NOP } if (v != null && v.length() > len) { - m.set(f, v.substring(0, len)); + m.set(f, v.substring(0, len) + (truncateAddEllipsis ? "...":"")); } } }