Java Card Technology Ch09: Applet Firewall and Object Sharing Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Computer.

Slides:



Advertisements
Similar presentations
Java Card Programming: Overview Presented by: Raman Sharykin PISCES Group: Soumyadeb Mitra, Sruthi Bandhakavi, Ragib Hasan, Raman Sharikyn University.
Advertisements

Java Card Technology Ch04: Java Card Object
Threads, SMP, and Microkernels
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Java Card Technology Ch07: Applet Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Computer Science & Engineering.
1 1 Lecture 14 Java Virtual Machine Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Java Card Technology Ch06: Exception and Exception Handling Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Computer.
Lecture 2 Basics of C#. Members of a Class A field is a variable of any type that is declared directly in a class. Fields are members of their containing.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Road Map Introduction to object oriented programming. Classes
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
CE6105 Linux 作業系統 Linux Operating System 許 富 皓. Chapter 2 Memory Addressing.
Slides prepared by Rose Williams, Binghamton University Chapter 5 Defining Classes II.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Java Card Open Platform Combines tomorrow's technology and platforms C:\Presentations - JavaCard_OpenPlatform.ppt - bsc page 1 Programming.
Comp 248 Introduction to Programming Chapter 4 - Defining Classes Part A Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
Programming Languages and Paradigms Object-Oriented Programming.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Java Programming Java Basics. Data Types Java has two main categories of data types: –Primitive data types Built in data types Many very similar to C++
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Jini Technology Basics Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
Java Card Technology Ch08: Working with APDUs
Processes and Virtual Memory
CSE 351 Final Exam Review 1. The final exam will be comprehensive, but more heavily weighted towards material after the midterm We will do a few problems.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Introduction to Object-Oriented Programming Lesson 2.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Java Card Technology Ch05: Atomicity and transactions Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Computer.
Remote Method Invocation A Client Server Approach.
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
ACCESS MATRIX IMPLEMENTATION AND COMPARISON By: Rushabh Dharwadkar Roll no: TE COMP.
1. Presentation Agenda  Identify Java Card Technology  Identify Elements of Java Card applications  Communicating with a Java Card Applet  Java Card.
Processes and threads.
Chapter 14: System Protection
Chapter 3: Using Methods, Classes, and Objects
Packages, Interfaces & Exception Handling
Programming Models for Distributed Application
Chapter 3 Introduction to Classes, Objects Methods and Strings
null, true, and false are also reserved.
Chapter 14: Protection.
The Procedure Abstraction Part I: Basics
Chapter 40 Remote Method Invocation
Threads Chapter 4.
Chapter 14: Protection.
Process Description and Control
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Object Oriented Programming in java
Chapter 2: Operating-System Structures
Java Remote Method Invocation
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Java Card Technology Ch09: Applet Firewall and Object Sharing Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Computer Science & Engineering Tatung University

Applet Firewall and Object Sharing This chapter explains the behavior of objects, exceptions, and Applets in the presence of their firewall and discusses how applets can safely share data by using the Java Card APIs. This chapter explains the behavior of objects, exceptions, and Applets in the presence of their firewall and discusses how applets can safely share data by using the Java Card APIs.

Context The applet firewall partitions the Java Card object system into separate protected object spaces called context. The applet firewall partitions the Java Card object system into separate protected object spaces called context. When an applet instance is created, the JCRE assigns it a context which is essentially a group context. When an applet instance is created, the JCRE assigns it a context which is essentially a group context. All applet instances of a single Java package share the same group context. All applet instances of a single Java package share the same group context.

Context There is no firewall between two applet instances in a group context. There is no firewall between two applet instances in a group context. The JCRE maintain its own JCER context The JCRE maintain its own JCER context JCRE context has special privileges: JCRE context has special privileges:  Access from the JCRE context to any applet’s context

Context JCRE context Group context Firewall Applet context

Object ownership At any time, there is only one active context within the virtual machine: either the JCRE context or an applet’s group context. At any time, there is only one active context within the virtual machine: either the JCRE context or an applet’s group context. When a new object is created, it is assigned an owning context-----the currently active context. When a new object is created, it is assigned an owning context-----the currently active context.

Object Access Exception If the contexts do not match, the access is denied, and the comparison results in a SecurityException. If the contexts do not match, the access is denied, and the comparison results in a SecurityException.

Static Fields and Methods Only instances of classes---objects--- are owned by context; classes themselves are not. Only instances of classes---objects--- are owned by context; classes themselves are not. Static fields and methods are accessible from any applet context in the defining package (i.e. group context). Static fields and methods are accessible from any applet context in the defining package (i.e. group context).

Object Access across Context Sharing mechanisms are accomplished by the following means: Sharing mechanisms are accomplished by the following means: JCRE privileges JCRE privileges JCRE entry point objects JCRE entry point objects Global arrays Global arrays Shareable interfaces Shareable interfaces

Context Switch When a sharing mechanism is applied, the Java Card virtual machine enables access by performing a context switch. When a sharing mechanism is applied, the Java Card virtual machine enables access by performing a context switch. Context switches occur Context switches occur  only during invocation of and return from instance methods of an object owned by a different context,  during exception exits form those methods.

Context Switch During a context-switching method invocation, the current context is saved, and the new context become the currently active context. During a context-switching method invocation, the current context is saved, and the new context become the currently active context. When the virtual machine begins running after card reset, the JCRE context is always the currently active context. When the virtual machine begins running after card reset, the JCRE context is always the currently active context.

JCRE Privileges JCRE Privileges : JCRE can JCRE Privileges : JCRE can  invoke a method on any object or  access an instance field of any on the card. Such system privileges enable the JCRE to control system resources and manage applets Such system privileges enable the JCRE to control system resources and manage applets  For example, when the JCRE receives an APDU command, it invokes the currently selected applet’s select, deselect or process method

JCRE Privileges When JCRE invokes an applet’s method, the JCRE context is switched to the applet’s context. When JCRE invokes an applet’s method, the JCRE context is switched to the applet’s context. The applet now takes control and loses the JCRE privileges. The applet now takes control and loses the JCRE privileges. Any objects created after the context switch are owned by the applet. Any objects created after the context switch are owned by the applet.

JCRE entry point objects By using JCRE entry point object, non- privileged users can request system services that are performed by privileged system routines. By using JCRE entry point object, non- privileged users can request system services that are performed by privileged system routines. JCRE entry point objects are normal objects owned by the JCRE context, but they have been flagged as containing entry point methods. JCRE entry point objects are normal objects owned by the JCRE context, but they have been flagged as containing entry point methods.

JCRE entry point objects The entry point designation allows the public methods of such objects to be invoked from any context. The entry point designation allows the public methods of such objects to be invoked from any context. When that occurs, a context switch to the JCRE context is performed. When that occurs, a context switch to the JCRE context is performed. Notice that only the public methods of JCRE entry point objects are accessible through the firewall. Notice that only the public methods of JCRE entry point objects are accessible through the firewall. The fields of these objects are still protected by the firewall. The fields of these objects are still protected by the firewall.

JCRE entry point objects Two categories of JCRE EPOs: Temporary JCRE entry point objects: Temporary JCRE entry point objects:  Examples : The APDU object and all JCRE-owned exception objects.  Reference to these objects can’t be stored in class varibles. Permanent JCRE entry point objects: Permanent JCRE entry point objects:  Examples :The JCRE-owned AID instances.  Reference to these objects can be stored and freely used.

Global Arrays Global arrays essentially provide a shared memory buffer whose data can be accessed by any applets and by the JCRE. Global arrays essentially provide a shared memory buffer whose data can be accessed by any applets and by the JCRE. Global arrays are a special type of JCRE entry point object. Global arrays are a special type of JCRE entry point object. The applet firewall enables public fields of such arrays to be accessed from any context. The applet firewall enables public fields of such arrays to be accessed from any context.

Global Arrays Only primitive arrays can be designated as global and Only primitive arrays can be designated as global and Only JCRE can designate global arrays. Only JCRE can designate global arrays. The only global arrays required in the Java Card APIs are the APDU buffer and the byte array parameter in an applet’s install method. The only global arrays required in the Java Card APIs are the APDU buffer and the byte array parameter in an applet’s install method. Whenever an applet is selected or before JCRE accepts a new APDU command, JCRE clears the APDU buffer. Whenever an applet is selected or before JCRE accepts a new APDU command, JCRE clears the APDU buffer.  No leaked message

Sharing between JCRE and applets JCRE can access any object due to its privileged nature. JCRE can access any object due to its privileged nature. Applet gains access to system service via JCRE entry point objects. Applet gains access to system service via JCRE entry point objects. JCRE and applets share primitive data by using designated global arrays. JCRE and applets share primitive data by using designated global arrays.

Shareable interface Shareable interface enable object sharing between applets. Shareable interface enable object sharing between applets. Simply an interface that extends, either directly or indirectly, the tagging interface javacard.framework.Shareable. Simply an interface that extends, either directly or indirectly, the tagging interface javacard.framework.Shareable. public interface Shareable{} public interface Shareable{}

Shareable interface Object(SIO) An object of a class that implements a shareable interface is called a SIO. An object of a class that implements a shareable interface is called a SIO. To the owning context, an SIO is a normal object whose fields and methods can be accessed. To the owning context, an SIO is a normal object whose fields and methods can be accessed. To any other context, the SIO is an instance of the shareable interface type, and only the methods defined in the shareable interface are accessible. To any other context, the SIO is an instance of the shareable interface type, and only the methods defined in the shareable interface are accessible.

Shareable interface example Wallet appletAir-miles applet Request miles Client applet Server applet

Shareable interface example Package com.fasttravel.airmiles; import javacard.framework.Shareable; Public interface AirMilesInterface extends Shareable { public void grantMiles(short amout); public void grantMiles(short amout);}

Shareable interface example Package com.fasttravel.airmiles; import javacard.framework.Shareable; public class AirMilesApp extends Applet implements AirMilesInterface { private short miles; private short miles; public void grantMiles(short amout) { public void grantMiles(short amout) { miles = (short)( miles + amout ); miles = (short)( miles + amout ); }}

Review about AID and Register Protected final void register(); Protected final void register(byte[] Array, short bOffset, byte bLength) The JCRE encapsulates the AID bytes in an AID object(owned by the JCRE) and associates this AID object whit the applet. During the object sharing, this AID object is used by a client applet to specify the server.

Request a Shareable Interface Object Client applet lookups the server AID by calling JCSystem.lookupAID method Client applet lookups the server AID by calling JCSystem.lookupAID method public static AID lookupAID(byte[] buffer, short offset, byte length) Client applet gets the server SIO by calling JCSystem.getAppletSharableInterface method Client applet gets the server SIO by calling JCSystem.getAppletSharableInterface method public static Shareable getAppletShareableInterfaceObject(AID server_aid, byte parameter) JCRE invokes Server applet’ getSharableInterfaceOjbect method JCRE invokes Server applet’ getSharableInterfaceOjbect method Public Shareable getShareableInterfaceObject(AID client_aid, byte parameter)

Request a Shareable Interface Object public class AirMilesApp extends Applet implements AirMilesInterface { short miles; short miles; public Shareable getShareableInterfaceObject (AID client_aid, byte parameter) { public Shareable getShareableInterfaceObject (AID client_aid, byte parameter) { //authenticate the client – explained later //authenticate the client – explained later return this; // return shareable interface object return this; // return shareable interface object }}

Request an SIO JCRE client Server SIO(or null) Applet.getSahreable InterfaceObject JCSystem.getAppletSha reableInterfceObject

Context Switches during Object Sharing JCRE CLINET APPLET SERVER APPLET SIO(or null) JCSystem.getAppletSha reableInterfceObject Applet.getSahreableInterfa ceObject RETURN FROM THE METHOD INVODE A SHAREALBE INGERFACE METHOD

Authenticate a Client Applet public class AirMilesApp extends Applet implements AirMilesInterface { public Shareable getShareableInterfaceObject (AID client_aid, byte parameter) { public Shareable getShareableInterfaceObject (AID client_aid, byte parameter) { if (client_aid.equals(wallet_app_aid_bytes, (short)0, (byte)wallet_app_aid_bytes.length)) == false) if (client_aid.equals(wallet_app_aid_bytes, (short)0, (byte)wallet_app_aid_bytes.length)) == false) return null; return null; if ( parameter != SECRET) if ( parameter != SECRET) return null; return null; return (this); return (this);}

Verify the client applet again public void grantMiles (short amount) { AID client_aid = JCSystem.getPreviousCOntextAID(); AID client_aid = JCSystem.getPreviousCOntextAID(); if (client_aid.equals(wallet_app_aid_bytes, (short)0, (byte)wallet_app_aid_bytes.length)) == false) if (client_aid.equals(wallet_app_aid_bytes, (short)0, (byte)wallet_app_aid_bytes.length)) == false) ISOException.throwIt(SW_UNAUTHORIZED- CLIENT); ISOException.throwIt(SW_UNAUTHORIZED- CLIENT); miles = (short)(miles + amount); miles = (short)(miles + amount);}

Summary If a server applet A want to share an object with another applet, it first defines a sharable interface SI If a server applet A want to share an object with another applet, it first defines a sharable interface SI Applet A then defines a service provider class C that implements the sharable interface SI. (i.e. C class provides actual implementations for the methods of SI.) Applet A then defines a service provider class C that implements the sharable interface SI. (i.e. C class provides actual implementations for the methods of SI.) Applet A creates an object o of Class C. Applet A creates an object o of Class C.

Summary If a client B wants to access applet A’s object o, it invokes JCSystem.getAppletSharableInterfae method to request the SIO. If a client B wants to access applet A’s object o, it invokes JCSystem.getAppletSharableInterfae method to request the SIO. The JCRE searches for its internal applet table for applet A. When found it invokes JCSystem.getSharableInterfaceObject. The JCRE searches for its internal applet table for applet A. When found it invokes JCSystem.getSharableInterfaceObject. Applet A receives the request and determines whether it wants to share object o with applet B (return o’s reference or null). Applet A receives the request and determines whether it wants to share object o with applet B (return o’s reference or null).

Summary Applet B receives the object reference and casts it to type SI (an SIO object). Applet B receives the object reference and casts it to type SI (an SIO object). Applet B then uses the services provided in the SIO object. Applet B then uses the services provided in the SIO object.