Developer Suite Getting Started
Developer Suite Getting Started
2
Getting Started
All information herein is either public information or is the property of and owned solely by Gemalto NV. and/or its subsidiaries
who shall have and keep the sole right to file patent applications or any other kind of intellectual property protection in
connection with such information.
Nothing herein shall be construed as implying or granting to you any rights, by license, grant or otherwise, under any
intellectual and/or industrial property rights of or concerning any of Gemaltos information.
This document can be used for informational, non-commercial, internal and personal use only provided that:
The copyright notice below, the confidentiality and proprietary legend and this full warning notice appear in all copies.
This document shall not be posted on any network computer or broadcast in any media and no modification of any part of
this document shall be made.
Use for any other purpose is expressly prohibited and may result in severe civil and criminal liabilities.
The information contained in this document is provided AS IS without any warranty of any kind. Unless otherwise expressly
agreed in writing, Gemalto makes no warranty as to the value or accuracy of information contained herein.
The document could include technical inaccuracies or typographical errors. Changes are periodically added to the information
herein. Furthermore, Gemalto reserves the right to make any change or improvement in the specifications data, information,
and the like described herein, at any time.
Gemalto hereby disclaims all warranties and conditions with regard to the information contained herein, including all
implied warranties of merchantability, fitness for a particular purpose, title and non-infringement. In no event shall
Gemalto be liable, whether in contract, tort or otherwise, for any indirect, special or consequential damages or any
damages whatsoever including but not limited to damages resulting from loss of use, data, profits, revenues, or
customers, arising out of or in connection with the use or performance of information contained in this document.
Gemalto does not and shall not warrant that this product will be resistant to all possible attacks and shall not incur,
and disclaims, any liability in this respect. Even if each product is compliant with current security standards in force
on the date of their design, security mechanisms' resistance necessarily evolves according to the state of the art in
security and notably under the emergence of new attacks. Under no circumstances, shall Gemalto be held liable for
any third party actions and in particular in case of any successful attack against systems or equipment
incorporating Gemalto products. Gemalto disclaims any liability with respect to security for direct, indirect,
incidental or consequential damages that result from any use of its products. It is further stressed that independent
testing and verification by the person using the product is particularly encouraged, especially in any application in
which defective, incorrect or insecure functioning could result in damage to persons or property, denial of service or
loss of privacy.
Copyright 2009 Gemalto N.V. All rights reserved. Gemalto and the Gemalto logo are trademarks and service marks of
Gemalto N.V. and/or its subsidiaries and are registered in certain countries. All other trademarks and service marks, whether
registered or not in specific countries, are the property of their respective owners.
GEMALTO, B.P. 100, 13881 GEMENOS CEDEX, FRANCE.
Tel: +33 (0)4.42.36.50.00 Fax: +33 (0)4.42.36.50.90
Printed in France.
www.gemalto.com
Introduction
11
Whats New in This Release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Who Should Read this Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Conventions Used in this Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 3
Chapter 4
13
System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Software Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Installation Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Before Installing Developer Suite V3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Installing Developer Suite V3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
After Installing Developer Suite V3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Apply and Import A License for Developer Suite V3.2 . . . . . . . . . . . . . . . . . . . .
Importing WTK Devices Into Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13
13
13
14
14
14
15
15
16
19
19
20
20
21
21
22
26
Contents
Chapter 1
iv
Contents
Chapter 5
Chapter 6
26
26
27
27
28
28
28
28
28
29
29
29
29
31
31
31
32
33
33
33
34
34
35
36
38
38
40
40
41
41
41
44
47
47
47
47
48
49
49
49
50
50
50
51
51
53
53
53
55
55
55
57
Contents
Chapter 7
Chapter 8
60
62
63
63
64
65
69
69
70
72
77
77
84
84
91
91
92
93
93
93
94
95
96
97
97
98
99
113
113
113
114
114
114
115
115
vi
Contents
Debugging the Java Card Applet Using the OCF Client Application . . . . . . . . . . . . 115
Loading and Installing the Applet in a Card using Eclipse . . . . . . . . . . . . . . . . . . . . 116
Testing the Java Card Applet in a Real Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Chapter 10
Chapter 11
Chapter 12
Chapter 13
117
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating the Applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Building the Midlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating the MIDlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Adding a SATSA Card Access Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debugging the Applet and MIDlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
117
117
119
120
122
123
127
127
134
135
145
145
146
146
147
147
147
149
150
150
150
152
153
155
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating the Servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating the HTTP MIDlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debugging the Applet and MIDlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
155
155
156
157
159
Chapter 15
161
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Overview of Defining and Running an Application . . . . . . . . . . . . . . . . . . . . . . . . .
Starting the Application Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The Application Manager Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
161
162
162
162
163
Contents
vii
167
171
Appendix A
173
173
174
175
176
176
178
179
179
180
180
181
181
182
The JCardManager
185
Appendix B
189
Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
References
195
Standards and Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Web Site Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Recommended Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Index
197
viii
Contents
List of Figures
Figure 1 - The Java Card Environment:a PC/Workstation-Resident Client Application 1
Figure 2 - The Compilation, Loading and Conversion Process . . . . . . . . . . . . . . . . . . 5
Figure 3 - The AID Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 4 - The Development Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 5 - Developer Suite V3.2 - Not Registered . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 6 - License Key Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 7 - Profile Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 8 - Importing Wireless WTK - Preference Window . . . . . . . . . . . . . . . . . . . . . 17
Figure 9 - Importing Wireless WTK - Import Devices . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 10 - Importing Wireless WTK - Browse For Folder Window . . . . . . . . . . . . . . 18
Figure 11 - Importing Wireless WTK - Devices Refreshed . . . . . . . . . . . . . . . . . . . . 18
Figure 12 - The Developer Suite V3.2 Plug-ins for Eclipse . . . . . . . . . . . . . . . . . . . . 20
Figure 13 - Static Content Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Figure 14 - Static Content Manager View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Figure 15 - Memory status bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Figure 16 - Create New Folder - Select A Parent Folder . . . . . . . . . . . . . . . . . . . . . . 23
Figure 17 - Create New Folder - Enter Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Figure 18 - Create New Folder - Content Structure Updated . . . . . . . . . . . . . . . . . . 24
Figure 19 - Launch Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 20 - Static Content Explorer Preference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 21 - Sim Card Simulator Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Figure 22 - The Mobile Simulator Parameters Window . . . . . . . . . . . . . . . . . . . . . . . 28
Figure 23 - The WTKOCF Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Figure 24 - Switch to Developer Suite Perspective . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Figure 25 - Java Card Project Management View . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Figure 26 - Applications Wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 27 - Application Wizard for Servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 28 - File Menu - Import & Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Figure 29 - Project Contextual Menu - Import & Export . . . . . . . . . . . . . . . . . . . . . . . 34
Figure 30 - Import Main Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Figure 31 - Import Projects Found . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Figure 32 - Developer Suite Export Wizard - Step 1 . . . . . . . . . . . . . . . . . . . . . . . . . 37
Figure 33 - Project Properties Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Figure 34 - Open With Project Properties Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Figure 35 - Overview of Project Properties Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Figure 36 - Project Properties Editor - Application Tab . . . . . . . . . . . . . . . . . . . . . . . 40
Figure 37 - Project Properties Editor - Exported Files Tab . . . . . . . . . . . . . . . . . . . . 40
Figure 38 - Development Flow with Developer Suite V3.2 Tools . . . . . . . . . . . . . . . 43
Figure 39 - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Figure 40 - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Figure 41 - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Figure 42 - NFC Phone Interaction Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Figure 43 - NFC Applet - Card Emulation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Figure 44 - NFC Applet - Reader Emulation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Figure 45 - Card Emulation Applets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Figure 46 - Reader Emulation Applets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Figure 47 - Emulation Servlet Creation - Step 1 - Technology Selection . . . . . . . . . 51
Figure 48 - Reader Servlet Creation - Step 1 - Technology Selection . . . . . . . . . . . 52
Figure 49 - Reader Servlet Creation Step 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Figure 50 - Select An Emulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Figure 51 - Start Reader Project - Select Reader Project . . . . . . . . . . . . . . . . . . . . . 53
Figure 52 - Start Reader Project- Mobile Simulator Launching In Process . . . . . . . . 53
Figure 53 - Start Reader Project - MS 3G Started With Reader Servlet . . . . . . . . . . 54
Figure 54 - Start Reader Project - Enter Pin Code for MS 3G . . . . . . . . . . . . . . . . . . 54
Contents
ix
55
55
56
56
56
57
57
57
58
58
58
60
60
61
62
63
65
66
66
67
67
67
68
68
69
70
71
72
72
72
73
73
74
74
78
79
80
81
82
83
84
85
85
86
86
87
88
88
89
90
91
93
93
94
95
96
Contents
Contents
xi
150
151
153
153
156
157
158
158
162
164
164
167
168
171
173
174
180
185
List of Tables
Table 1 - Development Stages and Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 2 - Accessing Developer Suite V3.2 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 3 - Simulator Versions Standards Compatibility . . . . . . . . . . . . . . . . . . . . . 27
Table 4 - Export Options and Relative Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Table 5 - Change Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Table 6 - Debugging and Testing Tools According to Applet Type . . . . . . . . . . . . . . 42
Table 7 - Mobile Simulator Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Table 8 - Mobile Simulator Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Table 9 - Contextual Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
1
Introduction
This chapter introduces the Java Card environment and explains the main Java Card
concepts and terminology. It then introduces the Developer Suite V3.2 tools and
describes when to use them during the development, conversion, and test phases of a
project.
Communications
using APDUs
Smart card reader
to PC link (USB or
serial ports)
Client application
resident on PC/
Workstation
Java Cards contain a microprocessor, but have no means of directly receiving input or
displaying output. They must therefore be connected to a card reader, also known as a
card acceptance device (CAD), or terminal, which is in turn connected to or contained
in:
A mobile phone
The card in a card reader and the client application communicate using application
protocol data unit (APDU) commands. APDUs contain command instructions, data and
responses. Refer to the ISO 7816-3 standard for detailed information on APDUs.
Introduction
A set of commands to manage the life cycle of the card and its applications, load,
install, and delete the applications on the card, and manage the cards security by,
for example, updating keys and setting up a secure channel between the card and
the terminal.
Introduction
Many different applets can be installed on the same card, and multiple instances of the
same applet can be created (instantiated) and run on the same card. You can also
load packages containing library functions that are used by other applets on the card.
In the telecommunications environment, Java Card applets are server applications
running in the card. These applets react to the mobile equipment (ME) user interface or
to an OTA application.
A telecom Java card can manage three types of API:
Toolkit
Java Card
GlobalPlatform
CDMA Extensions
Developer Suite V3.2 provides support for CDMA target cards, allowing you to
generate skeleton code for CCAT (CDMA Card Application Toolkit) applications.
You can use Developer Suite V3.2s Java Card project and applet creation wizards to
generate CCAT-compatible skeleton code for your project, then test and simulate
application deployment using Developer Suite V3.2 tools such as the Mobile Simulator
CDMA and the script editor.
The R-UIM card profile complies with the following specifications:
Introduction
Client Applications
A client application is a software program running on a workstation. The client
application communicates with an applet that has been uploaded and installed on a
card.
The client application controls all input and output operations on behalf of the applet,
and sends requests for processing to the applet. The applet acts as a server,
responding to the client applications requests.
The following client applications are provided with Developer Suite V3.2:
The Mobile Simulator GSM, Mobile Simulator 3G, and Mobile Simulator CDMA.
The JCardManager.
SATSA Midlet
You can also develop your own custom client applications with Eclipse. Developer
Suite V3.2 provides you with wizards to help you do this. To obtain further details about
developing your own client applications, see the documentation available at
www.opencard.org.
Targets
Applets can be loaded onto two types of target:
A card simulator supplied with Developer Suite V3.2, which simulates a card/card
reader combination. The card simulator makes it possible to develop applets
without having access to real Java Cards or a card reader and also allows you to
debug your applets.
Packages
A package is a Java programming term to describe the collection of related classes
and interfaces to which an applet belongs. Since an entire package can be uploaded to
a card, it is easy to upload several applets at the same time. If you choose to develop
your own client application, the client applications classes must belong to a different
package than the applets classes. A package can also be created that only contains
library classes to be loaded, that is, no applets.
In global system for mobile communications (GSM) environments, a package is often
referred to as an executable load file.
Introduction
File Formats
Before an applet can be loaded onto a card, it must be converted to byte code that can
be interpreted by the Java Card Virtual Machine (JCVM) on the card. The process is
illustrated in Figure 2 - The Compilation, Loading and Conversion Process:
Figure 2 - The Compilation, Loading and Conversion Process
Eclipse and Developer Suite V3.2
Compiler
Converter
Source
Java
Code
Compiled
Java Code
.Java
. Class
Loader
Byte
Code
. SAP . CAP
. JAR .IJC
Java Card
Virtual Machine
( JCVM)
The process involves converting the Java source files first to compiled Class files, then
to byte code. The byte code is then loaded onto the target card, where it is interpreted
by the Java Card Virtual Machine.
CAP Files
The .cap file format is the loadable file format defined by the Java Card
specification. It defines the binary representation of an applet (or library for packages
with no applets) that can be loaded and executed on a Java Card. A .cap file consists
of a set of components, each of which describes a different aspect of the contents. The
set of components in a CAP file includes a number of mandatory components defined
in the Java Card specification, but may also include a number of optional components
that are not necessarily supported by all card manufacturers.
For a complete description of the Java Card CAP file format, see Suns Java Card 2.2.1
Virtual Machine Specification.
JAR Files
The .jar file structure is also defined in the Java Card specification. A .jar file is NOT
a loadable file format, it is simply an archive (similar to a .zip archive) containing a
set of .cap files, each .cap file corresponding to one loadable component. In order to
be loaded on a card, a .jar file must systematically be converted into a loadable .cap
file (this very basically consists in concatenating the individual .cap components from
the .jar archive).
SAP Files
Simulator Applet Package (SAP) files are a Gemalto-proprietary version of the CAP
files. Although they cannot be downloaded onto a real card, when loaded into
Developer Suite V3.2s card simulator they accurately simulate an applet in almost all
other ways.
IJC Files
The .ijc format is not strictly speaking a standard file format. It was created by the SIM
Alliance because the converter provided by Sun only generates JAR files, leaving
JAR to CAP conversion open, which caused divergences in CAP file formats from one
manufacturer to another.
Introduction
The idea was thus to define a loadable file format containing only the components
described as mandatory by the Java Card specification (for example, the optional
Descriptor component has been removed in the IJC format).
In other words, the IJC format is the smallest common denominator of the different
CAP file components supported by the cards of the SIM Alliance members.
Projects
The term project in the Developer Suite V3.2 environment refers to a package which
may, or may not, include one or more applets, together with all necessary system
classes, with or without libraries. When no applets are included in the project it is a
library. The project file groups together all the files and environment variables
required for building, debugging and loading applets and libraries.
AIDs
For security reasons, client applications must be able to uniquely identify any installed
applet. Every package, applet, and instance of an applet loaded on a card must
therefore be assigned a unique identifier, known as an application identifier (AID). An
AID is a string of between 5 and 16 hexadecimal bytes.
Figure 3 - The AID Format
Application Identifier (AID)
RID (5 bytes)
The first five bytes of an AID (the RID) indicate the application provider, that is, the
company supplying the package or applet. To obtain an RID, your company must
register with the international standards organization (ISO). This procedure is
described in ISO7816-5 Numbering system and registration procedure for application
identifiers.
The remaining bytes (up to 11) of an AID contain the proprietary identifier extension
(PIX). The PIX is chosen by the application provider to uniquely identify a package or
applet. Your company is then responsible for assigning PIXs to individual applications.
As mentioned previously, three types of AID are used in a project:
An applet AID cannot have the same value as the AID of any other package or any
other applet stored on the same card.
Introduction
Wizards: These gather the information necessary to build and configure a skeleton
Java Card project, such as Java package names and default applet AID values. All
Wizards can be launched through quick access from Application Wizard view
panel (see Java Card Project Management View on page 32).
Pre-loading tools: The Developer Suite V3.2 Java Card plug-in for Eclipse
prepares the applet for loading onto the card by converting Class files to byte code.
The JCardManager loads packages into a card or the card simulator, and
exchanges APDU commands with a loaded applet.
The Script Editor creates and edits XML script files to provide batch execution
of commands.
Simulation tools: A card simulator simulates all aspects of particular card types
behavior, and is extremely useful for testing and debugging the functionality of an
applet. The Mobile Simulator GSM, Mobile Simulator 3G and Mobile Simulator
CDMA card simulators operate in exactly the same way as the equivalent real
mobile telephones. The Simulation Chain 2G and Simulation Chain 3G tools
simulate a secure connection between a server and a mobile station.
The Cap File utility lets you visualize the contents of a loadable CAP file.
The Crypto Tool provides a method of enciphering and deciphering data using
the DES, 3DES, AES and RSA cryptographic algorit3.2hms and provides a
method of hashing using the SHA1 and MD5 hash algorithms.
The File System Editor allows you to view the file structure in a card or card
simulator and the properties and access conditions for any given file.
The Key File Editor allows you to create custom key files.
The following table lists the Developer Suite V3.2 tools and the corresponding
development stages and target types required.
Table 1 - Development Stages and Steps
Development Tools
Development Stages
Quick-start tools:
Wizards
Pre-loading tools:
Developer Suite V3.2 Java
Card Plug-in for Eclipse
Introduction
Development Stages
JCardManager
Script Editor
Simulation Chain 3G
Mobile Simulator 3G
JCardManager
Card simulator
Miscellaneous utilities:
Cap File utility
CryptoTool
OTA Interpreter
WTKOCF bridge
The Developer Suite V3.2 tools can be launched from within the plug-ins provided for
Eclipse, or from within the JCardManager. Some can also be launched from the
command line using supplied batch files. Table 2 - Accessing Developer Suite V3.2
Tools summarizes the launch options.
Table 2 - Accessing Developer Suite V3.2 Tools
Tool
Accessible from:
Eclipse
Plug-in
JCardManager
Command Line
Wizards
Yes
No
No
Mobile Simulators
Yes
No
Yes
Yes
Yes
No
CryptoTool
Yes
Yes
No
Introduction
Accessible from:
Eclipse
Plug-in
JCardManager
Command Line
Script Editor
Yes
Yes
No
Yes
Yes
No
No
Yes
No
OTA Interpreter
Yes
Yes
No
WTKOCF bridge
Yes
Yes
No
Development Phase
For the rapid development of a prototype applet with Developer Suite V3.2, do the
following:
Run the Wizards. Use the supplied wizards to generate skeleton code and a
project definition.
Debug the Project. Set breakpoints and then use Developer Suite V3.2 tools to
launch the simulator, load the files into the card simulator and launch the client
application.
Note: When you debug a project, Developer Suite V3.2 automatically builds the
project for you first, that is, compiles the Java source code to Class files and converts
the Class files to CAP, JAR, or other file formats as necessary.
Developer Suite V3.2 automatically generates a GXSC script file containing all
necessary load and install parameters. If necessary, you can edit this file using the
Script Editor.
10
Introduction
Eclipse IDE
Debugger
Project
Installed applet
triggers breakponts
File
Conversion
Script Editor
.JAR
.SAP
.CAP
.IJC
Loader
Card Simulator
Communication
Communication
JCard Manager
Mobile Simulators
(GSM, 3G, CDMA)
Communication
Load the applet into the card with JCardManager (possibly using GXSC scripts) or
the Application Manager (refer to Using the Application Manager on page 161).
Alternatively, you can use the deployment script generated with the project.
Test the applet using the client applications provided with Developer Suite V3.2:
The Mobile Simulator GSM, Mobile Simulator 3G, or Mobile Simulator CDMA
Simulation Chain 2G or Simulation Chain 3G
JCardManager (for Java Card applets)
OCF Client application (for Java Card applets)
JCRMI Client application (for JCRMI applets)
SATSA Midlet
Other improvements
>
Menu selection sequences are shown using the > symbol to link
the selections. For example:
... select Start > All Programs > Gemalto > Wireless
Solutions...
italics
notation
Preface
This document is designed to help you learn about Gemalto Developer Suite V3.2 by
using it. It guides you step by step from the creation of a new Java Card applet, through
to its installation and testing.
12
Preface
installdir
carddir
3
Installing Developer Suite
V3.2
This chapter describes how to install Developer Suite V3.2.
System Requirements
Hardware Requirements
The following hardware is required to install and use Developer Suite V3.2:
A Windows-compatible PC with:
A PC/SC compliant smart card reader with associated connection cables and
drivers, such as the GemPC Twin smart card reader (P/N HWP108765 C); this is
not required for the Evaluation Version.
Optionally, a SIM Toolkit, USIM Toolkit, or CCAT (CDMA Card Application Toolkit)
Java Card (for example, GemXplore Xpresso v3 or GemXplore Generations). In
order to be able to download applets onto a card in Developer Suite V3.2, it must
be either Global Platform or 3GPP 23.048 compliant.
Software Requirements
1
14
access to Java Card project and applet creation wizards. Certain tools display their
output in Eclipses messages window.
Note: Eclipse is installed as part of the Developer Suite V3.2 installation procedure.
3
The Java 2 Software Development Kit (SDK) 1.5 or higher. This is also installed
as part of the Developer Suite V3.2 installation procedure.
Adobe Acrobat Reader Version 4.0 or later. This is required to read the online
documentation provided on the installation CD-ROM.
Microsoft Internet Explorer Version 5.01 and Microsoft XML Parser Version 4.0, or
Microsoft Internet Explorer Version 6.0 or later.
If you are using the card simulator, you must make sure the TCP/IP networking
protocol is installed on your PC.
Installation Overview
You can either install the Developer Suite V3.2 environment from a CD-ROM or a .zip
file downloaded from the product website. The installation program installs any
additional components required. If you have a card reader installed, it is configured for
use. The card simulator is automatically installed on your workstation during
installation.
Configure the display settings on your computer. The desktop resolution must be at
least 1,024 by 768 pixels, with 65,536 colors (16bit).
Log in with an account that has Administrator rights on your computer, otherwise
you will not be able to install Developer Suite V3.2. Contact your System
Administrator if do not have these rights.
Insert the Developer Suite V3.2 CD-ROM into the CD-ROM drive on your
computer; or unzip the installation archive (the .zip file) to a temp directory and
double-click the executable program (like GXDev_Install.exe).
The installation program starts automatically.
For CD-ROM installation, if for any reason it does not start automatically, run the
drive:\Developer_Suite_x.y.z.exe program on the installation CD-ROM, where
drive is the drive letter of the CD-ROM drive.
15
Choose the Install Developer Suite V3.2 Installation option. This program guides
you through the installation process.
Click Apply License to activate the Developer Suite V3.2 product. This starts the
license application wizard. Then following steps in To apply a License to
Developer Suite V3.2: on page 15 to complete registration.
After clicking Apply License button, the License Key Manager window appear
like blow:
16
If a license is already achieve, click Import License to browse and locate it on your
local disk. Follow the wizard to complete.
If you have no license on hand, you need to apply one first. Click Export Profile,
the following window appear:
Fill in the blank form in window as the above figure presents. All fields with a * are
required. For the Gemalto contact option, choose either the Gemalto Web Store
or Gemalto Email Address as your email receiptor.
Click Save if you want to further revise your information before sending; click Save
& Send to take modification in effect and feedback them to Gemalto.
A message will the be sent to your registered Email Box. A license (XML file) will be
attached.
Go back to the License Key Manager window. Click Import License and follow
the wizard to complete.
On Eclipse menu bar, click Window > Preferences. This prompts the
Preference window.
17
On the left pane of Preference window, click J2ME node to unfold it and select
Device Management, shown as follows:
On the Device Management page shown on the right, click Import button. On the
Import Devices window, click Browse button next to the Specify search
directory: textbox, as follows:
18
On the Browse For Folder window, browse to WTK 2.5s installation directory(c:\
DeveloperSuiteWtk by default).
Click OK to close Browse For Folder window and return to Import Devices
window. Click Refresh button. Four lines appear in the Devices list and are
selected, shown as below:
Click Finish button to close Import Devices and return to Preference window.
Now you have finished configuration of J2ME for Eclipse. This is a global setting which
means you dont have to configure it each time you use the tool.
4
Developer Suite V3.2
Components
License Key Manager
The License Key Manager applies a license protection mechanism to the Developer
Suite V3.2 at component level. Under the License Key Management System, the
products components are divided into two categories:
License-free components
Components that are open to use in both an evaluation version and a full
version of the Developer Suite V3.2 product.
License-protected components
Components that are only available in the full version of the Developer Suite
V3.2 product.
Smart Card Access. The Evaluation Version cannot access a real card and does
not generate byte code (.cap, .jar files) for cards. To test the behavior of your applet
in a card, you must use a card simulator.
For legal reasons, the cryptographic capabilities are limited in the Evaluation
Version:
For RSA, to 512bit key lengths (instead of 2,048 bits for the Full Version)
For DES and 3DES to 56 bits (instead of 168 bits for the Full Version)
For AES to 56 bits (instead of 256 bits for the Full Version)
Note: Longer values are accepted by the Evaluation Version, but in practice the
bits that exceed the allowed length are set to zero.
Only the SCWS card and SIM R5 card profiles (available in wizards, mobile
simulators, commands, and so on) are available in the evaluation version.
20
Eclipse
The Developer Suite V3.2 is a Java Card plugin for Eclipse. To use the Developer
Suite V3.2, Eclipse needs to be installed on your PC. For more information about which
features are accessible from Eclipse, see Table 2 - Accessing Developer Suite V3.2
Tools on page 8.
Because Developer Suite V3.2 automatically launches Eclipse SDK, no separate
shortcuts are provided for Eclipse in Start menu. The IDE starts with an embedded
Developer Suite V3.2 plug-in when you click:
Start > All Programs > Gemalto > Wireless Solutions > Developer Suite.
The Developer Suite V3.2 adds a Developer Suite menu in Eclipse menu bar, from
which you can launch all the Developer Suite V3.2 tools. The following figure show the
Developer Suite menu and its menu items.
Figure 12 - The Developer Suite V3.2 Plug-ins for Eclipse
21
Menu to Access
From the Eclipse menu bar, click Developer Suite > Static Content Manager, as the
following figure shows:
Figure 13 - Static Content Menu
The static contents are automatically started when the Static Content Explorer is
opened. The SCWS card memory status are present on the status bar (at the button of
Eclipse workbench), as below:
Figure 15 - Memory status bar
22
Put button is for recursively adding files into the SCWS card.
In the static content tree structure, select a folder (root included) to add the
imported files.
Click the Put button to display the file explorer, where you can choose a single file
or a batch of files from your PC local disk.
Tip: Press Ctrl and click the to select multiple files in the explorer window.
After adding file(s) finished, the contents structure and memory status are
refreshed automatically.
In the static content tree structure, select a folder (root included) to add the
imported files.
On the Browse for Folder window displayed, browse the file system to specify a
directory on your PC local disk.
23
In the oncard static contents tree structure, click to select a parent folder for the
folder to be created, e.g. SCWS as highlighted in the figure below:
Click the Create Folder button. This display a New Folder page as below:
On the window above, the select folders path is given. The new folder will be
added into that directory.
In the text field, enter a name for new folder.
Note: When you name the new folder, notice that space is allowed which a
backslash (\) is forbidden.
You can also use a slash (/) to including a sub folder, e.g. On card port/images
(double quotation marks excluded).
Click Ok to add folder(s). The contents structure and memory status are refreshed
automatically.
If you cant see update in the tree structure, click Refresh button or press F5 key to
refresh the display.
24
The new created folder(s) appears in the static content tree structure, as the figure
below shows:
Delete allows you to remove unwanted files or folders from the SCWS card.
In the static content tree structure, select a single file or folder to delete. Like the
case for adding files, you can also choose a batch of files to delete.
Warning: To delete a folder will recursively delete all files and sub-folders under
its directory.
Refresh button refresh your static content tree structure. This will:
In the static content tree structure, select a single file or folder to display.
25
Click the View in web browser button to launch the web browser. The selected file
or folder is opened in the web browser. As the following figure shows:
As in Figure 19, the selected image file back.jpg is displayed in the web
browser on the right.
26
On the HTTP Proxy screen, define the following parameters or use the default
values:
Compress text file as gzip encoding: if gziped the file when put text file, there
is a list if MIME type that the gzip option may compress when put files. Multiple
types are separated by space. For example, text/html text/plain.
Http server Address: The ip address of the http server, default value is
127.0.0.1.
Http server Port: This is a http service port, default value is 3516.
Chained receive: if true try to optimize the flow by using remaining data length
in the receive buffer, else perform a data available between each receive. The
default value is true.
timeout: use for receive and emit data. On the user point of view, it looks like
Http request time out. Default value is 60000 (1 min).
BIP Channel size: the size of BIP channel pool, default value is 5. It can open
multiple BIP channels at the same time.
Force the Memory Access by using specific perso commands, and temporarily
disable the SCWS security (for the current ATR session) if the current card is in
secure mode.
After modification, you need to re-start the Static Contents Explorer to take effect.
JCardManager
The JCardManager is a powerful tool used to load CAP files, exchange APDUs, and
run traces. More generally, it is used to send any Global Platform command to a card
or simulator. For more details about the JCardManager, refer to Appendix B - The
JCardManager.
The Application Manager is started from the Developer Suite menu in Eclipse IDE and
is fully explained in Chapter 14 - Using the Application Manager.
Simulators
There are four types of simulators available in Developer Suite V3.2:
27
Telecom standard
GP standard
2.2.1
3GPP release 6
2.1.1
2.2.1
3GPP release 5
2.0.1
2.1.1
3GPP release 5
2.0.1
2.1.1
2.0.1
2.2.1
3GPP2 C.S0035-A
2.1.1
2.2.1
3GPP release 6
2.2.1
28
The mobile simulators first display the Mobile Simulator Parameters window, as shown
in the following figure:
Figure 22 - The Mobile Simulator Parameters Window
Proceed as follows:
1
Click OK to continue.
Tools
Cap File Utility
This tool enables you to view and optionally save a .cap file in text format. Access this
tool in Eclipse by choosing Developer Suite > Cap File utility.
Crypto Tool
Developer Suite V3.2 contains a tool you can use to perform DES and Triple DES
computations. Access this tool in Eclipse by choosing Developer Suite > Crypto Tool.
29
OTA Interpreter
This tool is installed automatically with Simulation Chain . For more information refer to
the Getting Started document that is located on your Developer Suite V3.2 CD in
DeveloperSuite\SimulationChain2G\GettingStarted.pdf.
Script Editor
The Script Editor is a tool that enables you to create and edit configuration files and
scripts. A script is a sequence of command APDUs. For information about the Script
Editor, refer to Chapter 15 - The Script Editor.
WTKOCF Bridge
This tool aides communication between a J2ME emulator and a smart card. The J2ME
emulator communicates with the card simulator using the TLP 224 protocol. A real
smart card needs the TPDU protocol to interpret APDU commands. The bridge
reformats commands received in TLP 224 protocol into TPDU format as shown in the
following figure:
Figure 23 - The WTKOCF Bridge
WTK-OCF
Bridge
OCF Protocol
J2ME Emulator
Card Simulator
Smart Card
5
Getting Started with
Developer Suite V3.2
Developer Suite V3.2 Working Environment
As we mentioned previously in Eclipse on page 20, the Developer Suite V3.2adds a
Java Card plug-in to Eclipse and by embedding the Developer Suite menu in Eclipse
menu bar, make its major tools easy to access.
In this chapter, we further explore Developer Suite V3.2 proprietary GUIs and
features integrated in Eclipse IDE. Here we mainly focus on features closely related to
the Developer Suite working mode, apart from the Developer Suite menu and its
members we introduced before in Chapter 4 - Developer Suite V3.2 Components.
32
on the upper-right corner of current workbench and select Developer Suite from the
popup menu, as highlighted in the following figure (the pressed-down button
indicates that Developer Suite perspective is currently in use):
Figure 24 - Switch to Developer Suite Perspective
The Bookmarks view displays all bookmarks in the Workbench along with the
names of the files with which the bookmarks are associated.
Developer Suite V3.2 provides wizards for creating the most common types of Java
Card development projects. These wizards can be quickly accessed by double-clicking
their icons on Java Card Project Management view panel (only appears in Developer
Suite perspective). Figure 25 shows where Java Card Project Management view
panel is docked on the workbench window and a close-up view of the panel:
Figure 25 - Java Card Project Management View
33
Project Wizards:
The Project Wizards combo box contains three projects types:
Java Card Project: including several sub types of Java Card Projects, each
specifying a card profile (R-UIM, SIM R99, USIM R5, etc.).
JCRMI / APDU OCF Client Project: used to create offcard client application for
testing compatible oncard applets.
When a Java Card project is currently selected, the Applications Wizards area
appears like below:
When a SCWS project is currently selected, the Applications Wizards changes its
outlook.
The wizards generate skeleton Java code that is ready to compile, and gather the
information necessary to build and configure a skeleton Java Card project, such as
Java package names and default applet AID values.
Chapter 7 - Worked Example with USIM Toolkit Applet is a quick tutorial on how to
use the wizards to create a Java Card project in Eclipse.
34
As the following figure shows, click File Eclipse menu and select Import/Export.
On the Package explorer, select a project and right-click. On the contextual menu
displayed (see Figure 29), select Import/Export.
35
Under Developer Suite node, select a project type. You can choose to:
Click Next to proceed. This displays steps 1 of the Import Projects Wizard, on
which browse to locate an archive file (for New and Existing Developer Suite
Projects) or specify a directory (for JBuilder java card project).
Note: To use Update Existing Developer Suite Projects, make sure the archive file
you destine to import contains at least one project named the same as an existing
project under Eclipse workspace.
36
Projects in the specified archived file or under the specified directory will be
automatically detected and displayed in the Projects field once they are found. All
the detected projects are selected by default as shown in the figure below:
Select the projects you want to include. Click Finish to complete import. Eclipse
starts building the projects immediately after they are imported if Build
Automatically is selected under the Project menu.
Under Developer Suite folder, select the only option Developer Suite Archive.
Current release of the Developer Suite only allows you to export Java Card projects
into a ZIP file.
37
On the above window, user can choose export all relative files or specify part of
them. See description below.
Default export
DS configurations
(.gdp, .gbp,
.launch)
Simulation Chain
configurations
+Sources
+External class
paths
+External scripts
X
X
External libraries
(.jar, .zip, .class)
Local scripts
(.gxsc, .atf, )
External scripts
(.gxsc, .atf)
X
X
Note: For easy synchronization with Simulation Suite, Developer Suite export all the
Simulation Suite configuration files under project/.conf directory.
5
38
By default, the Project Properties Editor is used as the default editor for .gbp and
.gdp files. You can open a Java Card/SCWS projects parameters in Project
Properties Editor at any time by double-clicking the projects .gbp/.gdp file. You can
also right-click a .gbp/.gdp file and select Open With > Project Properties Editor,
as below:
Figure 34 - Open With Project Properties Editor
39
The Project Properties Editor has multiple tab-pages, as we can see on its Overview
tab-page as follows:
Figure 35 - Overview of Project Properties Editor
Overview
The Overview page is displayed when the Overview tab is selected. On this page,
shortcuts are available to modify general Java Card/SCWS project definition, including.
Project Location: Click this link to retrieve the first page of a Java Card project
wizard.
Java Card Project Settings: Click this link to retrieve the second page of a Java
Card project wizard.
Personalization script or Set project environment: Click this link to open the current
projects run dialogue.
DAP setting: Click this link to retrieve the last page of a Java Card project, or the
second last page of an SCWS project wizard.
As most of the shortcuts reuse Java Card/SCWS project wizard, you can follow the
instruction next to each link to make changes to projects parameters.
Any modification made will overwrite the corresponding parameter you specified before
within project creation wizard.
To make it clearer, the table below shows which parts of the project are accordingly
changed with the above parameters:
.gdp File
.gbp File
ClassDir
ConversionDir
Name
Wizards
Version
40
Applications
The Application page is displayed when the Application tab is selected. With this
page, user can easily manage a Java Card/SCWS projects applets/servlets:
Figure 36 - Project Properties Editor - Application Tab
To add an applet/servlet: Click Add button to bring out the Applications Wizards
panel, on which all available applications types are displayed.
Export Files
The Application page is displayed when the Application tab is selected.
Figure 37 - Project Properties Editor - Exported Files Tab
41
In this page, user can customize exported files path by clicking Add, Remove or
Properties button.
In this page the user can also choose which compiler is used for java class compiling.
With this option, the problem mentioned in http://gallium.rnd.gemplus.com/phpBB2/
viewtopic.php?t=1350 will be avoided.
This feature will change both the .gdp and .gbp files.
Two compilers are provided at your choice: Eclipse JDT compiler and Javac
complier.
Create the project definition and Java code skeleton with wizards.
The Mobile Simulator GSM (for SIM Toolkit applets), Mobile Simulator CDMA
(for CCAT Toolkit Applet) or Mobile Simulator 3G (for USIM Toolkit) in an I/O
(APDU exchange) mode.
The Simulation Chain 2G (for SIM Toolkit applets or CCAT Toolkit applets) or
Simulation Chain 3G (for USIM Toolkit applets) that trigger over-the-air (OTA)
events.
Command line
Load and install the applet in a real card using one of the following:
42
Carry out tests on a real card using one of the tools listed for debugging.
The applications that can be used for debugging and testing the applet depends on the
type of applet as shown in the following table:
Table 6 - Debugging and Testing Tools According to Applet Type
PC
Card
Toolkit Applet
JCRMI Applet
SATSA Midlet
Simulation Chain 3G
Mobile Simulator 3G
HTTP Midlet Test Application
Static Content Explorer
Some worked examples are described to help you get started, as follows:
USIM Toolkit Applet, debugged and tested using the Mobile Simulator 3G,
described in Chapter 7 - Worked Example with USIM Toolkit Applet.
JCRMI Applet, debugged and tested using the JCRMI Client Application, described
in Chapter 8 - Worked Example with JCRMI Applet and Client.
GP Applet debugged and tested using the OCF Client Application and
JCardManager, described in Chapter 9 - Worked Example with JavaCard Applet
and Client.
Figure 38 shows the basic development process followed in this document for the
USIM Toolkit Example applet, described in Chapter 7 - Worked Example with USIM
Toolkit Applet.
Java Source
Code
.class file
Java Card
Simulator
File
Conversion
File
Conversion
.JAR File
.SAP file
Start Card
Simulator
Non-automated Tasks
Personalize the
Applet
(Optional)
Personalize the
Applet
(Optional)
Run the
application on the
simulator
Run the
application on the
Java Card
Debug
Test
43
44
Figure 39 -
45
Then you will see the picture below and click the Import Examples and Click the
Next button to continue
Figure 40 -
46
Then you can select the example you want by click the square in front of each
example. Then Click Finish
Figure 41 -
6
M-NFC Enabled JavaCard
Applet/Servlet
NFC Contactless Technology
NFC Technology Introduction
This example describes the main concepts of the NFC technology involving the SIM/
USIM card. It guides you how to develop an applet in the SIM/USIM that enables
communication between the SIM/USIM card in the phone and any external contactless
devices like payment cards, Tags or readers in the field.
It is recommended to familiarize first with contactless technologies and especially the
ISO 14443 standards and the Single Wire Protocol (SWP).
A SWP-NFC phone is composed by the following elements:
The SIM/USIM card processing data coming from the phone on the legacy ISO
7816 interface and data coming from the NFC chip (and so, from the contactless
devices) on the Single Wire Protocol - SWP interface.
Card emulation: the phone is acting as an NFC card in the contactless system.
Reader emulation: the phone is acting as a NFC reader in the contactless system.
48
49
These applets are very similar to classic JavaCard applets. All commands (APDUs) are
sent by the RF reader. At the reception of each Contactless APDU the process ()
method is called with the APDU header in parameter. The applet computes the
response and sends it back using the classic JavaCard API. It is the responsibility of
the (U)SIM operating System and the NFC chip to forward the response back to the
contactless reader.
In Reader mode, the behavior is more complex because the applet needs to send
commands and there is no existing adapted interface to do that.
First, there is a new package to start and stop the reader mode (it must not be always
activated for consumption issues. When reader mode is activated, the NFC chip
generates a Contactless field, and it consumes power from the phone battery).
This package is com.axalto.contactless.readermode.
It contains two main native functions ReaderModeStart() and ReaderModeStop()
to respectively start and stop the reader emulation mode.
An NFC contactless applet should always use transient variables when possbile for
better performance.
In card emulation mode, the first APDU sent by the reader should be a SELECT AID
containing the AID of the card emulation applet, otherwise, by default the Contactless
logical channel will stay closed.
50
Note:
We put this working example ahead of all the other applets/servlets because it is the
main new feature we want to introduce to you with Developer Suite V3.2.
If Developer Suite V3.2 is complete new to you, please start from the Worked
Example with USIM Toolkit Applet on page 77 and then get back to this chapter after
finishing other parts in this guide.
This demo consists of two NFC JavaCard Applets (SWSC feature optional but not
mandatory), one acting in Reader Emulation mode and the other in Card Emulation
Mode. Then two applets then interact with each other.
The general steps will be:
1
Create two NFC JavaCard Projects (i.e. a JavaCard project with NFC with
Proprietary/Standard SCWS chosen as the Target Card Type).
Create a NFC Applet (Servlet optional) in the first project, choosing Card
Emulation in Select NFC Mode.
Create a NFC Applet (Servlet optional) in the second project, choosing Card
Reader in Select NFC Mode.
Trigger Mode Switching to change the second NFC applets current mode from
Emulation to Reader.
Start communication between two applets from the NFC Management Window.
Build a NFC Java Card project and name it as, e.g. emulation. To create a NFC
project, keep the default seletion NFC with Proprietary SCWS in the third window
of the project creation wizard and then click Finish to complete.
51
In the same way, create the second NFC Java Card project and name it as
reader.
Note: On the Target Card Type window, you can also select NFC with Standard
SCWS instead. The difference between an NFC&SCWS Proprietary card project and
an NFC&SCWS Standard card project is the library of project and the code generated.
Click OK to continue. This will add a servlet (by default named as MyServlet 1)
into your project because in the example here SCWS is selected.
Follow the Wizard or directly click Finish to quickly complete creating project.
Now you have created a NFC servlet project which will be run in emulation mode in
our demostration.
52
The Technology selection window appear. Choose NFC and Card Reader icons;
;also select SCWS and STK to enable the SCWS and STK features.
Click OK to continue.
53
Now you have a servlet (default name MyServlet1) added to your project.
54
55
Run the emulation project in the same way described in Starting the Reader
Project on page 53.
This starts another instance of Mobile Simulator 3G for the card emuation servlet
MyServlet1 we created before.
56
On the Mobile Simulator 3G window of the Emulation servlet, click Simulation ->
NFC Window, like Figure 58 shows.
If the communication completes successfully, you can see the picture below.
Please note the Mobile Simulator in reader mode changes back to Emulation
mode.
Click the Select button at the center of the Mobile Simulator interface:
57
58
On the Load URL window, add MyServlet1 (your reader servlet name) after the
existing url. Then it looks like below:
Enter what you want to transfer in the blank, e.g. 1 Menu1. Then click the Start
button.You can see the mode change into the Reader mode.
On the Mobile Simulator 3G window of the Emulation servlet, click Simulation ->
NFC Window. The NFC Management Window appears, like Figure 58 - Using
STK Method - NFC Window Menushows.
If the communication completes successfully, you can see the picture below.
Please note the Mobile Simulator in reader mode changes back to Emulation
mode.
59
60
On the left the tabs list all card types that is running; on the right you can see some
trace information.
1
Clicking on the
button will pop up the configuration dialogue. The dialogue will
let you choose the parameter as you want. Click OK to save your changes.
61
The
button is used to terminate running card simulator(s). On clicking on this
button, a warning message appears, asking for your confirmation.
Note: If the simulator started from the project you can terminate it by clicking the red
button on right bottom.
Click to
stop card
simulator
62
63
64
After you fill the Project name,Package and Name ,click Finish to complete the
Wizards
You can specify the command you want to send and the response you expected to
receive in an XML file .
Following is an example of the format of the XML file( The same format as contact-less
reader application):
65
You can implement more complicated function by programming in the java file
which automatically generated with the contact-less tag application.
There are some API you should implement in the java file.
In the processData (byte[] data) , you can judge each command if the one you
expected, and response the command you want to send.
sessionStarted () is called when the tag re-enterField, so you maybe want to clear
some variable in this method. sessionEnded()is called when one session ended.
Figure 71 - Souce Code
66
Figure 72 -
Figure 73 -
Figure 74 -
Right Click the file to select Run As->1 Java Application to run
Figure 75 -
Figure 76 -
67
68
1 You can Click the Select button to import the XML file
Figure 77 -
3 Click the Enter Field button.You can see the tag communicates with the card
simulator.
Figure 78 -
Figure 79 -
69
70
Figure 80 -
After you fill the Project name,Package and Name ,click Finish to complete the
Wizards
You can specify the command you want to send and the response you expected to
receive in an XML file .
71
You can implement more complicated function by programming in the java file
which automatically generated with the contact-less reader application.
There are some API you should implement in the java file.
firstCmd()return the first command you want to send, normally it will be select the card
emulation application aid , like in the xml file the cmd is
00A4040010A0000000185000000000000052414441.
In the processData (byte[] data) , you can judge each command if the one you
expected, and response the command you want to send.
sessionStarted () is called when click start button( the commnucation between the card
simulator/real card and the contact-less reader application start) , so you maybe want
to clear some variable in this method. sessionEnded()is called when one session
ended.
Figure 81 -
72
Figure 82 -
Right Click the reader.java file to select Run As->1 Java Application
Figure 83 -
Figure 84 -
You can select Click the Select button to select the XML file then Click the Start
button
Figure 85 -
Figure 86 -
73
74
Figure 87 -
Run the project and Click the NFC Window to see how they work
You will see the picture below to select the available reader mode simulator
Figure 88 -
Click the Enter Field button.You will see how they work
75
7
Worked Example with USIM
Toolkit Applet
This chapter takes you stepbystep through a worked example of how to create an
applet in your smart card.
In this chapter you will learn how to:
1
Note: You can also use the JCardManager and Application Manager to load and
install an applet in the card. For the former, refer to Appendix B - The
JCardManager. For the latter, refer to Chapter 14 - Using the Application Manager.
On the Java Card Project Management view as Figure 25 - Java Card Project
Management View on page 32 shows, double-click Java Card Project (the top
icon on the left column).
The Java Card Project wizard starts and displays the first step to let you define the
settings for your project files: Name and Path Name. For the Path Name you can
78
Note: At any time during the execution of the wizard you can click: Back to return to
the previous step, Finish to complete the wizard using the default settings, or Cancel
to stop the wizard.
5
The Java Card Project wizard displays the next step to let you define your
Package name and Package AID. Enter the required information and click Next to
continue.
The Java Card Project wizard displays the next step to let you select the type of
card for which you are creating the project. It also provides details about the
standards that will be used for your project. In Card type, select USIM Card R5
and click Next to continue.
79
The Java Card Project wizard displays the next step to let you optionally choose a
sample as the template for your new project, as below:
To use a sample template, select the Create a project from one of available
sample templates checkbox and select a template from the Available
Samples combo box.
Click Next button to continue.
On the Sample Template Information page, select dependencies projects for
the main project and click Finish to complete the wizard.
If you dont want to use a sample template, click Next button to continue.
The Java Card Project wizard displays the next step to let you select whether or
not you want to use an APDU trace format (ATF) personalization script for the
project. This script would be run before the applet is loaded in the card or simulator.
It could for example be used to create files that will be used by the applet. To use a
script, check the box Select a personalization script, then enter the path and
name of the script file in ATF Script. You can use the browse button
to the right
of the box to select the script file. Click Next to continue.
80
Note: You can also include personalization scripts by customizing the generated
_.load.gxsc file using the Script Editor.
9
The Java Card Project wizard displays the next step to let you choose which tool
you want to use for running and debugging your applet:
Mobile Simulator 3G
Command Line
JCardManager
Simulation Chain 2G
Simulation Chain 3G
None
81
10 The Java Card Project wizard displays the next step to let you add external export
files to the project.
Figure 92 - Java Card Project Creation Wizard - Step 7
Note: Adding external files is optional. It is necessary, however, if you are importing
an external library into your project:
b) When the Select the directory window opens, browse to the export file that
you want to add to the project. Repeat this operation for each file to be added.
To edit the path name of an export file:
a) Select the export file in the Step 7 Export Files window.
b) Click
11 Set the class path and optionally the source path of the external library.
Note: You only need to set the source path if you want to debug this external library.
To set the class path:
a) Click the Class Path tab in the Step 7 Export Files window.
82
b) Use the buttons to add, edit or remove paths in the same way as for export
files.
The class path is used when compiling the project (an external library configuration
is created).
To set the source path:
a) Click the Source Path tab in the Step 7 Export Files window.
b) Use the buttons to add, edit or remove paths in the same way as for export
files.
12 Click Next to continue. The Java Card Project wizard displays the final step to let
you add DAP load parameters as shown in the following figure:
Figure 93 - Java Card Project Creation Wizard - Step 8
Note: This step is optional. To simplify your project, you can omit DAP settings during
initial development, debugging and testing. Then if you want to use DAP to load your
application, you can add it at a later stage by downloading it with the JCardManager or
Application Manager.
83
b) In Security Domain, enter the AID of a security domain or select it from the list.
c) Either choose the option button Manual, and enter the value of the DAP
parameters in DAP Value, or choose the option button Automatic and specify
the Key Definition parameters. In Key Definition field:
Select Key File option button. Check Use default key file or enter values for
Key file, Key set version (hex), and Key index in set.
Or select Key value, and then either enter the value in Key or select it from the
list.choose one of the option buttons Key file or Key value.
84
15 After creation, the Project Properties Editor launches with the created projects
definition. Please refer to Project Properties Editor on page 38 for more
information.
When you start the wizard, the first step window displays to let you define the
package settings for your USIM Toolkit applet:
Enter the Applet name and Applet AID, then click Next to continue.
2
The Toolkit Applet wizard displays the next step, as shown in Figure 96, to let
you define the applet's Instance AID and any optional Application specific
parameters that will be used for the applet. These parameters are the Application
specific parameters passed in the applets install() method defined in the Java
Card specification and also in the Install command, as specified in the Global
85
Enter the Instance AID value. If you are entering application specific parameters,
check the box Application specific parameters and enter the value in Specific
parameters. Click Next to continue.
The Toolkit Applet wizard displays the next step to let you select the event(s) that
trigger the applet as shown in the following figure:
Figure 97 - The Toolkit Applet Wizard Step 3
86
Select the event(s) that you want to trigger the applet in the Toolkit events
available column and click the right arrow. The events appear in the Toolkit
events selected column. To remove any selected events, select them in the right
pane and click the left arrow. Click Next to continue.
The Toolkit Applet wizard displays the next step to let you to define the USIM
Toolkit applet's installation parameters. Click each folder in turn to expand it and
reveal the parameters.
Note: If you had chosen a (U)SIM R6 or R-UIM card instead of a USIM card as your
card type when creating the Java Card project, this fourth step would contain a slightly
different list of parameters.
5
Click the + next to Menus, to display the menus as shown in the following figure:
87
a) If you want to add one or more menus, click + for each new menu. You can
remove a menu by selecting it and clicking -. The Max Menu Entries
automatically displays the number of menus. For this example, click + once to
add a second menu.
b) Enter a value in hex for Max Text Length.
c) If you want to change the values for Position and/or Identifier, double-click the
value you want to change and enter the new value. By default, the wizard gives
a position of 0, which means that the operating system chooses the position for
you.
d) Click the - next to Menus to hide the menu parameters.
6
Click the + next to Priority and Timer, to display the priority level and maximum
number of timers as shown in the following figure:
Figure 100 - The Toolkit Applet Wizard Step 4 Priority and Timers
Enter the Priority Level value (01hFFh where FFh is the lowest priority) and Max
timer value (the maximum number of timers).
e) Click the - next to Priority and Timer, to hide the priority level and maximum
number of timers parameters.
88
Click the + next to Minimum security level, to display these parameters as shown
in the following figure:
Figure 102 - The Toolkit Applet Wizard Step 4 Min. Security Level
89
Choose Proprietary Mechanisms, enter the MSL parameter and MSL data
Choose Minimum SPI1, and click Edit to display the Security Parameters
dialog box as shown in the following figure:
90
Figure 104 - The Toolkit Applet Wizard Step 4 SIM Access Parameters
If you choose APDU access mechanism, click Edit and in the dialog box Set
the access rights, check the codes that the applet is considered to know, that
is the code is considered as being correctly presented. This is used to access
the files in the file system.
If you choose 3GPP access mechanism, enter the value in Access Domain
Data.
If you choose Custom Access domain, enter the values in Access Domain
Parameter and Access Domain Data.
Note: For more detailed information about the individual parameters, click Help. For
information about the Access Domain Data values, refer to 3GPP TS 23.048 for
details.
Click Next to continue.
11 The Toolkit Applet wizard displays the next step to let you enter titles for the
menus you specified in the previous step. Click each title that you want to edit and
enter the title. When you have finished, click Next.
12 The Toolkit Applet wizard displays the last step to let you select whether or not
you want to use an ATF personalization script for the applet, for example to update
files. To use a script, check the box Select a personalization script, then enter
91
the path and name of the script file in ATF Script. You can use the browse button
to the right of the box to select the script file.
Note:
A personalization script is used to perform tasks that are only required once when the applet is
initially installed. A typical example is initializing objects (for example, key values) used by the
applet - in this case the script would contain APDU commands to be executed by the applet via its
process() method.
You can also include personalization scripts by customizing the _.load.gxsc file using the
Script Editor.
13 Click Finish to complete the wizard. Eclipse displays the Java code for your newly
created applet as shown in the following figure:
Figure 105 - The Toolkit Applet Wizard Termination
The Mobile Simulator GSM, Mobile Simulator 3G, or Mobile Simulator CDMA.
The JCardManager for Java CardGP applets (but you can also use it to send
APDU commands to a Toolkit applet).
92
Simulation Chain 2G (for SIM Toolkit or CCAT Toolkit applets), or Simulation Chain
3G for USIM Toolkit applets).
Note: You can change the client application in the Run or Debug window by selecting
a different application in the Choose the client application to run list (see Figure
108 - Debug window on page 94). In fact the two windows are almost identical apart
from the Run or Debug button at the final step.
As the applet in this example is a USIM Toolkit Applet, this chapter describes how to
debug the applet with the Mobile Simulator 3G. Examples for debugging with
JCardManager or the OCF client or JCRMI client applications, are given in Chapter
8 - Worked Example with JCRMI Applet and Client.
Full Version
Can load and simulate two cards and simulate dual slot operation
No APDU Exchange
No pause mode
Note: These capabilities are valid for all the Mobile Simulators.
93
IDE
Card
Simulator
Applet
Client
Application
Notify
execution
stopped
(Step 4)
Stop
on
Breakpoint
Trigger
Applet
User Interaction
Automated Action
In the .java source file, set a breakpoint at the menuAction line (single menu that
you specified in step 4a) on page 87).
94
To remove a breakpoint:
Double-click the gray bar to the left of current line. The bullet disappears.
In Eclipse, select Project > Run > Debug to open the Debug window.
In the tree structure in the left pane, click the Javacard Project Launch node and
select your project to display the runtime configuration as shown in the following
figure:
From the Choose client application to run dropdown menu, select Mobile
Simulator 3G. Features availability varies according to the license status of
Simulation Suite V2.0 on your PC.
Click Apply and then Close to close Debug window if you want to debug later.
Click Debug to close the Debug window and start debugging right away.
This: launches the card simulator, loads the applet and runs any personalization
scripts, and launches the Mobile Simulator 3G.
for OK.
for OK.
95
96
for OK.
A dialogue prompts to you, asking whether you like to switch to Debug perspective
or keep using current one. Click No to continue.
Execution stops.
97
Authenticate
Load
You can edit the script by rightclicking the _load.gxsc file in the Package Explorer
window, and choosing Script > Edit as shown in the following figure:
Figure 111 - Accessing the Script File in Eclipse
98
This action opens the Script Editor as shown in the following figure:
Figure 112 - Script Editor Showing the Load Script
To edit the parameters of a command, select the command in the Command list on
the left.
You can also use the Script Editor to add applet or card personalization scripts. To load
and install the USIM Toolkit Applet, run the load script by rightclicking the _load.gxsc
file in the Project window, and choose Script > Play.
Load the applet on the card, for example, using the GXSC deployment script.
8
Worked Example with JCRMI
Applet and Client
This chapter presents an example of how to create a Java Card RMI applet and a Java
Card RMI client application.
In this example, you will create a JCRMI applet that defines and implements an
interface with a method called sum that returns the result of two numbers added
together. You will also create a JCRMI Client project that connects to the applet and
calls the sum method in the applet.
Note: Typically, the Remote Object Interface wizard is invoked during step 2 of the
JCRMI applet wizard. This example runs it before the JCRMI Applet Wizard in order to
describe it more clearly.
This example uses the following steps:
1
Add a JCRMI Applet to the Java Card Project that will use the remote object
Create a JCRMI Client Project that will use the JCRMI applet
Test the Applet in the card using the JCRMI Client application
100
Make sure you are in Developer Suite perspective. More information on this
perspective has been mentioned in the previous chapter on page 31.
Note: You can only select the Remote Object wizard if you have previously created a
project with the Java Card Project wizard specifying card type USIM card R5, USIM
card R6, or R-UIM card. This example shows a typical USim Card R6 project. At any
time during the execution of the wizard you can click Back to return to the previous
step, Finish to complete the wizard using the default settings, or Cancel to stop the
wizard.
For this example, click Create a new interface, and enter the values for Interface
name, Implementation name and select a Base Class.
Note: You could also select Use existing interface and use the browse button
select the existing interface. In this case, the wizard skips the next wizard step.
2
Click Next.
to
The wizard displays step 2 as shown in the following figure where you define the
new interface.
Click
to open the Add Method dialog box as shown in the following figure:
101
102
You do not need them for this example, but you can use the edit buttons
and
remove buttons
to edit and remove parameters and exceptions. In the
Parameters section, you can change the order by using the up and down arrow
buttons. For more detailed help, click Help.
In this example you have not added any exceptions, but the buttons operate in the
same way as Parameters.
When you have completed the Add Method information, click OK. This returns you
to the Step 2 window. Again you can use the edit
and remove
buttons to
edit and remove methods.
In the step 2 window, click Next.
103
The final step of the wizard lets you specify the stub generators, as shown in the
following figure:
Check the box for the stub generators that you want to include (you must check at
least one of the boxes). If you want you can change the Directory Target by using
the browse buttons.
If you included the SATSA stub generator, enter the version of WTK in WTK Home
by selecting it from the list or using the browse button to reference it from your hard
disk. Optionally, check the Preverification box if you want to preverify the remote
object.
Note: The preverify process checks for the existence of finalizers, native method calls,
or floating point operations which may be prohibited by the connected limited device
configuration (CLDC).
When you have finished, click Finish.
Eclipse creates and displays the remote object.
7
In the Java Card project, select the class containing the interface implementation
on the Implementation tab to display the Java source code.
104
Locate the /**@todo YOUR CODE HERE*/ line and replace it with content
highlighted in the following figure. Also remember to change the result line below.
Compile the project by choosing Run > Run As > Java Card Project or using the
direct button
in Eclipse Toolbar.
105
When you start the wizard, the first step window displays to let you define the
package settings for your JCRMI Applet:
Enter the Applet name, and Applet AID then click Next to continue.
2
The JCRMI Applet wizard displays the next step as shown in Figure 120 to let
you select the remote object to use as the initial reference. For this example leave
the remote object you have just created as the initial reference. The wizard can let
106
you select an external project or create a new remote object. For more details
about these, click
.
Figure 120 - The JCRMI Applet Wizard Step 2
The JCRMI Applet wizard displays the next step as shown in Figure 121 to let
you define the applet's Instance AID and any optional Application specific
parameters that will be used for the applet. These parameters are the Application
specific parameters used in the Install command, as specified in GP 2.1.1. Refer
to GlobalPlatform Card Specification, Version 2.1.1 for more details.
107
Enter the Instance AID value. If you are entering application specific parameters,
check the box Application specific parameters and enter the value in Specific
parameters. Click Next to continue.
4
The JCRMI Applet wizard displays the last step to let you select whether or not
you want to use an ATF personalization script for the applet, for example to update
files. To use a script, check the box Select a personalization script, then enter
the path and name of the script file in ATF Script. You can use the browse button
to the right of the box to select the script file.
Click Finish to complete the wizard. Eclipse displays the Java code for your newly
created applet.
In Step 1, enter the information for the JCRMI client application and click Next.
108
In Step 2, enter the information for the JCRMI applet and click Next. This displays
the third and final step as follows:
If you checked GP Secure Channel in step 2 of the JCRMI applet wizard (see
Figure 120 on page 106), check Use GP Authentication and complete the
section Card Property File. In the Card Property File, either leave Use default
key file checked or clear it and browse to the key file that you want to use for
authentication. In this case you can use the dropdown combo boxes to modify the
Key set version. You can also change the values of the keys themselves by
clicking Edit.
In Security Level (SCP01) choose the level of security you want for the secure
channel by clicking one of the option buttons.
Click Finish.
109
Locate the line /**@todo ADD YOUR TEST HERE*/. Replace it with the lines 2329 as shown in the following figure:
Select the tab with the projects remote interface implementation and in the .java
source file, set breakpoints (see Step 1: Setting breakpoints in the applets code
on page 93 for more details about breakpoints). For this example, set a breakpoint
in the line shown in the following figure:
In Eclipse, select Debug from the Run menu. This opens the debug window.
To create a Debug configuration for client project, expand Java Application node
in the tree structure in the left pane. Click the
button. A new item named
New_configuration is added under Java Application and by default selected.
110
On the configuration page shown on the right, enter a name for the new
configuration(e.g. JCRMIClient). Click Browse and select your client project. Click
Search and select the class package of your client project.
Then, in the tree structure in the left pane, switch to the applet project. On the run
time configuration pane to the right, select Client Test Application from the
Choose client application to run drop-down list, as shown in the following figure:
Click Customize. This opens the Application Parameter Editor dialog box.
In the Application Parameter Editor dialog box, click Browse and select the
JCRMI client project.
111
10 If you dont start debugging immediately, click Apply to save changes and then OK
to close the Debug window.
11 If you want to start debugging right away, click Debug button. This builds (compiles
and converts) the project, launches the card simulator, loads the applet in the card
simulator and runs any personalization scripts, and launches the client application.
Note: Eclipse may prompt a dialogue to you, asking whether to change current
perspective to Debug. Click No to discard it.
9
Worked Example with
JavaCard Applet and Client
This chapter presents an example of how to create a JavaCard applet and a Java Card
client application.
A Java Card applet can be debugged and tested using either an OCF Client application
or the JCardManager. This example shows how to use both options and uses the
following steps:
1
Test the Applet in the Card using the JCardManager and OCF client application.
Make sure you are in Developer Suite perspective. More information on this
perspective has been mentioned in the previous chapter on page 31.
114
Note: You can only select the JavaCard Applet wizard if you have previously created
a project with the Java Card Project wizard.
When you start the JavaCard Applet wizard, the first step window displays the first
step to let you define the package settings for your JavaCard applet. Enter the
Applet name, and Applet AID then click Next to continue.
The JavaCard Applet wizard displays the next step to let you define the applet's
Instance AID and any optional Application specific parameters that will be used
for the applet. These parameters are the Application specific parameters used in
the Install command, as specified in GP 2.1.1. Refer to GlobalPlatform Card
Specification, Version 2.1.1 for more details.
Enter the Instance AID value. If you are entering application specific parameters,
check the box Application specific parameters and enter the value in Specific
parameters. Click Next to continue.
The JavaCard Applet wizard displays the next step to let you select whether or not
you want to use an ATF personalization script for the project. To use a script, check
the box Select a personalization script, then enter the path and name of the
script file in ATF Script. You can use the browse button
to the right of the box
to select the script file.
Note: A personalization script is used to perform tasks that are only required once
when the applet is initially installed. A typical example is initializing objects (for
example, key values) used by the applet - in this case the script would contain APDU
commands to be executed by the applet via its process() method.
4
Click Next. This displays the final step of the wizard in which you choose the
following Java Card options for the applet
Set breakpoints for the Initialize Update and External Authenticate commands in
the .java source file.
115
In Eclipse, select Debug from the Run menu. This opens the debug window.
In the tree structure in the left pane, switch to the applet project. On the run time
configuration pane to the right, select JCardManager from the Choose client
application to run drop-down list, as shown in the following figure:
If you dont start debugging immediately, click Apply to save changes and then OK
to close the Debug window.
If you want to start debugging right away, click Debug button. This: builds
(compiles and converts) the project launches the card simulator, loads the applet
and runs any personalization scripts, and launches the JCardManager.
In the Choose client application to run dropdown list, select Client Test
Application.
116
Create a Debug configuration for your Client Test project, as described by 2-5 in
Step 3: Debugging the project on page 109.
Click Customize. This opens the Application Parameter Editor dialog box.
In the Application Parameter Editor dialog box, click Browse and select the OCF
client project.
If you dont start debugging immediately, click Apply to save changes and then OK
to close the Debug window.
If you want to start debugging right away, click Debug button. This builds (compiles
and converts) the project, launches the card simulator, loads the applet in the card
simulator and runs any personalization scripts, and launches the client application.
If necessary, change the client program in the Edit Runtime Configuration dialog
box as follows:
For the OCF client, choose Client Test Application, and click Customize to
select the OCF client project.
If the applet is a GP applet, issue the commands you want to test the applet in the card
using Send APDU Secure (Commands > USim Card R6 > Platform > GP > Send
APDU Secure).
If the applet is not a GP applet, issue the commands you want to test the applet in the
card using APDU Commands (directly under Commands).
10
Worked Example with SATSA
MIDlets
This chapter presents an example of how to create a Security and Trust Services API
(SATSA) compatible midlet and configure it to access an applet on a card.
A MIDlet is a Java program for embedded devices, more specifically the Java ME
virtual machine. Generally, these are games and applications that run on a cell phone.
It is an application written for MIDP. MIDlet applications are subclasses of the
javax.microedition.midlet.MIDlet class that is defined by MIDP (Mobile Information
Device Profile). SATSA provides a standard API to allow MIDlets to communicate with
Java Card applets.
Note: Before starting this example, make sure that you have already installed Eclipse
Enterprise or Developer editions, and the Wireless Toolkit (WTK) 2.3. For details on
how to install WTK 2.3, refer to Importing WTK Devices Into Eclipse on page 16.
Overview
The major steps described in this example are:
1
Develop an applet. For SATSA, this applet can be a Java Card Applet, a Toolkit
Applet, or a JCRMI Applet.
In the MIDlet, add a SATSA access method to allow it to communicate with the
applet.
Create a new Java Card project: On the Java Card Project Management view,
double-click Java Card Project from Application Wizards field.
At Step 1 of the wizard, specify a name for the project and the Directory in which to
store project files.
At Step 5 of the wizard, choose Midlet Test Application from the list of available
Tools.
118
On the Add Method window, define an Add method in the remote interface with a
return type of Short and two Short parameters:
119
In the source code for the remote interface implementation, find the Add method.
Modify the code as follows and set a breakpoint on the highlighted line:
In Eclipse, from the File menu select New > Project. This action starts the New
Project window.
On the New Project window, unfold J2ME and select J2ME Midlet Suite under it,
as shown by the following figure:
In Name enter a name for your project, for example satsamidlet. Optionally you
can choose to change the default values for Location or enable preprocessing.
Click Next to continue.
120
In step 2 of the Project Wizard, select a device group and choose the device. You
can click Manage Devices button to import devices. Here Wireless Toolkit 2.5
should have been imported by you during post-installation phase following the
steps described in Importing WTK Devices Into Eclipse on page 16.
Click Finish to complete the wizard and generate skeleton code for the applet in
Eclipse.
In Eclipse, from the File menu select New > Other. This action starts the New
window.
On the New window, unfold J2ME and select J2ME Midlet under it, as shown by
the following figure:
121
For Source Folder, browse to select the midlet project you created (or any midlet
project you want to add the midlet to) in Source Folder Selection window.
Click OK to close Source Folder Selection window. Back on step1of New J2ME
Project wizard window, enter a name for the midlet (e.g. midlet1) and click Finish
to complete creation of the new midlet.
You have now created a midlet. In our example this is called midlet1.java (the name
chosen in step 1 of the wizard).
122
On Application Wizards area, double-click the SATSA Midlet Access icon. This
starts step1 of the SATSA Midlet Access wizard.
123
After selection, the boxes Applet Name, Applet AID and Instance AID display the
values used by the applet.
Check one or both of the boxes SATSA JCRMI Access and SATSA APDU
Access according to whether you want to access the JCRMI applet directly, with
APDU commands, or both. By default, SATSA APDU Access is already checked.
In this example, we only check SATSA JCRMI Access (as Figure 136 shows).
When SATSA JCRMI Access is checked, the corresponding Initial Reference is
automatically displayed.
Modify the source code as shown below to call the remote JCRMI method in the
MIDlet and set a breakpoint on the line:
In Eclipse menu bar, select Run > Debug to open Debug window.
In the tree structure in the left pane, select the project which contains the applet to
debug. On the run-time configuration page for current project to the right, click
124
Choose the client application to run drop-down menu and select Midlet Test
Application as the client application to run.
Figure 138 - Debug Configuration for the JCRMI Applet Project
125
Run the midlet from the WTK mobile simulator window. The previously set
breakpoints are triggered (for example, the breakpoint set in the applets remote
Add methodsee Figure 129 on page 119). The results printed by the remote
JCRMI method (see Figure 137 on page 123) are printed to the Messages area of
the Eclipse IDE.
You can now proceed to perform on-card testing by downloading the applet to a real
card.
11
Worked Example with Servlet
and Toolkit
This chapter takes you stepbystep through a worked example of how to create an
servlet and test it in your SCWS card.
In this chapter you will learn how to:
1
Note: You can also use the JCardManager and Application Manager to load and
install an servlet in the card. For the former, refer to Appendix B - The
JCardManager. For the latter, refer to Chapter 14 - Using the Application Manager.
On the Java Card Project Management view as Figure 25 - Java Card Project
Management View on page 32 shows, double-click Java Card Project (the top
icon on the left column).
The Java Card Project wizard starts and displays the first step to let you define the
settings for your project files: Name and Path Name. For the Path Name you can
128
Note: At any time during the execution of the wizard you can click: Back to return to
the previous step, Finish to complete the wizard using the default settings, or Cancel
to stop the wizard.
5
The Java Card Project wizard displays the next step to let you define your
Package name and Package AID. Enter the required information and click Next to
continue.
The Java Card Project wizard displays the next step to let you select the type of
card for which you are creating the project. It also provides details about the
standards that will be used for your project. In Card type, select NFC with
propriety SCWS to continue.
129
The Java Card Project wizard displays the next step to let you optionally choose a
sample as the template for your new project, as below:
To use a sample template, select the Create a project from one of available
sample templates checkbox and select a template from the Available
Samples combo box.
Click Next button to continue.
On the Sample Template Information page, select dependencies projects for
the main project and click Finish to complete the wizard.
If you dont want to use a sample template, click Next button to continue.
The Java Card Project wizard displays the next step to let you select whether or
not you want to use an APDU trace format (ATF) personalization script for the
project. This script would be run before the applet is loaded in the card or simulator.
It could for example be used to create files that will be used by the applet. To use a
script, check the box Select a personalization script, then enter the path and
name of the script file in ATF Script. You can use the browse button
to the right
of the box to select the script file. Click Next to continue.
130
Note: You can also include personalization scripts by customizing the generated
_.load.gxsc file using the Script Editor.
9
The Java Card Project wizard displays the next step to let you choose which tool
you want to use for running and debugging your applet:
Mobile Simulator 3G
Command Line
JCardManager
Simulation Chain 2G
Simulation Chain 3G
None
131
10 The Java Card Project wizard displays the next step to let you add external export
files to the project.
Figure 144 - Java Card Project Creation Wizard - Step 7
Note: Adding external files is optional. It is necessary, however, if you are importing
an external library into your project:
b) When the Select the directory window opens, browse to the export file that
you want to add to the project. Repeat this operation for each file to be added.
To edit the path name of an export file:
a) Select the export file in the Step 7 Export Files window.
b) Click
11 Set the class path and optionally the source path of the external library.
Note: You only need to set the source path if you want to debug this external library.
To set the class path:
a) Click the Class Path tab in the Step 7 Export Files window.
b) Use the buttons to add, edit or remove paths in the same way as for export
files.
132
The class path is used when compiling the project (an external library configuration
is created).
To set the source path:
a) Click the Source Path tab in the Step 7 Export Files window.
b) Use the buttons to add, edit or remove paths in the same way as for export
files.
12 Click Next to continue. The Java Card Project wizard displays the final step to let
you add DAP load parameters as shown in the following figure:
Figure 145 - Java Card Project Creation Wizard - Step 8
Note: This step is optional. To simplify your project, you can omit DAP settings during
initial development, debugging and testing. Then if you want to use DAP to load your
application, you can add it at a later stage by downloading it with the JCardManager or
Application Manager.
133
b) In Security Domain, enter the AID of a security domain or select it from the list.
c) Either choose the option button Manual, and enter the value of the DAP
parameters in DAP Value, or choose the option button Automatic and specify
the Key Definition parameters. In Key Definition field:
Select Key File option button. Check Use default key file or enter values for
Key file, Key set version (hex), and Key index in set.
Or select Key value, and then either enter the value in Key or select it from the
list.choose one of the option buttons Key file or Key value.
134
b) Browse to locate the files and folders to add. Only a single file or folder can be
added at one time.
c) Add files and folders one by one.
d) During this process, user can also select an added file or folder and click the
button to remove it.
e) After selection, click Finish to complete the wizard.
15 You project is completed now. You can see an
icon followed by your project
name in Package Explorer view on the left-hand of current workbench.
16 After creation, the Project Properties Editor launches with the created projects
definition. Please refer to Project Properties Editor on page 38 for more
information.
Servlet with STK features - a USIM R5 Toolkit Applet with extended SCWS
features
Both servlet types share that same SCWS Card profile the project definition.
In Package Explorer, select the Java Card project your just created (or any existing
Java Card project you want to add the servlet to). On the Java Card Project
Management view (as in Java Card Project Management View on page 32), doubleclick Servlet or Servlet with STK features to start the Servlet wizard.
135
When you start the wizard,you should choose the servlet and toolkit (refer to the
Demo of the NFC Card )the window displays to let you define the package settings
for your servlet:
Enter the Servlet name, Servlet AID and Servlet URL, then click Next to
continue.
2
The Servlet wizard displays the next step, as shown in Figure 148, to let you
define the applet's Instance AID and any optional Application specific
parameters that will be used for the applet. These parameters are the Application
specific parameters passed in the applets install() method defined in the Java
Card specification and also in the Install command, as specified in the Global
136
Enter the Instance AID value. If you are entering application specific parameters,
check the box Application specific parameters and enter the value in Specific
parameters. Click Next to continue.
3
This displays step 3 of the Servlet wizard which lets you set servlet parameters.
In the HTTP Methods combo box, click checkboxes in list to select HTTP Methods
to use. Use Select/Deselect All button to select/deselect all options.
In the Servlet Options field, check to use Chunked encoding or leave it
deselected.
After specify the above two options, click Next to proceed.
If you are creating a Servlet, jump to 17, the last step of the wizard.
137
If you area creating a Servlet with STK features, go step by step to finish the
wizard.
The Servlet wizard displays the next step to let you select the event(s) that trigger
the applet as shown in the following figure:
Select the event(s) that you want to trigger the applet in the Toolkit events
available column and click the right arrow. The events appear in the Toolkit
events selected column. To remove any selected events, select them in the right
pane and click the left arrow. Click Next to continue.
138
The Servlet Applet wizard displays the next step to let you to define the USIM
Toolkit applet's installation parameters. Click each folder in turn to expand it and
reveal the parameters.
Click the + next to Menus, to display the menus as shown in the following figure:
a) If you want to add one or more menus, click + for each new menu. You can
remove a menu by selecting it and clicking -. The Max Menu Entries
automatically displays the number of menus. For this example, click + once to
add a second menu.
b) Enter a value in hex for Max Text Length.
c) If you want to change the values for Position and/or Identifier, double-click the
value you want to change and enter the new value. By default, the wizard gives
139
a position of 0, which means that the operating system chooses the position for
you.
d) Click the - next to Menus to hide the menu parameters.
7
Click the + next to Priority and Timer, to display the priority level and maximum
number of timers as shown in the following figure:
Enter the Priority Level value (01hFFh where FFh is the lowest priority) and Max
timer value (the maximum number of timers).
e) Click the - next to Priority and Timer, to hide the priority level and maximum
number of timers parameters.
140
Click the + next to Minimum security level, to display these parameters as shown
in the following figure:
141
Choose Proprietary Mechanisms, enter the MSL parameter and MSL data
Choose Minimum SPI1, and click Edit to display the Security Parameters
dialog box as shown in the following figure:
142
If you choose APDU access mechanism, click Edit and in the dialog box Set
the access rights, check the codes that the applet is considered to know, that
is the code is considered as being correctly presented. This is used to access
the files in the file system.
If you choose 3GPP access mechanism, enter the value in Access Domain
Data.
If you choose Custom Access domain, enter the values in Access Domain
Parameter and Access Domain Data.
Note: For more detailed information about the individual parameters, click Help. For
information about the Access Domain Data values, refer to 3GPP TS 23.048 for
details.
143
You can either use the default value or change the number by clicking the spin box.
The maximum value is 8.
13 Click the + next to Toolkit Parameters DAP, to display these parameters as
shown in the following figure:
Figure 159 - The SCWS Wizard Step 5 Toolkit Parameters DAP
If you want to enter DAP information, check Compute DAP and select the
Algorithm from the list, otherwise leave this box empty.
144
The UICC Access Application Specific Parameters folder lets you specify the ADF
AID (except for parameter 1), the file system access conditions and DAP
information. Use the Add and Remove buttons for each parameter that you want to
add or remove. Expand each parameters folders by clicking +.
15 Click the + next to UICC Admin Access Application specific parameters, to
display these parameters as shown in the following figure:
Figure 161 - The SCWS Wizard Step 5 UICC Admin Access Application paras
145
The UICC Admin Access Application Specific Parameters folder lets you specify
the ADF AID (except for parameter 1), the file system access conditions and DAP
information. Use the Add and Remove buttons for each parameters that you want
to add or remove. Expand each parameters folder by clicking +.
Click Next to continue.
16 The Servlet wizard displays the next step to let you enter titles for the menus you
specified in the previous step. Click each title that you want to edit and enter the
title. When you have finished, click Next.
17 The Servlet wizard displays the last step to let you select whether or not you want
to use an ATF personalization script for the applet, for example to update files. To
use a script, check the box Select a personalization script, then enter the path
and name of the script file in ATF Script. You can use the browse button
to the
right of the box to select the script file.
Note:
A personalization script is used to perform tasks that are only required once when the applet is
initially installed. A typical example is initializing objects (for example, key values) used by the
applet - in this case the script would contain APDU commands to be executed by the applet via its
process() method.
You can also include personalization scripts by customizing the _.load.gxsc file using the
Script Editor.
18 Click Finish to complete the wizard. Eclipse displays the Java code for your newly
created applet as shown in the following figure:
Figure 162 - The Servlet Wizard Termination
146
Note: You can change the client application in the Run or Debug window by selecting
a different application in the Choose the client application to run list (see Figure
165 - Debug Window on page 148). In fact the two windows are almost identical
apart from the Run or Debug button at the final step.
In this chapter, we use Mobile Simulator 3G and Static Content Explorer as example.
Full Version
Can load and simulate two cards and simulate dual slot operation
No APDU Exchange
No pause mode
Note: These capabilities are valid for all the Mobile Simulators.
IDE
Card
Simulator
Applet
Client
Application
Notify
execution
stopped
(Step 4)
Stop
on
Breakpoint
User Interaction
Automated Action
Trigger
Applet
147
In the .java source file, set a breakpoint at the return line of process(APDU)
command on page 138).
To remove a breakpoint:
Double-click the gray bar to the left of current line. The bullet disappears.
In Eclipse, select Project > Run > Debug to open the Debug window.
148
In the tree structure in the left pane, click the Javacard Project Launch node and
select your project to display the runtime configuration as shown in the following
figure:
From the Choose client application to run dropdown menu, select Static
Content Explorer.
Click Apply and then Close to close Debug window if you want to debug later.
Click Debug to close the Debug window and start debugging right away.
149
This launches the card simulator, loads the servlet and runs any personalization
scripts, and launches the Static Content Explorer.
Launch system web browser in Eclipse Editor view panel to display a selected
oncard file.
Create oncard folder(s) at any node of the static content tree structure.
For more details on the Static Content Explorer, please refer to Static Content
Explorer on page 20.
150
Follow Step 1: Setting breakpoints in the Servlets code on page 147 to complete
setting breakpoints.
Refer to Step 2: Debugging the project on page 147 to open the Debug window.
On the Debug window as Figure 165 - Debug Window on page 148 shows,
select Mobile Simulator 3G from the Choose client application to run drop
down menu. Features availability varies according to the license status of
Simulation Suite V2.0 on your PC.
Click Apply and then Close to close Debug window if you want to debug later.
Click Debug to close the Debug window and start debugging right away.
This launches the card simulator, loads the applet and runs any personalization
scripts, and launches the Mobile Simulator 3G.
for OK.
for OK.
151
152
Select On Card Portal menu. This launches the browser within the Mobile
Simulator 3G and displays On Card Portal default page.
If no page has been specified for On Card Portal home, the browser displays the
HTTP 404 Error The page can not be found information.
10 A dialogue prompts to you, asking whether you like to switch to Debug perspective
or keep using current one. Click No to continue.
11 Execution stops.
12 Continue with Step 4: Notification that execution has stopped on a breakpoint on
page 150 and Step 5: Bug detection and correction on page 150.
Authenticate
Load
153
You can edit the script by rightclicking the _load.gxsc file in the Package Explorer
window, and choosing Script > Edit as shown in the following figure:
Figure 169 - Accessing the Script File in Eclipse
This action opens the Script Editor as shown in the following figure:
Figure 170 - Script Editor Showing the Load Script
To edit the parameters of a command, select the command in the Command list on
the left.
You can also use the Script Editor to add applet or card personalization scripts. To load
and install the USIM Toolkit Applet, run the load script by rightclicking the _load.gxsc
file in the Project window, and choose Script > Play.
154
Load the applet on the card, for example, using the GXSC deployment script.
12
Worked Example with HTTP
MIDlet
This chapter presents an example of how to create a J2ME MIDlet and configure it to
access a servlet on SCWS card.
A MIDlet is a Java program that runs on a Java Mobile Edition (J2ME) virtual machine.
Note: Before starting this example, make sure that you have already installed Eclipse
Enterprise or Developer editions, and the Wireless Toolkit (WTK) 2.3 or higher. For
details on how to install WTK 2.3, refer to Importing WTK Devices Into Eclipse on
page 16.
Overview
The major steps described in this example are:
1
Develop an servlet. Servlet is the test target and can be visited with a HTTP access
enabled midlet.
Create a HTTP MIDlet. This step involves creating a J2ME MIDlet and giving it
access to a servlet via HTTP protocol. The HTTP midlet is then used as a midlet
test application in servlet debugging.
On the Java Card Project Management view, double-click Java Card Project.
At Step 1 of the wizard, specify project name and project file location.
At Step 3 of the wizard, choose SCWS Card from the Card type drop down list.
At Step 5 of the wizard, choose Midlet Test Application from the list of available
Tools.
Double-click Servlet on the Application Wizards area. This starts Servlet creation
wizard.
156
Follow the instructions to finish the wizard and generate skeleton code.
Tip: Chapter 11 - Worked Example with Servlet and Toolkit contains detailed
information on how to create a Java Card Project as well as to add a Servlet.
If you still feel unclear about Java Card Project and servlet creation, you are
recommended to write that chapter first.
In Eclipses Package explorer, select the Java Card Project we just created.
The Applications Wizards area shifts to a Java Card Project particular display.
On Application Wizards area, we can find shortcuts to Servlet and HTTP MIDlet
creation wizard.
Double-click the HTTP Midlet icon to starts step 1 of the HTTP Midlet Access
Wizard.
Click the
On the New J2ME Project window displayed, enter a name for the new MIDlet
project, e.g. httpmidlet. Click Finish to complete the new MIDlet project creation.
This adds the new MIDlet projects directory in Midlet Project text field and
enables the
button next to Target Midlet drop-down list.
7
In the Target Midlet drop-down list, select a MIDlet to use. The Target Midlet list
contains all midlet under the selected MIDlet project.
157
Back on the Http Midlet Access Wizard step 1, after you specify a MIDlet to use,
click Next to proceed.
10 The step 2 of HTTP Midlet Access Wizard is displayed, as the figures shows
below:
Figure 172 - HTTP Midlet Access Wizard - Step 2
11 In Project Path field, the Java Card Project and servlet we created before are
selected by default.
12 HTTP Host is set to http://127.0.0.1:3516 by default.
13 Click Finish to complete the wizard and generate skeleton code.
In Eclipse menu bar, select Run > Debug to open Debug window.
From the left pane, select the launch profile for this servlet project. It is usually
under the JavaCard Project Launch folder.
158
On the run-time configuration page to the right, click Choose the client
application to run drop-down menu and select Midlet Test Application.
13
Creating and Using Libraries
This chapter provides details of how to create and use libraries in Developer Suite
V3.2. It covers:
How to create libraries. This shows you how to initially create a library.
How to use a library. This shows you how to use the library in an applet.
How to use a gxsc script file. This shows you how to modify the automatically
generated project_Load.gxsc script file so that it can be used to load the library
onto the card before the applet.
To illustrate these topics, working examples are provided that make use of some of the
samples included with Developer Suite V3.2, the SMSLibrary package and the
SIMAPIExample applet.
In Eclipse, run the Java Card Project wizard, as described in Creating the Java
Card Project with the Eclipse IDE on page 77.
After creation of the project, double-click Library icon in Java Card Project
Management view, as shown in Figure 25 on page 32, this add a MyClass.java
file to your project. Once created, add any methods that you want to the library
project.
In Eclipse, run the Java Card Project wizard, as described in Creating the Java
Card Project with the Eclipse IDE on page 77.
160
Click the Class Path tab and add the path for the directory containing the librarys
class files. Typically this directory is the Classes directory of the library project.
Click the Source Path tab and add the path to the librarys source files. This is
necessary if you want to step into the library code when you debug your project.
At the end of the wizard you are asked Do you want to copy the selected export
files into your project workspace. Click Yes if you want to copy the files locally to
your project. This is recommended if the imported libraries are unlikely to be
modified, that is, the export and class files are not likely to change.
When you have finished with the wizards, modify the code in your project to access
the library.
The Script Editor window is opened displaying the commands included in the gxsc
script (Load Context, Authenticate, Install for Load, Load and Install for Install
when the project is initially generated).
When using libraries in an applet, for practical reasons it is recommended that you edit
this script file in order to load the library package you have created. Use the Script
Editor to add the Install for Load, and Load commands, necessary to load the library
and replay the personalization script. The SIMAPIExample_load.gxsc file included in
the SIMAPIExample project has been modified as follows:
Install for Load and Load commands have been added to load the SMSLibrary
package before the applet.
The Select and ATF Script Player commands have been added to select the GSM
application and personalize the EFadn file after downloading the applet.
14
Using the Application
Manager
This chapter introduces the Application Manager tool supplied with Developer Suite
V3.2. The Application Manager is used to download packages onto real cards and
install and delete applets or applet instances.
Introduction
The main features of the Application Manager are that it:
Over-the-air (OTA) mode, which uses the 3GPP TS 23.048 Short Message
Service (SMS) facility to remotely download applications. The Application
Manager generates the appropriate envelope commands and parameters and
sends the application to the target card encapsulated within one or more SMS
point-to-point data download messages.
Uses card profiles to configure all the parameters necessary to send applications to
specific card types in I/O or OTA mode. Each card profile is based on a template. A
preconfigured and fully tested template is supplied for each of the sample card
types delivered with the product you have purchased, for example, the GemXplore
3G V3. You can create, copy, and delete card profiles and modify their properties
as necessary.
Provides flexibility in terms of the tasks you can perform. For example, you can
load packages that contain only Java library classes referenced by other applets,
load packages and install several different applets from the package, or create
multiple instances of an applet that has already been loaded onto the card. You can
also choose to perform separate load and install operations. For example, you load
a package initially, then install the applets it contains later.
Allows you to debug the load and install process by means of an easy to
understand trace window.
162
Create, configure, or select a suitable target card profile for the card.
For detailed instructions on performing these tasks, start the Application Manager then
click the
Help button in the top right-hand corner of the Application Manager
window that appears.
Start Eclipse.
From within Eclipse, choose the Developer Suite menu and select Application
Manager 2G or Application Manager 3G as appropriate.
Online Help
Application repository
Actions to perform
Carry out the
selected action
Trace window
Card profiles
15
The Script Editor
What is a Script?
A script is a file that contains a list of commands that are executed in sequence.
Scripts can either be created manually, as described in this chapter, or generated
automatically using the JCardManagers trace recorder (see Script Files on
page 186).
The Script Editor is a tool that enables you to create and edit configuration files and
scripts. You can use it to add, remove or rename the commands in the list and change
the order in which the commands are executed. You can also use the Script Editor to
set the parameters of individual commands in the sequence.
Choose Script > Edit or Script > Play as shown in Figure 111 - Accessing the
Script File in Eclipse on page 97.
164
Card List
For detailed help about how to use the Script Editor, click the Script Editor Help button
. This section provides an outline of the main operations that you can perform.
For detailed help about a particular command, select the command in the command list
and click Help at the bottom right of the window.
Use the Card list to select the type of card on which the script is to be run.
The Quick Access Tool Bar at the top left of the screen is mainly for operations on a
script file, opening, creating, saving and so on.
The Command List contains the list of commands that are to be executed in the
current script, in the order that they appear.
The Command Management Controls are used to move, sort or delete commands
from the Command List.
To add a command to the list:
1
Click the
button in the Quick Access Tool Bar. This opens the Add/Remove
Commands window as shown in the following figure:
165
The Script Commands List on the right displays the commands currently in the
script. Use the arrow buttons to add and remove commands.
In the Command List, select the command that you want to rename.
Click the
In the Name Definition window, enter the new name and click OK.
button.
In the Command List, select the command whose parameters you want to specify.
This action displays the parameters for the command in the Command
Parameters Area.
16
The File System Editor
What is the File System Editor?
This tool enables you to view the file structure in a card or a card simulator and the
properties and access conditions for any file. In addition it can be used to perform
certain commands on files.
You can launch the File System editor either from within the JCardManager, or from
the Developer Suite menu in Eclipse.
To start the File System Editor from JCardManager:
1
Select the card simulator or reader in the Terminal list in the toolbar.
Select the card type in the tree structure in the left pane.
in the toolbar.
In the Select the Target window that appears, choose the type of card you are
using and click Select:
168
Depending on the Scan Model you select, the File System Editor operates in 2G or 3G
mode. The current mode is displayed to the right of the toolbar.
Select a file in left pane to display the following properties in the right pane:
Properties
Access type
PINs and their statuses, that is, whether or not they have been successfully
presented. This last feature applies to the MF and DFs only.
169
Contextual Commands
You can perform certain commands on a file in the file system editor. The commands
available depend on the type of file. The following table describes the commands
available for each file type:
Table 9 - Contextual Commands
Command
Description
File type
Scan
MF, DF,
ADF (3G only)
Select
File Access
Management:
Verify PIN
Change PIN
Enable PIN
Disable PIN
Unblock PIN
Create
MF, DF,
ADF (3G only)
Delete
DF, EF,
ADF (3G only)
Update Record/Binary
EF
Choose the file in the left pane on which you want to perform the command.
For Create, PIN commands and Update commands, complete the dialog box for
the command and click the button with the command name, for example Update
Binary.
Click Close.
The pane at the bottom of the File System Editor displays the APDU code for the
command.
For details about individual commands, refer to the document ETSI TS 102 221 V7.0.0
(2004-12); Technical Specification; Smart cards; UICC-Terminal interface; Physical
and logical characteristics (Release 7), available at www.etsi.org.
17
The Key File Editor
The Key File Editor tool can be used to manage key profiles. It can be accessed either
from Eclipse or from the JCardManager.
To start the key file editor from Eclipse:
Choose Key File Editor from the Developer Suite menu.
To start the key file editor from JCardManager:
Choose Key File Editor from the Tools menu.
When opened, the Key File Editor appears as shown in the following figure:
Figure 180 - Key File Editor
Keys are stored in key profiles. A key profile comprises a mother key and one or more
key sets although it is possible to have a profile with just a mother key or with just one
or more key sets.
A key set normally contains three keys, but you can add or remove keys.
Each function is performed by clicking one of the icons on the toolbar. For information
about each function, click the online help button
.
To find out which version of the Key File Editor you are using, click
A
Managing OTA Profiles
This appendix describes how to configure OTA profiles in the OTA Profile Manager. To
start the OTA Profile Manager, select a card profile in the Target area of the
Application Manager and click
.
This window allows you to modify the selected OTA profile, in this example the
GemXplore 3G V3.0 displayed on the windows title bar.
The card template upon which the profile is based is displayed in the top right-hand
corner of the window.
An OTA profiles parameters are spread across three property sheets:
174
Expert. These parameters are intended for use by expert users only, and concern
the format of an SMS messages concatenation header, command packet and
response packet headers.
These parameters are described in Expert Options on page 180.
Optionally, click Apply to save the current values of parameters on the selected
property sheet.
Click OK to save the current values of all parameters on all property sheets and close
the OTA parameters window.
SMS Options
The SMS property sheet contains options relating to the Short Message Service
(SMS). The default values displayed are read from the template upon which this card
profile is based.
You can specify values for the following parameters:
Originating Address
It is usual for the receiving entity to implement a number of security mechanisms, which
may include a check that the message was sent by an authorized application provider.
This is done by checking the originating address (TP-OA field) included in the
messages OTA header.
Note: The originating address is the network address (MSISDN) of the messages
originator, that is, the sending entity, not that of the SMSC that forwards the message
to the SIM card.
To modify the default originating address, click Edit to display the Originating
Address Editor window:
Figure 182 - The Originating Address Editor Window
Specify the Type of Number (TON), Numbering Plan Identification (NPI), and
Address components of the originating address:
TON. Indicates the format of a number. The most commonly used settings are:
Note: The digits in parentheses following the options refer to the normative values of
the TON/NPI byte, bits 4 to 6. For example, 001 indicates use of the International
TON.
NPI. Used to ensure compatibility between numbering plans (for example, for a
private network) in which the digit sequences may have a different meaning and
175
structure than in the networks default numbering plan. The most commonly used
setting is ISDN/Telephone Number Plan.
True. A reply is to be sent. The value in the Originating Address field is used to
route the reply.
The SRI is coded as the TP-SRI field of the SMS DELIVER TPDU defined by the
3GPP 23.040 standard.
Enable 23.040 Concatenation
Indicates whether concatenation is to be used.
Concatenation, described in the 3GPP 23.040 specification, provides a mechanism for
transmitting command packets containing large blocks of data by breaking the data up
into segments and transmitting each segment as a separate SMS message. The
segments are then reassembled by the receiving entity (provided that it supports
concatenation: not all SIM cards in the field today support concatenation).
Without concatenation, a single SMS message can only contain up to 160 characters
of text (where each character is 7 bits according to the 7-bit default alphabet), or up to
140 characters of 8-bit binary data.
Specify either:
True. This message implements concatenation; the receiving entity should expect
other messages in the sequence.
Update Record. Download the text or data using an Update Record SIM Toolkit
command to update the EFSMS elementary file in the SIM cards GSM file system.
176
Note: Regardless of the method chosen, the capabilities of the mobile equipment
determine which method is actually used. For example, the SMS Point-To-Point Data
Download Envelope command is only supported by Phase 2+ mobile equipment.
Phase 2 mobile equipment systematically loads OTA messages using the Update
Record command, even if the Envelope option is selected.
DCS
Select the Data Coding Scheme (DCS) that the receiving entity is to use to encode the
text or data. The choice affects the maximum number of characters or bytes that a
single SMS message can contain:
8-bit. Unpacked format (eight-bit data), bit 7 is set to 0. Unused bytes are set to
FFh. A Text message string may contain up to 210 characters. A Data message
may contain up to 210 bytes.
7-bit. Packed format, the default seven-bit alphabet is used, packed into bytes. A
Text message string may contain up to 240 characters. A Data message may
contain up to 210 bytes.
UCS-2. In UCS-2 format, the UCS-2 alphabet is used. In a Text message, each
character uses two bytes and the string may contain up to 105 characters. A Data
message may contain 210 bytes.
Custom. The text or data in the message is in a custom format understood by the
receiving entity.
SPI
The Secured Packet Information (SPI) is a 2-byte field of the messages command
packet indicating:
In byte 2, the settings to build the response packet returned by the receiving entity.
Ciphering
Whether the contents of the message are ciphered:
If ciphering is to be implemented, use the options on the KIc property sheet to configure
the ciphering mechanism. Refer to KIc on page 178.
Security
Indicates which security mechanism is to be implemented:
No RC, CC, or DS. No security mechanism is used: the text or data to be sent are
written in clear into the body of the message.
177
It can only really be used to check that the message was correctly received by the
receiving entity. If you select this option:
a) Click Apply.
a) Select the KID property sheet.
b) In the RC Security area of the window, select the Algorithm to use to
calculate the redundancy checksum.
c) If you select the DES or Triple DES algorithm, you must enter the Key to use.
The receiving entity calculates a checksum based on the contents of the message
and compares it with the checksum value sent in the message. If the two match,
the receiving entity goes on to process the contents of the message. If a
discrepancy is detected, the message is rejected. If status reporting is switched on,
an error is returned to the sending entity.
Counter
A synchronization counter is used to prevent replay attacks and to re-synchronize the
OTA platform and SIM card when OTA message transmission fails for whatever
reason. Synchronization consists in comparing two values; one stored in the SMS
messages command packet, the second stored on the SIM card itself.
The following options are available:
Process if counter is higher than RE. Process the message if the value of the
synchronization counter in the message is greater than the current value stored on
the SIM card.
Process if counter is one higher than RE. Process the message if the value of
the synchronization counter in the message is exactly one more than the current
value stored on the SIM card.
178
If you choose to use a synchronization counter, enter the initial value to use in the
Counter value field.
The maximum possible value of synchronization counter and the method used to
format the synchronization counter can be set on the Expert property sheet. See
Expert Options on page 180.
The receiving entity retrieves the value of the synchronization counter from the
message and compares it to the value of the synchronization counter in the SIM card.
The message is considered to be valid if the counters value is greater than the value
stored in the SIM card, in which case the local counter is incremented.
Counter Value
Enter the initial value of synchronization counter to use. The default value is zero (0).
Click the Refresh button to read the most recently saved value of synchronization
counter from the card profile file. For example, if you replace the current value 0 with
999 and click Refresh, the value 0 reappears.
Proof of Receipt
The values you specify for the options in this area of the window are written into the
second SPI byte of the messages command header.
Proceed as follows:
1
To specify that no Proof of Receipt (PoR) is required, select No PoR reply to the
Sending Entity (SE).
To specify that a PoR is always sent, select PoR required to be sent to the SE.
To specify that a PoR is only to be sent when an error occurs, select PoR required
only when an error has occurred.
If you request that a PoR is sent, you can choose the security mechanism to apply to it:
No security to be applied
Note: Depending on the target chosen, not all of the above options may be available.
You can optionally choose whether the PoR is to be ciphered or not.
Finally, you can specify whether the PoR is to be sent using an SMS-DELIVERREPORT TPDU or an SMS-SUBMIT TPDU.
These options are explained in greater detail in the 3GPP 23.040 specification.
KIc
This property sheet is used to determine the contents of the key certificate (KIc) byte in
the command header.
The values on this property sheet are only used if ciphering of the message has been
requested. Check the value of the Ciphering field on the SPI property sheet, described
in SPI on page 176.
The window is divided into two parts:
In the top half of the window, specify the ciphering values to use when data
encryption is being used. See Configuring Data Encryption on page 179 below.
In the bottom half of the window, specify the settings for the ciphering key: see
Ciphering Key.
179
Ciphering Key
Select the algorithm type and mode to use to cipher the messages contents.
Algorithm. The following algorithms are available:
Value set in template. The value is read from the template upon which this profile
is based.
Key. Type the key value to use. The key should be:
8 bytes (56 bits), 16 bytes (112 bits), or 24 bytes (168 bits) long if the algorithm
selected is Triple DES/CBC/None or Triple DES/ECB/None.
KID
This property sheet is used to determine the contents of the key identifier (KID) byte in
the command header. The window is divided into two parts:
In the top half of the window, specify the ciphering values to use when data
encryption is being used. See Configuring Data Encryption on page 179 below.
In the bottom half of the window, specify the RC, CC, or DS algorithm and key to
use: see Configuring CC, RC, or DS Security Settings on page 180.
A proprietary algorithm.
Algorithm
Choose the encryption algorithm. The OTA Profile Manager supports the following
encryption algorithms:
DES. DES uses a binary number called a key to encrypt and decrypt sensitive data.
In the OTA Profile Manager, you simply type in the entire 192-bit (24 character) key
rather than entering each of the three keys individually.
Triple DES, with two or three keys. Triple DES is simply another mode of DES
operation. The procedure for encryption is exactly the same as regular DES, but it
is repeated three times (hence the name triple DES). The data is encrypted with the
180
first key, decrypted with the second key, and finally encrypted again with the third
key, as shown in Figure 183below:
Plain text
DES Encryption
Key 1
DES Decryption
Key 2
DES Encryption
Key 3
Ciphered text
If Security is set to the value Digital Signature, specify the digital signature to use
in the DS Security area of the window:
a) Choose the algorithm: XOR8, DES, or Triple DES.
b) If you select the DES or Triple DES algorithms, specify the Key to use; 8 bytes
(56 bits) for DES, 16 bytes (112 bits) or 24 bytes (168 bits) for Triple DES.
If Security is set to the value Redundancy check, specify the algorithm and key to
use in the RC Security area:
a) Select the Algorithm to use, XOR4 or CRC32.
Expert Options
The options on the Expert property sheet are typically parameters that are optional or
open to different interpretations in the 3GPP 23.040 or 3GPP 23.048 specifications.
Specific values may therefore be necessary to create OTA profiles compatible with
different manufacturers interoperable cards.
181
The parameters are divided into three sub-property sheets: click on the
Concatenation, Command Packet Header or Response Packet Header tabs to the
right of the window to access the other property pages.
Concatenation
When concatenation is being used, the first concatenated message contains three
elements:
A concatenation header.
The first part of the secured data, if there is room for it.
Subsequent messages contain only the concatenation header and secured data.
The options on this property sheet set the format of these components.
Concatenation Header Size (IEIa)
The length of Information Element Identifier A field to use when formatting messages.
Possible values are:
Value set in template, to use the value in the template upon which this card profile
is based.
One byte (0x00), if the concatenation header reference number size is one byte.
Two bytes (0x08), if the concatenation header reference number size is two bytes.
182
Extract data from the SPI, KIc, KID, TAR, CNTR, and PCNTR fields, together with
additional data and padding from the input stream.
Extract the data from the CPL, CHL, SPI, KIc, KID, TAR, CNTR, and PCNTR fields,
together with additional data and padding from the input stream.
To use a different format, select Value set in template to use the format specified in
the template upon which this card profile is based.
Data to cipher padder
Determines how to pad data that is to be ciphered. The default formatting library
always pads data with zeros.
To use a different format, select Value set in template to use the format specified in
the template upon which this card profile is based.
Extract data from the TAR, CNTR, and PCNTR fields, together with additional data
and padding from the input stream.
Extract data from the RPL, RHL, TAR, CNTR, and PCNTR fields, together with
additional data and padding from the input stream.
183
Extract data from the UDHL, RPI UDH, RPL, RHL, TAR, CNTR, and PCNTR fields,
together with additional data and padding from the input stream.
To use a different format, select Value set in template to use the format specified in
the template upon which this card profile is based.
B
The JCardManager
The JCardManager is a powerful tool that provides the following functions:
Display the results of APDU exchanges with the card or simulator and save them in
a trace file
A file system editor enabling you to view the files in a card and their properties. This
is described separately in Chapter 16 - The File System Editor.
From the Start button, choose All Programs > Gemalto > Wireless Solutions >
JCardManager.
Both these actions open the initial JCardManager window as shown in the following
figure:
Figure 184 - The Initial JCardManager Window
Tool bar
Current Trace
For detailed help about JCardManager, click the JCardManager Help button
. This
section provides an outline of the main operations that you will want to perform.
186
The JCardManager
For detailed help about a particular command, select the command in the command list
and click Help at the bottom right of the window.
To execute a command:
1
Expand the tree structure in the left pane and select the command. The parameters
for the command display in the right pane.
Complete the parameters in the right pane (these could include option buttons, text
fields, check boxes and so on and vary according to the command chosen).
Click Go.
Logical Channels
To select a logical channel, click the corresponding button in the multichannel bar.
APDUs will then be sent to this logical channel.
Script Files
Script files contain a sequence of command APDUs. You can make your own script file
by recording a sequence of commands and play back the script file.
There are two main types of script file:
.xml and .gxsc, which store the parameters and rebuild the APDUs, for example
they recalculate random numbers for you.
In JCardManager you can use the record and play tools described below to record and
play both types of file. However, JCardManager also contains specific script players,
the ATF Script player and the XML Script player (which can also play .gxsc scripts).
To record a script file:
1
In the Record Script. Output File Selection window, browse to the directory
where you want to save the script file and enter the file name (with a .gxsc or .xml
suffix).
Click Save.
Perform the sequence of commands that you want to record in your script.
In the Play Script. File Selection window, browse to the directory that contains the
script file you want to play and select the file.
The JCardManager
187
Click Open.
In ATF file, either select the .atf file from the list (the list stores all the previously
selected .atf files) or navigate to an .atf file.
Rename a command
Change the order of the commands in the list
Delete one or more commands from the list
Save the .atf file under the same or a different name.
Click Go to play the script. The results of the script execution are displayed in the
Message area of the window.
Note: For more detailed information about the ATF Script Player, click Help.
To play an .xml or .gxsc script using the XML Script Player:
1
Expand the folder in the left pane corresponding to your type of card, for example
USim Card R5, and select XML Script Player.
In GXSC(XML) file, either select the file from the list (the list stores all the
previously selected .gxsc and .xml files) or click the browse button and navigate to
a file.
Note: You can also edit XML files graphically using the Script Editor tool.
3
Rename a command
Change the order of the commands in the list
Delete one or more commands from the list
Save the .gxsc or .xml file under the same or a different name.
Click Go to play the script. The results of the script execution are displayed in the
Message area of the window.
Note: For more detailed information about the XML Script Player, click Help.
Traces
The lower pane in the JCardManager displays a log file known as a trace. You can
make this trace pane disappear and reappear (known as toggling), clear its contents or
save the contents to a file.
To make the trace pane disappear or reappear:
Click
in the toolbar or choose View > Trace > SwitchTrace Action or press Alt+X.
in the toolbar or choose View > Trace > CleanTrace Action or press Alt+E.
in the toolbar or choose View > Trace > SaveTrace Action or press Alt+S.
3GPP
AID
Application Identifier
APDU
API
ATF
ATR
Answer To Reset
CAD
CAP
CAT
CBC
CCAT
CLA
Class byte
CLDC
CPLC
DES
ECB
ETSI
EXP
FSD
GSM
ICV
IDE
INS
Instruction byte
ISO
J2ME
JAR
JCA
JCRE
JCVM
JDK
JSR
JVM
Terminology
Abbreviations
190
Terminology
Lc
Data length
Le
MAC
ME
Mobile Equipment
MIDP
OCF
OpenCard Framework
OP
Open Platform
OTA
PC/SC
PIX
PK
Public Key
RID
Registered Identifier
R-UIM
SAP
SAT
SATSA
SIM
TCP/IP
TPDU
TPUD
TP User Data
UICC
USAT
USIM
VM
Virtual Machine
WTK
Wireless Toolkit
Glossary
Applet
Application
identifier
Application
Protocol Data
Units (APDU)
Terminology
Application
Provider
ATF file
ATR
Bytecode
CAP files
A file format that can be loaded into a card. CAP files are
generated by .
Card
Application
Toolkit (CAT)
CCAT
CAT
Card Simulator
Class files
Client
application
Connected
limited device
configuration
(CLDC)
Conversion
Converter
JAR file
191
192
Terminology
Java Card-GP
applet
Java-GP Card
Smart cards that are fully compliant with both the Java
Card and GlobalPlatform specifications.
JCA file
JCardManager
Key index
Key set
Key version
Load file
MAC (Message
Authentication
Code)
MIDlet
Mobile
Information
Device Profile
(MIDP)
PC/SC
Project
Terminology
RID
SCR file
Scripts
SIM Application A set of commands that defines how a card should interact
Toolkit (SAT)
with the outside world and extends the communication
protocol between the card and the handset. With SAT, the
card has a proactive role in the handset (this means that
the SIM initiates commands independently of the handset
and the network).
In 2G networks, SIM Application Toolkit (SAT) was defined
in the GSM 11.14 standard.
SIM Toolkit
Target
Trace
Universal
Integrated
Circuit Card
(UICC)
USIM Toolkit
Wireless Toolkit The Sun Java Wireless Toolkit (formerly known as J2ME
Wireless Toolkit) is a set of tools for creating Java
applications that run on devices compliant with the
JSR185 specification. It consists of build tools, utilities,
and a device emulator.
Wizard
193
3GPP TS 11.14: Specification of the SIM Application Toolkit (SAT) for the
Subscriber Identity Module - Mobile Equipment (SIM - ME) interface (Release
1999)
References
196
References
JSR 185: Java Technology for the Wireless Industry, Sun Microsystems, July 2003
Recommended Reading
For more information about Java applet development for smart cards, see:
3DES
key lengths 19
performing computations using crypto tool 28
3GPP standards 27, 195
23.040 175, 178, 180
23.048 13, 161, 173, 176, 180
A
access conditions (USIM toolkit applets) 90, 142
AES key lengths 19
AIDs 6, 33
format 6
APDUs 1
commands 1
responses 1
APIs
GP 3
GSM extension to Java Card 3
Java Card 3
OP 2
open card framework (OCF) 2
applets 2
AIDs 6
debugging 41, 42, 9197, 114115
difference between Java Card & Java Card GP 3
installing 41
installing (in Eclipse) 97, 152
Java Card 3, 42, 113116
Java Card-GP 3, 114
JCRMI 42, 99111
loading 41, 97, 152
overview 2
testing 42, 98, 111, 116, 153
USIM toolkit 7798
application identifiers. see AID
application manager 161162
availability in different versions of GXD 19
interface 162
overview 162
starting 162
application repository (in application manager)
161
ATF
script player 187
ATF personalization scripts 79, 129, 186
atf script files. See ATF personalization scripts
D
DAP parameters 83, 133
Index
Numerics
198
Index
debugging
applets 41, 42, 9197, 114115
JCRMI applets 108111
libraries 81, 131
place in development flow 43
projects 9495, 109111, 114115, 147151
servlets 145150
tools 42, 80, 91, 92, 130, 145, 146
with JCardManager 114115
with JCRMI client application 108111
with mobile simulator 3G 9197
with OCF client application 115
with static content explorer 145150
DES
key lengths 19
performing computations using crypto tool 28
development cycle (typical) 41
development phase 9
E
Eclipse 10, 43
starting the key file editor 171
use to create projects 77
use to develop client applications 4
Eclispe
as test application 80, 130
ETSI standards
102-241 3
31-130 3
example
servlet 134154
export files 81, 131
external export files 81, 131
external libraries 81, 131
F
file system access conditions (USIM toolkit applets) 90, 142
file system editor 167169
contextual commands 169
interface 168
files
CAP 5, 10, 43
class 9
external export 81, 131
formats 5
IJC 5, 10, 43
JAR 5, 10, 43
SAP 5, 10, 43
script 9, 79, 129, 163165, 186187
G
GemXplore Xpresso V3 cards 13
H
hardware requirements 13
hash algorithms 7
http midlet
project creation 156157
I
IJC files 5, 10, 43
installation
afterwards 15
overview 14
preparation 14
procedure 14
wireless toolkit (WTK) 2.3 16
installing applets 41
in Eclipse 97, 152
instances 3
AIDs 6
ISO 7816-5 6
J
J2ME emulator 29
JAR files 5, 10, 43
Java Card
API 3
applet wizard 114
applets 3, 42, 113116
application 2
as a target 4
project wizard 77
virtual machine (JCVM) 5
Java Card specification
2.1.1 27
2.2 27
2.2.1 5, 27
GSM extension 3
Java Card-GP 106
declaring an applet as GP 114
Java code
generating 33
setting breakpoints 93, 147
Java packages
org.globalplatform 2
overview 4
visa.openplatform 2
Index
K
key file editor 171
interface 171
starting from Eclipse 171
starting from JCardManager 171
key lengths 19
L
libraries 6, 159160
creating 159
debugging 81, 131
using 159
loading
applets 41, 97, 152
logical channels 186
M
midlet
project creation 119120
midlet test application 80, 130
mobile simulator 10
operating the 3G simulator 95
starting 27
use in debugging 42, 9197
use in testing 42
versions 92, 146
O
OCF
client applications 42, 115
client projects 115
See also WTK-OCF bridge
OP 2.0.1 specification 2
Open Platform. see GlobalPlatform
opencard framework (OCF) 2
199
org.globalplatform package 2
OTA
events 28
interpreter 8, 29
minimum security for USIM toolkit applets 89,
141
profiles 173183
P
packages 4
AIDs 6
See also Java packages
personalization scripts. See ATF personalization
scripts
PIXs 6
profiles
OTA 173183
projects 10
creating http midlet 156157
creating Java Card 7783
creating JCRMI client 107108
creating midlet 119120
creating OCF clients 115
creating SCWS 127134
debugging 9495, 109111, 114115, 147
151
overview 6
R
remote object
creating interface 99104, 106
preverification 103
wizard 100103, 106
requirements
hardware 13
software 13
RIDs 6
RSA key lengths 19
S
SAP converter 5
SAP files 5, 10, 43
generated by gxpConverter 5
SATSA midlets 4, 16, 42
script editor 9, 98, 153, 163165
interface 164
starting 163
script files 9, 41, 163165, 186187
atf. See ATF personalization scripts
gxsc 160, 186
xml 186
secure channel 2
GP (for JCRMI applets) 106
200
Index
serial cable 1
servlet
example 134154
servlets
debugging 145150
SIM
access parameters (USIM toolkit applets) 90,
142
card simulator 27
SIM toolkit java card 13
Simulation Chain 2G 4, 14
as client application 10
as debugging tool 80, 130
Simulation Chain 3G.see Simulation Chain 2G.
simulators
card 4, 27, 98, 153
mobile 27
smart card reader 1
software requirements 13
static content explorer
use in debugging 145150
T
targets
loading applets onto 4
types 4
TCP/IP 1
test phase 10, 43
testing
applets 42, 98, 111, 116, 153
tools 42
TLP 224 protocol 29
tools 68, 10, 28
debugging 42, 80, 91, 130, 145
testing 42
TPDU 7, 29
traces 187
U
USIM toolkit applets 7798
adding to a project 84
debugging 91, 145
installation parameters 86
USIM toolkit java card 13
utilities 28
V
visa.openplatform package 2
W
wireless toolkit (WTK) 16, 103
installation 16
wizards
Java Card applet 114
Java Card project 77
JCRMI applet 105
JCRMI/OCF client project 107
OCF client project 115
remote object 100103
WTK-OCF bridge 29
X
xml
script files 186
script player 187