JPOS & HSM Translate a PIN

1,197 views
Skip to first unread message

Annisah S

unread,
Aug 30, 2015, 5:14:22 AM8/30/15
to jPOS Users
Hello,


Just wondering for some other people who already done with JPOS and HSM could be share here.
i just imagine the process doing a PIN translate is :

1. Terminal sending a PIN block over wire
2. Host received the transaction from terminal
3. Host request to HSM to do a translation
4. Host receive a new encrypted PIN block from HSM
5. Then Host sending a transaction into another host/simulator.
6. Host receive a response from simulator then
7. Host sending back to terminal for the result


what i want to ask is, how to implement using JPOS in a proper way? 
can we doing just only simply like code below? 



Translate.Java

.
.
.
public int prepare(long id, Serializable context) {
Context ctx = (Context) o;
HSMChannel channel = new HSMChannel();
channel.setPackager(new DummyPackager());
Properties props = new Properties ();
props.put ("basepath", "file:schema/hsm-");
props.put ("host", "localhost");
props.put ("port", "5555");
Configuration c = new SimpleConfiguration (props);
channel.setConfiguration(c);
channel.connect();
FSDISOMsg msg = (FSDISOMsg) channel.createMsg();
msg.set("command","E123");
msg.set("KK", "00");
channel.send(msg);
FSDISOMsg rec = (FSDISOMsg) channel.receive();
                 ctx.put("HSMRes", rec, true);
}
.
.
.



RemoteJava.java


.
.
.
public int prepare(long id, Serializable context) {
Context ctx = (Context) o;
FSDISOMsg fsd = (FSDISOMsg) ctx.get("HSMRes");
ISOMsg m = (ISOMsg) ctx.get("INCOMING");

QMUX mux = (QMUX) NameRegistrar.get("muxName");
m.set(52,fsd.get("PINBLOCK"))
ISOMsg r = mux.request(m,100000);


}
.
.
.




Best Regards





chhil

unread,
Aug 30, 2015, 6:26:02 AM8/30/15
to jPOS Users

Your process looks good.
If your hsm supports echoing back of fields and is not a constant  , use a channel adaptor and mux for the hsm with the unique echoed field as the mux key.
Use a mux to send and receive the message to and from the hsm.

-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
 
Join us in IRC at http://webchat.freenode.net/?channels=jpos
 
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
---
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/f6bf04ae-d14b-400f-8363-7e2aadf03389%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

carls...@apollo.com.ph

unread,
Nov 20, 2017, 4:25:13 AM11/20/17
to jPOS Users
Hello,

I'm also into PIN Translation to Thales HSM but having problems with getting the correct response for a request. I've tried to assign "message-trailer" as key but the application errors on runtime and <key> should be numeric. Is there a way to assign a <key></key> for FSDISOMsg or do I need to change my approach on handing HSM communication?

[File] 21_hsm_channel.xml : 

<?xml version="1.0" encoding="UTF-8"?>
<channel-adaptor class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2" name="HSMChannel">
<channel class="org.jpos.iso.channel.FSDChannel" logger="Q2"
packager="org.jpos.iso.packager.DummyPackager">

<property name="schema" value="file:cfg/hsm-resp-" />
<property name="packager-logger" value="Q2" />
<property name="host" value="192.168.xxx.xxx" />
<property name="port" value="xxxxx" />
</channel>
<in>hsm-send</in>
<out>hsm-receive</out>

</channel-adaptor>



====================================================================================================

[File] 31_hsm_mux.xml : 

<?xml version="1.0" encoding="UTF-8"?>
<channel-adaptor class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2" name="HSMChannel">
<channel class="org.jpos.iso.channel.FSDChannel" logger="Q2"
packager="org.jpos.iso.packager.DummyPackager">

<property name="schema" value="file:cfg/hsm-resp-" />
<property name="packager-logger" value="Q2" />
<property name="host" value="192.168.13.62" />
<property name="port" value="5100" />
</channel>
<in>hsm-send</in>
<out>hsm-receive</out>

</channel-adaptor>



====================================================================================================

[File] hsm-CA.xml :

<?xml version="1.0" encoding="UTF-8"?>
<schema id="CA">
<field id="source-tpk" type="A" length="33" />
<field id="destination-zpk" type="A" length="33" />
<field id="maximum-pin-length" type="N" length="2" />
<field id="source-pin-block" type="A" length="16" />
<field id="source-pin-block-format-code" type="N" length="2" />
<field id="destination-pin-block-format-code" type="N" length="2" />
<field id="account-number" type="N" length="12" />
<field id="end-message-delimeter" type="C" length="1" />
<field id="message-trailer" type="A" length="32" />
</schema>


Thanks in advance.

Best Regards,
Carl Sta.Ana

chhil

unread,
Nov 20, 2017, 8:02:02 AM11/20/17
to jpos-...@googlegroups.com
Please could you provide the mux definition xml , you seemed to have copied the channel one in your post.
Also could you provide the exact exception.

QMux.getKey does not have a check for a numeric Key, so please provide the exception stacktrace and log if possible.

-chhil




To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/3dd14f43-2d87-49fb-8720-d0e792269fb7%40googlegroups.com.

carls...@apollo.com.ph

unread,
Dec 7, 2017, 6:24:15 AM12/7/17
to jPOS Users
Hi, Sorry about that. Please see the proper xml below:

[File] 31_hsm_mux.xml : 

<?xml version="1.0" encoding="UTF-8"?>
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="HSMMux">
<in>hsm-receive</in>
<out>hsm-send</out>
</mux>


The program will not start if we will add <key>message-trailer</key> to the xml file.

Regards,
Carl Sta.Ana
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.

chhil

unread,
Dec 7, 2017, 6:51:20 AM12/7/17
to jpos-...@googlegroups.com
I use the following definition in prod.
​​

<?xml version="1.0" ?>

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="thales-mux">
 <in>thales-receive</in>
 <out>thales-send</out>
 <key>stan</key>
 <ready>thales-adaptor-channel.ready</ready> 
 <unhandled>thales-unhandled</unhandled>
</mux>

My request is based off the schema
<?xml version="1.0" encoding="UTF-8"?>
<schema>
<field id="stan" type="N" length="4"/>
 <field id="command" type="A" length="2" key="true" />
</schema>
And response is based off schema

<schema>
<field id="stan" type="N" length="4" />
 <field id="response" type="A" length="2" key="true" />
 <field id="error"    type="A" length="2" />
</schema>

So the stan (basically the header) is available in both request and response for matching.

If the program doesn't start you will need to provide logs with exception stack traces. The mux has no idea where that field occurs, except it knows the name and will grab it from the request/response and match, so being header or trailer does not matter. 
Please provide jpos version you are using too.
I cannot speculate on what you are doing wrong. One thing that you can try is pull the message-trailer definition on base file that has key as true i.e. since its going to be in all the keyed files, you might as well put it in one place, like the error in my base response schema.

-chhil



To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.

carls...@apollo.com.ph

unread,
Dec 7, 2017, 10:46:17 PM12/7/17
to jPOS Users
Hi,

I've copied your exact implementation and assigned "stan" as key. Please see the log file. This was happened on startup, the key "stan" stated as NumberFormatException. jPOS version we have is 1.8.1

<log realm="Q2.system" at="Fri Dec 08 11:51:55 PHT 2017.549">
  <info>
    deploy:/var/lib/tomcat6/Q2/31_hsm_mux.xml
  </info>
</log>
<log realm="org.jpos.q2.iso.QMUX" at="Fri Dec 08 11:51:55 PHT 2017.553">
  <warn>
    init
    <iso-exception>
      java.lang.NumberFormatException: For input string: "stan"
      <nested-exception>
      java.lang.NumberFormatException: For input string: "stan"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
at org.jpos.q2.iso.QMUX.toIntArray(QMUX.java:383)
at org.jpos.q2.iso.QMUX.initService(QMUX.java:67)
at org.jpos.q2.QBeanSupport.init(QBeanSupport.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
at sun.reflect.GeneratedMethodAccessor202.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:112)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:46)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)
at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.jpos.q2.QFactory.createQBean(QFactory.java:112)
at org.jpos.q2.Q2.deploy(Q2.java:425)
at org.jpos.q2.Q2.deploy(Q2.java:255)
at org.jpos.q2.Q2.run(Q2.java:164)
at java.lang.Thread.run(Thread.java:724)
      </nested-exception>
      org.jpos.core.ConfigurationException: java.lang.NumberFormatException: For input string: "stan" (java.lang.NumberFormatException: For input string: "stan")
at org.jpos.q2.iso.QMUX.toIntArray(QMUX.java:386)
at org.jpos.q2.iso.QMUX.initService(QMUX.java:67)
at org.jpos.q2.QBeanSupport.init(QBeanSupport.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
at sun.reflect.GeneratedMethodAccessor202.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:112)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:46)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)
at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.jpos.q2.QFactory.createQBean(QFactory.java:112)
at org.jpos.q2.Q2.deploy(Q2.java:425)
at org.jpos.q2.Q2.deploy(Q2.java:255)
at org.jpos.q2.Q2.run(Q2.java:164)
at java.lang.Thread.run(Thread.java:724)
Nested:java.lang.NumberFormatException: For input string: "stan"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
at org.jpos.q2.iso.QMUX.toIntArray(QMUX.java:383)
at org.jpos.q2.iso.QMUX.initService(QMUX.java:67)
at org.jpos.q2.QBeanSupport.init(QBeanSupport.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
at sun.reflect.GeneratedMethodAccessor202.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:112)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:46)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)
at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.jpos.q2.QFactory.createQBean(QFactory.java:112)
at org.jpos.q2.Q2.deploy(Q2.java:425)
at org.jpos.q2.Q2.deploy(Q2.java:255)
at org.jpos.q2.Q2.run(Q2.java:164)
at java.lang.Thread.run(Thread.java:724)
    </iso-exception>
  </warn>
</log>


Regards,
Carl Sta.Ana

chhil

unread,
Dec 8, 2017, 12:08:19 AM12/8/17
to jpos-...@googlegroups.com
In order of priority:
1. Please use a more current jpos.
2. name your header field with an int, call it 255 or 42 or any int you like. <key>message-trailer</key> becomes <key>255</key>, rename the field message-trailer in your schema with 255.
3. Add extend the Qmux with your own Qmux that handles what the newer Qmux file does.

-chhil

To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages