<note tip>The description in section 'JavaCard applet development with NetBeans IDE' is outdated as we now have easier option.</note>
© 2010-2011 by LaBAK FI MUNI (contact us at http://www.fi.muni.cz/research/laboratories/labak/)
Download script templates for common smart cards.
Download example project with standard Sun Java Card Hello World example with all configurations applied.
Download slides with JavaCard tutorial. To be used with Ubuntu VirtualBox image.
Following software will be used
Example of configuration:
# Java Card Development Kit home directory jc.home=C:\\Program Files\\Java\\java_card_kit-2_1_2 # Path to Java Card export files jc.export_files=${jc.home}\\api21_export_files # GPShell home directory, ${basdir} is a path to a base directory of the project gpshell.home=${basedir}\\bin\\GPShell-1.4.3 # GPShell executable gpshell.cmd=${gpshell.home}\\GPShell.exe # Path to the template directory gpshell.templatepath = ${basedir}\\scriptTemplates # Name of the script template gpshell.script=helloInstallgemXpressoProR3_2E64.txt # Path to Java Card Ant Tasks jctasks.path=${basedir}\\lib\\jctasks.jar # Applet parameters jc.applet.AID=0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1:0x1 jc.applet.AID_GPShell=a00000006203010c0101 jc.applet.name=HelloWorld # Package parameters jc.package.AID=0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1 jc.package.AID_GPShell=a00000006203010c01 jc.package.name=com.sun.javacard.samples.HelloWorld jc.package.path=com/sun/javacard/samples/HelloWorld jc.package.shortName=HelloWorld jc.package.version=1.0 ... rest of project.properties file as automatically generated for new project
<?xml version="1.0" encoding="UTF-8"?> <project name="SmartHelloWorld" default="default" basedir="." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3"> <description>Builds, tests, and runs the project SmartHelloWorld.</description> <import file="nbproject/build-impl.xml"/> <target name="-post-init"> <!-- Java Card Ant Tasks definition --> <path id="jc-tasks" > <pathelement path="${jctasks.path}"/> </path> <taskdef name="convert" classname="com.sun.javacard.ant.tasks.ConverterTask" classpathref="jc-tasks" /> <taskdef name="verifycap" classname="com.sun.javacard.ant.tasks.VerifyCapTask" classpathref="jc-tasks" /> <!-- Java Card classpath --> <path id="jc-classpath" > <pathelement path="${jc.home}/lib/converter.jar"/> <pathelement path="${jc.home}/lib/offcardverifier.jar"/> <pathelement path="${jc.home}/lib/scriptgen.jar"/> <pathelement path="${jc.home}/lib/apdutool.jar"/> <pathelement path="${jc.home}/lib/apduio.jar"/> <pathelement path="."/> </path> </target> <!-- Target responsible for conversion and verification of the applet --> <target name="convert" depends="init"> <convert dir="${build.classes.dir}" nobanner="true" JCA="true" EXP="true" CAP="true" packagename="${jc.package.name}" packageaid="${jc.package.AID}" majorminorversion="${jc.package.version}"> <AppletNameAID appletname="${jc.package.name}.${jc.applet.name}" aid="${jc.applet.AID}"/> <exportpath> <pathelement path="${jc.export_files}"/> </exportpath> <classpath refid="jc-classpath"/> </convert> <verifycap Verbose="true" CapFile="${build.classes.dir}/${jc.package.path}/javacard/${jc.package.shortName}.cap"> <exportfiles file="${jc.export_files}/java/lang/javacard/lang.exp" /> <exportfiles file="${jc.export_files}/javacard/framework/javacard/framework.exp" /> <exportfiles file="${jc.export_files}/javacard/security/javacard/security.exp" /> <exportfiles file="${jc.export_files}/javacardx/crypto/javacard/crypto.exp" /> <exportfiles file="${build.classes.dir}/${jc.package.path}/javacard/${jc.package.shortName}.exp" /> <classpath refid="jc-classpath"/> </verifycap> </target> <!-- Overriding target, which runs conversion and verification instead of creating JAR file --> <target name="jar" depends="init,compile,convert"> </target> <!-- Target, which runs specific script via GPShell --> <target name="run-script" depends="init"> <!-- Generate and execute build script --> <copy file="${gpshell.templatepath}\\${gpshell.script}" todir="build//scripts" overwrite="true"> <filterchain> <expandproperties/> </filterchain> </copy> <exec executable="${gpshell.cmd}"> <arg value="build//scripts//${gpshell.script}"/> </exec> </target> <!-- Overriding target, which runs script during testing --> <target name="test" depends="jar,run-script"> </target> </project>
# Usable for: # NXP JCOP 4.1, 3.1 and 2.1 cards mode_211 enable_trace establish_context card_connect select -AID a000000003000000 open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f // Open secure channel delete -AID ${jc.applet.AID_GPShell} delete -AID ${jc.package.AID_GPShell} install -file ${build.classes.dir}/${jc.package.path}/javacard/${jc.package.shortName}.cap -nvDataLimit 2000 -instParam 00 -priv 2 select -AID ${jc.applet.AID_GPShell} card_disconnect release_context