TlvUtil { public static String prettyPrintAPDUResponse(final byte[] data) { return prettyPrintAPDUResponse(data, 0); } private  TlvUtil(); static String getFormattedTagAndLength(final byte[] data, final int indentLength); static TLV getNextTLV(final TLVInputStream stream); static List<TagAndLength> parseTagAndLength(final byte[] data); static String prettyPrintAPDUResponse(final byte[] data); static List<TLV> getlistTLV(final byte[] pData, final ITag pTag, final boolean pAdd); static List<TLV> getlistTLV(final byte[] pData, final ITag... pTag); static byte[] getValue(final byte[] pData, final ITag... pTag); static String prettyPrintAPDUResponse(final byte[] data, final int indentLength); static String getSpaces(final int length); static String prettyPrintHex(final String in, final int indent); static String prettyPrintHex(final byte[] data); static String prettyPrintHex(final String in, final int indent, final boolean wrapLines); static String getSafePrintChars(final byte[] byteArray); static String getSafePrintChars(final byte[] byteArray, final int startPos, final int length); static int getLength(final List<TagAndLength> pList);  }
@Test public void testPrettyPrint() { String expResult = "\n" + "70 63 -- Record Template (EMV Proprietary)\n" + " 61 13 -- Application Template\n" + " 4F 09 -- Application Identifier (AID) - card\n" + " A0 00 00 03 15 10 10 05 28 (BINARY)\n" + " 50 03 -- Application Label\n" + " 50 49 4E (=PIN)\n" + " 87 01 -- Application Priority Indicator\n" + " 01 (BINARY)\n" + " 61 15 -- Application Template\n" + " 4F 07 -- Application Identifier (AID) - card\n" + " A0 00 00 00 04 30 60 (BINARY)\n" + " 50 07 -- Application Label\n" + " 4D 41 45 53 54 52 4F (=MAESTRO)\n" + " 87 01 -- Application Priority Indicator\n" + " 02 (BINARY)\n" + " 61 1D -- Application Template\n" + " 4F 07 -- Application Identifier (AID) - card\n" + " A0 00 00 00 04 80 02 (BINARY)\n" + " 50 0F -- Application Label\n" + " 53 65 63 75 72 65 43 6F 64 65 20 41 75 74 68 (=SecureCode Auth)\n" + " 87 01 -- Application Priority Indicator\n" + " 00 (BINARY)\n" + " 61 16 -- Application Template\n" + " 4F 07 -- Application Identifier (AID) - card\n" + " A0 00 00 03 15 60 20 (BINARY)\n" + " 50 08 -- Application Label\n" + " 43 68 69 70 6B 6E 69 70 (=Chipknip)\n" + " 87 01 -- Application Priority Indicator\n" + " 00 (BINARY)\n" + "90 00 -- Command successfully executed (OK)"; Assertions.assertThat(TlvUtil.prettyPrintAPDUResponse(DATA)).isEqualTo(expResult); }
@Test public void testPrettyPrintTransactionRecord() { Assertions.assertThat(TlvUtil.prettyPrintAPDUResponse(BytesUtils.fromString("00 00 00 00 46 00 40 02 50 09 78 14 03 16 20 90 00"))) .isEqualTo(""); }