C H A P T E R 14 |
Using SATSA |
The Security and Trust Services APIs (SATSA) provide smart card access and cryptographic capabilities to applications running on small devices. JSR 177 (the SATSA specification) defines four distinct APIs as optional packages:
The Sun JavaTM Wireless Toolkit for CLDC emulator fully supports SATSA. This chapter describes how you can use the Sun JavaTM Wireless Toolkit for CLDC to work with SATSA in your own applications.
For a more general introduction to SATSA and using smart cards with small devices, see the SATSA Developer's Guide, which is available at
http://java.sun.com/j2me/docs/satsa-dg/.
The Sun JavaTM Wireless Toolkit for CLDC includes the Java Card Platform Simulator, which you can use to simulate smart cards in the Sun JavaTM Wireless Toolkit for CLDC emulator's slots. The Java Card Platform Simulator is found in.
Hereafter we refer to it as simply cref.
If you need to develop your own Java Card applications, download the Java Card Development Kit, available at http://java.sun.com/products/javacard/.
Real SATSA devices are likely to have one or more slots that house smart cards. Applications that use SATSA to communicate with smart cards need to specify a slot and a card application.
The Sun JavaTM Wireless Toolkit for CLDC emulator is not a real device and, therefore, does not have physical slots for smart cards. Instead, it communicates with a smart card application using a socketprotocol. The other end of the socket might be a smart card simulator or it might be a proxy that talks with real smart card hardware.
The Sun JavaTM Wireless Toolkit for CLDC emulator includes two simulated smart card slots. Each slot has an associated socket that represents one end of the protocol that is used to communicate with smart card applications. You can set the socket port number for each slot. Choose Edit > Preferences, then click the SATSA tab. The default ports are 9025 for slot 0 and 9026 for slot 1.
FIGURE 14-1 Setting Port Numbers for Smart Card Slots
The basic procedure for testing SATSA applications with the Sun JavaTM Wireless Toolkit for CLDC is as follows:
1. Start cref with a Java Card platform application.
2. Start the Sun JavaTM Wireless Toolkit for CLDC emulator.
When a SATSA application attempts to communicate with a smart card, it uses a socket connection to communicate with cref.
It's important, therefore, to make sure that you start cref with the same port number as one of the slot port numbers you specified in the Sun JavaTM Wireless Toolkit for CLDC preferences.
For example, you could run cref on port 9025 with a prebuilt memory image using a command line like this:
cref -p 9025 -i memory_image.eeprom
The Sun JavaTM Wireless Toolkit for CLDC includes a demonstration application, Mohair, which illustrates how to use SATSA. For detailed instructions on running Mohair, see Appendix A.
The Sun JavaTM Wireless Toolkit for CLDC can display data exchanged with simulated smart card applications in the network monitor. The network monitor displays Application Protocol Data Units (APDUs) that are exchanged between the emulator and the smart card simulator. It can also show data exchanged using the Java Card Remote Method Invocation (Java Card RMI) protocol. The APDU and JCRMI tabs in the network monitor show data exchanged with a smart card.
The network monitor parses each APDU and shows fields in the request and response as appropriate.
FIGURE 14-2 Viewing an APDU in the Network Monitor
Access control permissions and PIN properties can be specified in text files. When the first APDU or Java Card RMI connection is established, the implementation reads the ACL and PIN data from the acl_slot-number in the workdir\appdb directory. For example, an access control file for slot 0 is workdir\appdb\acl_0. If the file is absent or contains errors, the access control verification for this slot is disabled.
The file can contain information about PIN properties and application permissions.
PIN properties are represented by a pin_data record in the access control file.
Application permissions are defined in access control file (acf) records.
The acf record is an Access Control File. The AID after acf identifies the application. A missing AID indicates that the entry applies to all applications. The acf record can contain ace records. If there are no ace records, access to an application is restricted by this acf.
The ace record is an Access Control Entry. It can contain root, apdu, jcrmi, pin_apdu, and pin_jcrmi records.
The root record contains one CA name. If the MIDlet suite was authorized using a certificate issued by this CA, this ace grants access to this MIDlet. A missing root field indicates that the ace applies to all identified parties. One principal is described by one line. This line must contain only the word root and the principal name, for example:
root CN=thehost;OU=JCT;O=dummy CA;L=Santa Clara;ST=CA;C=US
The apdu or jcrmi record describes an APDU or Java Card RMI permission. A missing permission record indicates that all operations are allowed.
An APDU permission contains one or more sequences of eight hexadecimal values, separated by blanks. The first four bytes describe the APDU command and the other four bytes are the mask, for example:
apdu { 0 20 0 82 0 20 0 82 80 20 0 0 ff ff 0 0 }
The Java Card RMI permission contains information about the hash modifier (optional), class list, and method list (optional). If the list of methods is empty, an application is allowed to invoke all the remote methods of interfaces in the list of classes, for example:
jcrmi { classes { com.sun.javacard.samples.RMIDemo.Purse } hashModifier zzz methods { debit(S)V setAccountNumber([B)V getAccountNumber()[B } } |
All the numbers are hexadecimal. Tabulation, blank, CR, and LF symbols are used as separators. Separators can be omitted before and after symbols { and }.
The pin_apdu and pin_jcrmi records contain information necessary for PIN entry methods, which is the PIN identifier and APDU command headers, or remote method names.
Copyright © 2007, Sun Microsystems, Inc. All Rights Reserved.