diff --git a/.gitignore b/.gitignore index cffcf37238..25ccfd8274 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *.swp .DS_Store +modules/*/bin +.vscode/ # IDEA Ignores *.iml *.ipr diff --git a/modules/txn/src/main/java/org/jpos/transaction/ProtectDebugInfo.java b/modules/txn/src/main/java/org/jpos/transaction/ProtectDebugInfo.java index 2699108b6d..7384644d06 100644 --- a/modules/txn/src/main/java/org/jpos/transaction/ProtectDebugInfo.java +++ b/modules/txn/src/main/java/org/jpos/transaction/ProtectDebugInfo.java @@ -23,6 +23,7 @@ import org.jpos.iso.ISOException; import org.jpos.iso.ISOMsg; import org.jpos.iso.ISOUtil; +import org.jpos.tlv.TLVList; import org.jpos.util.FSDMsg; import org.jpos.util.ProtectedLogListener; @@ -41,6 +42,7 @@ * <property name="protect-entry" value="REQUEST" /> * <property name="protect-entry" value="RESPONSE" /> * <property name="protect-entry" value="PAN" /> + * <property name="protect-entry" value="REQUEST_ICC_DATA" /> * * <property name="wipe-entry" value="EXPDATE" /> * @@ -49,6 +51,11 @@ * <property name="protect-ISOMsg" value="45" /> * <property name="wipe-ISOMsg" value="52" /> * <property name="wipe-ISOMsg" value="55" /> + * + * <property name="wipe-TLVList" value="0x56" /> + * <property name="wipe-TLVList" value="0x57" /> + * <property name="wipe-TLVList" value="0x5a" /> + * <property name="wipe-TLVList" value="0x5f20" /> * * <property name="protect-FSDMsg" value="account-number" /> * <property name="protect-FSDMsg" value="track2-data" /> @@ -62,6 +69,7 @@ public class ProtectDebugInfo extends TxnSupport implements AbortParticipant { private String[] protectFSD; private String[] protectISO; private String[] wipeISO; + private String[] wipeTLV; public int prepare (long id, Serializable o) { return PREPARED | READONLY; @@ -105,6 +113,13 @@ private void protect (Context ctx) { if (p != null){ ctx.put(s, protect (p)); } + } + if (o instanceof TLVList) { + TLVList tlv = ctx.get(s); + if (tlv != null) { + for (String t: wipeTLV) + wipeTag(tlv, t); + } } } } @@ -131,6 +146,19 @@ private void wipeField (ISOMsg m, String f) { } } + static void wipeTag(TLVList tlv, String tag) { + if (tlv == null) + return; + try { + int tagName = Integer.decode(tag); + if (tlv.hasTag(tagName)) { + tlv.deleteByTag(tagName); + tlv.append(tagName, ProtectedLogListener.BINARY_WIPED); + } + } + catch (Throwable ignored) { } + } + private void protectField (FSDMsg m, String f) { if (f != null) { String s = m.get (f); @@ -153,9 +181,8 @@ public void setConfiguration (Configuration cfg) this.protectedEntrys = cfg.getAll("protect-entry"); this.wipedEntrys = cfg.getAll("wipe-entry"); this.protectFSD = cfg.getAll("protect-FSDMsg"); - this.protectISO = cfg.getAll("protect-ISOMsg"); this.wipeISO = cfg.getAll("wipe-ISOMsg"); + this.wipeTLV = cfg.getAll("wipe-TLVList"); } - } diff --git a/modules/txn/src/test/java/org/jpos/transaction/ProtectDebugInfoTest.java b/modules/txn/src/test/java/org/jpos/transaction/ProtectDebugInfoTest.java new file mode 100644 index 0000000000..2113277711 --- /dev/null +++ b/modules/txn/src/test/java/org/jpos/transaction/ProtectDebugInfoTest.java @@ -0,0 +1,36 @@ +package org.jpos.transaction; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import org.jpos.core.ConfigurationException; +import org.jpos.core.SimpleConfiguration; +import org.jpos.tlv.TLVList; +import org.junit.jupiter.api.Test; + +public final class ProtectDebugInfoTest { + + @Test + void test_wipe_tag() throws ConfigurationException { + + TLVList tlv = new TLVList(); + tlv.append(0x54, "AABBCCDDEEFF"); + tlv.append(0x55, "BBDDFFEEDDAA"); + + SimpleConfiguration cfg = new SimpleConfiguration(); + cfg.put("protect-entry", "TEST_ENTRY"); + cfg.put("wipe-TLVList", "0x54"); + + ProtectDebugInfo participant = new ProtectDebugInfo(); + participant.setConfiguration(cfg); + + Context ctx = new Context(); + ctx.put("TEST_ENTRY", tlv); + + participant.commit(0, ctx); + + ctx.dump(System.out, " "); + assertNotEquals("AABBCCDDEEFF", tlv.getString(0x54)); + assertEquals("BBDDFFEEDDAA", tlv.getString(0x55)); + } +} \ No newline at end of file