JavaLoyalty



com.licel.jcardsim.samples.JavaLoyalty
Class JavaLoyalty

java.lang.Object
  extended by javacard.framework.Applet
      extended by com.licel.jcardsim.samples.JavaLoyalty.JavaLoyalty
All Implemented Interfaces:
JavaLoyaltyInterface, Shareable

public class JavaLoyalty
extends Applet
implements JavaLoyaltyInterface

Minimalistic loyalty applet. JavaPurse uses grantPoints method implementing JavaLoyaltyInterface to grant loyalty points. JavaLoyalty can process only two command APDUs: READ_BALANCE and RESET_BALANCE.


Constructor Summary
protected JavaLoyalty(byte[] bArray, short bOffset, byte bLength)
          Performs memory allocations, initializations, and applet registration
 
Method Summary
 Shareable getShareableInterfaceObject(AID clientAID, byte parameter)
          Implements getShareableInterfaceObject method of Applet class.
 void grantPoints(byte[] buffer)
          Implements main interaction with a client.
static void install(byte[] bArray, short bOffset, byte bLength)
          Installs Java Loyalty applet.
 void process(APDU apdu)
          Dispatches APDU commands.
 
Methods inherited from class javacard.framework.Applet
deselect, register, register, select, selectingApplet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaLoyalty

protected JavaLoyalty(byte[] bArray,
                      short bOffset,
                      byte bLength)
Performs memory allocations, initializations, and applet registration

Parameters:
bArray - received by install.
bOffset - received by install.
bLength - received by install.
Method Detail

install

public static void install(byte[] bArray,
                           short bOffset,
                           byte bLength)
Installs Java Loyalty applet.

Parameters:
bArray - install parameter array.
bOffset - where install data begins.
bLength - install parameter data length.

getShareableInterfaceObject

public Shareable getShareableInterfaceObject(AID clientAID,
                                             byte parameter)
Implements getShareableInterfaceObject method of Applet class.

JavaLoyalty could check here if the clientAID is that of JavaPurse Checking of the parameter to be agreed upon value provides additional security, or, if the Shareable Interface Object weren't JavaLoyalty itself it could return different Shareable Interface Objects for different values of clientAID and/or parameter.

SeeJava Card Runtime Environment (JCRE) Specification for details.

Overrides:
getShareableInterfaceObject in class Applet
Parameters:
clientAID - AID of the client
parameter - additional parameter
Returns:
JavaLoyalty object

grantPoints

public void grantPoints(byte[] buffer)
Implements main interaction with a client. The data is transfered through APDU buffer which is a global array accessible from any context. The format of data in the buffer is subset of Transaction Log record format: 2 bytes of 0, 1 byte of transaction type, 2 bytes amount of transaction, 4 bytes of CAD ID, 3 bytes of date, and 2 bytes of time. This sample implementation ignores everything but transaction type and amount.

Specified by:
grantPoints in interface JavaLoyaltyInterface
Parameters:
buffer - APDU buffer

process

public void process(APDU apdu)
Dispatches APDU commands.

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