Java Code Examples for javax.smartcardio.Card#disconnect()
The following examples show how to use
javax.smartcardio.Card#disconnect() .
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: TestDirect.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); if (cardTerminals.isEmpty()) { System.out.println("Skipping the test: " + "no card terminals available"); return; } System.out.println("Terminals: " + cardTerminals); CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 2
Source File: TestDirect.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); System.out.println("Terminals: " + cardTerminals); if (cardTerminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 3
Source File: TestDirect.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); if (cardTerminals.isEmpty()) { System.out.println("Skipping the test: " + "no card terminals available"); return; } System.out.println("Terminals: " + cardTerminals); CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 4
Source File: TestDirect.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); System.out.println("Terminals: " + cardTerminals); if (cardTerminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 5
Source File: TestDirect.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); if (cardTerminals.isEmpty()) { System.out.println("Skipping the test: " + "no card terminals available"); return; } System.out.println("Terminals: " + cardTerminals); CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 6
Source File: TestDirect.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); if (cardTerminals.isEmpty()) { System.out.println("Skipping the test: " + "no card terminals available"); return; } System.out.println("Terminals: " + cardTerminals); CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 7
Source File: TestDirect.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); System.out.println("Terminals: " + cardTerminals); if (cardTerminals.isEmpty()) { throw new Exception("No card terminals available"); } CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 8
Source File: TestDirect.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); if (cardTerminals.isEmpty()) { System.out.println("Skipping the test: " + "no card terminals available"); return; } System.out.println("Terminals: " + cardTerminals); CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 9
Source File: TestDirect.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); if (cardTerminals.isEmpty()) { System.out.println("Skipping the test: " + "no card terminals available"); return; } System.out.println("Terminals: " + cardTerminals); CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 10
Source File: TestDirect.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); if (cardTerminals.isEmpty()) { System.out.println("Skipping the test: " + "no card terminals available"); return; } System.out.println("Terminals: " + cardTerminals); CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true); System.out.println("OK."); }
Example 11
Source File: TestTransmit.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CardTerminal terminal = getTerminal(args); Card card = terminal.connect("T=0"); CardChannel channel = card.getBasicChannel(); BufferedReader reader = new BufferedReader(new FileReader("apdu.log")); byte[] command = null; while (true) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(CMD_MARKER)) { System.out.println(line); line = line.substring(CMD_MARKER.length()); command = parse(line); } else if (line.startsWith(RES_MARKER)) { System.out.println(line); line = line.substring(RES_MARKER.length()); Bytes response = parseWildcard(line); CommandAPDU capdu = new CommandAPDU(command); ResponseAPDU rapdu = channel.transmit(capdu); byte[] received = rapdu.getBytes(); if (received.length != response.bytes.length) { throw new Exception("Length mismatch: " + toString(received)); } for (int i = 0; i < received.length; i++) { byte mask = response.mask[i]; if ((received[i] & response.mask[i]) != response.bytes[i]) { throw new Exception("Mismatch: " + toString(received)); } } } // else ignore } // disconnect card.disconnect(true); System.out.println("OK."); }
Example 12
Source File: TestTransmit.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CardTerminal terminal = getTerminal(args); if (terminal == null) { System.out.println("Skipping the test: " + "no card terminals available"); return; } Card card = terminal.connect("T=0"); CardChannel channel = card.getBasicChannel(); BufferedReader reader = new BufferedReader(new FileReader("apdu.log")); byte[] command = null; while (true) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(CMD_MARKER)) { System.out.println(line); line = line.substring(CMD_MARKER.length()); command = parse(line); } else if (line.startsWith(RES_MARKER)) { System.out.println(line); line = line.substring(RES_MARKER.length()); Bytes response = parseWildcard(line); CommandAPDU capdu = new CommandAPDU(command); ResponseAPDU rapdu = channel.transmit(capdu); byte[] received = rapdu.getBytes(); if (received.length != response.bytes.length) { throw new Exception("Length mismatch: " + toString(received)); } for (int i = 0; i < received.length; i++) { byte mask = response.mask[i]; if ((received[i] & response.mask[i]) != response.bytes[i]) { throw new Exception("Mismatch: " + toString(received)); } } } // else ignore } // disconnect card.disconnect(true); System.out.println("OK."); }
Example 13
Source File: TestTransmit.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CardTerminal terminal = getTerminal(args); if (terminal == null) { System.out.println("Skipping the test: " + "no card terminals available"); return; } Card card = terminal.connect("T=0"); CardChannel channel = card.getBasicChannel(); BufferedReader reader = new BufferedReader(new FileReader("apdu.log")); byte[] command = null; while (true) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(CMD_MARKER)) { System.out.println(line); line = line.substring(CMD_MARKER.length()); command = parse(line); } else if (line.startsWith(RES_MARKER)) { System.out.println(line); line = line.substring(RES_MARKER.length()); Bytes response = parseWildcard(line); CommandAPDU capdu = new CommandAPDU(command); ResponseAPDU rapdu = channel.transmit(capdu); byte[] received = rapdu.getBytes(); if (received.length != response.bytes.length) { throw new Exception("Length mismatch: " + toString(received)); } for (int i = 0; i < received.length; i++) { byte mask = response.mask[i]; if ((received[i] & response.mask[i]) != response.bytes[i]) { throw new Exception("Mismatch: " + toString(received)); } } } // else ignore } // disconnect card.disconnect(true); System.out.println("OK."); }
Example 14
Source File: TestTransmit.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CardTerminal terminal = getTerminal(args); if (terminal == null) { System.out.println("Skipping the test: " + "no card terminals available"); return; } Card card = terminal.connect("T=0"); CardChannel channel = card.getBasicChannel(); BufferedReader reader = new BufferedReader(new FileReader("apdu.log")); byte[] command = null; while (true) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(CMD_MARKER)) { System.out.println(line); line = line.substring(CMD_MARKER.length()); command = parse(line); } else if (line.startsWith(RES_MARKER)) { System.out.println(line); line = line.substring(RES_MARKER.length()); Bytes response = parseWildcard(line); CommandAPDU capdu = new CommandAPDU(command); ResponseAPDU rapdu = channel.transmit(capdu); byte[] received = rapdu.getBytes(); if (received.length != response.bytes.length) { throw new Exception("Length mismatch: " + toString(received)); } for (int i = 0; i < received.length; i++) { byte mask = response.mask[i]; if ((received[i] & response.mask[i]) != response.bytes[i]) { throw new Exception("Mismatch: " + toString(received)); } } } // else ignore } // disconnect card.disconnect(true); System.out.println("OK."); }
Example 15
Source File: TestTransmit.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CardTerminal terminal = getTerminal(args); if (terminal == null) { System.out.println("Skipping the test: " + "no card terminals available"); return; } Card card = terminal.connect("T=0"); CardChannel channel = card.getBasicChannel(); BufferedReader reader = new BufferedReader(new FileReader("apdu.log")); byte[] command = null; while (true) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(CMD_MARKER)) { System.out.println(line); line = line.substring(CMD_MARKER.length()); command = parse(line); } else if (line.startsWith(RES_MARKER)) { System.out.println(line); line = line.substring(RES_MARKER.length()); Bytes response = parseWildcard(line); CommandAPDU capdu = new CommandAPDU(command); ResponseAPDU rapdu = channel.transmit(capdu); byte[] received = rapdu.getBytes(); if (received.length != response.bytes.length) { throw new Exception("Length mismatch: " + toString(received)); } for (int i = 0; i < received.length; i++) { byte mask = response.mask[i]; if ((received[i] & response.mask[i]) != response.bytes[i]) { throw new Exception("Mismatch: " + toString(received)); } } } // else ignore } // disconnect card.disconnect(true); System.out.println("OK."); }
Example 16
Source File: TestTransmit.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CardTerminal terminal = getTerminal(args); if (terminal == null) { System.out.println("Skipping the test: " + "no card terminals available"); return; } Card card = terminal.connect("T=0"); CardChannel channel = card.getBasicChannel(); BufferedReader reader = new BufferedReader(new FileReader("apdu.log")); byte[] command = null; while (true) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(CMD_MARKER)) { System.out.println(line); line = line.substring(CMD_MARKER.length()); command = parse(line); } else if (line.startsWith(RES_MARKER)) { System.out.println(line); line = line.substring(RES_MARKER.length()); Bytes response = parseWildcard(line); CommandAPDU capdu = new CommandAPDU(command); ResponseAPDU rapdu = channel.transmit(capdu); byte[] received = rapdu.getBytes(); if (received.length != response.bytes.length) { throw new Exception("Length mismatch: " + toString(received)); } for (int i = 0; i < received.length; i++) { byte mask = response.mask[i]; if ((received[i] & response.mask[i]) != response.bytes[i]) { throw new Exception("Mismatch: " + toString(received)); } } } // else ignore } // disconnect card.disconnect(true); System.out.println("OK."); }
Example 17
Source File: TestTransmit.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CardTerminal terminal = getTerminal(args); Card card = terminal.connect("T=0"); CardChannel channel = card.getBasicChannel(); BufferedReader reader = new BufferedReader(new FileReader("apdu.log")); byte[] command = null; while (true) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(CMD_MARKER)) { System.out.println(line); line = line.substring(CMD_MARKER.length()); command = parse(line); } else if (line.startsWith(RES_MARKER)) { System.out.println(line); line = line.substring(RES_MARKER.length()); Bytes response = parseWildcard(line); CommandAPDU capdu = new CommandAPDU(command); ResponseAPDU rapdu = channel.transmit(capdu); byte[] received = rapdu.getBytes(); if (received.length != response.bytes.length) { throw new Exception("Length mismatch: " + toString(received)); } for (int i = 0; i < received.length; i++) { byte mask = response.mask[i]; if ((received[i] & response.mask[i]) != response.bytes[i]) { throw new Exception("Mismatch: " + toString(received)); } } } // else ignore } // disconnect card.disconnect(true); System.out.println("OK."); }
Example 18
Source File: PCSCUtils.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
private static ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException { TerminalFactory factory = TerminalFactory.getDefault(); List<CardTerminal> terminals = factory.terminals().list(); LOG.debug("Terminals: " + terminals); Card card = null; Iterator i$ = terminals.iterator(); while(i$.hasNext()) { CardTerminal terminal = (CardTerminal)i$.next(); if (terminal.isCardPresent()) { card = terminal.connect("*"); if (card != null && matchesEidAtr(card.getATR())) { break; } } } if (card == null) { throw new CardNotPresentException("EID is not present"); } else { card.beginExclusive(); LOG.debug("card: " + card); CardChannel cardChannel = card.getBasicChannel(); ResponseAPDU responseApdu = cardChannel.transmit(commandApdu); if (108 == responseApdu.getSW1()) { LOG.debug("sleeping..."); try { Thread.sleep(10L); } catch (InterruptedException var7) { throw new be.ehealth.technicalconnector.exception.InterruptedException("Cannot sleep", var7); } responseApdu = cardChannel.transmit(commandApdu); } card.endExclusive(); card.disconnect(false); return responseApdu; } }
Example 19
Source File: PCSCUtils.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
private static ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException { TerminalFactory factory = TerminalFactory.getDefault(); List<CardTerminal> terminals = factory.terminals().list(); LOG.debug("Terminals: " + terminals); Card card = null; Iterator i$ = terminals.iterator(); while(i$.hasNext()) { CardTerminal terminal = (CardTerminal)i$.next(); if (terminal.isCardPresent()) { card = terminal.connect("*"); if (card != null && matchesEidAtr(card.getATR())) { break; } } } if (card == null) { throw new CardNotPresentException("EID is not present"); } else { card.beginExclusive(); LOG.debug("card: " + card); CardChannel cardChannel = card.getBasicChannel(); ResponseAPDU responseApdu = cardChannel.transmit(commandApdu); if (108 == responseApdu.getSW1()) { LOG.debug("sleeping..."); try { Thread.sleep(10L); } catch (InterruptedException var7) { throw new be.ehealth.technicalconnector.exception.InterruptedException("Cannot sleep", var7); } responseApdu = cardChannel.transmit(commandApdu); } card.endExclusive(); card.disconnect(false); return responseApdu; } }
Example 20
Source File: TestTransmit.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CardTerminal terminal = getTerminal(args); if (terminal == null) { System.out.println("Skipping the test: " + "no card terminals available"); return; } Card card = terminal.connect("T=0"); CardChannel channel = card.getBasicChannel(); BufferedReader reader = new BufferedReader(new FileReader("apdu.log")); byte[] command = null; while (true) { String line = reader.readLine(); if (line == null) { break; } if (line.startsWith(CMD_MARKER)) { System.out.println(line); line = line.substring(CMD_MARKER.length()); command = parse(line); } else if (line.startsWith(RES_MARKER)) { System.out.println(line); line = line.substring(RES_MARKER.length()); Bytes response = parseWildcard(line); CommandAPDU capdu = new CommandAPDU(command); ResponseAPDU rapdu = channel.transmit(capdu); byte[] received = rapdu.getBytes(); if (received.length != response.bytes.length) { throw new Exception("Length mismatch: " + toString(received)); } for (int i = 0; i < received.length; i++) { byte mask = response.mask[i]; if ((received[i] & response.mask[i]) != response.bytes[i]) { throw new Exception("Mismatch: " + toString(received)); } } } // else ignore } // disconnect card.disconnect(true); System.out.println("OK."); }