licel / jcardsim

https://jcardsim.org
224 stars 123 forks source link

add way for simulator to return select data #31

Closed klali closed 10 years ago

klali commented 10 years ago

changes some underlying dynamics but keeps the current api where selectApplet() returns boolean and adds selectAppletWithResult() returning byte[]

also fixes #21 by calling the process() method once with selectingApplet true.

I'm not sure this is the "correct" way of doing this, but seems to work fine enough for me, though completely open to opinions/changes/etc.

klali commented 10 years ago

Any updates on this? If it's not acceptable in this form (or at all?) that'd be good to know..

/klas

licel commented 10 years ago

Hi, We did not forget about your pull request. Prior to implementing Global Platform we were planned to rework the mechanism of interaction with applets, by adding CardManager entity, which receives APDU commands, implements security policies, works with SecureChannel and interacts with applets. Unfortunately, we had no time to implement it fast, that is why your pull request is stuck a bit.

We are ready to accept it, but there is one wish: replace Simulator method

 public boolean selectApplet(AID aid) throws SystemException {
          return SimulatorSystem.selectApplet(aid);
      }

on

 public boolean selectApplet(AID aid) throws SystemException {
       byte[] resp = runtime.selectApplet(aid);
        if(resp != null && resp.length > 1) {
            int len = resp.length;
        if(resp[len - 2] == (byte)0x90 && resp[len - 1] == 0) {
            return true;
            }
       }
       return false;
 }

and remove static boolean selectApplet(AID aid) method from SimulatorSystem

Thank you very much for your contribution in jCardSim project.

klali commented 10 years ago

I've just pushed a new commit there which I think does what you suggested..

Very happy to contribute to jcardsim, it greatly simplifies our testsuites for applets.

licel commented 10 years ago

It's great! Thank you very much for the commit!