C H A P T E R 14 |
Starting the Java Card Runtime Environment |
This chapter describes how to use the Java Card RMI client-side API. Support for the Java Card RMI client-side API is optional according to the Java Card specifcations, but it has been implemented in the Classic RI available in the Classic development kit. Note that it has not been implemented in the Connected RI available in the Connected development kit.
A Java Card RMI client application runs on a Card Acceptance Device (CAD) terminal that supports a Java SE or Java ME 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 .
The library is located in the file lib/tools.jar .
The reference implementation of the 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 Chapter 15.
The Java Card RMI API 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 the Java Card RMI API. 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, Java Card Platform, Version 3.0.1, Classic Edition .
Note - Some versions of the RMIC do not treat Throwable as a superclass of RemoteException . The workaround is to declare remote methods to throw Exception instead. |
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.
In the release bundles, the Javadoc tool files for this API are located at:
JC_CLASSIC_HOME\docs\rmijavadocs
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.
Copyright © 2009 Sun Microsystems, Inc. All rights reserved.