How can I send APDU's to a Java Card
Hi Friends!,
I am new in Java Card programming. I programmed a card but I don't know how can I send the APDU commands to the card.
Do I need any API for that?, do you have an example?.
Thanks a lot and greetings from Venezuela!.
# 2
In other words, you need to create a client program? If yes, the most easy way is to work with OpenCard Framework (aka OCF).
Try to read:
http://www.opencard.org/docs/pguide/PGuide.html
I will also give you a code for future help:
SmartCard.start();
cr = newCardRequest(CardRequest.ANYCARD,null,PassThruCardService.class);
myCard = SmartCard.waitForCard(cr);
myCS = (PassThruCardService) myCard.getCardService(PassThruCardService.class, true);
byte[] COMMAND = {
(byte)0x00, (byte)0xA4, ........, (byte)0x00
};
CommandAPDU cmd = new CommandAPDU(COMMAND);
ResponseAPDU ans = myCS.sendCommandAPDU(cmd);
System.out.print(cmd.toString()+ans.toString());
SmartCard.shutdown();
You can develop the client into an IDE.
Don't forget to import the necessary packages and add to the project's classpath some (ATTENTION! NOT ALL) jar's,
from JC_HOME\lib (for jcdk 2.2 or higher).
If you are going to work with real cards, you must have the appropriate API's\Drivers for the reader.
You may don't need those right now, but keep those and you will remember me.
Friendly Bill.
# 3
I wish people would stop advocating the use of OCF. The OCF consortium has dissolved and ceased to exist about 6 years ago. It is dead technology that is no longer actively being maintained.
Please use Java 6, JPCSC, the JCOP offcard API, or Jaccal.
# 4
Dear mkdata thank you for your information, I must confess that don't knew that OCF consortium has been dissolved.
I have to say that I have buy a development kit (not exactly development kit but anyway), and the manual encouraged me
to use OCF. Also it has API's for the reader communication via OCF. I try to say, instead it is a dead technology,
some kits are old too and use this technology.
Also can you, please, give some resources and informations about the relative API's in java 6?
I will appreciate your help, friendly Bill.
# 5
It sure doesn't help that the OCF website still exists. I will see what I can do about that... :)
The Java 6 Smart Card I/O API is documented here: http://java.sun.com/javase/6/docs/jre/api/security/smartcardio/spec/javax/smartcardio/package-summary.html
-mkdata