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

smartcardio: terminal factory got from TeminalFactory.getDefault()can not get any terminal

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • security-libs
    • beta
    • generic
    • generic
    • Verified

      In the following code, using TerminalFactory factory = TerminalFactory.getDefault();
      instead of TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null, "SunPCSC");
      will get "No card teminals available" exception.

      It works fine before b50 and start to fail after b51.

      ===================
      import java.security.*;
      import java.io.*;
      import java.util.*;
      import javax.smartcardio.*;

      public class PermissionTest {
         public static void main(String[] args) throws Exception{
               
               String defaultType = TerminalFactory.getDefaultType();
               TerminalFactory factory = TerminalFactory.getDefault();
               //TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null, "SunPCSC");
               System.out.println(factory);
               Provider provider = factory.getProvider();
               String type = factory.getType();
           
               List<CardTerminal> terminals = factory.terminals();
               if (terminals.isEmpty()) {
      throw new Exception("No card terminals available");
      }
               // get the first terminal
               CardTerminal terminal = terminals.get(0);
             
               String terminalName = terminal.getName();
               if (terminal.isCardPresent() == false) {
      System.out.println("*** Insert card");
      if (terminal.waitForCardPresent(20 * 1000) == false) {
      throw new Exception("no card available");
      }
               }
            
               // establish a connection with the card
               Card card = terminal.connect("T=0");
               CardChannel cc = card.getBasicChannel();
               // disconnect
               card.disconnect(true);
               System.out.println("Pass");
         }
      }

            andreas Andreas Sterbenz
            lzhanorcl Lichun Zhan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: