How to parse a Visa BER TLV field to tag level and define field packager for it?

686 views
Skip to first unread message

Adnan Sohail

unread,
Oct 1, 2019, 6:05:41 AM10/1/19
to jPOS Users
Hi,

I am getting problem while parsing Visa BER TLV field like Field 55, 104 and 123 to tag level. However I have been able to parse the complete field value, but unable to extract list of tags within each dataset.

Can anyone help me achieve that?

Regards,
Adnan Sohail

chhil

unread,
Oct 1, 2019, 6:35:53 AM10/1/19
to jpos-...@googlegroups.com
There is a tlvlist object that jpos provides, use it. 

-chhil

--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/e22eb86b-5384-428f-bf18-a28915b4c70b%40googlegroups.com.

Adnan Sohail

unread,
Oct 1, 2019, 7:13:07 AM10/1/19
to jPOS Users
I have tried using it but its unable to parse data sets of a BER TLV. For example, while parsing Visa Field-55 with value [01005E9F3303E02080950500000000009F3704A5CC06CF9F100706010A03A0B0009F26080562599501ED00039F3602010C82025C009F3704A5CC06CF9F3704A5CC06CF9F3704A5CC06CF9F02060000000010005F2A0208409F0306000000000000] using below code, I am getting below exception:

Can you please what is wrong I am doing in below Code Snippet:

TLVList list = new TLVList();

list.unpack(ISOUtil.hex2byte(fieldValue));

List<TLVMsg> tags = list.getTags();


for (TLVMsg tlv : tags) {

lgr.debug("Value of FieldID-{}, Tag [{}], Value [{}] is parsed as: ", () -> fieldId, () -> tlv.getTag(), () -> ISOUtil.byte2hex(tlv.getValue()));

}


Exception:

java.lang.NegativeArraySizeException: -1342136538

at org.jpos.tlv.TLVList.getTLVMsg(TLVList.java:369) ~[jpos-2.1.3.jar:2.1.3]

at org.jpos.tlv.TLVList.unpack(TLVList.java:193) ~[jpos-2.1.3.jar:2.1.3]

at org.jpos.tlv.TLVList.unpack(TLVList.java:163) ~[jpos-2.1.3.jar:2.1.3]


--
Adnan 


On Tuesday, 1 October 2019 15:35:53 UTC+5, chhil wrote:
There is a tlvlist object that jpos provides, use it. 

-chhil

On Tue, Oct 1, 2019, 3:35 PM Adnan Sohail <adnaan...@gmail.com> wrote:
Hi,

I am getting problem while parsing Visa BER TLV field like Field 55, 104 and 123 to tag level. However I have been able to parse the complete field value, but unable to extract list of tags within each dataset.

Can anyone help me achieve that?

Regards,
Adnan Sohail

--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-...@googlegroups.com.

chhil

unread,
Oct 1, 2019, 9:21:47 AM10/1/19
to jpos-...@googlegroups.com
Your data does not appear to be standard ber tlv.
-chhil

To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/7cbbc0c2-fb99-4bbf-9bb4-ff4ca4f73495%40googlegroups.com.

chhil

unread,
Oct 1, 2019, 9:33:43 AM10/1/19
to jpos-...@googlegroups.com
If I remove the data upto 9F and process it, it works. You will need to read your spec to see what that additional data is. BTW I am not TLV expert, just hacking your data).


        String fieldValue = "9F3303E02080950500000000009F3704A5CC06CF9F100706010A03A0B0009F26080562599501ED00039F3602010C82025C009F3704A5CC06CF9F3704A5CC06CF9F3704A5CC06CF9F02060000000010005F2A0208409F0306000000000000";
        list.unpack(ISOUtil.hex2byte(fieldValue));

        list.dump(System.out, "");

Output
<tlvlist>
   <tag id='9f33' value='E02080' />
   <tag id='95' value='0000000000' />
   <tag id='9f37' value='A5CC06CF' />
   <tag id='9f10' value='06010A03A0B000' />
   <tag id='9f26' value='0562599501ED0003' />
   <tag id='9f36' value='010C' />
   <tag id='82' value='5C00' />
   <tag id='9f37' value='A5CC06CF' />
   <tag id='9f37' value='A5CC06CF' />
   <tag id='9f37' value='A5CC06CF' />
   <tag id='9f02' value='000000001000' />
   <tag id='5f2a' value='0840' />
   <tag id='9f03' value='000000000000' />
</tlvlist>

To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/7cbbc0c2-fb99-4bbf-9bb4-ff4ca4f73495%40googlegroups.com.

Adnan Sohail

unread,
Oct 3, 2019, 7:28:46 AM10/3/19
to jPOS Users
Thanks chhil,

I figured the same problem. I guess I need to parse Data Set IDs my self and then TLVs within a DataSet will be parsed using TLVList.

--
Adnan Sohail

Chhil

unread,
Oct 3, 2019, 7:31:00 AM10/3/19
to jpos-...@googlegroups.com

In another thread that you had created, a user has provided a packager that handles data set id. Though I am not sure how that will work for multiple data set ids.

 

-chhil

To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/5769f554-31ac-4722-8441-c19745c0afaf%40googlegroups.com.

 

Mark S

unread,
Oct 6, 2019, 11:30:20 PM10/6/19
to jPOS Users
I would check the spec first to make sure where the TLV data in a Visa message actually starts.

-- 
Mark

From: jpos-...@googlegroups.com <jpos-...@googlegroups.com> on behalf of Adnan Sohail <adnaan...@gmail.com>
Sent: Thursday, October 3, 2019 12:28:46 PM
To: jPOS Users <jpos-...@googlegroups.com>

Subject: Re: [jpos-users] How to parse a Visa BER TLV field to tag level and define field packager for it?
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/5769f554-31ac-4722-8441-c19745c0afaf%40googlegroups.com.

Adnan Sohail

unread,
Oct 7, 2019, 8:25:27 AM10/7/19
to jPOS Users
Although I haven't tried that packager but I am not sure whether that packager would work. Because a BER TLV field contains as many datasets as possible and each data set can contain multiple TLVs. So, I doubt that packager would work for it.

Anyhow, I have figured out a solution already with little manual work.


Kogan Moonsamy

unread,
Oct 8, 2019, 2:22:32 AM10/8/19
to jpos-...@googlegroups.com
Hi,

As Chhil mentioned a few mails above, I have replied to your other post with part of my packager. I have just implemented a VISA SMS switch into production, so it works.

As for your implementation of the TLVList, its probably not working because your packager is incorrect.

Regards
Kogan

To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/08fd0f50-0dea-4d09-be32-9dfdf372ff3c%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages