Applications & SmartCard : JavaCard - Identification - LIFL
Applications & SmartCard : JavaCard - Identification - LIFL
Applications & SmartCard : JavaCard - Identification - LIFL
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>JavaCard</strong> APIs<br />
<strong>JavaCard</strong> APIs<br />
• Every exception has an associated reason<br />
A short value<br />
Forwarded to the JCVM using<br />
http://www.lifl.fr/~grimaud/Cours<br />
xxxException.throwIt(short reason)<br />
Rather than<br />
throw new xxxException(short reason)<br />
• Card returns the reason for ISOException exceptions<br />
only.<br />
For otherException, reason is always “6F00” code (JCVM<br />
terminated).<br />
<strong>JavaCard</strong> System & Framework 13<br />
• How can you customize your exceptions : example<br />
<br />
<br />
<br />
http://www.lifl.fr/~grimaud/Cours<br />
define an exception<br />
APDUException a<br />
associate a reason to this exception and throw it<br />
a.throwIt(BAD_LENGTH)<br />
catch it and convert it into a ISOException with a customized reason,<br />
then throw it<br />
ISOException.throwIt(SW_UNKNOWN+0x30+a.getReason())<br />
ISOException reasons are always returned :<br />
SW1 SW2 =<br />
SW1 SW2 = 6F 33<br />
6F 00 (SW_UNKNOWN:defined in ISO7816 interface)<br />
+ 0x30 (customized convention)<br />
+ 0x03 (BAD_LENGTH:defined in APDUException class)<br />
<strong>JavaCard</strong> System & Framework 14<br />
http://www.lifl.fr/~grimaud/Cours<br />
<strong>JavaCard</strong> APIs<br />
• 1. java.lang<br />
• 2. javacard.framework<br />
Interfaces ISO7816 PIN Shareable<br />
Classes AID APDU Applet JCSystem OwnerPIN Util<br />
Exceptions<br />
Provides framework of classes and interfaces for the core<br />
functionality of a Java Card applet.<br />
• 3. javacard.security<br />
• 4. javacardx.crypto<br />
<strong>JavaCard</strong> System & Framework 15<br />
<strong>JavaCard</strong>.Framework APIs<br />
° class java.lang.Object<br />
° class javacard.framework.AID<br />
° class javacard.framework.APDU<br />
° class javacard.framework.Applet<br />
° class javacard.framework.JCSystem<br />
° class javacard.framework.OwnerPIN (implements javacard.framework.PIN)<br />
° class java.lang.Throwable<br />
° class java.lang.Exception<br />
° class javacard.framework.CardException<br />
° class javacard.framework.UserException<br />
° class java.lang.RuntimeException<br />
° class javacard.framework.CardRuntimeException<br />
° class javacard.framework.APDUException<br />
° class javacard.framework.ISOException<br />
° class javacard.framework.PINException<br />
° class javacard.framework.SystemException<br />
° class javacard.framework.TransactionException<br />
° class javacard.framework.Util<br />
° interface javacard.framework.ISO7816<br />
Optionally used by the<br />
° interface javacard.framework.PIN<br />
developer...<br />
° interface javacard.framework.Shareable<br />
http://www.lifl.fr/~grimaud/Cours<br />
<strong>JavaCard</strong> System & Framework 16