C H A P T E R 8 |
Loading and Managing Applications |
This chapter describes the use of the card installer in loading, creating, unloading, and deleting applications on a card. The card installer consists of two components, an on-card installer and an off-card Installer tool (Installer tool) provided by the Development Kit, that work in conjunction to provide card application management functions.
See Chapter 3 to better understand the role and relationship between the Installer tool and the other Development Kit tools used in developing and deploying applications for the Java Card 3 platform.
This chapter consists of the following sections:
The on-card installer is a ROMized servlet responsible for handling requests received from the off-card installer, extracting the command and data, forwarding them to the card manager. Upon the return of the card manager, the installer forms the response to send back to the off-card installer.
The on-card installer provides the interface between the Installer tool and the card manager and provides a request handling function for the card manager to perform card management tasks. The on-card installer assumes the /cardmanager context to represent the on-card card manager. All /cardmanager/ command URIs (in which command represents load, create, delete, unload, or list) are mapped to one context /cardmanager assigned to the on-card installer.
The on-card installer parses and extracts the command, name, and data information in the multi-part POST requests. The information is passed on by calling the appropriate card manager’s API. The on-card installer and the filter are registered and started with the web container at card initialization.
The on-card installer provides the following functionality:
1. Handles requests received from the off-card installer.
These requests include the command for card application management and the data (application module JAR file).
2. Extracts data (JAR file) contained in the HTTP request and saves it to an on-card file.
3. Passes the load , create , delete , unload , or list command, parameters and the location of the saved JAR file to the Card Manager.
4. Handles the return from the Card Manager.
5. Builds the response content and sending the response back to the off-card installer.
6. Can be configured to require PIN authentication of the off-card installer via basic HTTP authentication:
The Installer tool works on behalf of the on-card installer to perform various card management tasks such as deploying an application and listing all applications. The communication between the Installer tool and on-card installer is proprietary. For the RI, HTTP POST is used as the communication protocol.
The following is the list of functionalities required by the Installer tool:
The Installer tool is a command-line tool, implemented using Java SE. The command line interface for the Installer tool has the following syntax:
installer.bat subcommand [options] [arguments]
In the command line, the subcommand must be the first argument after the installer.bat command. Options and arguments can be in any order.
In the command line, subcommands and options can be specified in either a short form or a long form. The short form is a single character preceded by a hyphen (-). The long form uses a meaningful name preceded by two hyphens (--). Each subcommand can take one or more options or arguments that must follow the subcommand but can be in any order. For example, -i instance-name or
--instance instance-name .
Arguments are command line arguments that are not bound to an option. For example, an application or module file name used in the load command is an argument.
The following is a list of the available subcommands for the installer.bat command:
Causes the Installer tool to load a specified application module or library file. The load subcommand can have one or more options and arguments.
TABLE 8-1 lists and describes the available load subcommand options.
Command line arguments available for the load subcommand are the module or application group file name.
The following is an example of the load subcommand format:
installer.bat load -c oncardinstaller-url -s signature-file -t file-type -n module-or-library-name [-u user-id -p password] application-module (or library-file)
In the following example, the Installer loads the file Calculator.war with the name calc .
installer.bat load -c http://localhost:8019/cardmanager -s mysig.properties -n calc -t web Calculator.war
Causes the Installer to create an instance of an application from a specified group with a specified context. The create subcommand can have one or more options but has no arguments.
TABLE 8-2 lists and describes the available create subcommand options.
There are no command line arguments for the create subcommand.
The following is an example of the create subcommand format:
installer.bat create -c oncardinstaller-url -n module-or-library-name [-a applet-name-or-id] [-d install-parameters] [-i name] [-u user-id -p password]
The following example assumes that a module was previously loaded and named calc . See load Subcommand Example. The Web-Context-Path in RD is /Calculator .
This example of the create command registers the web application with a web container using /Calculator as the context. Users access this web application by using http://cardip:cardport/Calculator .
installer.bat create -c http://localhost:8019/cardmanager -n calc
Similar to Command Example 1, the following example assumes that a module was previously loaded and named calc , with the exception that instead of using the default /Calculator , the application is registered with a web-container using the context /Mycalc .
installer.bat create -c http://localhost:8019/cardmanager -n calc -i /MyCalc
Similar to Command Example 2, the following example assumes that a module was previously loaded and named calc , with the exception that the application is registered as an applet instead of a web-container and has an instance ID of /01 .
installer.bat create -c http://localhost:8019/cardmanager -n calc -a //aid/A000000062/03010C0201 -d a000f0 -i /01
Causes the installer to delete an instance that was created by the create subcommand. The delete subcommand can have one or more options but no arguments.
TABLE 8-3 lists and describes the available delete subcommand options.
There are no command line arguments for the delete subcommand.
The following is an example of the delete subcommand format:
installer.bat delete -c oncardinstaller-url -i name [-u user-id -p password]
In the following example, the installer deletes the instance /MyCalc.
installer.bat delete -c http://localhost:8019/cardmanager -i /MyCalc
Causes the installer to unload (remove) the specified module or application from the card including all instances created by the create command. The delete subcommand can have one or more options but no arguments.
TABLE 8-4 lists and describes the available unload subcommand options.
There are no command line arguments for the unload subcommand.
The following is an example of the unload subcommand format:
installer.bat unload -c oncardinstaller-url -n module-or-library-name [-f] [-u user-id -p password]
In the following example, the installer completely removes the calc module and all of its instances.
installer.bat unload -c http://localhost:8019/cardmanager -n calc
Causes the installer to display summary or detailed information about loaded application modules, instances, and libraries.
TABLE 8-5 lists and describes the available list subcommand options.
There are no command line arguments for the list subcommand.
The following is an example of the list subcommand format:
installer.bat list -c oncardinstaller-url [-d] [-u user-id -p password]
In the following example, the installer displays summary information about modules, applications, and libraries.
installer.bat list -c http://localhost:8019/cardmanager
In the following example, the installer displays detailed information about modules, applications, and libraries.
installer.bat list -d -c http://localhost:8019/cardmanager
Causes the installer to display summary or detailed information about one or more installer subcommands.
There are no command line options for the help subcommand.
Command line arguments for the help command are optional and consist of the name of the subcommand for which detailed help is requested.
The following is an example of the list subcommand format:
installer.bat help [subcommand]
In the following example, the installer displays summary help about all of its subcommands.
installer.bat help
In the following example, the installer displays detailed help about the load subcommand.
installer.bat help load
The following use case, Load an Application, illustrates a common use of the card installer.
This use case loads an application module to the card.
The following preconditions must be satisfied for this use case:
The module is loaded and ready to be created.
1. The user executes the following command:
installer.bat load -c http://localhost:8019/cardmanager -s sig.properties -n app1 mymodule.war
2. The off-card installer connects to the on-card installer servlet and POSTs the required information.
3. A message is displayed on the console with the success information.
Copyright © 2009 Sun Microsystems, Inc. All rights reserved.