a way to send and receive messages between applets?
Posted: Sun Feb 26, 2017 9:52 pm
Is there a way to send and receive messages between applets?
For example, is it possible to run the functions defined in the process function in A applet with the B applet?
For example code
A applet
B applet
For example, is it possible to run the functions defined in the process function in A applet with the B applet?
For example code
A applet
Code: Select all
package Test
import javacard.framework.*;
public class A extends Applet
{
private A() {
}
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new A().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x00:
// Send message to B applet(apdu or ....)
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}
B applet
Code: Select all
package Test
import javacard.framework.*;
public class B extends Applet
{
private B() {
}
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new B().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}
// Receive message from A applet(apdu or ...)
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
// Execute A applet message
case (byte)0x00:
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}