Java Card Applet Development

Please I am doing my final year project on secure mobile application using Java Card Technology.
I need to write and an application that can send SMS on a SIM card to another SIM card with the same application. The application will have a server side which manage the storage of messages and at the same time communicate information to the client on the SIM remotely. I am suppose to use wi-fi (TCP/IP) for transmission.
Can anybody please give me ideas and possible working codes and simulators.
I mean step by step procedure of how to start.
THANK YOU.

1. Good.
2. I suggest you start testing using the simulator, however if you want to test directly on the card at once, select your card reader using the /term command and use the commands as described in help to start sending APDUs to the card.
3. This is not a part of the JCOP tools for eclipse (which is developed by IBM and maintained by NXP), but part of the JavaCard development toolkit developed and maintained by Sun. See http://java.sun.com/products/javacard/dev_kit.html.
4. Read the above. None of this is part of JCOP tools for eclipse.
5. As far as I know, there is no independent newbie guide for JCOP tools, but I would check out the help function included in the tools themselves if I were you.
Good luck!

Similar Messages

  • Java Card Applet Development, Testing, Loading in Eclipse 3.2.0

    Dear friends,
    1.
    we have installed Eclipse 3.2.0, activated JCOP Tools 3.1.2, installed Java Card 2.2.1 devepment tools..
    2.
    How we can start testing and loading the java applet into JCOP31 chip ??
    3.
    It's said that we should use Java Card Workstation Development Environment (JCWDE), but we can not find it in the eclipse .
    4.
    Where we can find Eclipse menu for the
    -Converter tool
    -APDU Tool Utility
    -Java Card Workstation Development Environment (JCWDE)
    5.
    is there any resource/web/link that contains Eclipse tutorial on this Java Card Development ???
    Tks,
    hendy

    1. Good.
    2. I suggest you start testing using the simulator, however if you want to test directly on the card at once, select your card reader using the /term command and use the commands as described in help to start sending APDUs to the card.
    3. This is not a part of the JCOP tools for eclipse (which is developed by IBM and maintained by NXP), but part of the JavaCard development toolkit developed and maintained by Sun. See http://java.sun.com/products/javacard/dev_kit.html.
    4. Read the above. None of this is part of JCOP tools for eclipse.
    5. As far as I know, there is no independent newbie guide for JCOP tools, but I would check out the help function included in the tools themselves if I were you.
    Good luck!

  • Java card applet space

    I am working on a project related to java card applet development. My project consists of 4 java classes which are used to store date of created objects, and a java card applet which contains method that enables me to de some kind of actions on the created objects, such as create a new object of a specified class or edited it and son on.
    Now I have 2 classes done ; first one is called Odemeler which contains variables of type byte and the second one is called SadakatUygulamalar which contains   variables.
    Inside the class I have defined 2 arrays, one of type Odemeler and the other of type SadakatUygulamalar and I set their size to be 200. I have tried to create 100 object of kind Odemeler and to store them in the array
    but the applet is able to store up to 92 object, at the other hand after creating those objects and storing them I am not able to store objects of type SadakatUygulamalar.
    Is this problem related to the applet size or what ?? any help please
    The applet code is here :
    package sTez_1;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    import javacard.framework.ISO7816;
    import javacard.framework.ISOException;
    import javacard.framework.JCSystem;
    import javacard.framework.Util;
    public class TestApplet1 extends Applet {
         private static Odeme[] odemeArray;
         private static SadakatUygulamalar[] uygulamaArray;
         private static short index = 00;
         private static short index2 = 00;
         private static byte[] result;
         private static byte[] result2;
         private static short res_index =00;
         private static short res2_index =00;
         private static short FirmaIDFlag = 0;
         private static final byte ODEME_CLA = (byte) 0xB0;
         private static final byte UYGULAMA_CLA = (byte) 0xA0;
         private static final byte ODEME_INS_CREATE_PROFILE = (byte) 0x10;
         private static final byte UYGULAMA_INS_CREATE_PROFILE = (byte) 0x20;
         private static final byte ODEME_INS_GET_PROFILE = (byte) 0x30;
         private static final byte ODEME_INS_LIST_SOME = (byte) 0x35;
         private static final byte ODEME_INS_VIEW_PROFILE = (byte) 0x37;
         private static final byte ODEME_INS_GET_PUAN_VIA_FIRMA = (byte) 0x38;
         private static final byte ODEME_INS_GET_ALISVERIS_VIA_KAT = (byte) 0x39;
         private static final byte UYGULAMA_INS_GET_PROFILE = (byte) 0x40;
         private static final byte UYGULAMA_INS_LIST_ALL = (byte) 0x50;
         private static final byte UYGULAMA_INS_UPDATE_ID = (byte) 0x60;
         private static final byte UYGULAMA_INS_UPDATE_NAME = (byte) 0x80;
         private static final byte UYGULAMA_INS_SEARCH = (byte) 0x90;
         private static final byte SPLIT_PARTS = (byte) 0x2C;
         private static final short CLA_ERROR = (short) 0x13;
         private static final short INS_ERROR = (short) 0x14;
         private static final short NO_SUCH_INDEX = (short) 0x15;
         private static final short NO_DATA_FOUND = (short) 0x16;
         private static final short FIRMA_ID_IN_USE = (short) 0x9C;
         private static final short ODEME_ARRAY_FULL = (short) 0x18;
         private TestApplet1() {
              odemeArray = new Odeme[(short) 250];
              uygulamaArray = new SadakatUygulamalar[(short) 200];
              register();
         public static void install(byte bArray[], short bOffset, byte bLength)
                   throws ISOException {
              new TestApplet1();
         public void process(APDU apdu) throws ISOException {
              // TODO Auto-generated method stub
              if (selectingApplet())
                   return;
              byte[] buffer = apdu.getBuffer();
              byte INS = (byte) (buffer[ISO7816.OFFSET_INS] & 0xFF);
              switch (INS) {
              case ODEME_INS_CREATE_PROFILE:
                   odemeCreateProfile(apdu);
                   break;
              case UYGULAMA_INS_CREATE_PROFILE:
                   uygulamaCreateProfile(apdu);
                   break;
              case ODEME_INS_GET_PROFILE:
                   odemeGetProfile(apdu);
                   break;
              case ODEME_INS_LIST_SOME:
                   odemeListSome(apdu);
                   break;
              case ODEME_INS_VIEW_PROFILE:
                   odemeViewProfile(apdu);
                   break;
              case ODEME_INS_GET_PUAN_VIA_FIRMA:
                   odemeGetPuanByFirma(apdu);
                   break;
              case ODEME_INS_GET_ALISVERIS_VIA_KAT:
                   odemeGetAlisverisByKat(apdu);
                   break;
              case UYGULAMA_INS_GET_PROFILE:
                   uygulamaGetProfile(apdu);
                   break;
              case UYGULAMA_INS_UPDATE_ID:
                   uygulamaUpdateID(apdu);
                   break;
              case UYGULAMA_INS_UPDATE_NAME:
                   uygulamaUpdateName(apdu);
                   break;
              case UYGULAMA_INS_LIST_ALL:
                   uygulamaListAll(apdu);
                   break;     
              case UYGULAMA_INS_SEARCH:
                   uygulamaSearch(apdu);
                   break;
              default:
                   ISOException.throwIt(INS_ERROR);
         public void odemeCreateProfile(APDU apdu) {
              byte[] buffer = apdu.getBuffer();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              JCSystem.beginTransaction();
              short fieldIndex = 0;
              short field1counter = 0;
              short field2counter = 0;
              short field3counter = 0;
              short field4counter = 0;
              short field5counter = 0;
              short field6counter = 0;
              short field7counter = 0;
              short field8counter = 0;
              short field9counter = 0;
              short field10counter = 0;
              short field11counter = 0;
              short field12counter = 0;
              short field13counter = 0;
              short field14counter = 0;
              for (short i = 0; i < lc; i++) {
                   fieldIndex++;
                   field1counter++;
                   if (buffer[(short) (5 + i)] == SPLIT_PARTS)
                        i = lc;
              for (short j = fieldIndex; j < lc; j++) {
                   fieldIndex++;
                   field2counter++;
                   if (buffer[(short) (5 + j)] == SPLIT_PARTS)
                        j = lc;
              for (short k = fieldIndex; k < lc; k++) {
                   fieldIndex++;
                   field3counter++;
                   if (buffer[(short) (5 + k)] == SPLIT_PARTS)
                        k = lc;
              for (short h = fieldIndex; h < lc; h++) {
                   fieldIndex++;
                   field4counter++;
                   if (buffer[(short) (5 + h)] == SPLIT_PARTS)
                        h = lc;
              for (short u = fieldIndex; u < lc; u++) {
                   fieldIndex++;
                   field5counter++;
                   if (buffer[(short) (5 + u)] == SPLIT_PARTS)
                        u = lc;
              for (short u1 = fieldIndex; u1 < lc; u1++) {
                   fieldIndex++;
                   field6counter++;
                   if (buffer[(short) (5 + u1)] == SPLIT_PARTS)
                        u1 = lc;
              for (short u2 = fieldIndex; u2 < lc; u2++) {
                   fieldIndex++;
                   field7counter++;
                   if (buffer[(short) (5 + u2)] == SPLIT_PARTS)
                        u2 = lc;
              for (short u3 = fieldIndex; u3 < lc; u3++) {
                   fieldIndex++;
                   field8counter++;
                   if (buffer[(short) (5 + u3)] == SPLIT_PARTS)
                        u3 = lc;
              for (short u4 = fieldIndex; u4 < lc; u4++) {
                   fieldIndex++;
                   field9counter++;
                   if (buffer[(short) (5 + u4)] == SPLIT_PARTS)
                        u4 = lc;
              for (short u5 = fieldIndex; u5 < lc; u5++) {
                   fieldIndex++;
                   field10counter++;
                   if (buffer[(short) (5 + u5)] == SPLIT_PARTS)
                        u5 = lc;
              for (short u6 = fieldIndex; u6 < lc; u6++) {
                   fieldIndex++;
                   field11counter++;
                   if (buffer[(short) (5 + u6)] == SPLIT_PARTS)
                        u6 = lc;
              for (short u7 = fieldIndex; u7 < lc; u7++) {
                   fieldIndex++;
                   field12counter++;
                   if (buffer[(short) (5 + u7)] == SPLIT_PARTS)
                        u7 = lc;
              for (short u8 = fieldIndex; u8 < lc; u8++) {
                   fieldIndex++;
                   field13counter++;
                   if (buffer[(short) (5 + u8)] == SPLIT_PARTS)
                        u8 = lc;
              for (short u9 = fieldIndex; u9 < lc; u9++) {
                   fieldIndex++;
                   field14counter++;
                   if (buffer[(short) (5 + u9)] == SPLIT_PARTS)
                        u9 = lc;
              short cc = 5;
              byte[] _id = new byte[field1counter];
              for (short i1 = 0; i1 < (short) _id.length; i1++)
                   _id[i1] = buffer[(short) (cc + i1)];
            cc = (short)(cc + field1counter);
              byte[] _tarih = new byte[field2counter];
              for (short j1 = 0; j1 < (short) _tarih.length; j1++)
                   _tarih[j1] = buffer[(short) (cc + j1)];
              cc = (short)(cc + field2counter);
              byte[] _saat = new byte[field3counter];
              for (short j2 = 0; j2 < (short) _saat.length; j2++)
                   _saat[j2] = buffer[(short) (cc + j2)];
              cc = (short)(cc + field3counter);  
              byte[] _firma = new byte[field4counter];
              for (short j3 = 0; j3 < (short) _firma.length; j3++)
                   _firma[j3] = buffer[(short) (cc + j3)];
              cc = (short)(cc + field4counter);
              byte[] _kategori = new byte[field5counter];
              for (short j4 = 0; j4 < (short) _kategori.length; j4++)
                   _kategori[j4] = buffer[(short) (cc + j4)];
              cc = (short)(cc + field5counter);
              byte[] _tutar = new byte[field6counter];
              for (short j5 = 0; j5 < (short) _tutar.length; j5++)
                   _tutar[j5] = buffer[(short) (cc + j5)];
              cc = (short)(cc + field6counter);
              byte[] _birim = new byte[field7counter];
              for (short j6 = 0; j6 < (short) _birim.length; j6++)
                   _birim[j6] = buffer[(short) (cc + j6)];
              cc = (short)(cc + field7counter);
              byte[] _ulke = new byte[field8counter];
              for (short j7 = 0; j7 < (short) _ulke.length; j7++)
                   _ulke[j7] = buffer[(short) (cc + j7)];
              cc = (short)(cc + field8counter);
              byte[] _sehir = new byte[field9counter];
              for (short j8 = 0; j8 < (short) _sehir.length; j8++)
                   _sehir[j8] = buffer[(short) (cc + j8)];
              cc = (short)(cc + field9counter);
              byte[] _ilce = new byte[field10counter];
              for (short j9 = 0; j9 < (short) _ilce.length; j9++)
                   _ilce[j9] = buffer[(short) (cc + j9)];
              cc = (short)(cc + field10counter);
              byte[] _aid = new byte[field11counter];
              for (short j10 = 0; j10 < (short) _aid.length; j10++)
                   _aid[j10] = buffer[(short) (cc + j10)];
              cc = (short)(cc + field11counter);
              byte[] _banka = new byte[field12counter];
              for (short j11 = 0; j11 < (short) _banka.length; j11++)
                   _banka[j11] = buffer[(short) (cc + j11)];
              cc = (short)(cc + field12counter);
              byte[] _taksit = new byte[field13counter];
              for (short j12 = 0; j12 < (short) _taksit.length; j12++)
                   _taksit[j12] = buffer[(short) (cc + j12)];
              cc = (short)(cc + field13counter);
              byte[] _puan = new byte[field14counter];
              for (short j13 = 0; j13 < (short) _puan.length; j13++)
                   _puan[j13] = buffer[(short) (cc + j13)];
              cc = (short)(cc + field3counter);
              Odeme m = new Odeme(_id, _tarih, _saat, _firma, _kategori, _tutar, _birim, _ulke, _sehir, _ilce, _aid, _banka, _taksit, _puan);
              if(index2 >= (short)odemeArray.length)
                   ISOException.throwIt(ODEME_ARRAY_FULL);
              odemeArray[index2] = m;
              index2++;
              JCSystem.commitTransaction();
              buffer[0] = (byte)index2;
              apdu.setOutgoingAndSend((short) 0, (short) 1);
         public void odemeGetProfile(APDU apdu) {
              byte[] buffer = apdu.getBuffer();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              byte[] sent_id = new byte[lc];
              for (short i5 = 0; i5 < lc; i5++)
                   sent_id[i5] = buffer[(short) (5 + i5)];
              for (short h = 0; h < index2; h++) {
                   Odeme m = odemeArray[h];
                   byte[] _id = m.getID();
                   if (equals(sent_id, _id)) {
                        byte[] banka = m.getBanka();
                        byte[] sehir = m.getSehir();
                        byte[] firma = m.getFirma();
                        short counter = 0;
                        for (short i = 0; i < (short) banka.length; i++)
                             buffer[i] = banka;
                        counter = (short) banka.length;
                        for (short j = 0; j < (short) sehir.length; j++)
                             buffer[(short) (counter + j)] = sehir[j];
                        counter = (short) (counter + sehir.length);
                        for (short j = 0; j < (short) firma.length; j++)
                             buffer[(short) (counter + j)] = firma[j];
                        counter = (short) (counter + firma.length);
                        apdu.setOutgoingAndSend((short) 0, counter);
         public void odemeGetPuanByFirma(APDU apdu)
              byte[] buffer = apdu.getBuffer();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              byte[] puan = null;
              byte[] res = new byte[200];
              byte[] fname = new byte[lc];
              for(short t = 0; t < lc; t++)
                   fname[t] = buffer[(short)(t + 5)];
              short counter = 0;
              for(short z = 0; z < index2 ; z++)
                   Odeme m = odemeArray[z];
                   byte[] _name = m.getFirma();
                   if (equals(fname, _name)) {
                        puan = m.getKazanilanpuan();
                        Util.arrayCopy(puan, (short)0, res, counter, (short)puan.length);
                        counter = (short)(counter + puan.length);
                        res[counter] = (byte)0x7C;
                        counter++;
              Util.arrayCopy(res, (short)0, buffer, (short)0, (short)counter);
              apdu.setOutgoingAndSend((short)0, (short)counter);
         public void odemeGetAlisverisByKat(APDU apdu)
              byte[] buffer = apdu.getBuffer();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              byte[] alisveris = null;
              byte[] res = new byte[200];
              byte[] kat = new byte[lc];
              for(short t = 0; t < lc; t++)
                   kat[t] = buffer[(short)(t + 5)];
              short counter = 0;
              for(short z = 0; z < index2 ; z++)
                   Odeme m = odemeArray[z];
                   byte[] _kategori = m.getKategori();
                   if (equals(kat, _kategori)) {
                        alisveris = m.getTutar();
                        Util.arrayCopy(alisveris, (short)0, res, counter, (short)alisveris.length);
                        counter = (short)(counter + alisveris.length);
                        res[counter] = (byte)0x7C;
                        counter++;
              Util.arrayCopy(res, (short)0, buffer, (short)0, (short)counter);
              apdu.setOutgoingAndSend((short)0, (short)counter);
         public void odemeListSome(APDU apdu)
              byte[] buffer = apdu.getBuffer();
              result2 = new byte[(short) 200];
              byte[] id = null, sehir = null, _banka = null;
              if(index2 == 0)
                   ISOException.throwIt(NO_DATA_FOUND);
              for(short r = 0; r < index2; r++)
                   Odeme m = odemeArray[r];
                   _id = m.getID();
                   _sehir = m.getSehir();
                   _banka = m.getBanka();
                   copyData2(_id, sehir, banka);
              Util.arrayCopy(result2, (short)0, buffer, (short)0, res2_index);
              result2 = null;
              short len = res2_index;
              res2_index = 00;
              apdu.setOutgoingAndSend((short)0, len);
         public void odemeViewProfile(APDU apdu)
              byte[] buffer = apdu.getBuffer();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              byte[] id = new byte[lc];
              for (short j3 = 0; j3 < lc; j3++)
                   id[j3] = buffer[(short) (5 + j3)];
              for (short h = 0; h < index2; h++) {
                   Odeme m = odemeArray[h];
                   byte[] H_id = m.getID();
                   if (equals(id, H_id)) {
                        byte[] tarih = m.getTarih();
                        byte[] saat = m.getSaat();
                        byte[] firma = m.getFirma();
                        byte[] kategori = m.getKategori();
                        byte[] tutar = m.getTutar();
                        byte[] birim = m.getParabirimi();
                        byte[] ulke = m.getUlke();
                        byte[] sehir = m.getSehir();
                        byte[] ilce = m.getIlce();
                        byte[] aid = m.getAID();
                        byte[] banka = m.getBanka();
                        byte[] taksit = m.getTaksitsayisi();
                        byte[] puan = m.getKazanilanpuan();
                        short counter1 = 0;
                        Util.arrayCopy(tarih, (short)0, buffer, (short)0, (short)tarih.length);
                        counter1 = (short)(counter1 + tarih.length);
                        Util.arrayCopy(saat, (short)0, buffer, counter1, (short)saat.length);
                        counter1 = (short)(counter1 + saat.length);
                        Util.arrayCopy(firma, (short)0, buffer, counter1, (short)firma.length);
                        counter1 = (short)(counter1 + firma.length);
                        Util.arrayCopy(kategori, (short)0, buffer, counter1, (short)kategori.length);
                        counter1 = (short)(counter1 + kategori.length);
                        Util.arrayCopy(tutar, (short)0, buffer, counter1, (short)tutar.length);
                        counter1 = (short)(counter1 + tutar.length);
                        Util.arrayCopy(birim, (short)0, buffer, counter1, (short)birim.length);
                        counter1 = (short)(counter1 + birim.length);
                        Util.arrayCopy(ulke, (short)0, buffer, counter1, (short)ulke.length);
                        counter1 = (short)(counter1 + ulke.length);
                        Util.arrayCopy(sehir, (short)0, buffer, counter1, (short)sehir.length);
                        counter1 = (short)(counter1 + sehir.length);
                        Util.arrayCopy(ilce, (short)0, buffer, counter1, (short)ilce.length);
                        counter1 = (short)(counter1 + ilce.length);
                        Util.arrayCopy(aid, (short)0, buffer, counter1, (short)aid.length);
                        counter1 = (short)(counter1 + aid.length);
                        Util.arrayCopy(banka, (short)0, buffer, counter1, (short)banka.length);
                        counter1 = (short)(counter1 + banka.length);
                        Util.arrayCopy(taksit, (short)0, buffer, counter1, (short)taksit.length);
                        counter1 = (short)(counter1 + taksit.length);
    Util.arrayCopy(puan, (short)0, buffer, counter1, (short)puan.length);
    counter1 = (short)(counter1 + puan.length);
                        apdu.setOutgoingAndSend((short) 0, counter1);
         public void uygulamaCreateProfile(APDU apdu) {
              byte[] buffer = apdu.getBuffer();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              // JCSystem.beginTransaction();
              JCSystem.beginTransaction();
              short fieldIndex = 0;
              short field1counter = 0;
              short field2counter = 0;
              short field3counter = 0;
              // byte test;
              for (short i = 0; i < lc; i++) {
                   fieldIndex++;
                   field1counter++;
                   if (buffer[(short) (5 + i)] == SPLIT_PARTS)
                        i = lc;
              for (short j = fieldIndex; j < lc; j++) {
                   fieldIndex++;
                   field2counter++;
                   if (buffer[(short) (5 + j)] == SPLIT_PARTS)
                        j = lc;
              for (short k = fieldIndex; k < lc; k++) {
                   fieldIndex++;
                   field3counter++;
                   if (buffer[(short) (5 + k)] == SPLIT_PARTS)
                        k = lc;
              byte[] uygulama_id = new byte[field1counter];
              for (short i1 = 0; i1 < (short) uygulama_id.length; i1++)
                   uygulama_id[i1] = buffer[(short) (5 + i1)];
              byte[] firma_id = new byte[field2counter];
              for (short j1 = 0; j1 < (short) firma_id.length; j1++)
                   firma_id[j1] = buffer[(short) (5 + field1counter + j1)];
    getFirmaIDFlag(firma_id);
    if(FirmaIDFlag == 1)
         ISOException.throwIt(FIRMA_ID_IN_USE);
              byte[] firma_ismi = new byte[field3counter];
              for (short j2 = 0; j2 < (short) firma_ismi.length; j2++)
                   firma_ismi[j2] = buffer[(short) (5 + field1counter + field2counter + j2)];
              SadakatUygulamalar su = new SadakatUygulamalar(uygulama_id, firma_id,
                        firma_ismi);
              uygulamaArray[index] = su;
              index++;
              JCSystem.commitTransaction();
              buffer[0] = (byte) index;
              apdu.setOutgoingAndSend((short) 0, (short) 1);
         public void uygulamaGetProfile(APDU apdu) {
              byte[] buffer = apdu.getBuffer();
              short p1 = (short) (buffer[ISO7816.OFFSET_P1]);
              if (p1 >= index)
                   ISOException.throwIt(NO_SUCH_INDEX);
              SadakatUygulamalar su = uygulamaArray[p1];
              byte[] uygulama_id = su.getUygulama_id();
              byte[] firma_id = su.getFirma_id();
              byte[] firma_ismi = su.getFirma_ismi();
              short counter = 0;
              for (short i = 0; i < (short) uygulama_id.length; i++)
                   buffer[i] = uygulama_id[i];
              counter = (short) uygulama_id.length;
              for (short j = 0; j < (short) firma_id.length; j++)
                   buffer[(short) (counter + j)] = firma_id[j];
              counter = (short) (counter + firma_id.length);
              for (short j = 0; j < (short) firma_ismi.length; j++)
                   buffer[(short) (counter + j)] = firma_ismi[j];
              counter = (short) (counter + firma_ismi.length);
              apdu.setOutgoingAndSend((short) 0, counter);
         public void uygulamaUpdateID(APDU apdu) {
              byte[] buffer = apdu.getBuffer();
              short p1 = (short) (buffer[ISO7816.OFFSET_P1]);
              if (p1 >= index)
                   ISOException.throwIt(NO_SUCH_INDEX);
              JCSystem.beginTransaction();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              SadakatUygulamalar su = uygulamaArray[p1];
              byte[] newFirmaID = new byte[lc];
              for (short i = 0; i < lc; i++)
                   newFirmaID[i] = buffer[(short) (5 + i)];
              su.setFirma_id(newFirmaID);
              JCSystem.commitTransaction();
              byte[] currentFirmaID = su.getFirma_id();
              for (short k = 0; k < (short) currentFirmaID.length; k++)
                   buffer[k] = currentFirmaID[k];
              apdu.setOutgoingAndSend((short) 0, (short) currentFirmaID.length);
         public void uygulamaUpdateName(APDU apdu) {
              byte[] buffer = apdu.getBuffer();
              short p1 = (short) (buffer[ISO7816.OFFSET_P1]);
              if (p1 >= index)
                   ISOException.throwIt(NO_SUCH_INDEX);
              JCSystem.beginTransaction();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              SadakatUygulamalar su = uygulamaArray[p1];
              byte[] newFirmaName = new byte[lc];
              for (short i = 0; i < lc; i++)
                   newFirmaName[i] = buffer[(short) (5 + i)];
              su.setFirma_ismi(newFirmaName);
              JCSystem.commitTransaction();
              byte[] currentFirmaName = su.getFirma_ismi();
              for (short k = 0; k < (short) currentFirmaName.length; k++)
                   buffer[k] = currentFirmaName[k];
              apdu.setOutgoingAndSend((short) 0, (short) currentFirmaName.length);
         public static boolean equals(byte[] b1, byte[] b2) {
              if (b1 == null && b2 == null) {
                   return true;
              if (b1 == null || b2 == null) {
                   return false;
              if ((short) b1.length != (short) b2.length) {
                   return false;
              for (short i = 0; i < (short) b1.length; i++) {
                   if (b1[i] != b2[i]) {
                        return false;
              return true;
         public void uygulamaSearch(APDU apdu) {
              byte[] buffer = apdu.getBuffer();
              short lc = (short) buffer[ISO7816.OFFSET_LC];
              byte[] f_id = new byte[lc];
              for (short i3 = 0; i3 < lc; i3++)
                   f_id[i3] = buffer[(short) (5 + i3)];
              for (short h = 0; h < index; h++) {
                   SadakatUygulamalar su = uygulamaArray[h];
                   byte[] H_Firma_id = su.getFirma_id();
                   if (equals(f_id, H_Firma_id)) {
                        byte[] H_Uygulama_id = su.getUygulama_id();
                        byte[] H_Firma_ismi = su.getFirma_ismi();
                        short counter1 = 0;
                        for (short k1 = 0; k1 < (short) H_Uygulama_id.length; k1++)
                             buffer[k1] = H_Uygulama_id[k1];
                        counter1 = (short) H_Uygulama_id.length;
                        for (short j2 = 0; j2 < (short) H_Firma_ismi.length; j2++)
                             buffer[(short) (counter1 + j2)] = H_Firma_ismi[j2];
                        counter1 = (short) (counter1 + H_Firma_ismi.length);
                        apdu.setOutgoingAndSend((short) 0, counter1);
         public void uygulamaListAll(APDU apdu)
              byte[] buffer = apdu.getBuffer();
              result = new byte[(short) 200];
              byte[] u_id = null, f_id = null, f_isim = null;
              for(short r = 0; r < index; r++)
                   SadakatUygulamalar su = uygulamaArray[r];
                   u_id = su.getUygulama_id();
                   f_id = su.getFirma_id();
                   f_isim = su.getFirma_ismi();
                   copyData(u_id, f_id, f_isim);
              Util.arrayCopy(result, (short)0, buffer, (short)0, res_index);
              result = null;
              short len = res_index;
              res_index = 00;
              apdu.setOutgoingAndSend((short)0, len);
         public void copyData(byte[] u_id, byte[] f_id, byte[] f_isim)
              Util.arrayCopy(u_id, (short)0, result, res_index, (short)u_id.length);
              res_index = (short)(res_index + u_id.length);
              Util.arrayCopy(f_id, (short)0, result, res_index, (short)f_id.length);
              res_index = (short)(res_index + f_id.length);
              Util.arrayCopy(f_isim, (short)0, result, res_index, (short)f_isim.length);
              res_index = (short)(res_index + f_isim.length);
              result[res_index] = (byte)0x7C;
              res_index = (short)(res_index + 1);
         public void copyData2(byte[] id, byte[] sehir, byte[] _banka)
              Util.arrayCopy(_id, (short)0, result2, res2_index, (short)_id.length);
              res2_index = (short)(res2_index + _id.length);
              Util.arrayCopy(_banka, (short)0, result2, res2_index, (short)_sehir.length);
              res2_index = (short)(res2_index + _sehir.length);
              Util.arrayCopy(_banka, (short)0,result2, res2_index, (short)_banka.length);
              res2_index = (short)(res2_index + _banka.length);
              result2[res2_index] = (byte)0x7C;
              res2_index = (short)(res2_index + 1);
         public void getFirmaIDFlag(byte[] f_id)
              for(short g = 0; g < index; g++)
                   SadakatUygulamalar su = uygulamaArray[g];
                   byte[] firma_no = su.getFirma_id();
                   if(equals(f_id, firma_no))
                        FirmaIDFlag = 1;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  

    Again, could you rewrite the createOdemeProfie() method code using TLV ??I guess you are referring to<tt> odemeCreateProfile </tt>in the original applet.
    I could* rewrite it in a cleaner way. But
    - Why should I* do that?
    - You did not give the spec of the applet and its APDU, and I'd hate to write code without specs, instead having to rely on the assumption that the original code is valid, which is dubious. For a tiny example, how could one guess if<tt> short lc = (short) buffer[ISO7816.OFFSET_LC]; </tt>is correct, or if rather the canonical<tt> short lc = (short)(buffer[ISO7816.OFFSET_LC]&0xFF); </tt>is required (that is, if the incoming data can exceed 127 bytes)?
    - the original sin lies in the design of new<tt> Odeme(_id, tarih, saat, firma, kategori, tutar, birim, ulke, sehir, ilce, aid, banka, taksit, _puan) </tt>needing so many explicit parameters.
    Without fixing the very definition of<tt> Odeme </tt>, the code will remain ugly. One possible design would be to have a method to set a field designated by its tag, and another to get the value of a field designated by its tag. Another design would be a method to set any number of fields passed as an array of bytes containing a concatenation of TLVs, and another to get any number of fields designated by an array of tag bytes, as an array of bytes containing a concatenation of the TLVs.
    Again, you* want to generalize what the code does until the nature of the data items manipulated never appear in a method or variable name, except as the name of a finalstatic variable (that is, as a constant), at least in utility methods like<tt> odemeCreateProfile </tt>, and in the constructor and accessors of <tt> Odeme </tt>. Think of it a building a tiny database engine, then using it. Of course when performing actual computation as opposed to mere data storage, it helps to name the variables, e.g. when adding a traveled distance to an odometer, or computing a cost from this or that per some formula (but beware that in Java Card, especially on platforms without<tt> int </tt>, straight formulas are seldom the right way to perform any but the simplest computations required in a real application).
    Edited by: fgrieu on Feb 8, 2013 11:46 AM

  • Testing java card applet

    Hi all,
    Am new to java card applet development. I have developed a sample applet. But i don't know how to test it. So can anyone help me understand this.
    please help.
    Thanks

    Hi,
    To test your application you need to install it on a Java Card virtual machine. This can either be on a real smartcard or in an emulator (such as the ones in the JCDK). When you have it installed you can then send APDU commands to exercise the applet. From memory, there is an example of how to use the CREF simulator in the JCDK Developer Guide that is a part of the package.
    If you have a real card, you can use something like GPShell to load and install your applet and to send commands to it. I have also found it is useful to have a host application written in Java (using jUnit) to test specific commands.
    - Shane

  • IDES for writing Java card applets and converting the applets as CAP FILE.

    I have developed a JAVA CARD APPLET , FindMFValueJCA.java . It gets compiles in net beans 6.0 But while converting the applet to CAP file i am getting some errors. Is there any other IDES which take care of converting the CAP files

    What's the Java version you are using?
    As the java card tool kit has version dependencies. If you are using java_card _kit 2.2.2 then 1.5 is fine.                                                                                                                                                                                                                                                                                                   

  • How to create an instance (or instances) of the java card applet?

    Here I have a backend, a host application (a terminal)
    and a Java card that needs to be instanced to multiple cards to different users.
    I wonder how you can make instances of Java card applets of different IDs or PINs.

    933351 wrote:
    Yes, I would like to emulate an environment first, Unfortunately I cannot help with this (never really used this tool).
    I'd like to know also how to install them later on real cards.You need something that can perform the secure channel and card content management functions of the GlobalPlatform card specification. A good starting point is GPShell. It provides a simple scripting interface to be able to:
    1) Authenticate with a card with developer keys
    2) Load you cap file(s)
    3) Instantiate any instances you require (you can have multiple instances from a single applet)
    4) Send arbitrary APDU's to the card for testing.
    GPShell has a README text file that is a good reference and there are sample scripts for a number of card types.
    - Shane

  • How to load a java card applet into a java card

    Dear All,
    I am a novice to java card technology..
    I have done some search on how to load a java card applet into a smart card but haven't found a satisfactory answer. I have read about installer.jar and scriptgen tool but I want to load the applet from a java program and not from command line. It would be of great help if somebody can help me out.
    If somebody can share a sample program which load a javacard applet(.CAP file) into a smart card, I will be very thankful.
    I am able to find some client applications which help us send APDU commands and recieve response APDU's to interact with an applet loaded on to the smart card but not application which actually load the applet.
    I have heard of OCF and GP.. some say that OCF technology is outdated and no longer in use.. can somebosy throw some light on this too..
    cheers,
    ganesh

    hi siavash,
    thanks for the quick response.. i checked out GPShell as suggested, it looked like a tool by which one can load an applet on to card and send some sample apdu commands... but I want to load the applet from the code.
    My application should look something like this.. it will be a swing applicaton where I have a drop down with a list of readers, I select the one desired and then click on "LOAD" after inserting a blank java card, at this point my applet which is stored in my DB should get loaded on to the java card. The next step should be to personalize it where I enter the values for the static variables of my applet and click "PERSONALIZE", at this point all these values should be embedded into APDU commands and sent to the java card for processing.
    For achieving this I am yet to find a comprehensive sample or documentation on the net.
    Please help...
    regards,
    ganesh

  • Java application communicate with java card applet without java card

    Can I write java application to communicate with java card applet without using java card?
    Can I send APDU to java card applet on computer(not install in java card)? If it's not, how can I write?
    Best Regard,
    Thanawan

    Your JCOP simulator implements a JCVM/JCRE according
    to specs. The CREF does that same thing excepts it's
    only simulates the API without crypto or third party
    applets. JCOP simulator is more then that. They are using thesame_ codebase for simulator and for oncard JCVM. Basically you are dealing with the same environment in both cases.

  • How can we create a common function for 2 or more java card applets?

    I have 2 java card applets. They use one common function. But i don't know how to set up it. Anybody knows it, please help me. Please show me step by step to do it. Thank you.

    When insert below line of code in the Test_Class_1.java and Test_Class_2, the Project will be failed:
    byte aP1 = Test_common_function.GetP1((byte)0x02);
    byte aP1 = Test_common_function.GetP1((byte)0x01);
    Here is the source code:
    Test_Class_2.java
    package Test_Class_2;
    import Test_common_function.Test_common_function;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    public class Test_Class_2 extends Applet
       public static void install(byte[] bArray, short bOffset, byte bLength)
          // GP-compliant JavaCard applet registration
          new Test_Class_2().register(bArray, (short) (bOffset + 1),
                bArray[bOffset]);
       public void process(APDU apdu)
          byte aP1 = Test_common_function.GetP1((byte)0x02);
    }Test_Class_1.java
    package Test_Class_1;
    import Test_common_function.Test_common_function;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    public class Test_Class_1 extends Applet
       public static void install(byte[] bArray, short bOffset, byte bLength)
          // GP-compliant JavaCard applet registration
          new Test_Class_1().register(bArray, (short) (bOffset + 1),
                bArray[bOffset]);
       public void process(APDU apdu)
          byte aP1 = Test_common_function.GetP1((byte)0x02);
    }Test_common_function.java
    package Test_common_function;
    import javacard.framework.APDU;
    import javacard.framework.ISO7816;
    import javacard.framework.Applet;
    import javacard.framework.ISOException;
    public class Test_common_function extends Applet
       public static void install(byte[] bArray, short bOffset, byte bLength)
          // GP-compliant JavaCard applet registration
          new Test_common_function().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 static byte bP1_Class1 = (byte)0x90;
       public static byte bP1_Class2 = (byte)0x90;
       public static byte GetP1(byte idclass)
          return idclass == (byte)0x01? bP1_Class1:bP1_Class2;
    }and here is the trace log (in case of failure)
    cm>  /term "Remote|localhost:60351"
    --Opening terminal
    /card -a a000000003000000 -c com.ibm.jc.CardManagerresetCard with timeout: 0 (ms)
    --Waiting for card...
    ATR=3B F8 13 00 00 81 31 FE 45 4A 43 4F 50 76 32 34    ;.....1.EJCOPv24
        31 B7                                              1.
    IOCTL().
    ATR:
             T = 1                  
    => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00          ..............
    (578768 nsec)
    <= 6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 9F 65    oe...........Y.e
        01 FF 9F 6E 06 47 91 01 17 33 00 73 4A 06 07 2A    ...n.G...3.sJ..*
        86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B    .H..k.`...*.H..k
        02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64    ....c...*.H..k.d
        0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09    ...*.H..k...e...
        2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01    +...Hd...f...+..
        04 01 2A 02 6E 01 02 90 00                         ..*.n....
    Status: No Error
    cm>  set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
    cm>  init-update 255
    => 80 50 00 00 08 37 0D D8 24 C9 C8 32 53 00          .P...7..$..2S.
    (1829 usec)
    <= 00 00 DE 81 34 18 39 B7 09 70 FF 02 00 00 3D 02    ....4.9..p....=.
        9C 31 C7 89 7A 8E 57 44 05 A7 67 C7 90 00          .1..z.WD..g...
    Status: No Error
    cm>  ext-auth plain
    => 84 82 00 00 10 D8 BE 91 A3 94 E8 34 18 42 28 F6    ...........4.B(.
        74 EE 50 06 29                                     t.P.)
    (1683 usec)
    <= 90 00                                              ..
    Status: No Error
    cm>  delete -r 01020304050102
    => 80 E4 00 80 09 4F 07 01 02 03 04 05 01 02 00       .....O.........
    (833593 nsec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  delete -r 01020304050103
    => 80 E4 00 80 09 4F 07 01 02 03 04 05 01 03 00       .....O.........
    (769014 nsec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  delete -r 010203040501
    => 80 E4 00 80 08 4F 06 01 02 03 04 05 01 00          .....O........
    (734456 nsec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  upload -c -d -b 250 "D:\WorkSpace\Test_Common_Funcation\bin\Test_common_function\javacard\Test_common_function.cap"
    => 80 E6 02 00 13 06 01 02 03 04 05 01 08 A0 00 00    ................
        00 03 00 00 00 00 00 00 00                         .........
    (1864 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Start loading Header.cap (44 byte)
    => 80 E8 00 00 2C C4 82 03 E3 01 00 25 DE CA FF ED    ....,......%....
        02 02 04 00 01 06 01 02 03 04 05 01 14 54 65 73    .............Tes
        74 5F 63 6F 6D 6D 6F 6E 5F 66 75 6E 63 74 69 6F    t_common_functio
        6E 00                                              n.
    (1607 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Header.cap loaded (44 byte)
    Start loading Directory.cap (36 byte)
    => 80 E8 00 01 24 02 00 21 00 25 00 21 00 0C 00 0B    ....$..!.%.!....
        00 26 00 0E 00 4C 00 0C 00 0D 00 00 00 6F 02 5D    .&...L.......o.]
        00 02 00 00 00 00 01 01 00 00                      ..........
    (1368 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Directory.cap loaded (36 byte)
    Start loading Import.cap (14 byte)
    => 80 E8 00 02 0E 04 00 0B 01 03 01 07 A0 00 00 00    ................
        62 01 01 00                                        b...
    (1096 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Import.cap loaded (14 byte)
    Start loading Applet.cap (15 byte)
    => 80 E8 00 03 0F 03 00 0C 01 08 01 02 03 04 05 01    ................
        01 01 00 08 00                                     .....
    (1188 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Applet.cap loaded (15 byte)
    Start loading Class.cap (17 byte)
    => 80 E8 00 04 11 06 00 0E 00 00 00 80 03 00 FF 00    ................
        07 01 00 00 00 1C 00                               .......
    (1457 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Class.cap loaded (17 byte)
    Start loading Method.cap (79 byte)
    => 80 E8 00 05 4F 07 00 4C 00 01 10 18 8C 00 02 7A    ....O..L.......z
        05 30 8F 00 08 3D 8C 00 00 18 1D 04 41 18 1D 25    .0...=......A..%
        8B 00 01 7A 02 21 18 8B 00 06 60 03 7A 19 8B 00    ...z.!....`.z...
        04 2D 1A 04 25 73 00 09 00 00 00 00 00 0F 11 6D    .-..%s.........m
        00 8D 00 07 7A 02 10 1C 04 6B 07 7C 00 03 70 05    ....z....k.|..p.
        7C 00 05 78 00                                     |..x.
    (1101 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Method.cap loaded (79 byte)
    Start loading StaticField.cap (15 byte)
    => 80 E8 00 06 0F 08 00 0C 00 02 00 00 00 00 00 00    ................
        00 02 90 90 00                                     .....
    (1069 usec)
    <= 00 90 00                                           ...
    Status: No Error
    StaticField.cap loaded (15 byte)
    Start loading ConstantPool.cap (41 byte)
    => 80 E8 00 07 29 05 00 26 00 09 06 00 00 01 03 80    ....)..&........
        03 02 06 80 03 00 05 00 00 00 03 80 0A 01 05 00    ................
        00 01 03 80 03 03 06 80 07 01 01 00 02 00 00       ...............
    (3134 usec)
    <= 00 90 00                                           ...
    Status: No Error
    ConstantPool.cap loaded (41 byte)
    Start loading RefLocation.cap (16 byte)
    => 80 E8 00 08 10 09 00 0D 00 00 00 09 05 06 04 0A    ................
        07 07 13 0A 05 00                                  ......
    (2067 usec)
    <= 00 90 00                                           ...
    Status: No Error
    RefLocation.cap loaded (16 byte)
    Start loading Descriptor.cap (114 byte)
    => 80 E8 00 09 72 0B 00 6F 01 00 01 00 02 00 00 02    ....r..o........
        00 04 00 09 00 00 00 80 03 01 09 00 00 01 80 03    ................
        00 81 00 01 00 14 00 05 00 00 00 00 01 09 00 08    ................
        00 16 00 12 00 00 00 00 07 01 00 1C 00 19 00 1F    ................
        00 00 00 00 02 09 00 3D 00 1D 00 0D 00 00 00 00    .......=........
        00 09 00 14 00 16 00 14 00 1F 00 21 00 1F 00 23    ...........!...#
        00 25 FF FF 01 10 04 B4 31 06 68 00 A1 02 33 01    .%......1.h...3.
        30 01 B0 01 20 02 41 00                            0... .A.
    (1344 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Descriptor.cap loaded (114 byte)
    Start loading Debug.cap (608 byte)
    => 80 E8 00 0A FA 0C 02 5D 00 1A 00 29 54 65 73 74    .......]...)Test
        5F 63 6F 6D 6D 6F 6E 5F 66 75 6E 63 74 69 6F 6E    _common_function
        2F 54 65 73 74 5F 63 6F 6D 6D 6F 6E 5F 66 75 6E    /Test_common_fun
        63 74 69 6F 6E 00 19 6A 61 76 61 63 61 72 64 2F    ction..javacard/
        66 72 61 6D 65 77 6F 72 6B 2F 41 70 70 6C 65 74    framework/Applet
        00 19 54 65 73 74 5F 63 6F 6D 6D 6F 6E 5F 66 75    ..Test_common_fu
        6E 63 74 69 6F 6E 2E 6A 61 76 61 00 0A 62 50 31    nction.java..bP1
        5F 43 6C 61 73 73 31 00 01 42 00 0A 62 50 31 5F    _Class1..B..bP1_
        43 6C 61 73 73 32 00 06 3C 69 6E 69 74 3E 00 03    Class2..<init>..
        28 29 56 00 04 74 68 69 73 00 2B 4C 54 65 73 74    ()V..this.+LTest
        5F 63 6F 6D 6D 6F 6E 5F 66 75 6E 63 74 69 6F 6E    _common_function
        2F 54 65 73 74 5F 63 6F 6D 6D 6F 6E 5F 66 75 6E    /Test_common_fun
        63 74 69 6F 6E 3B 00 07 69 6E 73 74 61 6C 6C 00    ction;..install.
        07 28 5B 42 53 42 29 56 00 06 62 41 72 72 61 79    .([BSB)V..bArray
        00 02 5B 42 00 07 62 4F 66 66 73 65 74 00 01 53    ..[B..bOffset..S
        00 07 62 4C 65 6E 67 74 68 00 07 70 72 6F 63 00    ..bLength..proc.
    (937268 nsec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 00 0B FA 65 73 73 00 1C 28 4C 6A 61 76 61    .....ess..(Ljava
        63 61 72 64 2F 66 72 61 6D 65 77 6F 72 6B 2F 41    card/framework/A
        50 44 55 3B 29 56 00 04 61 70 64 75 00 19 4C 6A    PDU;)V..apdu..Lj
        61 76 61 63 61 72 64 2F 66 72 61 6D 65 77 6F 72    avacard/framewor
        6B 2F 41 50 44 55 3B 00 03 62 75 66 00 05 47 65    k/APDU;..buf..Ge
        74 50 31 00 04 28 42 29 42 00 07 69 64 63 6C 61    tP1..(B)B..idcla
        73 73 00 14 54 65 73 74 5F 63 6F 6D 6D 6F 6E 5F    ss..Test_common_
        66 75 6E 63 74 69 6F 6E 00 19 00 01 00 00 00 01    function........
        00 02 00 01 00 02 00 00 02 00 04 00 03 00 04 00    ................
        09 00 00 00 00 00 05 00 04 00 09 00 00 00 01 00    ................
        06 00 07 00 01 00 01 02 00 05 00 01 00 01 00 00    ................
        08 00 09 00 00 00 05 00 00 00 04 00 0F 00 0A 00    ................
        0B 00 09 00 08 02 00 12 00 03 00 04 00 00 0C 00    ................
        0D 00 00 00 12 01 00 0E 00 0F 00 00 00 12 02 00    ................
        10 00 04 00 00 00 12 00 00 00 07 00 14 00 08 00    ................
        0D 00 15 00 0E 00 10 00 14 00 11 00 11 00 16 00    ................
    (785421 nsec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 80 0C 6C 00 11 00 12 00 01 00 1C 02 00 1F    ....l...........
        00 03 00 06 00 00 08 00 09 00 00 00 1F 01 00 13    ................
        00 14 00 00 00 1F 02 00 15 00 0D 00 0C 00 13 00    ................
        00 00 05 00 1B 00 06 00 06 00 1D 00 07 00 0B 00    ................
        20 00 0C 00 17 00 21 00 18 00 1D 00 27 00 1E 00     .....!.....'...
        1E 00 29 00 16 00 17 00 09 00 3D 02 00 0D 00 01    ..).......=.....
        00 01 00 00 18 00 04 00 00 00 0D 00 00 00 0C 00    ................
        2F 00                                              /.
    (1986 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Debug.cap loaded (608 byte)
    Load report:
      999 bytes loaded in 0.0 seconds
      effective code size on card:
          + package AID       6
          + applet AIDs       15
          + classes           17
          + methods           79
          + statics           2
          + exports           0
            overall           119  bytes
    cm>  install -i 0102030405010101  -q C9#() 010203040501 0102030405010101
    => 80 E6 0C 00 1F 06 01 02 03 04 05 01 08 01 02 03    ................
        04 05 01 01 01 08 01 02 03 04 05 01 01 01 01 00    ................
        02 C9 00 00 00                                     .....
    (2346 usec)
    <= 00 90 00                                           ...
    Status: No Error
    cm>  upload -c -d -b 250 "D:\WorkSpace\Test_Common_Funcation\bin\Test_Class_2\javacard\Test_Class_2.cap"
    jcshell: Cannot read <D:\WorkSpace\Test_Common_Funcation\bin\Test_Class_2\javacard\Test_Class_2.cap>: java.io.FileNotFoundException: D:\WorkSpace\Test_Common_Funcation\bin\Test_Class_2\javacard\Test_Class_2.cap (The system cannot find the path specified)
    cm>  install -i 0102030405010303  -q C9#() 01020304050103 0102030405010303
    => 80 E6 0C 00 20 07 01 02 03 04 05 01 03 08 01 02    .... ...........
        03 04 05 01 03 03 08 01 02 03 04 05 01 03 03 01    ................
        00 02 C9 00 00 00                                  ......
    (1231 usec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Unexpected error; aborting executionThank very much!
    Edited by: WhoKnows on Apr 20, 2012 9:32 PM

  • Urgent ! writing a java card applet -APDU problem

    hi
    i'm fairly new to the java programming language. i'm trying to write an RSA java card applet to run on a java card simulator.
    I am not sure at all what code i need to write for the CLA byte in the command APDU and what code i need to write for the INS byte in the command APDU, and where exactly to put it in my program.
    if anybody knows please could you help me out.
    So far i have written the code below.
    thanx
    louise
    import javacard.framework.*;
    import java.math.*;
    import java.util.*;
    /*the public key is the public part of the key. Anyone
    can have it. It can only encrypt data, not decrypt.*/
    public class publickey extends Applet{
    //code of the CLA byte in the command APDU header
    final static byte publickey_CLA = (byte)0x00;
    //max number of characters for text message is 60
    final static char MAX_TXT_MSG = 0x3c;
    //MAX number of tries (3) before PIN is blocked
    final static byte PIN_TRY_LIMIT = (byte)0x03;
    //size of PIN must be 4 digits long
    final static byte PIN_SIZE = (byte)0x04;
    //below status word(SW) values are returned by applet
    //in certain circumstances:
    //signal that the PIN verification failed
    final static short SW_PIN_VERIFICATION_FAIL = 0x6300;
    //signal that PIN validation required for txt msging
    final static short SW_PIN_VERIFICATION_REQUIRED = 0x630;
    //instance variables declaration
    OwnerPIN pin; //variable for holding owners pin
    BigInteger n,e;
    String owner;//variable for holding owners name
    /*make a public key. Do not do it yourself, but
    make a public key from a private key.*/
    publickey(String iowner,BigInteger in,BigInteger ie){
    owner=iowner;
    n=in;
    e=ie;
    public void process (APDU apdu) {
    byte[] buffer = apdu.getBuffer();
    //check Select APDU command
    if((buffer[ISO7816.OFFSET_CLA] ==0) &&
    (buffer[ISO7816.OFFSET_INS] ==(byte) (0xA4)) )
    return;
    if(buffer[ISO7816.OFFSET_CLA] !=publickey_CLA)
    ISOException.throwIt
    (ISO7816.SW_CLA_NOT_SUPPORTED);
    /*read the key back from a string.*/
    publickey(String from){
    StringTokenizer st=new StringTokenizer(from," ");
    owner=st.nextToken();
    n=readBI(st.nextToken());
    e=readBI(st.nextToken());
    /*use the key to encrypt a 'message' m. m should be a
    number from 1 to n (n not included).
    use makemessage to convert your message to a BigInteger.
    BigInteger encrypt(BigInteger m){
    return m.modPow(e,n);
    /*make a string from this key.*/
    public String toString(){
    return owner+" "+printBI(n)+" "+printBI(e);
    /*help methods for reading and writing:*/
    final static int radix=36;
    static String printBI(BigInteger b){
    return b.toString(radix);
    static BigInteger readBI(String s){
    return new BigInteger(s,radix);
    /* these methods convert an arbitrary message,
    in the form of an array of bytes, to a message
    suitable for encryption. To do this random bits
    are added (this is needed to make cracking of the
    system harder), and it is converted to a BigInteger.*/
    BigInteger makemessage(byte[] input){
    /*to understand this part of the program,
    read the description of the BigInteger constructor
    (in the standard java help). */
    if(input.length>128 ||
    input.length*8+24>=n.bitLength())
    return new BigInteger("0"); //error! message to long.
    byte[] paddedinput=new byte[n.bitLength()/8-1];
    for(int i=0;i<input.length;i++)
    paddedinput[i+1]=input;
    paddedinput[0]=(byte)input.length;
    for(int i=input.length+1;i<paddedinput.length;i++)
    paddedinput[i]=(byte)(Math.random()*256);
    return new BigInteger(paddedinput);
    /*the inverse of makemessage.*/
    static byte[] getmessage(BigInteger b){
    byte[] paddedoutput=b.toByteArray();
    byte[] output=new byte[paddedoutput[0]];
    for(int i=0;i<output.length;i++)
    output[i]=paddedoutput[i+1];
    return output;
    class privatekey{
    /*the data of a key*/
    BigInteger n,e,d;
    String owner;
    int bits;
    Random ran;
    /*unimportant things, needed for calculations:*/
    static int certainty=32;
    static BigInteger one=new BigInteger("1"),
    three=new BigInteger("3"),
    seventeen=new BigInteger("17"),
    k65=new BigInteger("65537");
    /*make a new key. supply the name of the owner of the
    key, and the number of bits.
    owner: all spaces will be replaced with underscores.
    bits: the more bits the better the security. Every
    value above 500 is 'safe'. If you are a really paranoid
    person, you should use 2000.*/
    privatekey(String iowner,int ibits){
    BigInteger p,q;
    bits=ibits;
    owner=iowner.replace(' ','_');//remove spaces from owner name.
    ran=new Random();
    p=new BigInteger(bits/2,certainty,ran);
    q=new BigInteger((bits+1)/2,certainty,ran);
    n=p.multiply(q);
    BigInteger fi_n=fi(p,q);
    e=chooseprimeto(fi_n);
    d=e.modInverse(fi_n);
    /*read the key back from a string*/
    privatekey(String from){
    StringTokenizer st=new StringTokenizer(from," ");
    st.nextToken();
    n=readBI(st.nextToken());
    e=readBI(st.nextToken());
    d=readBI(st.nextToken());
    /*some help methods:*/
    static BigInteger fi(BigInteger prime1,BigInteger prime2){
    return prime1.subtract(one).multiply(prime2.subtract(one));
    static BigInteger BI(String s)
    {return new BigInteger(s);}
    BigInteger chooseprimeto(BigInteger f){
    /*returns a number relatively prime to f.
    this number is not chosen at random, it first
    tries a few primes with few 1's in it. This
    doesn't matter for security, but speeds up computations.*/
    if(f.gcd(three).equals(one))
    return three;
    if(f.gcd(seventeen).equals(one))
    return seventeen;
    if(f.gcd(k65).equals(one))
    return k65;
    BigInteger num;
    do{
    num=new BigInteger(16,ran);
    }while(!f.gcd(num).equals(one));
    return num;
    final static int radix=36;
    static String printBI(BigInteger b){
    return b.toString(radix);
    static BigInteger readBI(String s){
    return new BigInteger(s,radix);
    /*returns the public key of this private key.*/
    publickey getpublickey(){
    return new publickey(owner,n,e);
    /*the same encryption that the public key does.*/
    BigInteger encrypt(BigInteger m){
    return m.modPow(e,n);
    /*decryption is the opposite of encryption: it
    brings the original message back.*/
    BigInteger decrypt(BigInteger m){
    return m.modPow(d,n);
    public String toString(){
    return owner+" "+printBI(n)+" "+printBI(e)+" "+printBI(d);
    /*this main demonstrates the use of this program.*/
    public static void main(String[] ps){
    say("************ make key:");
    privatekey priv=new privatekey("sieuwert",92);
    publickey pub=priv.getpublickey();
    say("the public key:"+priv);
    say("************ encrypt message:");
    byte[] P="RUOK?".getBytes();
    BigInteger Pc=pub.makemessage(P);
    say("converted:\t"+printBI(Pc));
    BigInteger C=pub.encrypt(Pc);
    say("coded message: "+printBI(C));
    say("************ decrypt message:");
    BigInteger Pc2=priv.decrypt(C);
    say("decoded:\t"+printBI(Pc2));
    byte[] P2=publickey.getmessage(Pc2);
    say("deconverted: "+new String(P2));
    static void say(String s){
    System.out.println(s);

    Command APDU is not written in your source code, rather it is sent from PC or programmed Card Acceptance Device/ Card Reader/ Terminal.
    The code installed in the Java Card should be able to handle the Command APDU received and process it accordingly, and finally your code should be able to send out response APDU.
    You may think your code as a decoder, to retrieve each byte (CLA, INS, P1, P2, DATA, LC) using the Java Card API, you should be able to do it.
    Also, I notice in your code that you want to work out with strings, but Java Card does not support strings, chars, long, float, double ...
    to send out reponse APDU, there are certain steps that you can use, not just simply print like ordinary J2SE may use.
    hope this will help u

  • Java card applet debugging in Netbeans 6.8

    Hi,
    | am writing a Java Card applet and a client MIDlet. I would like to debug my applet: I want to see the interaction process with MIDlet. However, for some reason I cannot start debugging in Netbeans 6.8. Could someone help? Thanks in advance.
    Regards,
    Aleksandr

    Hi sanyas,
    sorry, i'm not answering your question..
    I'm a newbie in Java Card technology..
    After i had read your post, it makes me curious about Java Card Client..
    I want to know, what kind of Java Card Client that we could create?..
    Can we create a Java Card client application from Java SE (GUI/Swing base application), or it's limited for MIDlet only?
    Thanks in advance..

  • 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.

  • How do I communicate a Java Card applet with a server?

    I'm new to Java and Java Card and currently developing a smart card system. I'm not sure what to use on my applet or server, JCSystem or SecureConnection or something else?
    If I'm writing a server application, then how do I install it so that I can simulate it with cjre?
    Thanks in advance.
    p/s: Connection is using TSL.

    The flow is like this:
    Java Card --> POS terminal -> Server
    Yes. I'm using JC3.
    Here's what I've achieved so far using SocketConnection
    SocketConnection sc = (SocketConnection) Connector.open("socket://localhost:50007");
    InputStream is = sc.openInputStream();
    OutputStream os = sc.openOutputStream();
    os.write("Hello world!".getBytes());
    is.read(buffer);
    os.close();
    is.close();
    sc.close(); Edited by: andirady on Dec 4, 2012 11:59 PM

  • I cannot load my java card applet Response APDU: 69 85

    I know there have been many threads on this subject, I am a newbie to Java card development.
    Please someone help me.
    I am using the gpj for downloading the applet.
    The following is the output from the command "java -jar gpj.jar -load JCHelloWorld.cap -install"
    Thanks in advance
    run:
    Found terminals: [PC/SC terminal Generic PCSC Smartcard Reader 0]
    Found card in terminal: Generic PCSC Smartcard Reader 0
    ATR: 3B DB 96 00 80 B1 FE 45 1F 83 00 31 C0 64 C7 FC 10 00 01 90 00 74
    INFO: Selecting Security Domain OP201a, AID=A000000003000000
    DEBUG: Command APDU: 00 A4 04 00 08 A0 00 00 00 03 00 00 00
    DEBUG: Response APDU: 6F 6E 84 08 A0 00 00 00 03 00 00 00 A5 62 73 2F 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 01 05 9F 6E 2A 48 20 50 2B 82 31 80 30 00 63 03 12 63 00 07 BB 03 00 11 42 12 97 11 43 12 97 11 44 12 97 01 00 00 00 00 00 00 00 00 00 00 00 9F 65 01 FF 90 00
    Successfully selected Security Domain OP201a A0 00 00 00 03 00 00 00
    DEBUG: Command APDU: 80 50 00 00 08 FC 81 DB FE 80 72 19 28
    DEBUG: Response APDU: 00 00 03 12 63 00 07 BB 03 00 FF 01 DA 26 EF 49 10 B7 72 00 9A 24 7F B4 A0 1F C7 C8 90 00
    INFO: INITIALIZE UPDATE Successful
    DEBUG: Command APDU: 84 82 00 00 10 D5 41 CE BE F4 A8 E4 DD 36 6C C5 3E 19 9C 77 93
    DEBUG: Response APDU: 90 00
    DEBUG: Command APDU: 84 82 00 00 08 D5 41 CE BE F4 A8 E4 DD
    DEBUG: Response APDU: 90 00
    INFO: External Authentication Successful
    DEBUG: packagePath: com/samptah/card/javacard/
    DEBUG: package: com.samptah.card
    DEBUG: package AID: 9C 25 F6 5E AB 3F
    DEBUG: applet AIDs: [9C 25 F6 5E AB CD ]
    DEBUG: Command APDU: 80 E6 02 00 13 06 9C 25 F6 5E AB 3F 08 A0 00 00 00 03 00 00 00 00 00 00
    DEBUG: Response APDU: 00 90 00
    DEBUG: Command APDU: 80 E8 00 00 FF C4 82 01 4C 01 00 10 DE CA FF ED 01 02 04 00 01 06 9C 25 F6 5E AB 3F 02 00 1F 00 10 00 1F 00 0A 00 15 00 2E 00 0C 00 7F 00 18 00 12 00 00 00 6F 00 02 00 01 00 0B 02 01 00 04 00 15 02 04 01 07 A0 00 00 00 62 01 01 00 01 07 A0 00 00 00 62 00 01 03 00 0A 01 06 9C 25 F6 5E AB CD 00 08 06 00 0C 00 80 03 00 FF 00 07 01 00 00 00 1C 07 00 7F 00 01 10 18 8C 00 00 7A 05 30 8F 00 01 3D 8C 00 02 18 1D 04 41 18 1D 25 8B 00 03 7A 02 23 18 8B 00 04 60 03 7A 19 8B 00 05 2D 1A 03 25 11 00 FF 53 5B 32 1A 04 25 11 00 FF 53 5B 29 04 1F 10 80 6A 08 11 6E 00 8D 00 06 16 04 75 00 10 00 01 00 00 00 09 18 19 8C 00 07 70 08 11 6D 00 8D 00 06 7A 05 22 19 8B 00 05 2D 7B 00 08 92 32 7B 00 08 03 1A 03 1F 8D 00 09 3B 19 03 1F 8B 00 0A 7A 08 00 18 00 02 00 01 00 01 03 00 0B 48 65 6C 6C
    DEBUG: Response APDU: 69 85
    net.sourceforge.gpj.cardservices.exceptions.GPLoadException: Load failed, SW: 69 85
    at net.sourceforge.gpj.cardservices.GlobalPlatformService.loadCapFile(GlobalPlatformService.java:707)
    at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(GlobalPlatformService.java:1675)
    at gpj.Main.main(Main.java:26)
    BUILD SUCCESSFUL (total time: 1 second)

    Quite similar problem here. Here's what I got from GPShell:
    enable_trace
    establish_context
    card_connect
    select -AID a0000000030000
    Command --> 00A4040007A0000000030000
    Wrapped command --> 00A4040007A0000000030000
    Response <-- 6F658408A000000003000000A5599F6501FF9F6E06479181023100734A06072A864
    886FC6B01600C060A2A864886FC6B02020101630906072A864886FC6B03640B06092A864886FC6B0
    40215650B06092B8510864864020103660C060A2B060104012A026E01029000
    open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4
    f -enc_key 404142434445464748494a4b4c4d4e4f // Open secure channel
    Command --> 805000000804C1C46CBC9932AA00
    Wrapped command --> 805000000804C1C46CBC9932AA00
    Response <-- 000010700108859552580101AA4F3AEC5503E7A7435A0560E047AF489000
    Command --> 84820100100C2766279A1FC158181037B7A811AB93
    Wrapped command --> 84820100100C2766279A1FC158181037B7A811AB93
    Response <-- 9000
    delete -AID D0D1D2D3D4D50101
    Command --> 80E400000A4F08D0D1D2D3D4D5010100
    Wrapped command --> 84E40000124F08D0D1D2D3D4D501014018673D5E89975900
    Response <-- 6A88
    delete() returns 0x80206A88 (6A88: Referenced data not found.)
    delete -AID D0D1D2D3D4D501
    Command --> 80E40000094F07D0D1D2D3D4D50100
    Wrapped command --> 84E40000114F07D0D1D2D3D4D501887135A5C0B424D500
    Response <-- 6A88
    delete() returns 0x80206A88 (6A88: Referenced data not found.)
    delete -AID D0D1D2D3D4D50101
    Command --> 80E400000A4F08D0D1D2D3D4D5010100
    Wrapped command --> 84E40000124F08D0D1D2D3D4D501017144DF5DE0D2DE9F00
    Response <-- 6A88
    delete() returns 0x80206A88 (6A88: Referenced data not found.)
    install -file helloworld.cap -nvDataLimit 500 -instParam 00 -priv 2
    Command --> 80E602001907D0D1D2D3D4D50107A00000000300000006EF04C60201600000
    Wrapped command --> 84E602002107D0D1D2D3D4D50107A00000000300000006EF04C602016000
    C6EDAE8F91652A3B00
    Response <-- 6A88
    install_for_load() returns 0x80206A88 (6A88: Referenced data not found.)And this is what I've got from gpj
    Found terminals: [PC/SC terminal ACS ACR1281 1S Dual Reader ICC 0, PC/SC termina
    l ACS ACR1281 1S Dual Reader PICC 0, PC/SC terminal ACS ACR1281 1S Dual Reader S
    AM 0]
    Found card in terminal: ACS ACR1281 1S Dual Reader ICC 0
    ATR: 3B F8 18 00 00 81 31 FE 45 4A 43 4F 50 76 32 34 31 BC
    DEBUG: Command  APDU: 00 A4 04 00 07 A0 00 00 01 51 00 00
    DEBUG: Response APDU: 6A 82
    Failed to select Security Domain GP211 A0 00 00 01 51 00 00 , SW: 6A 82
    DEBUG: Command  APDU: 00 A4 04 00 08 A0 00 00 00 18 43 4D 00
    DEBUG: Response APDU: 6A 82
    Failed to select Security Domain GemaltoXpressPro A0 00 00 00 18 43 4D 00 , SW:
    6A 82
    DEBUG: Command  APDU: 00 A4 04 00 08 A0 00 00 00 03 00 00 00
    DEBUG: Response APDU: 6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 9F 65 01 FF 9F 6
    E 06 47 91 81 02 31 00 73 4A 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86
    FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B
    04 02 15 65 0B 06 09 2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 04 01 2A 0
    2 6E 01 02 90 00
    Successfully selected Security Domain OP201a A0 00 00 00 03 00 00 00
    DEBUG: Command  APDU: 80 50 00 00 08 A5 6A EB 5F E3 31 30 37
    DEBUG: Response APDU: 00 00 10 70 01 08 85 95 52 58 01 01 2E 43 22 1A A3 0A 65 4
    0 AA 8B D1 2A D5 89 8D 70 90 00
    DEBUG: Command  APDU: 84 82 00 00 10 B8 3A E1 AD 36 01 D8 E3 5F CC 77 B4 A7 F2 B
    E 68
    DEBUG: Response APDU: 90 00
    DEBUG: Command  APDU: 84 82 00 00 08 B8 3A E1 AD 36 01 D8 E3
    DEBUG: Response APDU: 90 00
    DEBUG: packagePath: com/tru/card/javacard/
    DEBUG: package: com.tru.card
    DEBUG: package AID: C3 79 3E 65 A1 00 EB F3 FD 20
    DEBUG: applet AIDs: [C3 79 3E 65 A1 C9 85 3B ]
    DEBUG: Command  APDU: 80 E6 02 00 17 0A C3 79 3E 65 A1 00 EB F3 FD 20 08 A0 00 0
    0 00 03 00 00 00 00 00 00
    DEBUG: Response APDU: 00 90 00
    DEBUG: Command  APDU: 80 E6 02 00 17 0A C3 79 3E 65 A1 00 EB F3 FD 20 08 A0 00 0
    0 00 03 00 00 00 00 00 00
    DEBUG: Response APDU: 00 90 00
    DEBUG: Command  APDU: 80 E8 00 00 FF C4 82 04 32 01 00 14 DE CA FF ED 01 02 04 0
    0 01 0A C3 79 3E 65 A1 00 EB F3 FD 20 02 00 1F 00 14 00 1F 00 0C 00 15 00 86 00
    12 02 CE 00 0A 00 53 00 00 00 F9 00 00 00 00 00 00 02 01 00 04 00 15 02 04 01 07
    A0 00 00 00 62 01 01 00 01 07 A0 00 00 00 62 00 01 03 00 0C 01 08 C3 79 3E 65 A
    1 C9 85 3B 00 01 06 00 12 00 80 03 0C 00 06 04 04 00 00 00 0C FF FF FF FF 01 27
    07 02 CE 00 02 30 8F 00 0C 3D 8C 00 0E 3B 7A 01 10 18 8C 00 0D AD 00 8B 00 0F 7A
    05 10 18 8C 00 10 18 10 08 88 01 18 11 3F 02 89 02 18 11 3F 03 89 03 18 11 3F 0
    4 89 04 18 11 3F 05 89 05 18 8B 00 1E 18 10 08 90 0B 3D 03 10 54 38 3D 04 10 52
    38 3D 05 10 55 38 3D 06 10 53 38 3D 07 10 4D 38 3D 08 10 41 38 3D 10 06 10 52 38
    3D 10 07 10 54 38 87 06 18 10 06 90 0B 3D 03 10 54 38 3D 04 10 53 38 3D 05 10 4
    3
    DEBUG: Response APDU: 6A 80
    DEBUG: Command  APDU: 80 E8 00 00 FF C4 82 04 32 01 00 14 DE CA FF ED 01 02 04 0
    0 01 0A C3 79 3E 65 A1 00 EB F3 FD 20 02 00 1F 00 14 00 1F 00 0C 00 15 00 86 00
    12 02 CE 00 0A 00 53 00 00 00 F9 00 00 00 00 00 00 02 01 00 04 00 15 02 04 01 07
    A0 00 00 00 62 01 01 00 01 07 A0 00 00 00 62 00 01 03 00 0C 01 08 C3 79 3E 65 A
    1 C9 85 3B 00 01 06 00 12 00 80 03 0C 00 06 04 04 00 00 00 0C FF FF FF FF 01 27
    07 02 CE 00 02 30 8F 00 0C 3D 8C 00 0E 3B 7A 01 10 18 8C 00 0D AD 00 8B 00 0F 7A
    05 10 18 8C 00 10 18 10 08 88 01 18 11 3F 02 89 02 18 11 3F 03 89 03 18 11 3F 0
    4 89 04 18 11 3F 05 89 05 18 8B 00 1E 18 10 08 90 0B 3D 03 10 54 38 3D 04 10 52
    38 3D 05 10 55 38 3D 06 10 53 38 3D 07 10 4D 38 3D 08 10 41 38 3D 10 06 10 52 38
    3D 10 07 10 54 38 87 06 18 10 06 90 0B 3D 03 10 54 38 3D 04 10 53 38 3D 05 10 4
    3
    DEBUG: Response APDU: 6A 80
    net.sourceforge.gpj.cardservices.exceptions.GPLoadException: Load failed, SW: 6A
    80
            at net.sourceforge.gpj.cardservices.GlobalPlatformService.loadCapFile(Un
    known Source)
            at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S
    ource)
    javax.smartcardio.CardNotPresentException: No card present
            at sun.security.smartcardio.TerminalImpl.connect(Unknown Source)
            at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S
    ource)
    Caused by: sun.security.smartcardio.PCSCException: SCARD_W_REMOVED_CARD
            at sun.security.smartcardio.PCSC.SCardConnect(Native Method)
            at sun.security.smartcardio.CardImpl.<init>(Unknown Source)
            ... 2 more
    Found card in terminal: ACS ACR1281 1S Dual Reader PICC 0
    java.lang.NullPointerException
            at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S
    ource)
    javax.smartcardio.CardNotPresentException: No card present
            at sun.security.smartcardio.TerminalImpl.connect(Unknown Source)
            at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S
    ource)
    Caused by: sun.security.smartcardio.PCSCException: SCARD_W_REMOVED_CARD
            at sun.security.smartcardio.PCSC.SCardConnect(Native Method)
            at sun.security.smartcardio.CardImpl.<init>(Unknown Source)
            ... 2 more
    Found card in terminal: ACS ACR1281 1S Dual Reader SAM 0
    java.lang.NullPointerException
            at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S
    ource)What can I do to fix this? Did I missed any steps? Thanks for any reply.

  • How to run java card applet

    dear friend
    i am using java card development kit version 2.2.2. i have downloaded apache-ant-1.7.0-bin .i have tried to run the sample code provided by the kit.i n the kit i have seen a HelloWorld Applet. i have compiled it.using the follwing commands
    F:\Program Files\Java\jdk1.6.0_05>set JAVA_HOME=F:\Program Files\Java\jdk1.6.0_0
    5
    F:\Program Files\Java\jdk1.6.0_05>set PATH=%JC_HOME%\bin;%JAVA_HOME%\bin;%PATH%
    F:\Program Files\Java\jdk1.6.0_05>cd..
    F:\Program Files\Java>cd..
    F:\Program Files>cd..
    F:\>cd arun
    F:\arun>cd apache-ant-1.7.0-bin\apache-ant-1.7.0\bin
    F:\arun\apache-ant-1.7.0-bin\apache-ant-1.7.0\bin>set PATH=%PATH%;F:\arun\apache
    -ant-1.7.0-bin\apache-ant-1.7.0\bin
    F:\arun\apache-ant-1.7.0-bin\apache-ant-1.7.0\bin>cd..
    F:\arun\apache-ant-1.7.0-bin\apache-ant-1.7.0>cd..
    F:\arun\apache-ant-1.7.0-bin>cd..
    F:\arun>cd java_card_kit-2_2_2
    F:\arun\java_card_kit-2_2_2>cd java_card_kit-2_2_2-rr-bin-windows-do\samples
    F:\arun\java_card_kit-2_2_2\java_card_kit-2_2_2-rr-bin-windows-do\samples>javac
    -g -classpath .\classes;..\lib\api.jar;..\lib\installer.jar src\com\sun\javacard
    \samples\HelloWorld\*.java
    F:\arun\java_card_kit-2_2_2\java_card_kit-2_2_2-rr-bin-windows-do\samples>javac
    -g -classpath .\classes;..\lib\api.jar;..\lib\installer.jar src\com\sun\javacard
    \samples\HelloWorld\*.java
    F:\arun\java_card_kit-2_2_2\java_card_kit-2_2_2-rr-bin-windows-do\samples>javac
    -g -classpath .\classes;..\lib\api.jar;..\lib\installer.jar src\com\sun\javacard
    \samples\HelloWorld\*.java
    F:\arun\java_card_kit-2_2_2\java_card_kit-2_2_2-rr-bin-windows-do\samples>
    and now what i have to do to get the output of this applet? can u please help me with detailed description of te steps and commands and the directory from which i have to use those commands
    thanks in advance
    bye

    Is there any suggestion for my question?.. :(
    Thanks in advance..

Maybe you are looking for