Additional Optional Ant Tasks
This appendix contains a description of the optional Ant tasks supported by this development kit.
The command line tools in this development kit execute Apache Ant transparently, so you are not required to use Ant directly to use the command line tools themselves. Those Ant tasks are required to install and run the development kit.
This development kit also includes additional, optional Apache Ant tasks for skilled Ant users to streamline using the development kit. These optional Ant tasks group several command line tools into a single Ant task. This chapter describes how to use these additional, optional, and unsupported Apache Ant tasks.
This chapter includes the following sections:
Location and Installation
The optional Ant tasks are included at:
- JC_HOME_TOOLS
\lib\jctasks_tools.jar
Note:
Use of the additional Ant tasks described in this section is strictly optional and is not formally supported, nor has it been fully tested.
Installing the Ant Tasks
-
Be sure Ant is configured as described in Installing the Java Card Development Kit Tools .
-
Copy the file JC_HOME_TOOLS
\lib\jctasks_tools.jarto a directory that serves as your Ant tasks home directory. -
Add the
jctasks_tools.jarfile to your classpath or put it into the Ant-Home-Path\libdirectory to be automatically picked up when Ant is run.Where:
-
Ant-Home-Path is the path to the Ant installation.
-
The value of the ANT_HOME environment variable is properly configured to run Ant (see Installing the Java Card Development Kit Tools).
-
Setting Up the Optional Ant Tasks
The following XML must be added to your build.xml file to use the optional Ant tasks in your build.
<!-- Definitions for tasks for Java Card tools -->
<taskdef name="capdump" classname="com.sun.javacard.ant.tasks.CapdumpTask" />
<taskdef name="capgen" classname="com.sun.javacard.ant.tasks.CapgenTask" />
<taskdef name="exp2text" classname="com.sun.javacard.ant.tasks.Exp2TextTask" />
<taskdef name="convert" classname="com.sun.javacard.ant.tasks.ConverterTask" />
<taskdef name="verifyexport" classname="com.sun.javacard.ant.tasks.VerifyExpTask" />
<taskdef name="verifycap" classname="com.sun.javacard.ant.tasks.VerifyCapTask" />
<taskdef name="verifyrevision" classname="com.sun.javacard.ant.tasks.VerifyRevTask" />
<typedef name="appletnameaid" classname="com.sun.javacard.ant.types.AppletNameAID" />
<typedef name="jcainputfile" classname="com.sun.javacard.ant.types.JCAInputFile" />
<typedef name="exportfiles" classname="org.apache.tools.ant.types.FileSet" />
Library Dependencies
The JAR files located in JC_HOME_SIMULATOR\lib\tools_simulator.jar and JC_HOME_TOOLS\lib\tools.jar contain the libraries required to execute the optional ant tasks. These JAR files must be in the classpath during build execution.
Custom Types
This section includes the following information and description about available custom types:
AppletNameAID
AppletNameAID groups together name and AID for a Java Card applet.
Table -2 Parameters for AppletNameAID
| Attribute | Description | Required |
|---|---|---|
|
|
Fully qualified name of the Java Card applet. |
Yes |
|
|
AID (Application Identifier) of the Java Card applet. |
Yes |
Example
To use these examples:
-
Enter the following example code to set the fully qualified name and AID for the
HelloWorldapplet:<AppletNameAID appletname="com.oracle.jcclassic.samples.helloworld.HelloWorld" aid="0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1:0x1"/>
JCAInputFile
This type is a simple wrapper for a fully qualified JCA file name or a name of an input file that contains a list of input JCA files. In case the input file contains a list of input JCA files, the name of the file should be prepended with “@”.
Table -3 Parameters for JCAInputFile
| Attribute | Description | Required |
|---|---|---|
|
|
Fully qualified name of the input file |
Yes |
Examples
To use these examples:
-
Enter the following example code to set the fully qualified name of an input JCA file.
<jcainputfile inputfile="C:\jcas\common\com\sun\javacard\installer \javacard\installer.jca" /> -
Enter the following example code to set the fully qualified name of an input file that contains a list of JCA files.
<jcainputfile inputfile="@C:\jc\jcaDemo.in" />
ExportFiles
This type is actually the Ant FileSet type. It is used to specify a group of export files for the off-card verifier. For details, see Apache Ant documentation for FileSet type.
Examples
To use these examples:
-
Enter the following example code to set the fully qualified name of an input EXP file:
<exportfiles file="C:\samples\classes\com\sun\javacard\samples \HelloWorld\javacard\HelloWorld.exp" /> -
Enter the following example code to group all the files in the directory
${server.src}that are EXP files and do not have the textTestin their names:<exportfiles dir="${server.src}"> <include name="**/*.exp"/> <exclude name="**/*Test*"/> </exportfiles>
Ant Task Descriptions
The Ant tasks provided in the Ant tasks bundle are provided to simplify the use of the development kit for Ant users. This section describes each of these Ant tasks and how to use them. Note that the JAR files for the tasks are expected to be in the system classpath, unless otherwise noted.
CapDump
Run the CapDump tool to dump the contents of a CAP file.
Table -4 Parameters for CapDump
| Attribute | Description | Required |
|---|---|---|
|
CapFile |
Fully qualified name of CAP file. |
Yes |
|
classpath |
Classpath to use for this task. If required JAR files are not already in the system classpath, you can specify this attribute to put them in the classpath when this task is executed. |
No |
|
dir |
The directory in which to invoke the JVM software. |
No |
Capgen
Runs Capgen to generate a CAP file from a JCA file.
Table -5 Parameters for Capgen
| Attribute | Description | Required |
|---|---|---|
|
JCAFile |
Fully qualified path and name of the input JCA file. |
Yes |
|
OutFile |
Fully qualified path and name of the output CAP file. |
No |
|
classpath |
Classpath to use for this task. If required JAR files are not already in the system classpath, you can specify this attribute to put them in the classpath when this task is executed. |
No |
|
dir |
The directory in which to invoke the JVM software. |
No |
|
nobanner |
Set this element to |
No |
|
version |
Prints Capgen version number. |
No |
Converter
Runs Converter to generate CAP, EXP and JCA files from a Java technology-based package. By default the Java Card platform converter creates CAP and EXP files for the input package. However, if any one of the CAP, JCA or EXP flags are enabled, only the output files enabled are generated.
Table -6 Parameters for Converter
| Attribute | Description | Required |
|---|---|---|
|
PackageName |
Fully qualified name of the package being converted. |
Yes, if the configuration file is not provided. |
|
PackageAID |
AID of the package being converted. |
Yes, if the configuration file is not provided. |
|
MajorMinorVersion |
Major and Minor version numbers of the package, for example, 1.2 (where 1 is major version number and 2 is minor version number). |
Yes, if the configuration file is not provided. |
|
CAP |
If enabled, tells the converter to create a CAP file. |
No |
|
EXP |
If enabled, tells the converter to create a EXP file. |
No |
|
JCA |
If enabled, tells the converter to create a JCA file. |
No |
|
ClassDir |
The root directory of the class hierarchy. Specifies the directory where the converter looks for class files. |
No |
|
Int |
If enabled, turns on support for the 32-bit integer type. |
No |
|
Debug |
If enabled, enables generation of debugging information. |
No |
|
ExportPath |
Root directories where the Converter looks for export files. |
No |
|
ExportMap |
If enabled, tells the converter to use the token mapping from the pre-defined export file of the package being converted. The converter looks for the export file in the exportpath. |
No |
|
Outputdirectory |
Sets the output directory where the output files are placed. |
No |
|
Verbose |
If enabled, enables verbose converter output. |
No |
|
noWarn |
If enabled, instructs the Converter to not report warning messages. |
No |
|
Mask |
If enabled, tells the Converter that this package is for mask, so restrictions on native methods are relaxed. |
No |
|
NoVerify |
If enabled, tells the Converter to turn off verification. Verification is turned on by default. |
No |
|
classpath |
Classpath to use for this task. If required JAR files are not already in the system classpath, you can specify this attribute to put them in the classpath when this task is executed. |
No |
|
dir |
The directory to invoke the Java VM in. |
No |
|
nobanner |
Set this element to |
No |
|
version |
Prints Converter version number. |
No |
|
ConfigFile |
Configuration file containing all the configuration parameters for the converter. |
No |
|
target |
If enabled, tells the converter the Java Card platform version on which the CAP file that is generated is meant to be loaded. If not enabled, the default value will be 3.2.0. Other valid values are 3.0.4, 3.0.5 and 3.1.0. |
No |
| enablePreview | If enabled, tells the converter to use the -enable-preview command line parameter as described in the "Running the Converter" section of this document. | No |
In addition to the parameters specified in the preceding table, the target Java Card platform can be specified for the converter through the environment variable JC_TARGET_PLATFORM. If this environment variable is set, then the converter creates the CAP files for the specified target platform.
Exp2Text
Run Exp2Text tool to convert the export file of a package to a text file.
Table -7 Parameters for Exp2Text
| Attribute | Description | Required |
|---|---|---|
|
PackageName |
Fully qualified name of the package. |
Yes |
|
ClassDir |
Root directory where the exp2text tool looks for the export file. If no ClassDir is specified, the directory in which the Java VM is invoked is taken as base dir. |
No |
|
OutputDir |
The root directory for output. |
No |
|
classpath |
Classpath to use for this task. If required JAR files are not already in the system classpath, you can specify this attribute to put them in the classpath when this task is executed. |
No |
|
dir |
The directory to invoke the Java VM in. |
No |
|
nobanner |
Set this element to |
No |
|
version |
Prints Exp2Text version number. |
No |
VerifyCap
Runs off-card Java Card platform CAP file verifier to verify a CAP file. The Java Card platform off-card verifier is invoked in a separate instance of Java VM.
Table -8 Parameters for VerifyCap
| Attribute | Description | Required |
|---|---|---|
|
CapFile |
Fully qualified path and name of CAP file that is to be verified. |
Yes |
|
PkgName |
Fully qualified Name of the package inside the CAP file for which the CAP file was generated. |
No |
|
noWarn |
If enabled, tells the verifier not to output any warning messages. |
No |
|
Verbose |
If enabled, enables verbose verifier output. |
No |
|
classpath |
Classpath to use for this task. If required JAR files are not already in the system classpath, you can specify this attribute to put them in the classpath when this task is executed. |
No |
|
dir |
The directory to invoke the Java VM in. |
No |
|
outFile |
Fully qualified output path of the digest file, which contains the digests generated using the default algorithm (SHA-256) for all CAP file components. |
|
|
nobanner |
Set this element to |
No |
|
version |
Prints the version number of the off-card verifier. |
No |
|
target |
If enabled, tells the verifier the Java Card platform version on which the CAP file that is verified is meant to be loaded. If not enabled, the default value will be 3.2.0. Other valid values are 3.0.4, 3.0.5 and 3.1.0. |
No |
VerifyExp
Runs off-card Java Card platform EXP file verifier to verify an EXP file. Java Card platform off-card verifier is invoked in a separate instance of Java VM.
Table -9 Parameters for VerifyExp
| Attribute | Description | Required |
|---|---|---|
|
noWarn |
If enabled, tells the verifier not to output any warning messages. |
No |
|
Verbose |
If enabled, enables verbose verifier output. |
No |
|
classpath |
Classpath to use for this task. If required JAR files are not already in the system classpath, you can specify this attribute to put them in the classpath when this task is executed. |
No |
|
dir |
The directory to invoke the Java VM in. |
No |
|
nobanner |
Set this element to |
No |
|
version |
Prints the version number of off-card verifier. |
No |
VerifyRev
Runs off-card Java Card platform verifier to verify binary compatibility between two versions of an EXP file. Java Card platform off-card verifier is invoked in a separate instance of Java VM.
Table -10 Parameters for VerifyRev
| Attribute | Description | Required |
|---|---|---|
|
noWarn |
If enabled, tells the verifier not to output any warning messages. |
No |
|
Verbose |
If enabled, enables verbose verifier output. |
No |
|
classpath |
Classpath to use for this task. If required jar files are not already in the system classpath, you can specify this attribute to put them in the classpath when this task is executed. |
No |
|
dir |
The directory to invoke the Java VM in. |
No |
|
nobanner |
Set this element to |
No |
|
version |
Prints the version number of off-card verifier. |
No |