faraxnak / seek-for-android

Automatically exported from code.google.com/p/seek-for-android
0 stars 0 forks source link

Session::OpenLogicalChannel does not return NoSuchElementException #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
according to API Spec @ 
http://seek-for-android.googlecode.com/svn/trunk/doc/org/simalliance/openmobilea
pi/Session.html#openLogicalChannel(byte[]), when user call 
Session.openLogicalChannel against an non-existing AID or non-multiselectable 
AID, he/she should get NoSuchElementException according to following statement:

java.utils.NoSuchElementException - if an Applet with the defined AID does not 
exist in the SE or a logical channel is already open to a non-multiselectable 
applet

But they would not get it because in SEService.java openLogicalChannel, when 
checkIfAppletAvailable() is called, NoSuchElementException got casted into 
IOException, following is the solution:

    private void checkIfAppletAvailable(SmartcardError error) throws IOException {
        Exception exp = error.createException();
        if (exp != null) {
            if(exp instanceof NoSuchElementException) {
                //wrong behavior against API spec
                        // start of solution
                //throw new IOException("Applet with the defined aid does not exist in the SE");
                throw new NoSuchElementException("Applet with the defined aid does not exist in the SE");
                        // end of solution
            }
        }
    }

Original issue reported on code.google.com by tommypo...@gmail.com on 7 Jun 2012 at 9:17

GoogleCodeExporter commented 9 years ago
trunk contains older code than the patch files. SCAPI-2_3_2 already has such 
behavior

Original comment by Daniel.A...@gi-de.com on 19 Jun 2012 at 1:11