How to get a CardHolder Name - java

I am trying to read a smart card and i have been able to get some data from the smart card. The issue i am facing now is how to get the CardHolder name from the smart card.
i have
if(emv_is_tag_present(0x5F20) >=0){
tagDataLength = emv_get_tag_data(0x5F20, tagData, tagData.length);
if(debug)Log.d(APP_TAG, "Carder "+ tagDataLength);
appState.trans.setuserName(StringUtil.toString(AppUtil.removeTailF(ByteUtil.bcdToAscii(tagData,0, tagDataLength))));
}
I do not really know the format to use in getting this field from the card while trying to use 5F20 Cardholder Name Indicates cardholder name according to ISO 7813 Card ans 2-26 '70' or '77' 2 26 primitive which i got from here
This is the output i am getting 3030303030333830D160222101..but, whenever i try to convert that into a String...it gives back 00000380Ñ`"! which is not really the name of the Cardholder.
Reading through the document (which link is posted there), i am not sure if i am using the correct format in getting my data. cos, in the document, i have ans 2-26. I do not really understand what it means.

Tag 5F20 - CARD HOLDER NAME, if CARD returning the value of this tag, value will be hex string - Hex value of ASCII characters , what you need to do is to convert value to string and you will get the value personalized in the card.
in the document, i have ans 2-26. I do not really understand what it means.
sometimes we avoid to personalize card holder name inside the card and then we personalize " /" - space followed by / = 2 char. It is the minimum value for tag 5F20 defined in different EMV specification. Max value is 26 therefore 2-26 used for Tag 5F20.
Hope this information will help you..

Related

Using trim() but still didn't get expected output

Ok,i am developing spring MVC based web application, application shows data is list, and i also facilitate filter options to enhanced search functionality, I also remove extra space by using trim(), but what happening now, when user input data in text field and enter the corresponding result will be displayed into the list, but if space added after input, the result will be "NOT FOUND" even i handle the space in javascript too
Java Code which fetches data from database
if (searchParamDTO.getRegNO().trim() != null && !searchParamDTO.getRegNO().trim().equals("") && !searchParamDTO.getRegNO().trim().equals("null")) {
query += " AND UR.REG_UNIQUE_ID = :REG_UNIQUE_ID ";
param.addValue("REG_UNIQUE_ID", searchParamDTO.getRegNO());
}
JavaScript Code: fetches the value in behalf of id
function setSearchParameters() {
regNo = $('#regNo').val().trim();}
i also attached two screenshot with spaces and without spaces
Without space
With space
As #Greg H said you're trimming the string when checking if it's blank, but then adding the raw string to the query which will include any trailing spaces.
Then, this line param.addValue("REG_UNIQUE_ID", searchParamDTO.getRegNO()); should be replaced by param.addValue("REG_UNIQUE_ID", searchParamDTO.getRegNO().trim());

How to convert string to MarketDataIncrementalRefresh in QUICKFIX in Java?

I am working on the Stock and Exchange Markets. I have a situation like : I need to take a string from the log and convert it to "Message" type Object. As per this link I have tried using all the three methods of the "MessageUtils" class in JAVA. But my String is being stripped to a Message class type object with unique tags. But as my string is "MarketDataIncrementalRefresh" type I want each every tag to be present in the Message.
For example : I am providing the following string to "MessageUtils.parse()" method.
8=FIX.4.2|9=00795|35=W|49=TT_PRICE|56=SAP0094X|34=2392|52=20170623-04:41:33.375|55=CL|48=00A0HR00CLZ|10455=CLQ7|167=FUT|207=CME|15=USD|262=MDRQ-751|200=201708|18210=1|387=12292|268=24|269=0|290=1|270=4290|271=33|269=0|290=2|270=4289|271=34|269=0|290=3|270=4288|271=40|269=0|290=4|270=4287|271=38|269=0|290=5|270=4286|271=46|269=0|290=6|270=4285|271=53|269=0|290=7|270=4284|271=46|269=0|290=8|270=4283|271=66|269=0|290=9|270=4282|271=48|269=0|290=10|270=4281|271=64|269=1|290=1|270=4291|271=21|269=1|290=2|270=4292|271=40|269=1|290=3|270=4293|271=48|269=1|290=4|270=4294|271=83|269=1|290=5|270=4295|271=62|269=1|290=6|270=4296|271=46|269=1|290=7|270=4297|271=34|269=1|290=8|270=4298|271=55|269=1|290=9|270=4299|271=31|269=1|290=10|270=4300|271=128|269=2|270=4291|271=1|269=4|270=4280|269=7|270=4292|269=8|270=4277|10=044|
But what I am getting is this:
8=FIX.4.2|9=192|35=W|34=2|49=TT_PRICE|52=20170622-14:16:23.685|56=SAP0094X|15=USD|48=00A0HR00GCZ|55=GC|167=FUT|200=201708|207=CME|262=MDRQ-21|268=25|269=0|270=12510|271=24|290=1|387=121890|10455=GCQ7|18210=1|10=036|
As you can observe only unique tags are present in the String. But I want each and every tag , no matter how many times it exists in the provided string.
Please can anyone help me doing this in JAVA. It will be really appreciable.
Below is the code I am using for converting :
MessageUtils mu = new MessageUtils();
Session session = Session.lookupSession(sessionID);
Message msg = MessageUtils.parse(new DefaultMessageFactory(), null, str);
// Message msg = new Message(str, false); //This can also be used for converting
System.out.println(msg.toString());
The other thread says:
MessageUtils.parse(MessageFactory messageFactory, DataDictionary dataDictionary, java.lang.String messageString)
And your code says:
Message msg = MessageUtils.parse(new DefaultMessageFactory(), null, str);
So you need to fix your data dictionary and pass it to the parse method instead of passing 'null'
I think the problem is as follows. There's a repeating group that starts with tag 286 (NoMDEntries). The order of fields in a repeating group should be strict, i.e. the same order as the definition of the repeating group. See Market Data - Snapshot/Full Refresh or the data dictionnary supplied by QuickFIX/J (FIX42.xml).
The 268 tag should be followed by 269 and then 270. I am seeing in your message string: |268=24|269=0|290=1|270=4290| which is the incorrect order of tags. That is probably the reason why the message is truncated by MessageUtils.parse.
As a test you could try to manually correct the order in the string and try parsing that to see if that gives the correct message.

When giving property value for JanusGraph,only first 20 characters are getting stored as value in the property using Java

Im creating a graph using JanusGraph.Creating a Vertex and added a property to it.I have assigned value to the property.The value is having more than 20 characters. After the graph commit, when I query the particular property of the graph, Im getting only first 20 characters.
Kindly help me on How to store more than 20 characters as a value to the property.
PFB the example for the above scenario
//Creating Graph
public JanusGraph graph = JanusGraphFactory.open("janusGraphBatch.properties");
JanusGraphManagement manageSystem = graph.openManagement();
//Adding Vertex
Vertex remitterV= graph.addVertex();
//Adding value(more than 20 characters) to the Property "NAME"
remitterV.property("NAME", "abcdefghijklmnopqrstuvwxyz");
manageSystem.commit();
//Querying property "NAME"
System.out.println("Value for NAME Property:"+remitterV.property("NAME"));
Result:
Value for NAME Property:abcdefghijklmnopqrst
You're using the toString method because of the System.out.println there. That calls the StringFactory in TinkerPop. The string factory method cuts off after 20 characters If you call .value() you should get what you expect.

How to add com.google.appengine.api.datastore.PhoneNumber Param from Api explorer to a Form

I have a form which takes Mobile number as com.google.appengine.api.datastore.PhoneNumber type param named as mobileNumber. It somewhat looks like this in API Explorer
This mobileNumber Field appears as a field enclosing number param which is the use to store number internally by PhoneNumber class. When I enter number here in the given format. It gives IllegalArgumentException (BadRequest 400).
Can anyone explain how to use PhoneNumber datatype in a form while using API Explorer for testing the API ?

How to show formatted contact numbers?

I have a field called phone number which has values such as 0833888999 that I want to format as following 0833 888 999.
The answer that Rachana offered blew is true for few countries but not all countries.
Therefore,
I am using this Google library to format contact numbers from different countries; however, the problem is that after persisting the contact numbers in database I can not search for them on database, for example the library would format contact numbers of different countries in different format, for example add space or "-" between them that makes hibernate unable to find them.
+18182223333 >>> +1 818-222-3333
+441135558888 >>> +44 113 555 8888
Hibernate
.add(Restrictions.ilike("user.phone","+18182223333");
Try this
<s:property value="getText('{0,number,0### ### ###}',{phone})"/>
Where,phone=0833888999
Hope this will help you also see Using Struts2 Tags to Formatting Numbers
you will get clear idea about number formatting
I think you should keep the raw phone number (e.g. 0833888999) in the database and it's the View responsibility to format it accordingly.
You can have a separate table "country_phone_format" holding a country_id and a phone_format and you could fetch the phone_format as a #ManyToOne entity so that you have both the raw data and the format to properly display it into the View.
The PhoneFormat could be easily cached with the second level cache, as they should be rarely modified.
Just as Vlad mentions, you should keep the raw phone number (e.g. 0833888999) in the database (or save it with the country and area code if you prefer) and leave th responsibility to format it accordingly to the View.
You can use Type Conversion to convert to/from the format you desire - and take advantage of the google library you mention. Something like the following can get you started (abbreviated just to get the gist of it):
public class MyConverter extends StrutsTypeConverter {
public Object convertFromString(Map context, String[] values, Class toClass) {
String phoneNr = values[0]
MyPhoneObject phone = googleLibrary.doYourMagic(phoneNr);
return phone;
}
public String convertToString(Map context, Object o) {
googleLibrary.parseString( ((MyPhoneObject)o).rawPhoneNr() );
}
}
Don't forget to register the converter in xwork-conversion.properties
my.PhoneObject=path.to.MyConverter

Categories