Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

SELECT command

JavaCard Applet Development Related Questions and Answers.
Robertdul
Posts: 7
Joined: Wed Sep 14, 2016 4:07 am
Points :92
Contact:

SELECT command

Post by Robertdul » Thu Jun 15, 2017 2:10 am

Can we override a select AID command and cause it to pass some data as response data? Thanks for any help.

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: SELECT command

Post by mabel » Thu Jun 15, 2017 10:24 pm

Can you describe your problem more detailed so that we can provide specific help for you.

Robertdul
Posts: 7
Joined: Wed Sep 14, 2016 4:07 am
Points :92
Contact:

Re: SELECT command

Post by Robertdul » Fri Jun 16, 2017 3:15 am

Just like this:

Code: Select all

// "some data " 
    private static final byte[] somedata= new byte[] {
        (byte)0x47, (byte)0x72, (byte)0x65, (byte)0x65,
            (byte)0x74, (byte)0x69, (byte)0x6E, (byte)0x67,
            (byte)0x73, (byte)0x20
    };


public void process(APDU apdu) {
          // Good practice: Return 9000 on SELECT
          if (selectingApplet()) {
               
               response=somedata;
               responseApdu=JCSystem.makeTransientByteArray(
                    (short)(response.length),
                    JCSystem.CLEAR_ON_DESELECT);
               apdu.setOutgoing();
               apdu.setOutgoingLength((short)response.length);
               apdu.sendBytesLong(responseApdu, (short)0, (short)responseApdu.length);
                         
          }

          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);
          }
     }


User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: SELECT command

Post by mabel » Fri Jun 16, 2017 5:37 am

Your code has told the OS to get ready to send the required data and then keeps executing through to your switch statement which does not understand the INS and throws the appropriate error. Please add a "return" statement after sendBytesLong().

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: Bing [Bot] and 18 guests

JavaCard OS : Disclaimer