C H A P T E R 7 |
Creating and Validating Application Modules |
This chapter describes creating and validating a Java Card technology-based application module with the Packager tool (Packager). See Chapter 3 to better understand the role and relationship between the Packager and the other Development Kit tools used in developing applications for the Java Card 3 platform.
This chapter contains the following sections:
When creating an application module, the Packager takes a specified folder containing the files for the application module, validates the input files and creates the application module archive file. If a web application contains JAR files in the lib directory, the Packager creates a corresponding library module in the application module.
Each application module can have a descriptor as a part of the MANIFEST.MF file that specifies application module declarative items. In cases where an application module has a descriptor, the descriptor information must be validated and preserved.
The following are options of the Packager:
The Packager creates an application module JAR file from input by performing the following actions:
1. Input files are extracted into a temp folder under a folder named either with the input file name or a name specified as a command line parameter.
2. Application module file types are checked and the application module type is determined.
3. A type entry is added to the application module.
4. The application module is placed under the temp folder.
If an optional keystore file is specified in the command line parameter, verified information from it is added to the resulting application module.
5. The entire contents are grouped together to create the final application module JAR file.
TABLE 7-1 provides a description of the possible Packager input files and corresponding output conditions.
Files of the same type but the type contradicts the passed --type argument |
The Packager can invoke the appropriate tools automatically to sign the application module JAR file. See create Subcommand. For information about creating a custom keystore that can be used to sign the application module JAR file, see Chapter 12.External signing tools can also be used to sign the modules if the user knows about those tools.
The Packager assumes that the keystore has everything needed in it and simply invokes the jarsigner to sign the module.
TABLE 7-2 provides a description of the possible Packager signing input and corresponding output conditions
Invalid keystore passed or invalid keystore username or password |
The command line interface for the Packager has the following syntax:
packager.bat subcommand [options] module-or-folder
The following is a list of the available subcommands for the Packager:
Creates the application module or library from a given module or folder.
TABLE 7-3 identifies the create subcommand options and provides their descriptions.
|
|
---|---|
Application signing attribute, where alias is the name used to retrieve the key from the keystore. |
|
Optional. If specified, the tool compresses the output application module file with DEFLATE algorithm. Otherwise creates an uncompressed application module file. |
|
Specifies the export files path. System’s api_export files are implicitely loaded. |
|
Optional. If specified, descriptors or application module assembly problems are automatically corrected when possible. See --force Option Behavior. |
|
Required only when the --sign option is specified. Application signing attribute, where keystore-file is the path and filename where the private keys are stored. A key utility (such as the JDK keytool) must be used to create and maintain this file. See Chapter 12, Creating a Custom keystore. |
|
Specifies the output application module file where file-name is the name of the output file. |
|
Application signing attribute, where key-password is the password for the private key. |
|
Specifies the package AID in //AID/<RID>/<PIX> format for classic-lib . Ignored if type is not classic-lib. |
|
Optional. Specifies that the Packager sign the application. If --sign is specified, --keystore keystore-file , |
|
Application signing attribute, where keystore-password is the password for the keystore. |
|
Specifies the application module file type, where file-type can be web, extended-applet, classic-applet, classic-lib, or extension-lib. The default value is web . |
The --force option affects the following aspects of the Packager’s behavior:
The following is an example of the create subcommand format:
packager.bat create --out file-name [--type file-type] [--exportpath path-of-export-files] [--packageaid package-AID-for-classic-lib] \ [--sign --storepass keystore-password --passkey key-password --alias alias] [--compress] [--force] [--nowarn] module- file-or-folder
Two examples are provided, an example of the output option and an example of the signing option.
The following is an example of the create subcommand with the output option:
packager.bat create -o mymodule.jar -t web -c c:\mymodulefolder
In this command line example, the Packager performs the following tasks:
1. Extracts the contents of mymodulefolder directory to a temporary folder under the subdirectory mymodulefolder .
2. Creates corresponding Web Application Module object and performs validation and canonicalization of all xml descriptors.
3. Creates a META-INF/MANIFEST.MF file with required information (such as application name).
4. Compresses the contents of the temporary folder to c:\temp\mymodule.jar .
The following is an example of the create subcommand with the output option:
packager.bat create -o mymodule.jar -t web --sign --keystore c:\mykeystore\c.keystore --storepass demo --keypass mykey --alias jckey -c c:\mymodulefolder
in addition to those tasks described in the previous example, the Packager in this command line example signs the application using the keystore from c:\mykeystore\c.keystore by performing the following:
Validates an application module.
The validate subcommand has a single option, -t or --type , used to specify the type of application module or group to be validated. The type can be web , extended-applet , classic-applet , classic-lib , or extension-lib .
The following is an example of the validate subcommand format where type can be web , extended-applet , or classic-applet :
packager.bat validate [--type type] module-file-name (or module-directory-name)
The following is an example of the validate subcommand:
packager.bat validate -t web myapp.war
In this command line example, the Packager performs the following tasks:
1. Extracts the contents of myapp.war application module to a temporary folder.
2. Validates the contents of the descriptors.
3. Validates that the classes specified in the descriptors actually exist in the application module.
4. Cross validates the descriptors.
5. Displays results of validation.
Displays the detailed copyright notice.
There are no options for the copyright subcommand.
The following is an example of the copyright subcommand format:
packager.bat copyright
The following is an example of the copyright subcommand:
packager.bat copyright
Prints information about using subcommands.
While there are no options for the help subcommand, it does accept a topic attribute consisting of a specific subcommand name for which detailed information is displayed.
The following is an example of the help subcommand format:
packager.bat help subcommand
The following is an example of the help subcommand:
packager.bat help validate
TABLE 7-4 provides use cases for the command line arguments and describes the expected output for each.
Copyright © 2009 Sun Microsystems, Inc. All rights reserved.