Esempio n. 1
0
  @Ignore("test currently failing - debug action required TODO: CCB")
  @Test
  public void test08ByteBitmap() throws Exception {

    ISOComponent c = new ISOBitMap(1);
    int consumed = eightBytes.unpack(c, inBytes, 0);
    assertEquals(
        "8 bytes should be consumed irrespective of 2nd and 3rd bitmap indicators", 8, consumed);
    assertEquals(
        "8 byte can only result in a bitmap holding fields up to 64",
        64,
        ((BitSet) c.getValue()).length() - 1);

    outBytes = eightBytes.pack(c);
    assertEquals(
        "8 byte bitmap pack should reflect unpack",
        ISOUtil.hexString(inBytes, 0, 8),
        ISOUtil.hexString(outBytes));

    try {
      outBytes = oneByte.pack(c);
      fail("Pack of bitmap with fields outside of 1 byte range should result in ISOException");
    } catch (Exception e) {
      // expected.
      assertEquals(
          "Bitmap can only hold fields numbered up to 8 in the 1 bytes available.", e.getMessage());
    }
  }
 public void interpret(String data, byte[] targetArray, int offset) {
   boolean negative = data.startsWith("-");
   if (negative) {
     ISOUtil.asciiToEbcdic(data.substring(1), targetArray, offset);
     targetArray[offset + data.length() - 2] =
         (byte) (targetArray[offset + data.length() - 2] & 0xDF);
   } else {
     ISOUtil.asciiToEbcdic(data, targetArray, offset);
   }
 }
Esempio n. 3
0
  @Before
  public void setUp() {
    oneByte = new IFB_BITMAP(1, "1 byte bitmap");
    eightBytes = new IFB_BITMAP(8, "8 byte bitmap");
    sixteenBytes = new IFB_BITMAP(16, "16 byte bitmap");
    twentyfourBytes = new IFB_BITMAP(24, "24 byte bitmap");

    //                                             Next Bitmap?    Next Bitmap?
    //                                             V               V
    inBytes = ISOUtil.hex2byte("8181421FF12418F18F81421FF12418F18F81421FF12418F1");
    eightByteBitMapIn24Bytes = ISOUtil.hex2byte("7181421FF12418F11881421FF12418F18F81421FF12418F1");
    sixteenByteBitMapIn24Bytes =
        ISOUtil.hex2byte("8181421FF12418F11881421FF12418F18F81421FF12418F1");
  }
Esempio n. 4
0
 /**
  * @param cfg
  *     <ul>
  *       <li>sequencer - a sequencer used to store counters
  *       <li>unset - space delimited list of fields to be unset
  *       <li>valid - space delimited list of valid fields
  *       <li>comma delimited list of fields to be unset when applying filter
  *       <li>xzy - property named "xyz"
  *     </ul>
  */
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   this.cfg = cfg;
   try {
     String seqName = cfg.get("sequencer", null);
     unsetFields = ISOUtil.toIntArray(cfg.get("unset", ""));
     validFields = ISOUtil.toIntArray(cfg.get("valid", ""));
     if (seqName != null) {
       seq = (Sequencer) NameRegistrar.get("sequencer." + cfg.get("sequencer"));
     } else if (seq == null) {
       seq = new VolatileSequencer();
     }
   } catch (NameRegistrar.NotFoundException e) {
     throw new ConfigurationException(e);
   }
 }
public class EbcdicBinaryInterpreterTest {
  public static final BinaryInterpreter interpreter = EbcdicBinaryInterpreter.INSTANCE;
  public static final byte[] EBCDICDATA =
      ISOUtil.hex2byte(
          "F1F2F3F4F5F6F7F8F9F0C1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7D8D9E2E3E4E5E6E7E8E9818283848586878"
              + "889919293949596979899A2A3A4A5A6A7A8A95FC0D0ADBD7F7E7D7C7A4F6B6C6D4C6E6F5A5C50");
  static final byte[] binaryData =
      "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz^{}[]\"='@:|,%_<>?!*&"
          .getBytes();

  @Test
  public void interpret() {
    byte[] result = new byte[binaryData.length];
    interpreter.interpret(binaryData, result, 0);
    assertThat(result, is(EBCDICDATA));
  }

  @Test
  public void uninterpret() {
    int offset = 0;
    int length = EBCDICDATA.length;
    byte[] result = interpreter.uninterpret(EBCDICDATA, offset, length);
    assertThat(result, is(binaryData));
  }
}
Esempio n. 6
0
  /**
   * @param c - the Component to unpack
   * @param b - binary image
   * @param offset - starting offset within the binary image
   * @return consumed bytes
   * @exception ISOException
   */
  public int unpack(ISOComponent c, byte[] b, int offset) throws ISOException {
    boolean pad = false;

    int len = ((b[offset] & 0x0f) * 100) + ((b[offset + 1] & 0x0f) * 10) + (b[offset + 2] & 0x0f);

    int tempLen = len * 2;

    // System.out.println("len "+ len +"len*2 "+tempLen);

    // odd handling
    byte testByte = b[(offset + 3 + len - 1)];

    if ((testByte | 0xf0) == 0xff) {
      // odd length
      tempLen--;
    }

    // bcd line
    // System.out.println("ISOUtil.bcd2str(b, offset+2, len, pad) "+ISOUtil.bcd2str(b, offset+2,
    // tempLen, pad));

    c.setValue(ISOUtil.bcd2str(b, offset + 3, tempLen, pad));

    // c.setValue(ISOUtil.ebcdicToAscii(b, offset+2, len));

    return len + 3;
  }
Esempio n. 7
0
 public void testUnpack() throws Exception {
   byte[] raw = new byte[] {68, 48, 48, 49, 50, 51};
   IFE_AMOUNT packager = new IFE_AMOUNT(6, "Should be C4F0F0F1F2F3");
   ISOField field = new ISOField();
   packager.unpack(field, ISOUtil.hex2byte("C4F0F0F1F2F3"), 0);
   assertEquals("D00123", (String) field.getValue());
 }
Esempio n. 8
0
 public static String getIsoCodeFromAlphaCode(String alphacode) throws IllegalArgumentException {
   try {
     Currency c = findCurrency(alphacode);
     return ISOUtil.zeropad(Integer.toString(c.getIsoCode()), 3);
   } catch (ISOException e) {
     throw new IllegalArgumentException("Failed getIsoCodeFromAlphaCode/ zeropad failed?", e);
   }
 }
Esempio n. 9
0
 /**
  * @param c - a component
  * @return packed component
  * @exception ISOException
  */
 public byte[] pack(ISOComponent c) throws ISOException {
   String s = (String) c.getValue();
   String amount = ISOUtil.zeropad(s.substring(1), getLength() - 1);
   byte[] b = new byte[1 + (getLength() >> 1)];
   b[0] = (byte) s.charAt(0);
   interpreter.interpret(amount, b, 1);
   return b;
 }
Esempio n. 10
0
  @Ignore("test currently failing - debug action required TODO: CCB")
  @Test
  public void test24ByteBitmap() throws Exception {
    ISOComponent c = new ISOBitMap(1);
    int consumed = twentyfourBytes.unpack(c, inBytes, 0);
    assertEquals("All 24 Bytes should be consumed", 24, consumed);
    assertEquals(
        "24 byte can only result in a bitmap holding fields up to 192",
        192,
        ((BitSet) c.getValue()).length() - 1);

    outBytes = twentyfourBytes.pack(c);
    assertEquals(
        "24 byte bitmap pack should reflect unpack",
        ISOUtil.hexString(inBytes, 0, 24),
        ISOUtil.hexString(outBytes));

    try {
      outBytes = sixteenBytes.pack(c);
      fail("Pack of bitmap with fields outside of 16 byte range should result in ISOException");
    } catch (Exception e) {
      // expected.
      assertEquals(
          "Bitmap can only hold fields numbered up to 128 in the 16 bytes available.",
          e.getMessage());
    }

    try {
      outBytes = eightBytes.pack(c);
      fail("Pack of bitmap with fields outside of 8 byte range should result in ISOException");
    } catch (Exception e) {
      // expected.
      assertEquals(
          "Bitmap can only hold fields numbered up to 64 in the 8 bytes available.",
          e.getMessage());
    }

    try {
      outBytes = oneByte.pack(c);
      fail("Pack of bitmap with fields outside of 1 byte range should result in ISOException");
    } catch (Exception e) {
      // expected.
      assertEquals(
          "Bitmap can only hold fields numbered up to 8 in the 1 bytes available.", e.getMessage());
    }
  }
Esempio n. 11
0
  @Test
  public void test24ByteBitmapWithOnly8BytesUsed() throws Exception {

    ISOComponent c = new ISOBitMap(1);
    int consumed = twentyfourBytes.unpack(c, eightByteBitMapIn24Bytes, 0);
    assertEquals("8 bytes should be consumed as the 2nd bitmap indicator if off", 8, consumed);
    assertEquals(
        "24 byte bitmap with just 8 bytes used should have a maximum field of ",
        64,
        ((BitSet) c.getValue()).length() - 1);

    outBytes = twentyfourBytes.pack(c);
    assertEquals(
        "24 Byte (8 bytes used) bitmap pack should reflect unpack",
        ISOUtil.hexString(eightByteBitMapIn24Bytes, 0, 8),
        ISOUtil.hexString(outBytes));
  }
Esempio n. 12
0
  @Test
  public void test01ByteBitmap() throws Exception {

    ISOComponent c = new ISOBitMap(1);
    int consumed = oneByte.unpack(c, inBytes, 0);
    assertEquals(
        "1 byte should be consumed irrespective of 2nd, 3rd or any bitmap indicators", 1, consumed);
    assertEquals(
        "1 byte can only result in a bitmap holding fields up to 8",
        8,
        ((BitSet) c.getValue()).length() - 1);

    outBytes = oneByte.pack(c);
    assertEquals(
        "1 byte bitmap pack should reflect unpack",
        ISOUtil.hexString(inBytes, 0, 1),
        ISOUtil.hexString(outBytes));
  }
Esempio n. 13
0
 /**
  * Return the String value associated with the given field path
  *
  * @param fpath field path
  * @return field's String value (may be null)
  */
 public String getString(String fpath) {
   String s = null;
   try {
     Object obj = getValue(fpath);
     if (obj instanceof String) s = (String) obj;
     else if (obj instanceof byte[]) s = ISOUtil.hexString((byte[]) obj);
   } catch (ISOException e) {
     // ignore ISOException - return null
   }
   return s;
 }
Esempio n. 14
0
  /**
   * @param c - a component
   * @return packed component
   * @exception ISOException
   */
  public byte[] pack(ISOComponent c) throws ISOException {
    boolean odd = false;
    int len;
    String s = (String) c.getValue();

    if ((len = s.length()) > getLength() || len > 99) // paranoia settings
    throw new ISOException("invalid len " + len + " packing IFEB_LLLNUM field " + c.getKey());

    // System.out.println("String s = (String) c.getValue(); "+s);

    // if odd length
    if ((len % 2) == 1) {
      odd = true;
      len = (len / 2) + 1;
    } else {
      odd = false;
      len = len / 2;
    }

    // System.out.println("len= "+ len +" s.length()= "+len);

    String fieldLength = ISOUtil.zeropad(Integer.toString(len), 3);

    byte[] EBCDIClength = ISOUtil.asciiToEbcdic(fieldLength);

    // bcd stuff
    byte[] bcd = ISOUtil.str2bcd(s, false);
    if (odd) bcd[len - 1] = (byte) (bcd[len - 1] | 0xf);

    // System.out.println("bcd2str "+ISOUtil.bcd2str(bcd, 0, bcd.length*2, false) );

    byte[] b = new byte[bcd.length + 3];

    b[0] = EBCDIClength[0];
    b[1] = EBCDIClength[1];
    b[2] = EBCDIClength[2];
    System.arraycopy(bcd, 0, b, 3, bcd.length);

    return b;
  }
Esempio n. 15
0
 /**
  * Return the String value associated with the given ISOField number
  *
  * @param fldno the Field Number
  * @return field's String value
  */
 public String getString(int fldno) {
   String s = null;
   if (hasField(fldno)) {
     try {
       Object obj = getValue(fldno);
       if (obj instanceof String) s = (String) obj;
       else if (obj instanceof byte[]) s = ISOUtil.hexString((byte[]) obj);
     } catch (ISOException e) {
       // ignore ISOException - return null
     }
   }
   return s;
 }
Esempio n. 16
0
 @Before
 public void setup() throws ISOException, NoSuchFieldException {
   p = new JSONPackager();
   m = new ISOMsg();
   m.set(0, "0800");
   m.set(3, "000000");
   m.set(11, "000001");
   m.set(41, "29110001");
   m.set(55, ISOUtil.hex2byte("55AA1122"));
   m.set("127.2", "Test 127.2");
   m.set("127.3", "Test 127.3");
   m.set("127.4", "Test 127.4");
   m.set("127.5.1", "Test 127.5.1");
   m.setPackager(p);
 }
Esempio n. 17
0
 /**
  * Creates an ISOField associated with fldno within this ISOMsg
  *
  * @param fldno field number
  * @param value field value
  */
 public void set(int fldno, String value) throws ISOException {
   if (value != null) {
     if (!(packager instanceof ISOBasePackager)) {
       // No packager is available, we can't tell what the field
       // might be, so treat as a String!
       set(new ISOField(fldno, value));
     } else {
       // This ISOMsg has a packager, so use it
       Object obj = ((ISOBasePackager) packager).getFieldPackager(fldno);
       if (obj instanceof ISOBinaryFieldPackager) {
         set(new ISOBinaryField(fldno, ISOUtil.hex2byte(value)));
       } else {
         set(new ISOField(fldno, value));
       }
     }
   } else unset(fldno);
 }
Esempio n. 18
0
 private void applyProps(ISOMsg m) throws ISOException {
   int maxField = m.getMaxField();
   for (int i = 0; i <= maxField; i++) {
     Object o = null;
     if (m.hasField(i)) o = m.getValue(i);
     if (o instanceof String) {
       String value = (String) o;
       if (value.length() == 0) continue;
       if (value.equalsIgnoreCase("$date"))
         m.set(new ISOField(i, ISODate.getDateTime(new Date())));
       else if ((value.toLowerCase().startsWith("$date")) && value.contains("GMT")) {
         String zoneID = value.substring(value.indexOf("GMT"));
         m.set(new ISOField(i, ISODate.getDateTime(new Date(), TimeZone.getTimeZone(zoneID))));
       } else if (value.charAt(0) == '#')
         m.set(new ISOField(i, ISOUtil.zeropad(Integer.toString(seq.get(value.substring(1))), 6)));
       else if (value.charAt(0) == '$') {
         String p = cfg.get(value.substring(1), null);
         if (p != null) m.set(new ISOField(i, p));
       }
     }
   }
 }
Esempio n. 19
0
  @Override
  public byte[] pack(ISOComponent c) throws ISOException {
    LogEvent evt = new LogEvent(this, "pack");
    try {
      int len = 0;
      Map tab = c.getChildren();
      List<byte[]> l = new ArrayList();

      for (Map.Entry ent : (Set<Map.Entry>) tab.entrySet()) {
        Integer i = (Integer) ent.getKey();
        if (i < 0) continue;
        if (fld[i] == null)
          throw new ISOException("Unsupported sub-field " + i + " packing field " + c.getKey());
        if (ent.getValue() instanceof ISOComponent)
          try {
            ISOComponent f = (ISOComponent) ent.getValue();
            byte[] b = fld[i].pack(f);
            len += b.length;
            l.add(b);
          } catch (Exception e) {
            evt.addMessage("error packing subfield " + i);
            evt.addMessage(c);
            evt.addMessage(e);
            throw e;
          }
      }
      int k = 0;
      byte[] d = new byte[len];
      for (byte[] b : l) {
        System.arraycopy(b, 0, d, k, b.length);
        k += b.length;
      }
      if (logger != null) // save a few CPU cycle if no logger available
      evt.addMessage(ISOUtil.hexString(d));
      return d;
    } catch (Exception ex) {
      throw new ISOException(ex);
    }
  }
Esempio n. 20
0
 /** Validate that the component is not blank-filled. */
 public ISOComponent validate(ISOComponent f) throws ISOException {
   ISOField c = (ISOField) f;
   try {
     /** no zero... * */
     c = (ISOField) super.validate(c);
     /** no blank * */
     if (ISOUtil.isBlank((String) c.getValue())) {
       ISOVError e =
           new ISOVError(
               "Invalid Value Error. It can not be blank-filled. (Current value: "
                   + c.getValue()
                   + ") ",
               getRejCode(ISOVError.ERR_INVALID_VALUE));
       if (c instanceof ISOVField) ((ISOVField) c).addISOVError(e);
       else c = new ISOVField(c, e);
       if (breakOnError) throw new ISOVException("Error on field " + c.getKey(), c);
     }
     return c;
   } catch (Exception ex) {
     if (ex instanceof ISOVException) throw (ISOVException) ex;
     return c;
   }
 }
  // --------------------------getDecryptedRecieptData-------------------------------------------------------------
  // public String getDebitCmd(String stCardRndNo, String stTerRndNo, String stAmt, String stPurse)
  // throws Exception {
  public String getDecryptedRecieptData(ETerminalDataDto objETerminalDataDto) throws Exception {

    // ETerminalDataDto objETerminalDataDto=new ETerminalDataDto();

    String strDecryptedRecieptDataRefNo = "";
    String strDecryptedRecieptData = "";
    String strResHeader = "";

    // String strDebitCmd=null;
    try {
      ezlink.info(
          "\n-------SerialManager--------------START----4 decrypting RecieptData-------------------");
      ezlink.info("getDecryptedRecieptData Request received in " + SerialManager.class.getName());
      // Commet this after testing with main method;
      // serialDemo.initConfig()
      // serialDemo.connection.sendMessage(ISOUtil.hex2byte("020079600037000002007024058000C10004164999770007848180000000000000011111011000100309020037003237303031393630313638313638313035323934202020000334343400063031313030320388"));

      // Debit command
      byte[] decRecieptData = null;
      try {
        decRecieptData =
            connection.sendMessage(
                ISOUtil.hex2byte(
                    HeaderUtil.getReqRecieptData(
                        objETerminalDataDto.getRecieptData(),
                        objETerminalDataDto.getTerminalSessionKey(),
                        objETerminalDataDto.getDebitSessionKey(),
                        objETerminalDataDto.getCan(),
                        objETerminalDataDto.getEzLinkString(),
                        "")));
      } catch (Exception e) {
        e.printStackTrace();
      }
      System.out.println("Decrypted Reciept Data=" + ISOUtil.hexString(decRecieptData));
      ezlink.info("Decrypted Reciept Data= : " + ISOUtil.hexString(decRecieptData));
      String strResponse = ISOUtil.hexString(decRecieptData);
      ezlink.info("+++Decrypted Reciept Data strResponse Length : " + strResponse.length());
      ezlink.info("+++Decrypted Reciept Data strResponse  : " + strResponse);
      //          if (strResponse.length() == 222) {
      // ezlink.info("+++Inside IF  :
      // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" );

      strResHeader = strResponse.substring(0, 34);
      strDecryptedRecieptDataRefNo = strResponse.substring(44, 68); // 24

      strDecryptedRecieptData = strResponse.substring(78, strResponse.length() - 2);

      System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
      System.out.println("Last two digits: " + strResponse.substring(strResponse.length() - 2));
      System.out.println("Response length : " + strResponse.length());
      System.out.println("Response from terminal DC : " + strResponse);
      System.out.println("Decrypted Ezlink String : " + strDecryptedRecieptData);
      System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++");

      ezlink.info(
          "\n--------SERIAL MANAGER-------RESPONSE----4DecryptedRecieptData----------------");
      ezlink.info("strResHeader : " + strResHeader);

      ezlink.info("strDecryptedRecieptDataRefNo : " + strDecryptedRecieptDataRefNo);
      ezlink.info("strDecryptedRecieptData : " + strDecryptedRecieptData);
      ezlink.info("\n--------SERIAL MANAGER-------RESPONSE--------------------");

      // strDebitCmd = "250315021403" + stTerRndNo + strActDebitCmd + strUserData;
      // System.out.println("strDebitCmd= " + strDebitCmd + "  Len  " + strDebitCmd.length());
      // ezlink.info("strDebitCmd= " + strDebitCmd + " Len : " + strDebitCmd.length());

      /*
                  } else {
                      //ezlink.info("+++Inside IF  : ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" );
                      System.out.println("Response from the Terminal not received fully...");
                      ezlink.info("Response from the Terminal not received fully...!!!!!!!");
                  }
      */
    } catch (Exception exp) {
      System.out.println(exp);
      ezlink.error(new Object(), exp);
      throw exp;
    }

    return strDecryptedRecieptData;
  }
Esempio n. 22
0
 public static Currency getCurrency(int code) throws ISOException {
   final String isoCode = ISOUtil.zeropad(Integer.toString(code), 3);
   return findCurrency(isoCode);
 }
Esempio n. 23
0
 public static Currency getCurrency(String code) throws ISOException {
   final String isoCode = ISOUtil.zeropad(code, 3);
   return findCurrency(isoCode);
 }
Esempio n. 24
0
 /** * @param header Hex representation of header */
 public void setHeader(String header) {
   super.setHeader(ISOUtil.hex2byte(header.getBytes(), 0, header.length() / 2));
 }
 public String uninterpret(byte[] rawData, int offset, int length) {
   boolean negative = ((byte) (rawData[offset + length - 1] & 0xF0)) == ((byte) 0xD0);
   rawData[offset + length - 1] = ((byte) (rawData[offset + length - 1] | 0xF0));
   return (negative ? "-" : "") + ISOUtil.ebcdicToAscii(rawData, offset, length);
 }
  // public String getDebitCmd(String stCardRndNo, String stTerRndNo, String stAmt, String stPurse)
  // throws Exception {
  public ETerminalDataDto getDebitCmd(
      String stCardRndNo, String stTerRndNo, String stAmt, String stPurse) throws Exception {

    ETerminalDataDto objETerminalDataDto = new ETerminalDataDto();

    String strDebitCmd = "";
    String strResHeader = "";
    String strActDebitCmd = "";
    String strUserData = "";
    String strSignSessionKey = "";
    String strDebitSessionKey = "";
    String strRefno = "";
    String strEzlinkString = "";

    // String strDebitCmd=null;
    try {
      ezlink.info("\n-------SerialManager--------------START--------------------------------");
      ezlink.info("getDebitCmd Request received in " + SerialManager.class.getName());
      // Commet this after testing with main method;
      // serialDemo.initConfig()
      // serialDemo.connection.sendMessage(ISOUtil.hex2byte("020079600037000002007024058000C10004164999770007848180000000000000011111011000100309020037003237303031393630313638313638313035323934202020000334343400063031313030320388"));

      // Debit command
      byte[] debitCommand =
          connection.sendMessage(
              ISOUtil.hex2byte(HeaderUtil.getReqHeader(stCardRndNo, stTerRndNo, stAmt, stPurse)));
      System.out.println("Debit Command=" + ISOUtil.hexString(debitCommand));
      ezlink.info("Debit Command= : " + ISOUtil.hexString(debitCommand));

      /*
      byte[] recieptData = connection.sendMessage(ISOUtil.hex2byte(HeaderUtil.getReqRecieptData("EEF6BAADFDDB93685EC111ACD05D7133E9472DA4416D0C079000")));
      System.out.println("Reciept Data =" + ISOUtil.hexString(recieptData));
      ezlink.info("Reciept Data= : " + ISOUtil.hexString(recieptData));
      */
      // debitCommand =
      // ISOUtil.hex2byte("36303030303030303030313132303030301C343100165F332D39907B07D4C9C72441CF93C3461C3432000854495430303031201C3433001647058A8594B61B0707BD7794B3F7078D1C34340016134DBF682CD22C68A60D1F0E71F929D01C34350012DC7934737E93BE4FDC7934731C30303030303031313230303030");
      /*
      String[] strResSplit = ISOUtil.hexString(debitCommand).split("1C");

      for(int i=0;i<strResSplit.length;i++)
      {
      strResSplit[i] = strResSplit[i].substring(8);
      System.out.println(strResSplit[i]);
      ezlink.info("strResSplit [ "+i+" ]" + strResSplit[i]);
      }
      strDebitCmd = "250315021403"+stTerRndNo+strResSplit[1]+strResSplit[2];
      System.out.println("strDebitCmd= "+strDebitCmd +"  Len  "+strDebitCmd.length());
      ezlink.info("strDebitCmd= "+strDebitCmd+" Len : " + strDebitCmd.length());

      */
      // String strResponse = ISOUtil.hexString(recieptData);
      String strResponse = ISOUtil.hexString(debitCommand);
      ezlink.info("+++strResponse Length : " + strResponse.length());
      ezlink.info("+++strResponse  : " + strResponse);
      //          if (strResponse.length() == 222) {
      // ezlink.info("+++Inside IF  :
      // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" );
      /*
      //Old terminal
      strResHeader = strResponse.substring(0, 34);
      strActDebitCmd = strResponse.substring(44, 76);
      strUserData = strResponse.substring(86, 102);
      strSignSessionKey = strResponse.substring(112, 144);
      strDebitSessionKey = strResponse.substring(154, 186);
      strRefno = strResponse.substring(196, 220);
      */
      // New Terminal
      strResHeader = strResponse.substring(0, 34);
      strRefno = strResponse.substring(44, 68); // 24
      strActDebitCmd = strResponse.substring(78, 110); // 32
      strUserData = strResponse.substring(120, 136); // 16
      strSignSessionKey = strResponse.substring(146, 178); // 32
      strDebitSessionKey = strResponse.substring(188, 220); // 32

      strEzlinkString = strResponse.substring(230, strResponse.length() - 2);

      System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
      System.out.println("Last two digits: " + strResponse.substring(strResponse.length() - 2));
      System.out.println("Response length : " + strResponse.length());
      System.out.println("Response from terminal DC : " + strResponse);
      System.out.println("Ezlink String : " + strEzlinkString);
      System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++");

      ezlink.info("\n--------SERIAL MANAGER-------RESPONSE--------------------");
      ezlink.info("strResHeader : " + strResHeader);
      ezlink.info("strActDebitCmd : " + strActDebitCmd);
      ezlink.info("strUserData : " + strUserData);
      ezlink.info("strSignSessionKey : " + strSignSessionKey);
      ezlink.info("strDebitSessionKey : " + strDebitSessionKey);
      ezlink.info("strRefno : " + strRefno);
      ezlink.info("strEzlinkString : " + strEzlinkString);
      ezlink.info("\n--------SERIAL MANAGER-------RESPONSE--------------------");

      strDebitCmd = "250315021403" + stTerRndNo + strActDebitCmd + strUserData;
      System.out.println("strDebitCmd= " + strDebitCmd + "  Len  " + strDebitCmd.length());
      ezlink.info("strDebitCmd= " + strDebitCmd + " Len : " + strDebitCmd.length());

      objETerminalDataDto.setDebitCmd(strDebitCmd);
      objETerminalDataDto.setTerminalSessionKey(strSignSessionKey);
      objETerminalDataDto.setDebitSessionKey(strDebitSessionKey);
      objETerminalDataDto.setEzLinkString(strEzlinkString);
      /*
                  } else {
                      //ezlink.info("+++Inside IF  : ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" );
                      System.out.println("Response from the Terminal not received fully...");
                      ezlink.info("Response from the Terminal not received fully...!!!!!!!");
                  }
      */
    } catch (Exception exp) {
      System.out.println(exp);
      ezlink.error(new Object(), exp);
      throw exp;
    }
    // return strDebitCmd;
    return objETerminalDataDto;
  }
Esempio n. 27
0
 public void testPack() throws Exception {
   ISOField field = new ISOField(12, "D123");
   IFE_AMOUNT packager = new IFE_AMOUNT(6, "Should be C4F0F0F1F2F3");
   TestUtils.assertEquals(ISOUtil.hex2byte("C4F0F0F1F2F3"), packager.pack(field));
 }