com.licel.jcardsim.samples.ChannelsDemo
Class ConnectionManager

java.lang.Object
  extended by javacard.framework.Applet
      extended by com.licel.jcardsim.samples.ChannelsDemo.ConnectionManager
All Implemented Interfaces:
MultiSelectable

public class ConnectionManager
extends Applet
implements MultiSelectable

This applet keeps track of the network connection for a fictional wireless device. Every time unit the device is being actively used on the network will result in decreasing credits available to the user. If the user changes areas, different charge rates applies. If the user runs out of credits, then the connection is terminated.


Method Summary
 void deselect()
          Called by the Java Card runtime environment to inform that this currently selected applet is being deselected on this logical channel and no applet from the same package is still active on any other logical channel.
 void deselect(boolean appInstStillSelected)
          Called by the Java Card runtime environment to inform that this applet instance has been selected while the same applet instance or another applet instance from the same package is active on another logical channel.
static void install(byte[] bArray, short bOffset, byte bLength)
           
 void process(APDU apdu)
          Called by the Java Card runtime environment to process an incoming APDU command.
 boolean select()
          Called by the Java Card runtime environment to inform this applet that it has been selected when no applet from the same package is active on any other logical channel.
 boolean select(boolean appInstAlreadySelected)
          Called by the Java Card runtime environment to inform that this applet instance has been selected while the same applet instance or another applet instance from the same package is active on another logical channel.
 
Methods inherited from class javacard.framework.Applet
getShareableInterfaceObject, register, register, selectingApplet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

install

public static void install(byte[] bArray,
                           short bOffset,
                           byte bLength)

select

public boolean select()
Description copied from class: Applet
Called by the Java Card runtime environment to inform this applet that it has been selected when no applet from the same package is active on any other logical channel.

It is called when a SELECT APDU command or MANAGE CHANNEL OPEN APDU command is received and before the applet is selected. SELECT APDU commands use instance AID bytes for applet selection. See Runtime Environment Specification for the Java Card Platform, section 4.5 for details.

A subclass of Applet should override this method if it should perform any initialization that may be required to process APDU commands that may follow. This method returns a boolean to indicate that it is ready to accept incoming APDU commands via its process() method. If this method returns false, it indicates to the Java Card runtime environment that this Applet declines to be selected.

Note:

The implementation of this method provided by Applet class returns true.

Overrides:
select in class Applet
Returns:
true to indicate success, false otherwise

deselect

public void deselect()
Description copied from class: Applet
Called by the Java Card runtime environment to inform that this currently selected applet is being deselected on this logical channel and no applet from the same package is still active on any other logical channel. After deselection, this logical channel will be closed or another applet (or the same applet) will be selected on this logical channel. It is called when a SELECT APDU command or a MANAGE CHANNEL CLOSE APDU command is received by the Java Card runtime environment. This method is invoked prior to another applet's or this very applet's select() method being invoked.

A subclass of Applet should override this method if it has any cleanup or bookkeeping work to be performed before another applet is selected.

The default implementation of this method provided by Applet class does nothing.

Notes:

Overrides:
deselect in class Applet

select

public boolean select(boolean appInstAlreadySelected)
Description copied from interface: MultiSelectable
Called by the Java Card runtime environment to inform that this applet instance has been selected while the same applet instance or another applet instance from the same package is active on another logical channel.

It is called either when the MANAGE CHANNEL APDU (open) command or the SELECT APDU command is received and before the applet instance is selected. SELECT APDU commands use instance AID bytes for applet selection. See Runtime Environment Specification for the Java Card Platform, section 4.5 for details.

A subclass of Applet should, within this method, perform any initialization that may be required to process APDU commands that may follow. This method returns a boolean to indicate that it is ready to accept incoming APDU commands via its process() method. If this method returns false, it indicates to the Java Card runtime environment that this applet instance declines to be selected.

Note:

Specified by:
select in interface MultiSelectable

deselect

public void deselect(boolean appInstStillSelected)
Description copied from interface: MultiSelectable
Called by the Java Card runtime environment to inform that this applet instance has been selected while the same applet instance or another applet instance from the same package is active on another logical channel.

It is called either when the MANAGE CHANNEL APDU (open) command or the SELECT APDU command is received and before the applet instance is selected. SELECT APDU commands use instance AID bytes for applet selection. See Runtime Environment Specification for the Java Card Platform, section 4.5 for details.

A subclass of Applet should, within this method, perform any initialization that may be required to process APDU commands that may follow. This method returns a boolean to indicate that it is ready to accept incoming APDU commands via its process() method. If this method returns false, it indicates to the Java Card runtime environment that this applet instance declines to be selected.

Note:

Specified by:
deselect in interface MultiSelectable
Parameters:
appInstStillSelected - boolean flag is true when the same applet instance is still active on another logical channel and false otherwise

process

public void process(APDU apdu)
Description copied from class: Applet
Called by the Java Card runtime environment to process an incoming APDU command. An applet is expected to perform the action requested and return response data if any to the terminal.

Upon normal return from this method the Java Card runtime environment sends the ISO 7816-4 defined success status (90 00) in APDU response. If this method throws an ISOException the Java Card runtime environment sends the associated reason code as the response status instead.

The Java Card runtime environment zeroes out the APDU buffer before receiving a new APDU command from the CAD. The five header bytes of the APDU command are available in APDU buffer[0..4] at the time this method is called.

The APDU object parameter is a temporary Java Card runtime environment Entry Point Object. A temporary Java Card runtime environment Entry Point Object can be accessed from any applet context. References to these temporary objects cannot be stored in class variables or instance variables or array components.

Notes:

Specified by:
process in class Applet
Parameters:
apdu - the incoming APDU object
See Also:
APDU