From 1890a09e326be591b80a6bbe0e38ee6d8cd8c93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Alcarraz?= Date: Wed, 19 Feb 2020 18:24:03 -0500 Subject: [PATCH] ProtectDebugInfo: Make wipe and protect iso paths In order to let the participant be configured to protect sub fields. --- .../jpos/transaction/ProtectDebugInfo.java | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) 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 c3eab8854a..2699108b6d 100644 --- a/modules/txn/src/main/java/org/jpos/transaction/ProtectDebugInfo.java +++ b/modules/txn/src/main/java/org/jpos/transaction/ProtectDebugInfo.java @@ -20,6 +20,7 @@ import org.jpos.core.Configuration; import org.jpos.core.ConfigurationException; +import org.jpos.iso.ISOException; import org.jpos.iso.ISOMsg; import org.jpos.iso.ISOUtil; import org.jpos.util.FSDMsg; @@ -59,8 +60,8 @@ public class ProtectDebugInfo extends TxnSupport implements AbortParticipant { private String[] protectedEntrys; private String[] wipedEntrys; private String[] protectFSD; - private int[] protectISO; - private int[] wipeISO; + private String[] protectISO; + private String[] wipeISO; public int prepare (long id, Serializable o) { return PREPARED | READONLY; @@ -86,9 +87,9 @@ private void protect (Context ctx) { if (m != null) { m = (ISOMsg) m.clone(); ctx.put (s, m); // place a clone in the context - for (int p: protectISO) + for (String p: protectISO) protectField(m,p); - for (int p: wipeISO) + for (String p: wipeISO) wipeField(m,p); } } @@ -107,19 +108,25 @@ private void protect (Context ctx) { } } } - private void protectField (ISOMsg m, int f) { + private void protectField (ISOMsg m, String f) { if (m != null) { m.set (f, protect (m.getString (f))); } } - private void wipeField (ISOMsg m, int f) { + private void wipeField (ISOMsg m, String f) { if (m != null) { - Object v = m.getValue(f); - if (v != null) { - if (v instanceof String) - m.set(f, ProtectedLogListener.WIPED); - else - m.set(f, ProtectedLogListener.BINARY_WIPED); + Object v = null; + try { + v = m.getValue(f); + if (v != null) { + if (v instanceof String) + m.set(f, ProtectedLogListener.WIPED); + else + m.set(f, ProtectedLogListener.BINARY_WIPED); + } + } catch (ISOException ignored) { + //ignore, valid routes for some messages in the context may not be vaild for others + //e.g. in transaction switches with protocol conversion } } } @@ -147,19 +154,8 @@ public void setConfiguration (Configuration cfg) this.wipedEntrys = cfg.getAll("wipe-entry"); this.protectFSD = cfg.getAll("protect-FSDMsg"); - try { - this.protectISO = parseInt(cfg.getAll("protect-ISOMsg")); - this.wipeISO = parseInt(cfg.getAll("wipe-ISOMsg")); - } catch (NumberFormatException e) { - throw new ConfigurationException (e); - } + this.protectISO = cfg.getAll("protect-ISOMsg"); + this.wipeISO = cfg.getAll("wipe-ISOMsg"); } - private int[] parseInt(String[] ss) throws NumberFormatException { - int[] ii = new int[ss.length]; - for (int i=0; i