Java Code Examples for javax.smartcardio.TerminalFactory#getInstance()
The following examples show how to use
javax.smartcardio.TerminalFactory#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java From hottub with GNU General Public License v2.0 | 6 votes |
static CardTerminal getTerminal(String[] args) throws Exception { setLibrary(args); TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } return terminal; }
Example 2
Source File: Utils.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
static CardTerminal getTerminal(String[] args) throws Exception { setLibrary(args); TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } return terminal; }
Example 3
Source File: Utils.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static CardTerminal getTerminal(String[] args, String provider) throws Exception { setLibrary(args); try { TerminalFactory factory = (provider == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provider); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { return null; } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } System.out.println("card present: " + terminal.isCardPresent()); return terminal; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 4
Source File: TestPresent.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal terminal = terminals.get(0); while (terminal.isCardPresent()) { System.out.println("*** Remove card!"); Thread.sleep(1000); } Timer timer = new Timer(); System.out.println("Testing waitForCardAbsent() with card already absent..."); isTrue(terminal.waitForCardAbsent(10)); timer.print(); isTrue(terminal.waitForCardAbsent(100)); timer.print(); isTrue(terminal.waitForCardAbsent(10000)); timer.print(); isTrue(terminal.waitForCardAbsent(0)); timer.print(); System.out.println("Testing waitForCardPresent() timeout..."); isFalse(terminal.waitForCardPresent(10)); timer.print(); isFalse(terminal.waitForCardPresent(100)); timer.print(); isFalse(terminal.waitForCardPresent(1000)); timer.print(); isFalse(terminal.isCardPresent()); isFalse(terminal.isCardPresent()); System.out.println("*** Insert card!"); isTrue(terminal.waitForCardPresent(0)); timer.print(); isTrue(terminal.isCardPresent()); isTrue(terminal.isCardPresent()); System.out.println("Testing waitForCardPresent() with card already present..."); isTrue(terminal.waitForCardPresent(0)); timer.print(); isTrue(terminal.waitForCardPresent(10000)); timer.print(); isTrue(terminal.waitForCardPresent(100)); timer.print(); isTrue(terminal.waitForCardPresent(10)); timer.print(); System.out.println("Testing waitForCardAbsent() timeout..."); isFalse(terminal.waitForCardAbsent(1000)); timer.print(); isFalse(terminal.waitForCardAbsent(100)); timer.print(); isFalse(terminal.waitForCardAbsent(10)); timer.print(); System.out.println("*** Remove card!"); isTrue(terminal.waitForCardAbsent(0)); timer.print(); isFalse(terminal.isCardPresent()); isFalse(terminal.isCardPresent()); System.out.println("OK."); }
Example 5
Source File: Utils.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static CardTerminal getTerminal(String[] args, String provider) throws Exception { setLibrary(args); try { TerminalFactory factory = (provider == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provider); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { return null; } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } System.out.println("card present: " + terminal.isCardPresent()); return terminal; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 6
Source File: Utils.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static TerminalFactory getTerminalFactory(String provName) throws Exception { try { TerminalFactory factory = (provName == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provName); System.out.println(factory); return factory; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 7
Source File: Utils.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static CardTerminal getTerminal(String[] args, String provider) throws Exception { setLibrary(args); try { TerminalFactory factory = (provider == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provider); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { return null; } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } System.out.println("card present: " + terminal.isCardPresent()); return terminal; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 8
Source File: Utils.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static TerminalFactory getTerminalFactory(String provName) throws Exception { try { TerminalFactory factory = (provName == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provName); System.out.println(factory); return factory; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 9
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static CardTerminal getTerminal(String[] args, String provider) throws Exception { setLibrary(args); try { TerminalFactory factory = (provider == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provider); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { return null; } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } System.out.println("card present: " + terminal.isCardPresent()); return terminal; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 10
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static TerminalFactory getTerminalFactory(String provName) throws Exception { try { TerminalFactory factory = (provName == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provName); System.out.println(factory); return factory; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 11
Source File: Utils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static CardTerminal getTerminal(String[] args, String provider) throws Exception { setLibrary(args); try { TerminalFactory factory = (provider == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provider); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { return null; } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } System.out.println("card present: " + terminal.isCardPresent()); return terminal; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 12
Source File: Utils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static TerminalFactory getTerminalFactory(String provName) throws Exception { try { TerminalFactory factory = (provName == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provName); System.out.println(factory); return factory; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 13
Source File: Utils.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static CardTerminal getTerminal(String[] args, String provider) throws Exception { setLibrary(args); try { TerminalFactory factory = (provider == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provider); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { return null; } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } System.out.println("card present: " + terminal.isCardPresent()); return terminal; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 14
Source File: Utils.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static TerminalFactory getTerminalFactory(String provName) throws Exception { try { TerminalFactory factory = (provName == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provName); System.out.println(factory); return factory; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 15
Source File: TestPresent.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal terminal = terminals.get(0); while (terminal.isCardPresent()) { System.out.println("*** Remove card!"); Thread.sleep(1000); } Timer timer = new Timer(); System.out.println("Testing waitForCardAbsent() with card already absent..."); isTrue(terminal.waitForCardAbsent(10)); timer.print(); isTrue(terminal.waitForCardAbsent(100)); timer.print(); isTrue(terminal.waitForCardAbsent(10000)); timer.print(); isTrue(terminal.waitForCardAbsent(0)); timer.print(); System.out.println("Testing waitForCardPresent() timeout..."); isFalse(terminal.waitForCardPresent(10)); timer.print(); isFalse(terminal.waitForCardPresent(100)); timer.print(); isFalse(terminal.waitForCardPresent(1000)); timer.print(); isFalse(terminal.isCardPresent()); isFalse(terminal.isCardPresent()); System.out.println("*** Insert card!"); isTrue(terminal.waitForCardPresent(0)); timer.print(); isTrue(terminal.isCardPresent()); isTrue(terminal.isCardPresent()); System.out.println("Testing waitForCardPresent() with card already present..."); isTrue(terminal.waitForCardPresent(0)); timer.print(); isTrue(terminal.waitForCardPresent(10000)); timer.print(); isTrue(terminal.waitForCardPresent(100)); timer.print(); isTrue(terminal.waitForCardPresent(10)); timer.print(); System.out.println("Testing waitForCardAbsent() timeout..."); isFalse(terminal.waitForCardAbsent(1000)); timer.print(); isFalse(terminal.waitForCardAbsent(100)); timer.print(); isFalse(terminal.waitForCardAbsent(10)); timer.print(); System.out.println("*** Remove card!"); isTrue(terminal.waitForCardAbsent(0)); timer.print(); isFalse(terminal.isCardPresent()); isFalse(terminal.isCardPresent()); System.out.println("OK."); }
Example 16
Source File: Utils.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static CardTerminal getTerminal(String[] args, String provider) throws Exception { setLibrary(args); try { TerminalFactory factory = (provider == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provider); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { return null; } CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent() == false) { System.out.println("*** Insert card"); if (terminal.waitForCardPresent(20 * 1000) == false) { throw new Exception("no card available"); } } System.out.println("card present: " + terminal.isCardPresent()); return terminal; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 17
Source File: Utils.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static TerminalFactory getTerminalFactory(String provName) throws Exception { try { TerminalFactory factory = (provName == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provName); System.out.println(factory); return factory; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 18
Source File: Utils.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static TerminalFactory getTerminalFactory(String provName) throws Exception { try { TerminalFactory factory = (provName == null) ? TerminalFactory.getInstance("PC/SC", null) : TerminalFactory.getInstance("PC/SC", null, provName); System.out.println(factory); return factory; } catch (NoSuchAlgorithmException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("PC/SC not available")) { return null; } throw e; } }
Example 19
Source File: TestPresent.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal terminal = terminals.get(0); while (terminal.isCardPresent()) { System.out.println("*** Remove card!"); Thread.sleep(1000); } Timer timer = new Timer(); System.out.println("Testing waitForCardAbsent() with card already absent..."); isTrue(terminal.waitForCardAbsent(10)); timer.print(); isTrue(terminal.waitForCardAbsent(100)); timer.print(); isTrue(terminal.waitForCardAbsent(10000)); timer.print(); isTrue(terminal.waitForCardAbsent(0)); timer.print(); System.out.println("Testing waitForCardPresent() timeout..."); isFalse(terminal.waitForCardPresent(10)); timer.print(); isFalse(terminal.waitForCardPresent(100)); timer.print(); isFalse(terminal.waitForCardPresent(1000)); timer.print(); isFalse(terminal.isCardPresent()); isFalse(terminal.isCardPresent()); System.out.println("*** Insert card!"); isTrue(terminal.waitForCardPresent(0)); timer.print(); isTrue(terminal.isCardPresent()); isTrue(terminal.isCardPresent()); System.out.println("Testing waitForCardPresent() with card already present..."); isTrue(terminal.waitForCardPresent(0)); timer.print(); isTrue(terminal.waitForCardPresent(10000)); timer.print(); isTrue(terminal.waitForCardPresent(100)); timer.print(); isTrue(terminal.waitForCardPresent(10)); timer.print(); System.out.println("Testing waitForCardAbsent() timeout..."); isFalse(terminal.waitForCardAbsent(1000)); timer.print(); isFalse(terminal.waitForCardAbsent(100)); timer.print(); isFalse(terminal.waitForCardAbsent(10)); timer.print(); System.out.println("*** Remove card!"); isTrue(terminal.waitForCardAbsent(0)); timer.print(); isFalse(terminal.isCardPresent()); isFalse(terminal.isCardPresent()); System.out.println("OK."); }
Example 20
Source File: TestPresent.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null); System.out.println(factory); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal terminal = terminals.get(0); while (terminal.isCardPresent()) { System.out.println("*** Remove card!"); Thread.sleep(1000); } Timer timer = new Timer(); System.out.println("Testing waitForCardAbsent() with card already absent..."); isTrue(terminal.waitForCardAbsent(10)); timer.print(); isTrue(terminal.waitForCardAbsent(100)); timer.print(); isTrue(terminal.waitForCardAbsent(10000)); timer.print(); isTrue(terminal.waitForCardAbsent(0)); timer.print(); System.out.println("Testing waitForCardPresent() timeout..."); isFalse(terminal.waitForCardPresent(10)); timer.print(); isFalse(terminal.waitForCardPresent(100)); timer.print(); isFalse(terminal.waitForCardPresent(1000)); timer.print(); isFalse(terminal.isCardPresent()); isFalse(terminal.isCardPresent()); System.out.println("*** Insert card!"); isTrue(terminal.waitForCardPresent(0)); timer.print(); isTrue(terminal.isCardPresent()); isTrue(terminal.isCardPresent()); System.out.println("Testing waitForCardPresent() with card already present..."); isTrue(terminal.waitForCardPresent(0)); timer.print(); isTrue(terminal.waitForCardPresent(10000)); timer.print(); isTrue(terminal.waitForCardPresent(100)); timer.print(); isTrue(terminal.waitForCardPresent(10)); timer.print(); System.out.println("Testing waitForCardAbsent() timeout..."); isFalse(terminal.waitForCardAbsent(1000)); timer.print(); isFalse(terminal.waitForCardAbsent(100)); timer.print(); isFalse(terminal.waitForCardAbsent(10)); timer.print(); System.out.println("*** Remove card!"); isTrue(terminal.waitForCardAbsent(0)); timer.print(); isFalse(terminal.isCardPresent()); isFalse(terminal.isCardPresent()); System.out.println("OK."); }