Smart cards and the OpenCard Framework
Learn how to implement a card terminal and use a standard API for interfacing to smart cards from your browser
By Rinaldo Di Giorgio, JavaWorld.com, 01/01/98
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
The previous
Java Developer column, "
Smart cards: A primer", gave a general overview of smart cards and how they work. It included a section on smart card standards, introducing the
concept of OpenCard. As described in the first article, OpenCard is an open standard that provides interoperability of smart
card applications across NCs, POS terminals, desktops, laptops, set tops, and PDAs. OpenCard can provide 100% pure Java smart
card applications. Smart card applications often are not pure because they communicate with an external device or use libraries
on the client. In this article we will provide two implementations to two different card readers, demonstrating how you would
add support for card readers to OpenCard. We are hopeful that ports for Litronic, Gemplus, Schlumberger, Bull, Toshiba, and
SCM will be available soon, compliments of OpenCard and
JavaWorld.
Introduction
In order to use a smart card, you need to be able to read the card and communicate with it using an application. OpenCard
provides a framework for this by defining interfaces that must be implemented. The OpenCard framework defines several of these
interfaces. Once these interfaces are implemented, you can use other services in the upper layers of the API. For example,
with a properly interfaced reader, OpenCard can start a Java card agent whenever the card is inserted. The card agent can
then communicate with applications on the smart card via the card terminal in the context of a session.
This article will teach you how to interface card terminals to OpenCard. Future articles will discuss how to write an agent.
A small test application, which gets the ATR (Answer to Reset) string is provided. The ATR is fundamental to smart cards.
We will take the OpenCard development kit and explain implementations for two different smart card readers using the Card
Terminal Interface. The techniques discussed in the article for powering up readers, starting card sessions, and the use of
Protocol Data Units and Application Protocol Data Units can be reused for most of the readers on the market.
While it's not necessary to use OpenCard in creating 100% pure Java smart card applications, without it developers are forced
to use home-grown interfaces to smart cards. (For a detailed explanation of what 100% pure really means, see the Resources section.) OpenCard also provides developers with an interface to PC/SC (a smart card application interface developed by Microsoft
and others for communicating with smart cards from Win32-based platforms for PCs) for use of existing devices on Win32 platforms.
Read on and learn how to use smart cards with your browser.
OpenCard architecture: An overview
OpenCard provides an architecture for developing applications in Java that utilize smart cards or other ISO 7816-compliant
devices on different target platforms such as Windows, network computers, Unix workstations, Webtops, set tops, and so on.
The OpenCard Framework provides an application programming interface (API), which allows you to register cards, look for cards
in readers, and optionally have Java agents start up when cards are inserted in the reader. The architecture of OpenCard is
depicted in Figure 1.
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- You can access source code for examples in this article through a .zip or .tar file
- The Resources section from the first in the series of articles on smart cards contains a fairly exhaustive list of URLS on
the smart card subject
http://www.javaworld.com/javaworld/jw-12-1997/jw-12-javadev.html
- Smart cards and the Web http://www.netscapeworld.com/netscapeworld/nw-03-1997/nw-03-smartcard.html
- General PCCard resources http://beta.missilab.com/readertest/pcmcia.html
- On using native methods to get to the serial ports http://www.javaworld.com/javaworld/jw-07-1997/jw-07-javadev.html
- Reflex20 contact information http://www.pcsc.austin.et.slb.com/cyberflex/pcsc/reflex20.html
- Latest firmware and SDK for the Reflex20. If you have problems with the example, download this file and replace the DLL interface library. Follow
the directions for updating the firmware.
- IBM 5948 Card Accepting Device http://www.chipcard.ibm.com/sc09adev.htm
- OpenCard architecture, documents, and source code for this article http://www.opencard.org/
- Latest version of Communicator (4.0.4) has JNI support for Windows 95 platforms http://developer.netscape.com/software/jdk/download.html
- 100% Pure -- the official definition. This FAQ has answers to most questions about what makes a Java applet, application,
or Bean 100% pure http://www.javasoft.com/features/1997/may/100percent_qna.html