Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSDProtectedLogListener now supports a parameter to optionally print … #592

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions jpos/src/main/java/org/jpos/util/FSDProtectedLogListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand All @@ -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()) {
Expand Down Expand Up @@ -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]);
Expand All @@ -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 ? "...":""));
}
}
}
Expand Down
Loading