|C H A P T E R 14|
Java Card RMI Client-Side Reference Implementation
A Java Card RMI client application runs on a Card Acceptance Device (CAD) terminal which supports a J2SE or J2ME platform. The client application requires a portable and platform independent mechanism to access the Java Card RMI server applet executing on the smart card.
The basic client-side framework is implemented in the package com.sun.javacard.javacard.rmiclientlib and com.sun.javacard.javacard.clientlib. Refer to Java Card RMI Client Application Programming Interface, Version 2.2.2.
The reference implementation of Java Card RMI client-side API is based on APDU I/O for its card access mechanisms. For more information on APDU I/O, see Application Programming Notes for the Java Card Platform, Version 2.2.2.
For an overview of the Java Card RMI client-side APIs, see Java Card RMI Client-Side API.
Java Card RMI supports two formats for passing remote references. The format for remote references containing the class name requires stubs for remote objects available to the client application.
The standard Java RMIC compiler tool can be used as the stub compilation tool to produce stub classes required for the client application. To produce these stub classes, the RMIC compiler tool must have access to all the non-abstract classes defined in the applet package which directly or indirectly implement remote interfaces. In addition, it needs to access the .class files of all the remote interfaces implemented by them.
If you want the stub class to be Java Card RMI-specific when it is instantiated on the client, it must be customized with a Java Card platform-specific implementation of the CardObjectFactory interface.
The standard Java RMIC compiler is used to generate the remote stub objects. JCRemoteRefImpl, a Java Card platform-specific implementation of the java.rmi.server.RemoteRef interface, allows these stub objects to work with Java Card RMI. The stub object delegates all method invocations to its configured RemoteRef instance.
The com.sun.javacard.rmiclientlib.JCRemoteRefImpl class is an example of a RemoteRef object customized for the Java Card platform.
For examples of how to use these interfaces and classes, see Application Programming Notes for the Java Card Platform, Version 2.2.2.
Note - Since the remote object is configured as a Java Card platform-specific object with a local connection to the smart card via the CardAccessor object, the object is inherently not portable. A bridge class must be used if it is to be accessed from outside of this client application.
The two packages in the Java Card RMI client-side reference implementation demonstrate remote stub customization using the RMIC compiler generated stubs and card access for Java Card applets.
The package com.sun.javacard.javacard.rmiclientlib implements Java Card RMI-specific functionality.
The package com.sun.javacard.javacard.clientlib implements basic functionality to exchange APDUs with a smart card or a smart card simulator. This implementation of clientlib requires that the ApduIO library is included in the CLASSPATH.
The Javadoc files for this API are in the binary release bundle in HTML format at java_card_kit-2_2_2/doc/en/guides/html/rmijavadocs/index.html. A compilation of the Javadoc files has been included in PDF format in the same directory as the PDF file for this book. The location of the PDF version of the Javadoc files is java_card_kit-2_2_2/doc/en/guides/pdf/rmijavadocs.pdf.
This package includes several classes.
The main method is:
public Object invoke(Remote remote, Method method, Object params, long unused) throws IOException, RemoteException, Exception
This method prepares the outgoing APDU, passes it to CardAccessor, and then uses CardObjectFactory to parse the returned APDU and instantiate the returned object or throw an exception.
This package includes an interface and a class.