Shareable Interface--Can arrays be passed from client applet to server app

Hi,

Not sure whether this topic is already discussed or not. I have 2 applets communicating each other through Shareable Interface. I want an array of data which is there in 'client Applet' to be available in 'Server applet'. I will pass this array through a function ( there in Interface) which accepts array as arguments.

I just tested the similar scenario, and I found the array object is null at server side, any suggestions?

Thanks in advance for reply

Regards

Raaghu.K

[515 byte] By [Raaghuamateura] at [2007-11-26 16:39:00]
# 1

You can pass arrays through shareable interfaces. If they are null on the other side, that's an error in the JCRE.

However, you may run into issues when accessing the array elements, if the array object is owned by a different context. Note that a context switch happens when invoking a shareable interface.

Global arrays (e.g. APDU buffer) can be accessed by any context.

mkdataa at 2007-7-8 23:05:51 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2
Thanks for the reply.You have any example to explain this ?. I am a SIM application developer, I havent used much of process(APDU apdu). RegardsRaaghu.KMessage was edited by: Raaghuamateur
Raaghuamateura at 2007-7-8 23:05:51 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 3

Here is the code of an client applet

/**

* Method Name : Client

* Returns : void

* Parameters : byte[], short, byte

* Description : Constructor - intializes the PIN objects, emv, bank record

* objets etc

*/

public Client(byte[] buffer, short offset, byte length) {

//super.process(object);

// Get the reference to GSM 3.19 Registry object

reg = ToolkitRegistry.getEntry();

// Add menu items to GSM 3.19 Registry

reg.initMenuEntry(menuLevel1, (short) 0,(short) menuLevel1.length, PRO_CMD_SELECT_ITEM, false,(byte) 0, (short) 0);

m_PIN = new OwnerPIN( (byte) PIN_TRY_LIMIT, (byte) MAX_PIN_LENGTH);

Util.arrayFillNonAtomic(temp_APDU,(short)0,(short)(temp_APDU.length & 0x00FF),(byte)0x30);

}

/**

* Method Name : install.

* Returns : void.

* Parameters : byte[], short, byte. [i.e AID of an applet, start offset, AID Length ] throws : ISOException.

* Description : called by JCRE while creating the Applet instance .

*/

public static void install(byte[] tmpBuf, short offset, byte length) throws ISOException {

// Create the Javacard applet

Client client = new Client(tmpBuf, offset, length);

// Install Applet onto Javacard 2.1 System

client.register();

}

/**

* Method Name: process.

* Returns : void

* Parameters : APDU apdu - Holds theCommand APDUs sent from Off-card

* Description : Handles the OTC commands,entry point OTC interface

*/

public void process(APDU apdu) {

try {

if (selectingApplet()) {

temp_APDU[0] = (byte)0x31;

temp_APDU[1] = (byte)0x32;

temp_APDU[3] = (byte)0x33;

return;

}

switch(apdu.getBuffer()[1]) {

// specific APDU for this applet to configure the MenuTitle from SelectItem

case (byte)0x46:

/*Util.arrayCopy(apdu.getBuffer(),(short)0x0005,menuTitle,(short)0x0000,

(short)0x0006);*/

break;

default:

ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);

}

} catch(Exception exception) {

}

// Handle the Select AID apdu

}

public boolean select() {

return true;

}

/**

* Method Name : processToolkit. Returns : void Parameters : Event

* -Generated by the handset Description : Handles the events generated by

* the handset

*/

public void processToolkit(byte event) throws ToolkitException {

// GSM 3.19 Proactive Command Object

ProactiveHandler proHdlr = ProactiveHandler.getTheHandler();

ProactiveResponseHandler respHandler = ProactiveResponseHandler.getTheHandler();

switch (event) {

// Trigger on envelope menu selection

case EVENT_MENU_SELECTION:

proHdlr.init( (byte)PRO_CMD_SELECT_ITEM, (byte)0x00, (byte)DEV_ID_ME);

proHdlr.appendTLV( (byte)(TAG_ITEM),(byte)0x01, g_Pay, (short)0, (short)g_Pay.length);

proHdlr.send();

if(respHandler.getGeneralResult() == (byte) 0x00)

callServerMethod();

break;

// Get Envelope Handler

}

}

private void callServerMethod() {

try {

AID aid = JCSystem.lookupAID(server_AID,(short)0,(byte)server_AID.length);

if(aid == null) {

} else {

}

mChekShareable shareable = (mChekShareable)JCSystem.getAppletShareableInterfaceObject(aid,(byte)0x6D);

/*temp_APDU[0] = (byte)0x31;

temp_APDU[1] = (byte)0x32;

temp_APDU[3] = (byte)0x33;*/

//byte b = (byte)shareable.verifymChekPin();

display(temp_APDU, (byte)0, (byte)0x03);

//byte b = (byte)shareable.testArray(server_AID, (byte)0, (byte)(server_AID.length & 0x00FF));

byte b = (byte)shareable.testArray(temp_APDU, (byte)0, (byte)(0x02 & 0x00FF));

//byte b = (byte)shareable.testArray(apdu);

if(b == 0x00)

display(Success,(short)0,(short)Success.length);

else if(b == (byte)0x01)

display(One_exception,(short)0,(short)One_exception.length);

else if(b == (byte)0x02)

display(Success,(short)0,(short)0x02);

} catch(Exception exception) {

}

}

Just want to know how to fill the data in "temp_APDU" array so that it is available in server applet?

Raaghuamateura at 2007-7-8 23:05:51 > top of Java-index,Java Mobility Forums,Consumer and Commerce...