Skip to content

Commit

Permalink
removed temporary 'protect0' method committed by mistake
Browse files Browse the repository at this point in the history
relates to #579
  • Loading branch information
ar committed Jan 11, 2024
1 parent f66f287 commit 16c7a12
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions jpos/src/main/java/org/jpos/iso/ISOUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -903,50 +903,6 @@ public static String normalize (String s) {
* @param mask char used to protect the string
* @return 'protected' String
*/
public static String protect0 (String s, char mask) {
StringBuilder sb = new StringBuilder();
int len = s.length();
int clear = len > 6 ? 6 : 0;
int lastFourIndex = -1;
if (clear > 0) {
lastFourIndex = s.indexOf ('=') - 4;
if (lastFourIndex < 0)
lastFourIndex = s.indexOf ('^') - 4;
if (lastFourIndex < 0 && s.indexOf('^')<0)
lastFourIndex = s.indexOf('D') - 4;
if (lastFourIndex < 0)
lastFourIndex = len - 4;
}
for (int i=0; i<len; i++) {
if (s.charAt(i) == '=' || s.charAt(i) == 'D' && s.indexOf('^')<0)
clear = 1; // use clear=5 to keep the expiration date
else if (s.charAt(i) == '^') {
lastFourIndex = 0;
clear = len - i;
}
else if (i == lastFourIndex)
clear = 4;
sb.append (clear-- > 0 ? s.charAt(i) : mask);
}
s = sb.toString();
try {
//Addresses Track1 Truncation
int charCount = s.replaceAll("[^\\^]", "").length();
if (charCount >= 2) {
int firstCaret = s.indexOf("^");
int secondCaret = s.indexOf("^", firstCaret + 1);

s = s.substring(0, firstCaret + 1);
s = padright(s, secondCaret, mask);
s = s.concat("^");
s = padright(s, len, mask);
}
} catch (ISOException e){
//cannot PAD - should never get here
}
return s;
}


public static String protect(String s, char mask) {
// Validation for minimum length
Expand Down Expand Up @@ -976,7 +932,6 @@ public static String protect(String s, char mask) {
return protectedTrack.toString();
}


public static String protect(String s) {
return protect(s, '_');
}
Expand Down

0 comments on commit 16c7a12

Please sign in to comment.