Compilation of an applet is done by two steps. The first is javac -g. This compiles a .java file to a .class file. javac is available on Sun workstation in CAEN labs. Make sure to use /usr/um/jdk-1.2.2/bin/javac, not /usr/um/bin/javac nor /usr/bin/javac. Also, do not forget -g. You can use javac version 1.2 on other machines.
The second is mksolo (in /afs/engin.umich.edu/u/i/t/itoi/sc_seminar/bin), which converts a .class file to a Cyberflex Access loadable applet. Compile your applet, and download it to your Cyberflex Access smartcard. This is done by pay commands "jl" which loads the applet, and "jp" which selects it.
Once the applet is downloaded and selected, you can communicate with the applet with APDUs. Wallet.java (which is in /afs/engin.umich.edu/u/i/t/itoi/sc_seminar/src) takes four types of APDUs, i.e., deposit (03 10), debit (03 20), balance (03 30), and validate PIN (03 40).
When finished communicating with it, use "jq" to unselect the applet, and "ju" to unload it.
Now the step-by-step example.
/* First, compile your applet with -g and appropriate class path. */
xnor% /usr/um/jdk-1.2.2/bin/javac -g -classpath /afs/engin.umich.edu/u/i/t/itoi/sc_seminar/lib Wallet.java
/* Second, run mksolo on the .class file and get .bin file */
-> Wallet.class
xnor% /afs/engin.umich.edu/u/i/t/itoi/sc_seminar/bin/mksolo -usemap=/afs/engin.umich.edu/u/i/t/itoi/sc_seminar/lib/Access.map -v -d Wallet.class
/* Start pay */
-> Wallet.bin
xnor% /afs/engin.umich.edu/u/i/t/itoi/sc_seminar/bin/pay -d /afs/engin.umich.edu/u/i/t/itoi/sc_seminar/bin/libtodos_ag.so
/* Help is available by typing 'h' in pay. */
pay> h
/* Choose the serial port. If you put your smartcard to serial port A,
type '1'. If it is on port B, type '2'. */
pay> 2
/* download "Wallet.bin" to the card */
1:3b 2:16 3:94 4:81 5:10 6:6 7:1 8:81 9:2f /* this is answer to reset */
pay> jl Wallet.bin
/* select the applet */
applet file "Wallet.bin"
program ID 77.77 /* program installed in file 3f00/7777 */
container ID 77.78 /* data container installed in file 3f00/7777 */
instance container size 2048
instance data size 1024
AID 7777777777 /* Application ID is 7777777777 */
signature eed461e31de414c1
90 00 ok
pay> jp
/* Now applet "Wallet.bin" is ready to take your APDUs. */
select applet
AID 7777777777
90 00 ok
/* first, validate PIN (it is 00 00 00 00) */
pay> ic 03 40 00 00 04
/* check the balance (default value = 0x20) */
Enter 4 data bytes (hex):
00 00 00 00
90 00 ok
>pay> oc 03 30 00 00 01
/* debit 0x8 */
1:20
90 00 ok
>pay> ic 03 20 00 00 01
/* check balance. 0x20 - 0x08 = 0x18. :) */
Enter 1 data bytes (hex):
8
90 00 ok
pay> oc 03 30 00 00 01
/* unselect and unload the applet */
1:18
90 00 ok
pay> jq
Now try changing the program slightly. For example, take $1 away
whenever the user debits money.
90 00 ok
pay> ju
90 00 ok
That's it!! You are welcome to modify Wallet.java and play with it further.