4

If someone wants to write a java application that interacts with a physical device, specifically a reader (e.g. as when you go in a hotel, gym, bank etc and you pass the card through a reader and the application finds you in the database) how is this done?
Is there a java api to interact with the reader and get the cards data?
When a company creates a reader (physical device) does it provide relevant apis?
Are the physical details abstracted from the application programmer?
I need to interact with a reader in java but I do not know how to start.
Any input is highly welcome!

Thanks

Lars Westergren
  • 2,119
  • 15
  • 25
Cratylus
  • 52,998
  • 69
  • 209
  • 339

3 Answers3

4

You can start playing with the javax.smartcardio package.

It's an official Oracle product to allow smart card interaction. This doesn't solve the general problem of device communication (in Unix, simply open /dev/whatever0 with right permissions as it was a file), but may help you with your smart card scenario.

usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
  • 2
    Can I request that instead of providing a link that simply says 'this' that you use a more descriptive term? That makes it easier for people who are scanning through the answers. Thanks! – Stewart Murrie Jan 15 '11 at 19:29
  • Thank you.So the reader device is irrelevant?I just need to know if the smart card is compliant to ISO/IEC 7816-4 APDUs?Or am I mixing the concepts here? – Cratylus Jan 15 '11 at 19:31
  • I believe that **all** smart card readers are compliant to that standard. I'm no big expert in that, I would try with a "hello world"-level application first. As you can see, there is sample code. – usr-local-ΕΨΗΕΛΩΝ Jan 15 '11 at 19:33
  • It will depend entirely on the card reader. Some use serial ports, other use USB; some need specific drivers and some appear just as HID input devices (so they act like a keyboard). Also, the smartcardio package is really designed for smart cards with an embedded chip, rather than simple magnetic stripe cards. – Stewart Murrie Jan 15 '11 at 19:40
3

It depends on the platform. For instance ORACLE states Java Communications 3.0 API to work with:

The Java Communications API (also known as javax.comm) provides applications access to RS-232 hardware (serial ports) and limited access to IEEE-1284 (parallel ports), SPP mode.

This could give you a starter.

DarkThrone
  • 1,954
  • 1
  • 14
  • 14
0

Here you have generic usb drivers for smartcard readers, as well as a daemon that can detect when new readers are plugged in, and some diagnostics information when the readers initiate a connection with a smartcard (either through contact, or contactless/NFC). http://www.linuxnet.com/

jpcsc can then be used as a java API towards the card, so you can read and write. You are abstracted away from the reader hardware, but you still need to know a lot about the specifics of the smartcard - which version of Javacard/GlobalPlatform it uses, what the crypto keys are that are used if you want to establish a secure connection, etc.

Or you can buy a complete development environment including a card, a reader, and an IDE (usually based on Eclipse) from a smartcard manufacturer such as G & D, Oberthur, Gemalto...

Lars Westergren
  • 2,119
  • 15
  • 25
  • jpcsc ist quit old and the development stoped long ago. You should ise javax.smartcardio in future projects, because there is now future with jpcsc. – Fa11enAngel Oct 22 '11 at 12:45