frc1983 / seek-for-android

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

SEService::OpenLogicalChannel return valid Channel Object (not null) even if SmartcardService.openLogicalChannel return 0 has Channel handle #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
SmartcardService.openLogicalChannel return a long value which is a handle 
(address to the object?), which should indicate the channel is NOT opened 
successfully.

However, in SEService.java, such condition is not being handled properly, below 
is a proposed solution on that.

    Channel openLogicalChannel(Session session, byte[] aid) throws IOException {
        if (session == null) {
            throw new NullPointerException("session must not be null");
        }
        if (session.getReader() == null) {
            throw new NullPointerException("reader must not be null");
        }

        if (mSmartcardService == null) {
            throw new IllegalStateException("service not connected to system");
        }
        if (session.isClosed()) {
            throw new IllegalStateException("session is closed");
        }

        SmartcardError error = new SmartcardError();
        long hChannel;
        try {
            hChannel = mSmartcardService.openLogicalChannel(session.getReader().getName(), aid,
                    mCallback, error);
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
        if (channelCannotBeEstablished(error)) {
            return null;
        }
        checkIfAppletAvailable(error);
        checkForException(error);

        // need to check whether channel is actually valid
        // my understanding is that channel 0 means it does not succeed.
        // start of solution
        if (hChannel == 0)
            return null;
        // end of solution

        Channel logicalChannel = new Channel(session, hChannel, true);
        return logicalChannel;
    }

Original issue reported on code.google.com by tommypo...@gmail.com on 6 Jun 2012 at 3:10

GoogleCodeExporter commented 9 years ago
fixed in attachment, issue.23 still needs more investigation

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

Attachments:

GoogleCodeExporter commented 9 years ago
setting old issues from fixed to done

Original comment by Daniel.A...@gi-de.com on 5 Jul 2013 at 2:33