FSDMsg, how to handle optional fields?

86 views
Skip to first unread message

Dan MacLeod

unread,
Feb 8, 2017, 12:14:25 PM2/8/17
to jPOS Users


Using the sample schema below, I'm trying to use a FSDMsg to send commands to an HSM. My problem comes when I have optional fields defined in the schema. Suppose field3 should only be sent when field1 contains a certain value. When field1 does not contain the required value, I don't want field3 or its separator to be sent. From what I've read, I though adding 'FS' to the field type would do the trick but it doesn't. What is the proper way to define an optional field?

thanks

field1 = 11
field2 = 22
field3 = 33
field4 = 44

For example when field1 contains '11' I want to send 11223344.
When field1 contains XX want to send XX2244

<?xml version="1.0" encoding="UTF-8"?>
<schema id='CW'>
 <field id="field1" type="A"   length="2" />
 <field id="field2" type="A"   length="2" />
 <field id="field3" type="AFS" length="2" />
 <field id="field4" type="A"   length="2" />
</schema>

Alejandro Revilla

unread,
Feb 8, 2017, 1:35:15 PM2/8/17
to jPOS Users
You use field 1 as a key (you add the value `key='true'`)

In your case, you'd have something like:

<schema id='CW'>
  <field id='field1' type='A' key='true' />
</schema>

When field 1 contains the value '11', the FSDMsg will read the rest of the fields from a file with the schema 'CW11' and there you can define your field 2 and 3. 

When field 1 contains 'XX', the schema 'CWXX' will get loaded and there you can define the fields required for that particular message.

Hope this helps, sorry it's tricky


--
--
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+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/be5b199d-2af0-4b7f-8002-b5035d96e4dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan MacLeod

unread,
Feb 8, 2017, 1:48:03 PM2/8/17
to jpos-...@googlegroups.com
Thanks, Is it possible to use two fields as one single key? For example: if field1 = '11' and field2 = '22', would JPos look for a schema called CW1122?
<schema id='CW'>
  <field id='field1' type='A' key='true' />
  <field id='field2' type='A' key='true' />
</schema>

Dan MacLeod
7222 Windy Preserve
Lake Worth, FL 33467

You received this message because you are subscribed to a topic in the Google Groups "jPOS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jpos-users/RnGceVAeqMI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jpos-users+unsubscribe@googlegroups.com.

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

Alejandro Revilla

unread,
Feb 8, 2017, 1:54:12 PM2/8/17
to jpos-...@googlegroups.com
Sure, that's how it works. 

You can have as many key fields as you want. 




To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@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/be5b199d-2af0-4b7f-8002-b5035d96e4dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
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 a topic in the Google Groups "jPOS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jpos-users/RnGceVAeqMI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jpos-users+...@googlegroups.com.
--
--
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 post to this group, send email to jpos-...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

luo...@peacesoft.net

unread,
Jan 25, 2022, 12:22:29 PM1/25/22
to jPOS Users
    Hi Alejandro,

I am trying to do the same with FSDMsg for Thales HSM request. 
Saying that HSM's response A1 will have "Key (under ZMK or TMK or Current BDK)" only if in A0 command having Mode = "1" or "B"


How can we translate this optional field in XML file?

Thanks a lot,

murtuza chhil

unread,
Feb 7, 2022, 8:13:38 PM2/7/22
to jPOS Users
FSDMsg does not support optional fields. In your case it needs to be aware of the some fields in the request to parse the response correctly.

However you can try the following....

If you and your thales are setup to send a header in the request that thales always echoes back you may be able to set it up.
I use the header field as a counter which is used to match requests to response in the mux.

Say you have configured a header of 8 bytes. 
You can set the header as 1 fixed char (header1_mode) for mode and 7 fixed characters of arbitrary data (header2_arbitary). 
Then key off the header1_mode to go the the appropriate schema for parsing mode 0 or 1.

I have not implemented this but looks feasible.

Alternatively, you can treat the whole response as a single string. You have the request, use that to create the appropriate FSDMsg by passing in the appropriate schema based on the mode in your request.


In the future please start a new thread and not open a thread that's about 5 years old.



-chhil
Reply all
Reply to author
Forward
0 new messages