Skip to content

Commit

Permalink
support wipe-ISOMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Jan 26, 2018
1 parent 9fb8ed9 commit 8f99427
Showing 1 changed file with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
import org.jpos.util.FSDMsg;
import org.jpos.util.ProtectedLogListener;

import java.io.Serializable;

Expand All @@ -46,8 +47,8 @@
* <property name="protect-ISOMsg" value="2" />
* <property name="protect-ISOMsg" value="35" />
* <property name="protect-ISOMsg" value="45" />
* <property name="protect-ISOMsg" value="52" />
* <property name="protect-ISOMsg" value="55" />
* <property name="wipe-ISOMsg" value="52" />
* <property name="wipe-ISOMsg" value="55" />
*
* <property name="protect-FSDMsg" value="account-number" />
* <property name="protect-FSDMsg" value="track2-data" />
Expand All @@ -56,13 +57,13 @@
**/

public class ProtectDebugInfo extends TxnSupport implements AbortParticipant {
private String[] protectedEntrys;
private String[] wipedEntrys;
private String[] protectISO;
private String[] wipeISO;
private String[] protectFSD;

String[] protectedEntrys;
String[] wipedEntrys;
String[] protectISO;
String[] protectFSD;

public int prepare (long id, Serializable o) {
public int prepare (long id, Serializable o) {
return PREPARED | READONLY;
}
public int prepareForAbort (long id, Serializable o) {
Expand All @@ -75,7 +76,6 @@ public void abort (long id, Serializable o) {
protect ((Context) o);
}
private void protect (Context ctx) {

/* wipe by removing entries from the context */
for (String s: wipedEntrys)
ctx.remove(s);
Expand All @@ -90,6 +90,8 @@ private void protect (Context ctx) {
ctx.put (s, m); // place a clone in the context
for (String p: protectISO)
protectField(m,Integer.parseInt(p));
for (String p: wipeISO)
wipeField(m,Integer.parseInt(p));
}
}
if (o instanceof FSDMsg){
Expand All @@ -112,7 +114,19 @@ private void protectField (ISOMsg m, int f) {
m.set (f, protect (m.getString (f)));
}
}
private void protectField (FSDMsg m, String f) {
private void wipeField (ISOMsg m, int 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);
}
}
}

private void protectField (FSDMsg m, String f) {
if (f != null) {
String s = m.get (f);
if (s != null)
Expand All @@ -134,6 +148,7 @@ public void setConfiguration (Configuration cfg)
this.protectedEntrys = cfg.getAll("protect-entry");
this.wipedEntrys = cfg.getAll("wipe-entry");
this.protectISO = cfg.getAll("protect-ISOMsg");
this.wipeISO = cfg.getAll("wipe-ISOMsg");
this.protectFSD = cfg.getAll("protect-FSDMsg");
}
}

0 comments on commit 8f99427

Please sign in to comment.