Home » Java » Accessing smart card with Java

Accessing smart card with Java

Posted by: admin December 28, 2021 Leave a comment

Questions:

I’m trying to learn about how does Java access smart cards, due to a project analysis. I wonder if there is any kind of virtual smart card which I could use to make some tests with Java?

By the way, I’ve read about Java Card, and looks like it is used to run Java in cards, not to smart card data access using Java, right?

Answers:

Look at this tutorial + example. And related. (I have used these examples and they work fine).

An important point is that you can’t get anything out of the smart card. You can only send things to its processor. So whenever you get a PrivateKey object, you don’t actually have the private key – this is only a proxy to the SmartCard processor, and calling methods on it, calls the processor.

I’m not aware of virtual smart cards, though.

An API of interest is javax.smartcardio

###

There is a Java Card emulator bundled with the Java Card Development Kit. If you plan on using a real card at some stage, get version 2.2.1 or 2.2.2 as I would not expect any version 3 cards for a while. You will still need an applet to put on the card. A java card does nothing by itself. It isn’t until you load a card applet that it will perform any useful function.

One problem with the emulator in the JCDK is that you cannot use javax.smartcardio to access the card and this is the prefered method at the moment for communicating with a card. The other popular alternative, OpenCard Framework, has not been actively maintained in some time.

###

You can get a virtual smartcard (and a virtual reader) here: http://sourceforge.net/projects/vsmartcard/

###

Javacard use Java only a subset of the Java development You’d better not use Java development environment Because there are some special effects is not support
You can download the plugin or a dedicated development IDE, you can download it from here www.javacos.com related development environment.

###

If you need to emulate JavaCard try to use jCardSim: http://jcardsim.org.
It also supports access via javax.smartcardio API and apdu-scripts.