GSMAppletpublic class GSMApplet extends Applet implements ToolkitConstantsThis applets is suppose to simulate the working of the main GSM applet in
(U)SIM that controls access to all other applets. No other applet is
selected directly but is invoked by this applet on basis of events. |
Fields Summary |
---|
private static final byte | ENVELOPE_INSInstruction byte for an Envelope. Only Envelopes are supported at
this time | private static final byte | GET_RESPONSE_INSInstruction byte value for GET RESPONSE APDU. | AccessSATImpl | SATAccessorA field to hold the instance of SATAccessor which is used by the
toolkit classes to set and get the APDU buffer. |
Constructors Summary |
---|
private GSMApplet()Constructor.
register();
SATAccessor = new AccessSATImpl();
AID aid = JCSystem.getAID();
ViewHandler.SATAccessor = (AccessSAT)
JCSystem.getAppletShareableInterfaceObject(aid, (byte)0);
|
Methods Summary |
---|
public Shareable | getShareableInterfaceObject(AID clientAID, byte parameter)Returns shareable interface object to SIM Framework.
return (Shareable)SATAccessor;
| public static void | install(byte[] bArray, short bOffset, byte bLength)Applet's install method. Creates an instance of GSMApplet
new GSMApplet();
| public void | process(APDU apdu)Process method that processes all the APDUs received from the terminal.
byte[] buffer = apdu.getBuffer();
// clear the channel information
buffer[ISO7816.OFFSET_CLA] = (byte)(buffer[ISO7816.OFFSET_CLA]
& (byte)0xFC);
// check SELECT APDU command
if ((buffer[ISO7816.OFFSET_CLA] == 0) &&
(buffer[ISO7816.OFFSET_INS] == (byte)(0xA4)))
return;
switch (buffer[ISO7816.OFFSET_INS]) {
case ENVELOPE_INS:
short incomingData = apdu.setIncomingAndReceive();
SATAccessor.resetBuffers();
SATAccessor.setAPDUBuffer(buffer, (short)(incomingData + 5));
for (byte i = 0; i < AccessSATImpl.MAX_LISTENERS; i++) {
ToolkitInterface ti = SATAccessor.tiList[i];
if (ti == null) {
continue;
}
ViewHandler.currentTI = ti;
ti.processToolkit(EVENT_UNFORMATTED_SMS_PP_ENV);
if (EnvelopeResponseHandler.status != 0) {
short dataLength = SATAccessor.getOutDataLength();
short st = (short)
((EnvelopeResponseHandler.status << 8) | dataLength);
ISOException.throwIt(st);
}
}
break;
case GET_RESPONSE_INS:
SATAccessor.setAPDUBuffer(buffer, (short)5);
short dataLength = SATAccessor.getOutDataLength();
apdu.setOutgoing();
apdu.setOutgoingLength(dataLength);
SATAccessor.setOutgoingAPDU();
Util.arrayCopy(SATAccessor.getAPDUBuffer(), (short)0,
buffer, (short)0, dataLength);
apdu.sendBytes((short)0, dataLength);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
| public void | uninstall()This method is called by JCRE before it tries to uninstall this applet.
ViewHandler.SATAccessor = null;
|
|