Application Programming Notes, Java Card 3 Platform, Classic Edition
Total Page:16
File Type:pdf, Size:1020Kb
Application Programming Notes Java Card™ 3 Platform Classic Edition Sun Microsystems, Inc. www.sun.com July 2009 Copyright © 2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries. U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. This distribution may include materials developed by third parties. Sun, Sun Microsystems, the Sun logo, Java, Solaris, Java Card, Mozilla, Netscape, Javadoc, JDK, JVM, NetBeans and Servlet are trademarks or registered trademarks of Sun Microsystems, Inc. or its subsidiaries in the U.S. and other countries. UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd. The Adobe logo is a trademark or registered trademark of Adobe Systems, Incorporated. Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited. DOCUMENTATION IS PROVIDED "AS IS" AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. Copyright © 2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, États-Unis. Tous droits réservés. Sun Microsystems, Inc. détient les droits de propriété intellectuels relatifs à la technologie incorporée dans le produit qui est décrit dans ce document. En particulier, et ce sans limitation, ces droits de propriété intellectuelle peuvent inclure un ou plus des brevets américains listés à l'adresse http://www.sun.com/patents et un ou les brevets supplémentaires ou les applications de brevet en attente aux États - Unis et dans les autres pays. Droits du gouvernement des États-Unis – Logiciel Commercial. Les droits des utilisateur du gouvernement des États-Unis sont soumis aux termes de la licence standard Sun Microsystems et aux conditions appliquées de la FAR et de ces compléments. Cette distribution peut inclure des éléments développés par des tiers. Sun, Sun Microsystems, le logo Sun, Java, Solaris, Java Card, Mozilla, Netscape, Javadoc, JDK, JVM, NetBeans et Servlet sont des marques de fabrique ou des marques déposées enregistrées de Sun Microsystems, Inc. ou ses filiales aux États-Unis et dans d'autres pays. UNIX est une marque déposée aux États-Unis et dans d'autres pays et licenciée exlusivement par X/Open Company, Ltd. Le logo Adobe est une marque déposée de Adobe Systems, Incorporated. Les produits qui font l'objet de ce manuel d'entretien et les informations qu'il contient sont regis par la legislation americaine en matière de contrôle des exportations et peuvent être soumis au droit d'autres pays dans le domaine des exportations et importations. Les utilisations finales, ou utilisateurs finaux, pour des armes nucleaires, des missiles, des armes biologiques et chimiques ou du nucleaire maritime, directement ou indirectement, sont strictement interdites. Les exportations ou reexportations vers des pays sous embargo des États-Unis, ou vers des entites figurant sur les listes d'exclusion d'exportation americaines, y compris, mais de maniere non exclusive, la liste de personnes qui font objet d'un ordre de ne pas participer, d'une façon directe ou indirecte, aux exportations de des produits ou des services qui sont regi par la legislation americaine sur le contrôle des exportations et la liste de ressortissants specifiquement designes, sont rigoureusement interdites. LA DOCUMENTATION EST FOURNIE "EN L'ÉTAT" ET TOUTES AUTRES CONDITIONS, DECLARATIONS ET GARANTIES EXPRESSES OU TACITES SONT FORMELLEMENT EXCLUES, DANS LA MESURE AUTORISEE PAR LA LOI APPLICABLE, Y COMPRIS NOTAMMENT TOUTE GARANTIE IMPLICITE RELATIVE À LA QUALITE MARCHANDE, À L'APTITUDE À UNE UTILISATION PARTICULIERE OU À L'ABSENCE DE CONTREFAÇON. Please Recycle Contents Preface vii 1. Using Object, Package and Applet Deletion 1–1 1.1 Object Deletion Mechanism 1–1 1.1.1 Requesting the Object Deletion Mechanism 1–2 1.1.2 Object Deletion Mechanism Usage Guidelines 1–2 1.2 Package and Applet Deletion 1–3 1.2.1 Developing Removable Packages 1–3 1.2.2 Writing Removable Applets 1–4 1.2.2.1 Using the AppletEvent.uninstall Method 1–4 2. Working with Logical Channels 2–1 2.1 Applets and Logical Channels 2–2 2.1.1 Non-MultiSelectable Applets 2–2 2.1.2 Interoperability 2–2 2.2 Understanding the MultiSelectable Interface 2–3 2.2.1 Selection for MultiSelectable Applets 2–3 2.2.2 Deselection for MultiSelectable Applets 2–4 2.3 Writing Applets For Concurrent Logical Channels 2–4 2.3.1 MultiSelectable Applet Example 2–5 iii 2.3.1.1 Handling Channel Information on APDU Commands 2–7 2.3.2 Writing ISO 7816-4:2005 Compliant Applets 2–11 2.3.2.1 ISO 7816-4:2005 Compliant Applet Example 2–11 2.3.3 Applet Firewall Operation Requirements 2–13 2.3.3.1 Working with Non-MultiSelectable Applets 2–13 2.3.4 ISO 7816-4:2005 Specific APDU Commands for Logical Channel Management 2–13 2.3.4.1 MANAGE CHANNEL OPEN 2–14 2.3.4.2 MANAGE CHANNEL CLOSE 2–15 2.3.4.3 SELECT FILE 2–16 3. Developing RMI Applications for the Java Card Platform 3–1 3.1 Developing an RMI Applet for the Java Card 3 Platform 3–1 3.1.1 Generating Stubs 3–2 3.1.2 Running a Java Card RMI Applet 3–2 3.1.3 Running the Java Card RMI Client Program 3–3 3.2 Basic Example 3–3 3.2.1 Main Program 3–3 3.2.2 Building an Applet 3–7 3.2.3 Writing a Client 3–9 3.2.4 Card Terminal Interaction 3–13 3.3 Adding Security 3–14 3.3.1 Implementing a Security Service 3–18 3.3.2 Building an Applet 3–19 3.3.3 Writing a Client 3–21 4. Using Extended APDU 4–1 4.1 Extended APDU Nominal Cases 4–1 4.2 Extended APDU Format 4–2 iv Application Programming Notes, Java Card 3 Platform, Classic Edition • July 2009 4.3 Extended APDU Limits 4–3 4.3.1 javacardx.framework.ExtendedLength Interface 4–3 4.3.2 Extensions To javacard.framework.APDU Class 4–4 4.4 Sending and Receiving Extended APDU Commands 4–4 Glossary Glossary–1 Index Index–1 Contents v vi Application Programming Notes, Java Card 3 Platform, Classic Edition • July 2009 Preface This book contains tips and guidelines for developers of Classic Java Card™ applets and for developers of vendor-specific frameworks. This book covers several topics that are substantially different from programming models found in earlier versions of the Java Card platform and is not meant to comprehensively introduce or cover general programming topics. The Java Card 3 Platform currently includes releases 3.0 and 3.0.1. The Java Card 3 Platform consists of two editions, both of which are backward compatible with previous versions and share key security features. This book is strictly for use with the Classic APIs, which appear in both editions. ■ Classic Edition - Targets more resource-constrained devices that support applet- based applications and contains only Classic APIs. The Classic Edition is based on an evolution of the Java Card Platform, Version 2.2.2. ■ Connected Edition - Features a significantly enhanced runtime environment and a new virtual machine. It includes new network-oriented features, such as support for web applications, including the Java™ Servlet APIs. The Connected Edition supports the Classic APIs, but also supports applets with extended and advanced capabilities. Java Card™ technology combines a subset of the Java™ programming language with a runtime environment optimized for smart cards and similar small-memory embedded devices. The goal of Java Card technology is to bring many of the benefits of the Java programming language to the resource-constrained world of smart cards. The Java Card API is compatible with international standards such as ISO7816 and industry-specific standards such as Europay, Master Card, Visa (EMV). vii Who Should Use This Book This book is for applet developers using the Application Programming Interface for the Java Card Platform, Version 3.0.1, Classic Edition to implement applet management, multiselectable applets, logical channels, Remote Method Invocation (RMI), and extended APDUs for the Java Card platform. This book is also for developers who are considering creating a vendor-specific framework based on version 3.0.1 of the Java Card technology specifications, Classic Edition. Before You Read This Book Before reading this guide, become familiar with the Java programming language, object-oriented design, the Java Card technology specifications, and smart card technology. A good resource for becoming familiar with Java and Java Card technology is the Sun Microsystems, Inc. web site, located at http://java.sun.com.