Events in a SIM toolkit applet
Hi,
I am looking at some sample (and simple) code:
public MyApplet() {
// Define the applet Menu Entry
idMenu1 = reg.initMenuEntry(Menu1, (short) 0, (short) Menu1.length,
PRO_CMD_SELECT_ITEM, false, (byte) 0, (short) 0);
// Define the Unformatted SMS PP event that trigger the applet
reg.setEvent(EVENT_UNFORMATTED_SMS_PP_ENV);
public void processToolkit(byte event) {
EnvelopeHandler envHdlr = EnvelopeHandler.getTheHandler();
if (event == EVENT_MENU_SELECTION) {
byte selectedItemId = envHdlr.getItemIdentifier();
if (selectedItemId == idMenu1) {
menu1Action();
if (event == EVENT_UNFORMATTED_SMS_PP_ENV) {
UnformattedSmsPpAction();
In processToolkit we procees EVENT_MENU_SELECTION and EVENT_UNFORMATTED_SMS_PP_ENV, yet in the ctor we subscribed only for the latter. Does that mean that it is not necessary to subscribe to EVENT_MENU_SELECTION and that this event is always delivered to the applet (that created the menu)?
For UICC, SIM etc check this link: [http://en.wikipedia.org/wiki/UICC]
For ETSI, 3GPP etc., this is where it gets confusing, you should do the research for yourself. As for using the latest specification, you actually want to use the specification your card complies to, i.e. if the card is old it may not comply with the latest specifications.
Regarding Java applets and toolkit applets:
To send commands to a Java applet you first select (see GlobalPlatform standard) it and then you send it some APDUs as specified in the 7816-4 and GlobalPlatform standards. You can also implement custom APDUs that only your applet will recognize.
The toolkit applets are Java applets, you can send them APDUs (first you select them) as well. The difference is that toolkit applets can also receive events from the mobile phone like SMS received or user selected some menu. You can also send commands to the phone to display text, menus etc.
A Java applet can do what a toolkit applet does, but to implement it yourself you be very hard. The Java API that is used in toolkit applet programming provides facilities to (for example) show something on the phone's display without sending and receiving heaps of APDUs.
If your card will be used in a mobile phone then you write a toolkit applet (to which you can still send APDUs if you have to). If your card will be used for something else, like access card or a bank card then you don't need toolkit applet functionality.
The biggest problem with this technology that there are almost no books, only the standards, which you do have to read, and forums.
Similar Messages
-
Java card Applet and sim toolkit applet
What is Difference between this two?
When i load java card applet on sim ,then applet is not visible on GSM phone. But sim toolkit Applet is visible on GSM phone.
i think,SIM uses sim.toolkit ad sim.access to interact with Applet.
is it so?
Plz solve my query.
Thankx 4 ur valuable time.
Regards
Divyesh.for programming in sim card, you must use necessarily sim toolkit applet.
I thing that the difference between Javacard applet and Simtoolkit applet is that:
- sim toolkit applet is only for sim card
- java card applet is for another smart card
of course, both have some joint things. -
Hi! I am a Java card programmer and i have worked with Java card 2.1.1 and 2.2.1. now, we are going to have a mobile banking project. but i dont know anything about that. so if i am asking funny questions, dont laugh at me!:)
- i dont know whats the difference between SIM card and the regular Java cards?
- am i able to use regular JAVA card 2.2.1 to use for this purpose?
- i dont know whats the difference between SIM and USIM?
- i have found some sample SIM applet, which use sim.toolkit,sim.access / uicc.toolkit,uicc.access, but i dont know where can i find these packages! for JCDK, we have downloaded it from Oracle(SUN) , but for this?
- can i use my regular reader to work with my card or i should put it on a mobile or a simulator?
please help me! i really need your help! :(
NargesFor UICC, SIM etc check this link: [http://en.wikipedia.org/wiki/UICC]
For ETSI, 3GPP etc., this is where it gets confusing, you should do the research for yourself. As for using the latest specification, you actually want to use the specification your card complies to, i.e. if the card is old it may not comply with the latest specifications.
Regarding Java applets and toolkit applets:
To send commands to a Java applet you first select (see GlobalPlatform standard) it and then you send it some APDUs as specified in the 7816-4 and GlobalPlatform standards. You can also implement custom APDUs that only your applet will recognize.
The toolkit applets are Java applets, you can send them APDUs (first you select them) as well. The difference is that toolkit applets can also receive events from the mobile phone like SMS received or user selected some menu. You can also send commands to the phone to display text, menus etc.
A Java applet can do what a toolkit applet does, but to implement it yourself you be very hard. The Java API that is used in toolkit applet programming provides facilities to (for example) show something on the phone's display without sending and receiving heaps of APDUs.
If your card will be used in a mobile phone then you write a toolkit applet (to which you can still send APDUs if you have to). If your card will be used for something else, like access card or a bank card then you don't need toolkit applet functionality.
The biggest problem with this technology that there are almost no books, only the standards, which you do have to read, and forums. -
Memory optimization in sim toolkit applet
Dear all
i am developing one sim toolkit application.
i am dispalying text on ME screen like this:
name
abcxyz(taking user input using GET INPUT)
password
abcxyz(taking user input using GET INPUT)
bank
ICICI(according to menu selection from user)
for this ,i am copying all this information in one array using
util.arraycopy
and then displaying all this info using
proHdlr.initdisplaytext
i am declaring all arrays (whose content is not going to be changed like name ,password and bank as
global) and all other arrays as transient.
There is some kind of memory leak in aplication ,due to this my application runs for
some(20 or 25) times and then it crash.(to make it work again i have to load it again on sim)
is it necessary to free merory allocated by transient array? or it will released automatically after its use.
// code for ur reference in which memory leaks is here
confirm1 = JCSystem.makeTransientByteArray((short)65, JCSystem.CLEAR_ON_RESET);
//buffer and tempBuffer are also transient arrays in which name and password from
proactive command GET INPUT are stored.
len = 0;
Util.arrayCopy(name, (short)0, confirm1, (short)0, (short)name.length);
len += name.length;
Util.arrayCopy(newLine, (short)0, confirm1, (short)len,(short)newLine.length);
len += newLine.length;
Util.arrayCopy(buffer, (short)0, confirm1,(short)len ,(short)l);
len += l;
Util.arrayCopy(newLine, (short)0, confirm1, (short)len,(short)newLine.length);
len += newLine.length;
Util.arrayCopy(password, (short)0, confirm1, (short)len, (short)password.length); len += password.length;
Util.arrayCopy(newLine, (short)0, confirm1, (short)len,(short)newLine.length);
len += newLine.length;
Util.arrayCopy(tempBuffer, (short)0, confirm1, (short)len, (short)j);
len += j;
Util.arrayCopy(newLine, (short)0, confirm1, (short)len, (short)newLine.length);
len += newLine.length;
Util.arrayCopy(bank, (short)0, confirm1, (short)len, (short)bank.length);
len += bank.length;
Util.arrayCopy(newLine, (short)0, confirm1, (short)len, (short)newLine.length);
len += newLine.length;
Util.arrayCopy(card, (short)0, confirm1, (short)len, (short)card.length);
len += card.length;
ProactiveHandler proHdlr = ProactiveHandler.getTheHandler();
proHdlr.initDisplayText((byte)0x81, DCS_8_BIT_DATA, confirm1, (short)0x0000, (short)len);
proHdlr.send();
//end of code
any other way of performing same functionality?
Thanx in advance.
Regards
DivyeshAs you have written beforehand: the API provides no possibility to issue directly a VERIFY PIN. The only possibility would be to check the user entered pin against the pin stored in the corresponding EF. But when i remember correctly: the EFs storing the card holder verification values are protected by NEVER (read AC), aren't they? Check the 11.11. Or ask your Schlumberger support for proprietary solutions, if they are available.
So you've got to find a workaround: another EF storing the same value which would rise some security concerns for your customer or storing the pin once at the first application startup (after the user entered it).
The solution with sending APDUs directly to the card will not work in a ME (the ME would have to select your application and i don't know any ME which would do that ;o) That would only be possible at your PC in a card reader. -
How to compile and test SIM card applet
Dear all
I have a sample applet:
package sim.access.sample;
import sim.access.*;
public final class helloFile extends Applet implements ToolkitInterface
private static SIMView theGsmApplet;
private static USIMView aUsimApplet;
private static AID theGSMAppletAID;
private static AID theUSIMAppletAID;
private static final byte[] baGSMAID = {(byte)0xA0,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x09,(byte)0x00,(byte)0x01};
protected helloFile(){
public MyApplet () {
theGSMAppletAID = new AID();
// get a reference to the GSM interface
theGsmApplet = SIMSystem.getTheSIMView(theGSMAppletAID);
public void doSomethingWithAFile(){
// returns the SIMView of the currently selected Applet
// allows to implement services that are depend on specific
// file in GSM or USIM application as well as to implement
// technolgie independent applets.
SIMView theView = SIMSystem.getTheSIMView();
if(theView instanceof SIMView){
// do something with a GSM file
else if(theView instanceof USIMView) {
//do something with a USIM specific file
// Or request a View to a specific application
USIMView theView = SIMSystem.getTheSIMView(aUSIMAppletAID);
}I want to compile and test it, how can i do it ???I am trying to compile it on eclipse using JCOP:
package mytest;
import sim.toolkit.ToolkitException;
import sim.toolkit.ToolkitInterface;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
public class Test extends Applet implements ToolkitInterface{
public static void install(byte[] bArray, short bOffset, byte bLength) {
// GP-compliant JavaCard applet registration
new Test().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
public void process(APDU apdu) {
// Good practice: Return 9000 on SELECT
if (selectingApplet()) {
return;
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS]) {
case (byte) 0x00:
break;
default:
// good practice: If you don't know the INStruction, say so:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
public void processToolkit(byte arg0) throws ToolkitException {
// TODO Auto-generated method stub
}It is giving following error on package name:
resolving constant-pool of clazz Lmytest/Test; failed: missing export file for package sim/toolkit -
Probability Of Sending ME/SIM data through WAP enabled on SIM Using Applet
Dear Friends,
I am new to java card development.
Is it possible or what is Probability Of Sending ME/SIM data through WAP enabled on SIM Using Applet?
Is it feasible to do so? Suppose if we write one application using java card to do so and then will load the applet into Smart card(Java Card).
Any sugestion will be highly appreciated and will of great help.
Thanks in advance for the response.
Regards,
Sunil KDear Friends,
I am new to java card development.
Is it possible or what is Probability Of Sending ME/SIM data through WAP enabled on SIM Using Applet?
Is it feasible to do so? Suppose if we write one application using java card to do so and then will load the applet into Smart card(Java Card).
Any sugestion will be highly appreciated and will of great help.
Thanks in advance for the response.
Regards,
Sunil K -
JAVA Sim Toolkit (STK)
I have good experience in JAVA card programming, however SIM is a whole new world for me.
Anyone please can indicate to me what the following means???
[electrical profile, ICCID, IMSI and Ki. The IMSI and Ki is mandatory ! others optional.]
The application i am trying to develop uses the Mobile phone STK functionality to display information on the screen only! and in no case does it access the GSM network and even doesnt need to register.
Are the above parameters still required? if so how do we get them? i assume there is a regulatory body that provides them?
thanksHi,
ad 2. SIM Application Toolkit as defined in gsm 11.14
(www.etsi.org) is just a definition of framework and
commands as extension to ME<->SIM protocol. There is
more or less defined API for the protocol for
JavaCard, but it is just the Java way and different
SIM vendors offer different things. Further real
JavaCard
STK implemenattions may vary, see www.simalliance.org
for certification effort.
(As of MS they pushed some own technology for SIM
cards but I haven't heard anybody ever used it. )
ad 1. You can use sun javacard tools for devel. For
deployment be warned to enter world of NDAs
and not an easy work with operators. Only operator can
deploy application on the SIM card.
The only other way how to deploy STK application
without operator I know of is the turbo accessory. It
uses
the GNU C compiler and tools. You can find the API at
http://www.bladox.com/devel-docs/index.html
(there is also light intro to sim toolkit).
FPThat means STK is just a protocol like TCP that programer can develop their program using winsock or java.net package. The server and client sides communicate each other using TCP as ME and SIM using STK. Is this right??
Actually, i am more concerned for phone aspect. How can i develop a program or routine to communicate with application in SIM card and get the information in SIM card like additional service. And i can present it as a menu on the phone. I have no idea to do this thing!!
thanks and appreciate your answer~~ -
Hi,
I'm new to java card area. I'm programming with SIM Toolkit . Actually I want to get the IMEI of the handset with the Proactive Command "PROVIDE LOCAL INFORMATION".
Also i am using the Gemalto developer suite for this. Can someone provide a sample application for this? Any pointers will be very helpful.
Thanks & Regards,
DhanyaHi,
I'm new to java card area. I'm programming with SIM Toolkit . Actually I want to get the IMEI of the handset with the Proactive Command "PROVIDE LOCAL INFORMATION".
Also i am using the Gemalto developer suite for this. Can someone provide a sample application for this? Any pointers will be very helpful.
Thanks & Regards,
Dhanya -
N900 can not MOBILE BANKING through SIM TOOLKIT
N900 can not Mobile banking through SIM TOOLKIT, because NOT support SIM TOOLKIT.
EVEN AFTER UPDATE 10.2010.19-1 (last update).yes, I agree "FANCY" N900 less fancy without this service.... I really disapointed because if NOKIA 900 can use STK and Browser, we can choose the way that we love to use, right?
now, "FANCY" Mobile PUSH
romanf wrote:
SIM TOOLKIT (STK) is need just for authorization (not only in Mobile Banking), Authorization system build on STK is handy and very secure.
There is short animation that shows how it looks like: http://www.id.ee/public/Mobiil_ID_animation/
Today STK is already realized on almost all mobile phones, but not on "fancy" Nokia N900. -
Ki for SIM card applet installation
Hi
How can i found/generate Ki for installation of a STK applet on SIM card ??You don't need a special sim card reader.
Any ISO compliant smart card reader plus an sim-adaptor (from from factor ID-000 to ID-1) will do the job, because the only difference is the size of the plastic around the chip.
Jan -
Can the J2ME access through the SIM toolkit application?
im a new to this.. can that be possible?
im about to develop an application that would access the program on the SIM. would that be possible with java?
tnx...reply plsss... hehehe i need help
-
Hi,
I am new to the java card dev
I have following tools
1.Gemxplore admin
2.Gemxporedeveloper (evaluation copy)
3.Gemxplore xpresso card and a card reader
are these what I need for the development.
Please help if i need any other tools.
It will be a great help to me if some one help me with
some simple tutorial links.
Thanks
Seoul soulHi Tushar
First of all,never mail anyone to his/her personeel id,post ur question on Forum ,u will definitely get answer.And before putting ques to forum
just check once in forum answer to ur ques is availabel or not.
And what u need to start with Sim toolkit applet is
java_card_kit-2_1_2
TS GSM 11.14 (the proactive commans)
TS GSM 11.11 (the SIM card File system)
TS GSM 03.48 (OTA mechaism to be able to send data remotmy to your Applets using secure SMS, TS GSM 03.40 may be useful to read too)
TS GSM 03.19 : the Java implementation of the 11.14 specifications
a very well done document from the SIM Alliance ( @see http://www.simalliance.org/ ) named "Interoperability Stepping Stones"
Take a look into the 3GPP TS 03.19. A Toolkit applet example is provided in the Annex D. The spec is located at the ftp-server ftp://ftp.3gpp.org/Specs/latest/R1999/03_series/ (this link points to release 1999, for REL-4 and higher you've got to look for the TS 43.019).
Regards
Divyesh. -
EVENT_MO_SHORT_MESSAGE_CONTROL_BY_SIM
Hi all, i have a problem with event handler in my sim toolkit applet.
i wrote the code:
reg.setEvent(EVENT_MO_SHORT_MESSAGE_CONTROL_BY_SIM);
case EVENT_MENU_SELECTION:
proHdlr.init(PRO_CMD_SEND_SHORT_MESSAGE, (byte)0x00, DEV_ID_NETWORK);
proHdlr.appendTLV(TAG_ALPHA_IDENTIFIER, strings,
(short)((MSG_SENDING_SMS * STRING_RECORD_LENGTH)+(short)1),
(short)(strings[(short)(MSG_SENDING_SMS * STRING_RECORD_LENGTH)]));
// Define and append optional "Service center address" for the message (TON/NPI + number)
Util.arrayFillNonAtomic(tempBuffer, (short)0, (short)tempBuffer.length, (byte)0x00);
tempBuffer[0] = (byte)0x91;
tempBuffer[1] = (byte)0x21;
tempBuffer[2] = (byte)0x43;
tempBuffer[3] = (byte)0x65;
tempBuffer[4] = (byte)0x87;
proHdlr.appendTLV(TAG_ADDRESS, tempBuffer, (short)0, (short)5);
// Define and append SMS TPDU
Util.arrayFillNonAtomic(tempBuffer, (short)0, (short)tempBuffer.length, (byte)0x00);
// TP-MTI
tempBuffer[0] = (byte)0x01;
// TP-MR
tempBuffer[1] = (byte)0x00;
// TP-DA length
tempBuffer[2] = (byte)0x04;
// TP-DA
tempBuffer[3] = (byte)0x91;
tempBuffer[4] = (byte)0x34;
tempBuffer[5] = (byte)0x12;
// TP-PID
tempBuffer[6] = (byte)0x41;
// TP-DCS
tempBuffer[7] = (byte)0xF2;
// TP-UDL
tempBuffer[8] = (byte)0x05;
// TP-UD 'Hello' in 7-bit packed format
tempBuffer[9] = (byte)'H';
tempBuffer[10] = (byte)'E';
tempBuffer[11] = (byte)'L';
tempBuffer[12] = (byte)'L';
tempBuffer[13] = (byte)'O';
proHdlr.appendTLV(TAG_SMS_TPDU, tempBuffer, (byte)0, (byte)14);
// Send the command to the mobile
proHdlr.send();
return;
case EVENT_MO_SHORT_MESSAGE_CONTROL_BY_SIM:
EnvelopeResponseHandler erh = EnvelopeResponseHandler.getTheHandler();
the sms is correctly sent, but the event is not captured!by debugging i can see that the line "EnvelopeResponseHandler erh = EnvelopeResponseHandler.getTheHandler();" is never reached!
Can anyone help me?
thanks!Hi Guys,
Have you found a slution? I have the same problem!!
many thanks
:-) -
Hi guys and girls
I have develoed sim toolkit applet to send sms,its complied sucessfully and also converted successfully.But when i am loding this applet to
java card its giving error like this:
[b]error:package loading failed !
loading ended with error:loading process failed1 !
i am using simera 3 classic323 vodafone javacard.
any suggestions will be highly appriciated.Hi,
The selection condition is only planning version 700. There is no other selection conditions.
I checked the process monitor and I can only find error messages Time Period Invalid and Errors in Source system. This error messages are not enough for trouble shooting.
thanks and regards
Murugesan -
Where the result of proactive command GETINPUT get stored?
Hi to all
i am writing one sim toolkit applet for an application.
i am asking user for input (input must be digits only)using GETINPUT proactive command.
Now i want to store user response,but while storing the response
i am getting random value.
I am doing like this;
//this is function to ask user for input
private byte []getInput(byte []input)
ProactiveHandler proHdlr = ProactiveHandler.getTheHandler();
proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, input,(byte)0x00,
(short)input.length,(short)0x0001,(short)buffer.length);
proHdlr.send();
return buffer;
//call to fuction is like this
buffer = getInput(amount);
i am displaying value of buffer as amount.is it so?
or How can i get the value of amount?
Thankx in advance.
Warm Regards
Divyesh.The buffer where the result will be stored is not passed as an argument to the initGetInput.
after you call the proHdlr.send(), the STK Framework will prepare an instance of the Object ProactiveResponseHandler. So you have to get a reference to this instance by doing :
ProactiveResponseHandler prh = ProactiveResponseHandler.getTheHandler();and use it to manipulate the data enterd by the user :
prh.getTextStringLength() : returns the length of the input (number of characters, or bytes)
prh.copyTextString(MyBuffer, MuOffset ); : will copy the entered data to a buffer (MyBufer) at a specified Offset.
after this, you can process the data stored in MyBuffer.
in a nutshell, the first "location" where the entered user data is stored is system internal, but you can copy it by the copyTextString method.
Kartagos
Maybe you are looking for
-
Docking station display doesn't activate after upgrading display driver
I have a ThinkPad T400. I just reinstalled Windows 7 (64-bit) using a clean image. The automatic display driver that Windows found was for ATI Mobility Radeon HD 3400 Series from 2010. When I put the laptop onto the ThinkPad docking station, the moni
-
Hello, I installed the brand new firefox. When I try to go to any webpage I get this error message: Firefox is configured to use a proxy server that is refusing connections. Check the proxy settings to make sure that they are correct. Contact your ne
-
Greetings. I'm setting up a Mac mini as the hub of a home theater system and the fact that it will be on a wireless network is important. We're going to be using the latest Airport which is 802.11n but the mini only has g. The furthest machine is goi
-
How do i get purchased music from my ipod into my itunes?
I am trying to put the music i just purchased on my Ipod into my Itunes but can't figure it out
-
Can't listen my music since i changed to ios5... What can i do?
Since i've changed to ios5 i can't hear o see no video or music , what can i do?