ISO8583 Unpack Issue - java

How I will unpack ISO message using JPOS library in java?
here is the sample ISO message.
0800. ..............1224190516424997001003
Sample Hex Dump:
30 38 30 30 82 20 01 00 00 00 00 00 04 00 00 00 0800. ..........
00 00 00 00 31 32 32 34 31 39 30 35 31 36 34 32 ....122419051642
34 39 39 37 30 30 31 30 30 33 4997001003
Please note that I have packed this above message using jpos library and bit map format is org.jpos.iso.IFB_BITMAP

If you want to unpack from the data you shared, you just need to use the same packager you used to pack the iso message to unpack what you generated.
You can instantiate a packager with the same parameters you used to pack the message and then:
ISOPackager pacakger = ....; //initialize the same way as used to pack
ISOMsg m = new ISOMsg();
//here we are using the hexdump since the plain data has non printable chars, because of the binary bitmap
byte[] packed = ISOUtil.decodeHexDump(
"30 38 30 30 82 20 01 00 00 00 00 00 04 00 00 00 0800. ..........\n" +
"00 00 00 00 31 32 32 34 31 39 30 35 31 36 34 32 ....122419051642\n" +
"34 39 39 37 30 30 31 30 30 33 4997001003");
packager.unpack(m, packed);
Alternatively you can
ISOMsg m = new ISOMsg();
m.setPackager(packager);
m.unpack(packed);
Provided that packed and packager variables are initialized in the ssame way as above.
And you will have the iso message content in the m variable.

Related

Why Java GzipOutputStream always write two bytes 03 00 before the trailer if flush() is called first then closed?

I found that when using Java.util.zip.GzipOutputStream, when I called flush() first then close(). The deflator always produce two bytes ('00' and '03' in hex) before writing the trailer. What does these two bytes mean? Why flush() does not flush all bytes in the compressor? I have already set the stream syncFlush to true. (In my use case I need to force flush the stream)
This is the test code I write.
File file = new File("gtest.gz");
OutputStream out = new FileOutputStream(file);
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(out, true);
gzipOutputStream.write("Each gzip file generated by JAVA GzipOutputStream has byte '0003' before Trailer"
.getBytes());
gzipOutputStream.flush();
gzipOutputStream.close();
And I run hexdump -C gtest.gz get
00000000 1f 8b 08 00 00 00 00 00 00 00 72 4d 4c ce 50 48 |..........rML.PH|
00000010 af ca 2c 50 48 cb cc 49 55 48 4f cd 4b 2d 4a 2c |..,PH..IUHO.K-J,|
00000020 49 4d 51 48 aa 54 f0 72 0c 73 54 70 07 ca f9 97 |IMQH.T.r.sTp....|
00000030 96 14 94 96 04 97 14 a5 26 e6 2a 64 24 16 03 25 |........&.*d$..%|
00000040 4b 52 15 d4 0d 0c 0c 8c d5 15 92 52 d3 f2 8b 52 |KR.........R...R|
00000050 15 42 8a 12 81 06 14 01 00 00 00 ff ff 03 00 96 |.B..............|
00000060 ef 3b 5d 50 00 00 00 |.;]P...|
00000067
The last 8 bytes are trailer of Gzip and the two bytes before '03' '00' will always be produced whatever content I change.

Port 0 in DIIOP_IOR.TXT, how do I change it?

I am trying to login remotely into Domino with standalone Java program.
I have ncso.jar (and TrustedCerts.class) in classpath.
The DIIOP_IOR.TXT file is generated by the diiop task. If I copy the file contents directly into my program and try creating the session like this:
String ior = "IOR:....." // 404 bytes
Session session = NotesFactory.createSessionWithIOR(ior, "username", "password");
the result is:
org.omg.CORBA.COMM_FAILURE: java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine Host: poseidon.heeros.com Port: 0 vmcid: 0x0 minor code: 1 completed: No
The server name is valid but port 0 seems odd. I tried an online decoder at http://www2.parc.com/istl/projects/ILU/parseIOR/ and here is the result:
object key is <#048525651a-ec68-106c-eee0-007e2d2233b5#00LotusNOI#01#00#01>;
no trustworthy most-specific-type info; unrecognized ORB type;
reachable with IIOP 1.1 at host "poseidon.heeros.com", port 0
...which seems to confirm that the port is incorrect. I have specified the server URL in Internet Sites with an IIOP Site document but there is no field for port there.
Questions:
Where do I set the port that appears in diiop_ior.txt?
Which port should I specify? (I'm guessing 1352)
EDIT
Here is the result of tell diiop show config on server:
Dump of Domino IIOP (DIIOP) Configuration Settings
Full Server Name: CN=Afrodite/O=Heeros
Common Server Name: Afrodite/Heeros
Refresh Interval: 3 minutes
Host Full Name: poseidon.heeros.com
Host Short Name: poseidon
Host Address: 10.163.0.146
Public Host Name/Address: poseidon.heeros.com
TCP Port: 0 Disabled
SSL Port: 63149 Enabled
Initial Net Timeout: 120 seconds
Session Timeout: 60 minutes
Client Session Timeout: 62 minutes
Allow Ambiguous Names: True
Web Name Authentic: False
User Lookup View: ($Users)
Allow Database Browsing: False
Internet Sites: Enabled
Internet Site Name: Heeros
Site Config Loaded from: Domino IIOP and Web Internet Site documents
Site is Default: False
Site Public Host Name/Address: poseidon.heeros.com
Site IOR File: D:\Lotus\Domino\data\domino\html\diiop_ior.txt
Site SSL Key File: D:\Lotus\Domino\data\heeros.kyr
Site Java Key File: D:\Lotus\Domino\data\domino\java\TrustedCerts.class
Site TCP Name/Password Allowed: False
Site TCP Anonymous Allowed: False
Site SSL Name/Password Allowed: True
Site SSL Anonymous Allowed: True
Site Multi-Server Session Authentication: Enabled
Site Multi-Server Session Configuration: LtpaToken
Single Server Cookies: Disabled
It seems that the correct port number is 63148. It must be specified in Server Document at Ports --> Internet Ports --> DIIOP as "TCP/IP port number".
Additionally, in the IIOP Site document, the TCP Authentication must be allowed.
In my experience DIIOP doesn't use SSL/TLS at all. Only the DIIOP_IOR.TXT is downloaded via SSL/TLS. Capture your network traffic with Wireshark or something similar and monitor: port 63148 or port 63149. #lauri-laanti : Could you please test in your environment if the connection is encrypted with wireshark?
Wireshark Ourput: GIOP createSession with Username and Password (Blanked with X)
0000 00 50 56 69 f5 2b 00 50 56 c0 00 02 08 00 45 00 .PVi.+.PV.....E.
0010 00 c0 0d 06 40 00 80 06 bb ca c0 a8 58 01 c0 a8 ....#.......X...
0020 58 15 d2 e0 f6 ac ef b6 47 e8 13 10 53 10 50 18 X.......G...S.P.
0030 01 00 29 bb 00 00 47 49 4f 50 01 00 00 00 00 00 ..)...GIOP......
0040 00 8c 00 00 00 00 00 00 00 05 01 00 00 00 00 00 ................
0050 00 31 04 38 35 32 35 36 35 31 61 2d 65 63 36 38 .1.8525651a-ec68
0060 2d 31 30 36 63 2d 65 65 65 30 2d 30 30 37 65 32 -106c-eee0-007e2
0070 64 32 32 33 33 62 35 00 4c 6f 74 75 73 4e 4f 49 d2233b5.LotusNOI
0080 01 00 01 00 00 00 00 00 00 0e 63 72 65 61 74 65 ..........create
0090 53 65 73 73 69 6f 6e 00 00 00 00 00 00 00 00 00 Session.........
00a0 00 01 00 00 00 00 00 00 00 01 00 00 00 0f 00 00 ................
00b0 00 06 00 61 00 64 00 6d 00 69 00 6e 00 00 00 00 ...a.d.m.i.n....
00c0 00 06 00 XX XX XX XX XX XX XX XX XX XX 00 ...XXXXXXXXXX.
Java Code used:
_diiop_args = new String[]{"-ORBEnableSSLSecurity", "-HTTPEnableSSLSecurity"};
String ior = NotesFactory.getIOR(_diiop_host + ":" + _diiop_port,
_diiop_args, _user_name, _user_pass);
_session = NotesFactory.createSessionWithIOR(ior, _user_name, _user_pass);

ISO 8583 Messge -- Bitmap not getting parsed at switch end using jpos

I'm trying to build a simulator in java using jpos.
However i'm able to send values to my switch but as per switch vendor they are not receiving proper values at tcpip level due to which the conversion is failing.
Please find the below log generated at my end during sending the data before socket stream.
Request sent to server
Clear String:
0200723A4401A8E19008166070658525235400011000000000150000020110150412345
61300000201020160119010680019206900000376070658525235400=24075203640000000000
428313349275RGB12345RGB12345 NPCI R-TECH GOREGAON(E)MUMBAI MHIN
022051005ATM010580050099935698BC03BEBAD073D9021121412220033000400085
Message Length : 291
Sent Hex Dump:
0000 30 32 30 30 37 32 33 41 34 34 30 31 41 38 45 31 0200723A4401A8E1
0010 39 30 30 38 31 36 36 30 37 30 36 35 38 35 32 35 9008166070658525
0020 32 33 35 34 30 30 30 31 31 30 30 30 30 30 30 30 2354000110000000
0030 30 30 31 35 30 30 30 30 30 32 30 31 31 30 31 35 0015000002011015
0040 30 34 31 32 33 34 35 36 31 33 30 30 30 30 30 32 0412345613000002
0050 30 31 30 32 30 31 36 30 31 31 39 30 31 30 36 38 0102016011901068
0060 30 30 31 39 32 30 36 39 30 30 30 30 30 33 37 36 0019206900000376
0070 30 37 30 36 35 38 35 32 35 32 33 35 34 30 30 3D 070658525235400=
0080 32 34 30 37 35 32 30 33 36 34 30 30 30 30 30 30 2407520364000000
0090 30 30 30 30 34 32 38 33 31 33 33 34 39 32 37 35 0000428313349275
00a0 52 47 42 31 32 33 34 35 52 47 42 31 32 33 34 35 RGB12345RGB12345
00b0 20 20 20 20 20 20 20 4E 50 43 49 20 52 2D 54 45 NPCI R-TE
00c0 43 48 20 47 4F 52 45 47 41 4F 4E 28 45 29 4D 55 CH GOREGAON(E)MU
00d0 4D 42 41 49 20 20 20 20 20 20 20 4D 48 49 4E 30 MBAI MHIN0
00e0 32 32 30 35 31 30 30 35 41 54 4D 30 31 30 35 38 22051005ATM01058
00f0 30 30 35 30 30 39 39 39 33 35 36 39 38 42 43 30 0050099935698BC0
0100 33 42 45 42 41 44 30 37 33 44 39 30 32 31 31 32 3BEBAD073D902112
0110 31 34 31 32 32 32 30 30 33 33 30 30 30 34 30 30 1412220033000400
0120 30 38 35 085
As per my switch vendor they should receive the value of bitmap in proper sequence and not as a HEX Value.
Please find the below sample line given by my switch vendor.
0000 30 32 30 30 72 3A 44 01 A8 E1 0200r:D¨á <--
Can any one please assist on this regards.
Please find my below code:
GenericPackager packager = new GenericPackager("basic.xml");
// Create ISO Message
ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.setMTI("0200");
isoMsg.set(2, "6070658525235400");
isoMsg.set(3, "11000");
isoMsg.set(4, "000000150000");
isoMsg.set(7, "0201101504");
isoMsg.set(11, "123456");
isoMsg.set(12, "130000");
isoMsg.set(13, "0201" );
isoMsg.set(15, "0201");
isoMsg.set(18, "6011");
isoMsg.set(22, "901");
// isoMsg.set(25, "00");
isoMsg.set(32, "800192");
isoMsg.set(33, "900000");
isoMsg.set(35, "6070658525235400=24075203640000000000");
isoMsg.set(37, "428313349275");
isoMsg.set(41 , "RGB12345");
isoMsg.set(42 , "RGB12345 ");
isoMsg.set(43 , "NPCI R-TECH GOREGAON(E)MUMBAI MHIN");
isoMsg.set(48 , "051005ATM0105800500999");
isoMsg.set(49 , "356");
isoMsg.set(52 , "98BC03BEBAD073D9");
isoMsg.set(61 , "121412220033000400085");
// print the DE list
logISOMsg(isoMsg);
byte[] send_PackedRequestData = isoMsg.pack();
:
:
outStream = new BufferedOutputStream(connection.getOutputStream());
outStream.write(send_PackedRequestData);
outStream.flush();
This question is flawed, it's not possible to help without studying the specs.
In addition, I hope the card you show there is a test card, otherwise, please notify the issuer to block it.
That said, you're probably using IFA_BITMAP instead of IFB_BITMAP, but that change will just solve your bitmap generation, you probably have many other fields badly configured.

How to get SSL Domino Session via DIIOP

I try to connect to a Domino Server with a remote Java application started from Eclipse. The Domino Server allows SSL connections only.
I try to get the session with the following code.
String[] arg = new String[1];
arg[0] = "-ORBEnableSSLSecurity";
String IOR = NotesFactory.getIOR(DOMINO_SERVER);
session = NotesFactory.createSessionWithIOR(IOR);
I get the following error message:
Could not get IOR from Domino Server: http:///diiop_ior.txt
I also checked if the URL works in a browser. If I put the URL in a browser I get the correct response from the server.
The TrustedCert.class from the Domino server is included in my Eclipse project.
Here some configuration details from the "diiopcfg.txt":
TCP Port: 0 Disabled
SSL Port: 63149 Enabled
Site TCP Name/Password Allowed: True
Site TCP Anonymous Allowed: False
Site SSL Name/Password Allowed: True
Site SSL Anonymous Allowed: False
Site Multi-Server Session Authentication: Disabled
[Update]
Enabled TCP Port 63148, now I get a session but cannot open a database. Error message NotesException: Database open failed () Only when I access the port directly I get a session object.
[Update 2]
Get the session now. Can't open the database.
Error message: NotesException: Database ... has not been opened yet.
If I use the "open" method of the Database object => Error message: Database open failed()
Database db = session.getDatabase(DOMINO_SERVER, DOMINO_DATABASE);
db.open();
ACL is correct, Maximum internet name and password = Reader
Any idea why the database could not be opened. Tried another database with the same result.
Try the following to connect to SSL.
String args[] = new String[1];
args[0] = "-ORBEnableSSLSecurity";
Session s = NotesFactory.createSession(host, args, user, pwd);
Another method to connect:
String args[] = new String[1];
args[0] = "-HTTPEnableSSLSecurity";
String ior = NotesFactory.getIOR(host,args);
s = NotesFactory.createSessionWithIOR(ior, user, pwd);
The variable host should just be the host name and nothing else. Your diiop_ior.txt needs to be visible on SSL though (so check that first).
Alternatively you can try accessing the port 63148 directly. For example.
s = NotesFactory.createSession( "server:63148", user, pwd);
But this can move depending on server configuration.
Lastly you can pull the DIIOP_IOR.txt and use it directly. Same issue as previous alternative though.
Sorry, this answer is almost a duplicate to this answer but is so important, that I think the text needs to be quoted in this post.
In my experience DIIOP doesn't use SSL/TLS at all. Only the DIIOP_IOR.TXT is downloaded via SSL/TLS. Capture your network traffic with Wireshark or something similar and monitor: port 63148 or port 63149. #michael-schlömp : Could you please test in your environment if the connection is encrypted with wireshark?
Wireshark Ourput: GIOP createSession with Username and Password (Blanked with X)
0000 00 50 56 69 f5 2b 00 50 56 c0 00 02 08 00 45 00 .PVi.+.PV.....E.
0010 00 c0 0d 06 40 00 80 06 bb ca c0 a8 58 01 c0 a8 ....#.......X...
0020 58 15 d2 e0 f6 ac ef b6 47 e8 13 10 53 10 50 18 X.......G...S.P.
0030 01 00 29 bb 00 00 47 49 4f 50 01 00 00 00 00 00 ..)...GIOP......
0040 00 8c 00 00 00 00 00 00 00 05 01 00 00 00 00 00 ................
0050 00 31 04 38 35 32 35 36 35 31 61 2d 65 63 36 38 .1.8525651a-ec68
0060 2d 31 30 36 63 2d 65 65 65 30 2d 30 30 37 65 32 -106c-eee0-007e2
0070 64 32 32 33 33 62 35 00 4c 6f 74 75 73 4e 4f 49 d2233b5.LotusNOI
0080 01 00 01 00 00 00 00 00 00 0e 63 72 65 61 74 65 ..........create
0090 53 65 73 73 69 6f 6e 00 00 00 00 00 00 00 00 00 Session.........
00a0 00 01 00 00 00 00 00 00 00 01 00 00 00 0f 00 00 ................
00b0 00 06 00 61 00 64 00 6d 00 69 00 6e 00 00 00 00 ...a.d.m.i.n....
00c0 00 06 00 XX XX XX XX XX XX XX XX XX XX 00 ...XXXXXXXXXX.
Java Code used:
_diiop_args = new String[]{"-ORBEnableSSLSecurity", "-HTTPEnableSSLSecurity"};
String ior = NotesFactory.getIOR(_diiop_host + ":" + _diiop_port,
_diiop_args, _user_name, _user_pass);
_session = NotesFactory.createSessionWithIOR(ior, _user_name, _user_pass);
If you download and analyse the DIIOP_IOR.TXT with the ILU IOR Parser you will see there is no SSL/TLS information nor port in the IOR File.
SSL/TLS only version:
object key is <#048525651a-ec68-106c-eee0-007e2d2233b5#00LotusNOI#01#00#01>;
no trustworthy most-specific-type info; unrecognized ORB type;
reachable with IIOP 1.1 at host "testdom01.jjtest.site", port 0
SSL/TLS and non SSL/TLS version:
object key is <#048525651a-ec68-106c-eee0-007e2d2233b5#00LotusNOI#01#00#01>;
no trustworthy most-specific-type info; unrecognized ORB type;
reachable with IIOP 1.1 at host "testdom01.jjtest.site", port 63148

reading unformatted data from socket in java

I have a server socket application which listens on particular ip and port. Then I have client socket which reads input from server and give response.
But my problem is that server do not give formatted line termination characters at the end. so when i use buffered reader readline method it hangs. so how should i read the data send by server.
here server is basically a API(METER).
Here is sample request/response sequence between server and client.
Request: 8/2/2012 3:28:24 PM.60764 (+0.0000 seconds)
53 0D S.
Answer: 8/2/2012 3:28:24 PM.87364 (+0.2656 seconds)
53 50 31 39 35 30 34 37 38 34 0D SP19504784.
Request: 8/2/2012 3:28:24 PM.92064 (+0.0000 seconds)
53 48 0D SH.
Answer: 8/2/2012 3:28:24 PM.02964 (+0.1094 seconds)
53 48 0D SH.
Request: 8/2/2012 3:28:24 PM.02964 (+0.0000 seconds)
53 0D S.
Answer: 8/2/2012 3:28:24 PM.13964 (+0.1094 seconds)
53 50 31 39 35 30 34 37 38 34 0D SP19504784.
Request: 8/2/2012 3:28:24 PM.20164 (+0.0000 seconds)
53 48 0D SH.
Answer: 8/2/2012 3:28:24 PM.31164 (+0.1094 seconds)
53 48 0D SH.
Request: 8/2/2012 3:28:24 PM.31164 (+0.0000 seconds)
80 ?
Answer: 8/2/2012 3:28:24 PM.46764 (+0.1563 seconds)
FC ü
Request: 8/2/2012 3:28:24 PM.46764 (+0.0000 seconds)
F1 ñ
Answer: 8/2/2012 3:28:25 PM.84264 (+0.3750 seconds)
8A 31 39 35 30 34 37 38 34 88 ?19504784?
Request: 8/2/2012 3:28:25 PM.90464 (+0.0000 seconds)
F1 ñ
Answer: 8/2/2012 3:28:25 PM.02964 (+0.1250 seconds)
8A 01 41 32 4D 47 30 31 42 B1 ?.A2MG01B±
Request: 8/2/2012 3:28:26 PM.81164 (+0.0000 seconds)
CA F0 00 00 00 00 00 00 00 3A Êð.......:
Answer: 8/2/2012 3:28:26 PM.02964 (+0.2188 seconds)
C4 00 05 00 C9 31 36 38 C4 B7 B7 3F 2E C9 74 5A Ä...É168Ä··?.ÉtZ
02 00 02 00 FE FC C9 A1 0D 07 00 FB FF FD FC C9 ....þüÉ¡...ûÿýüÉ
1E 0E FD FF FE FF FD FC C9 B8 FE 4E FF FA 01 FF ..ýÿþÿýüɸþNÿú.ÿ
FF B9 D0 F9 F0 3F D0 BF 50 9F ÿ¹Ðùð?пP?
You cannot use readline() if the server doesn't send line endings. However, something in the raw protocol has to indicate when a response is complete. This can be one or more of
a specific character sequence
the response to each command ("Request" in your sample) has a known, fixed length
each response contains the length embedded in it at a fixed offset from the start
You will have to do your own buffering and detect the end of each message yourself. Without a detailed description of the protocol being used, that's about as specific an answer as you can expect.
You could try with one of the read method of BufferedReader, and process any breaks in the data yourself. That's probably the best control you'll have.

Categories

Resources