Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7195480

javax.smartcardio does not detect cards on Mac OS X

    XMLWordPrintable

Details

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.7.0_07"
        Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
        Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Mac OS X 10.8.1
        Darwin lambda.local 12.1.0 Darwin Kernel Version 12.1.0: Tue Aug 14 13:29:55 PDT 2012; root:xnu-2050.9.2~1/RELEASE_X86_64 x86_64

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Connected a ACR38U smartcardreader (CCID)
        Inserted a Belgian eID card in the reader.

        A DESCRIPTION OF THE PROBLEM :
        Smartcards inserted in a smartcardreader are not detected by Oracle's Java 7 for Mac. It detects the reader, but not the card.

        REGRESSION. Last worked in version 6u31

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        connect a reader and insert a smartcard. Then basically do this in Java:

        TerminalFactory factory = TerminalFactory.getDefault();
        CardTerminals cardTerminals = factory.terminals();
        List<CardTerminal> cardTerminalList;
        cardTerminalList = cardTerminals.list();
        for (CardTerminal cardTerminal : cardTerminalList){
            System.out.println(cardTerminal.getName());
            if (cardTerminal.isCardPresent()) {
            // not getting here
           }
        }


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Expected to detect the card. This works in Mac OS X's own Java 6 VM.
        ACTUAL -
        The card is not detected. The VM acts as if the reader is empty.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.smartcardio.*;
        import java.util.List;

        public class SmartCardBug {

            public static void main(String[] args) {
                TerminalFactory factory = TerminalFactory.getDefault();

                CardTerminals cardTerminals = factory.terminals();
                List<CardTerminal> cardTerminalList;
                try {
                    cardTerminalList = cardTerminals.list();
                    for (CardTerminal cardTerminal : cardTerminalList) {
                        System.out.println(cardTerminal.getName());
                        cardTerminal.waitForCardPresent(10000);
                        if (cardTerminal.isCardPresent()) {
                            Card card;
                            try {

                                card = cardTerminal.connect("T=0");

                                card.beginExclusive();
                            } catch (CardException e) {
                                System.err.println("could not connect to card: "
                                        + e.getMessage());
                                continue;
                            }
                            ATR atr = card.getATR();

                            byte[] atrBytes = atr.getBytes();
                            StringBuffer atrStringBuffer = new StringBuffer();
                            for (byte atrByte : atrBytes) {
                                 atrStringBuffer.append(Integer
                                            .toHexString(atrByte & 0xff));
                            }
                            System.out.println("ATR= "
                                                + atrStringBuffer);

                            card.endExclusive();
                            card.disconnect(true);
                        }
                    }

                } catch (CardException e) {
                    System.err.println("error on card terminals list: "
                            + e.getMessage());
                    System.err.println("no card readers connected?");
                    Throwable cause = e.getCause();
                    if (null != cause) {
                        System.err.println("cause: " + cause.getMessage());
                        System.err.println("cause type: "
                                + cause.getClass().getName());
                    }
                }
            }

        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        We currently recommend our customers to deinstall Oracle's Java version and to stick with Apple's Java version.

        Attachments

          Issue Links

            Activity

              People

                igerasim Ivan Gerasimov
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: