< prev index next >

src/java.smartcardio/share/classes/javax/smartcardio/TerminalFactory.java

Print this page




  94     private final static String defaultType;
  95 
  96     private final static TerminalFactory defaultFactory;
  97 
  98     static {
  99         // lookup up the user specified type, default to PC/SC
 100         String type = AccessController.doPrivileged(
 101              (PrivilegedAction<String>) () -> System.getProperty(PROP_NAME, "PC/SC")).trim();
 102         TerminalFactory factory = null;
 103         try {
 104             factory = TerminalFactory.getInstance(type, null);
 105         } catch (Exception e) {
 106             // ignore
 107         }
 108         if (factory == null) {
 109             // if that did not work, try the Sun PC/SC factory
 110             try {
 111                 type = "PC/SC";
 112                 Provider sun = Security.getProvider("SunPCSC");
 113                 if (sun == null) {
 114                     Class<?> clazz = Class.forName("sun.security.smartcardio.SunPCSC");
 115                     sun = (Provider)clazz.newInstance();

 116                 }
 117                 factory = TerminalFactory.getInstance(type, null, sun);
 118             } catch (Exception e) {
 119                 // ignore
 120             }
 121         }
 122         if (factory == null) {
 123             type = "None";
 124             factory = new TerminalFactory
 125                         (NoneFactorySpi.INSTANCE, NoneProvider.INSTANCE, "None");
 126         }
 127         defaultType = type;
 128         defaultFactory = factory;
 129     }
 130 
 131     private static final class NoneProvider extends Provider {
 132 
 133         private static final long serialVersionUID = 2745808869881593918L;
 134         final static Provider INSTANCE = new NoneProvider();
 135         private NoneProvider() {




  94     private final static String defaultType;
  95 
  96     private final static TerminalFactory defaultFactory;
  97 
  98     static {
  99         // lookup up the user specified type, default to PC/SC
 100         String type = AccessController.doPrivileged(
 101              (PrivilegedAction<String>) () -> System.getProperty(PROP_NAME, "PC/SC")).trim();
 102         TerminalFactory factory = null;
 103         try {
 104             factory = TerminalFactory.getInstance(type, null);
 105         } catch (Exception e) {
 106             // ignore
 107         }
 108         if (factory == null) {
 109             // if that did not work, try the Sun PC/SC factory
 110             try {
 111                 type = "PC/SC";
 112                 Provider sun = Security.getProvider("SunPCSC");
 113                 if (sun == null) {
 114                     @SuppressWarnings("deprecation")
 115                     Object o = Class.forName("sun.security.smartcardio.SunPCSC").newInstance();
 116                     sun = (Provider)o;
 117                 }
 118                 factory = TerminalFactory.getInstance(type, null, sun);
 119             } catch (Exception e) {
 120                 // ignore
 121             }
 122         }
 123         if (factory == null) {
 124             type = "None";
 125             factory = new TerminalFactory
 126                         (NoneFactorySpi.INSTANCE, NoneProvider.INSTANCE, "None");
 127         }
 128         defaultType = type;
 129         defaultFactory = factory;
 130     }
 131 
 132     private static final class NoneProvider extends Provider {
 133 
 134         private static final long serialVersionUID = 2745808869881593918L;
 135         final static Provider INSTANCE = new NoneProvider();
 136         private NoneProvider() {


< prev index next >