本文整理汇总了Java中javax.smartcardio.Card.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Java Card.disconnect方法的具体用法?Java Card.disconnect怎么用?Java Card.disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.smartcardio.Card
的用法示例。
在下文中一共展示了Card.disconnect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.smartcardio.Card; //导入方法依赖的package包/类
public static void main(final String[] args) throws CardException, CommunicationException {
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
LOGGER.info("Terminals: " + terminals);
if (terminals != null && !terminals.isEmpty()) {
// Use the first terminal
CardTerminal terminal = terminals.get(0);
// Connect with the card
Card card = terminal.connect("*");
LOGGER.info("card: " + card);
CardChannel channel = card.getBasicChannel();
PcscProvider provider = new PcscProvider(channel);
EmvParser parser = new EmvParser(provider, false);
parser.readEmvCard();
// Disconnect the card
card.disconnect(false);
} else {
LOGGER.error("No pcsc terminal found");
}
}
示例2: main
import javax.smartcardio.Card; //导入方法依赖的package包/类
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.");
}
示例3: main
import javax.smartcardio.Card; //导入方法依赖的package包/类
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.");
}
示例4: logoff
import javax.smartcardio.Card; //导入方法依赖的package包/类
public void logoff(String readerName) throws Exception {
this.view.addDetailMessage("logoff from reader: \"" + readerName + "\"");
TerminalFactory factory = TerminalFactory.getDefault();
CardTerminals cardTerminals = factory.terminals();
CardTerminal cardTerminal = cardTerminals.getTerminal(readerName);
if (null == cardTerminal) {
this.view.addDetailMessage("logoff: card reader not found: " + readerName);
List<String> readerList = getReaderList();
this.view.addDetailMessage("reader list: " + readerList);
// throw new RuntimeException("card reader not found: " +
// readerName);
// we won't fail in this case...
return;
}
Card card = cardTerminal.connect("T=0");
try {
CardChannel cardChannel = card.getBasicChannel();
CommandAPDU logoffApdu = new CommandAPDU(0x80, 0xE6, 0x00, 0x00);
ResponseAPDU responseApdu = cardChannel.transmit(logoffApdu);
this.view.addDetailMessage("logoff... " + readerName);
if (0x9000 != responseApdu.getSW()) {
this.view.addDetailMessage("logoff status word: " + Integer.toHexString(responseApdu.getSW()));
if (0x6e00 == responseApdu.getSW()) {
// BUD001 smart card reader work-around
return;
}
throw new RuntimeException("logoff failed");
}
} finally {
card.disconnect(true);
}
}
示例5: main
import javax.smartcardio.Card; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
// show the list of available terminals
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
// get the first terminal
if (terminals.isEmpty()) {
System.out.println("No terminals found!");
} else {
System.out.println("Terminals: " + terminals);
CardTerminal terminal = terminals.get(0);
// establish a connection with the card
// Card card = terminal.connect("T=1");
Card card = terminal.connect("DIRECT");
System.out.println("card: " + card);
byte[] ccidResp = card.transmitControlCommand(
CM_IOCTL_GET_FEATURE_REQUEST, new byte[] {});
System.out.println(HexString.bufferToHex(ccidResp));
CardChannel channel = card.getBasicChannel();
// channel.transmit(new CommandAPDU(new byte[]{0,1,2,3,4,5,6}));
// disconnect
card.disconnect(false);
}
} catch (Exception e) {
System.err.println(e.getLocalizedMessage());
}
}
示例6: connect
import javax.smartcardio.Card; //导入方法依赖的package包/类
protected void connect(CardTerminal cardTerminal) throws Exception {
System.out.println("" + cardTerminal + " connect");
Card card = cardTerminal.connect("*");
try {
System.out.println("" + card + " begin transaction");
card.beginExclusive();
System.out.println("" + card + " end transaction");
card.endExclusive();
} finally {
System.out.println("" + card + " disconnect");
card.disconnect(false);
}
}
示例7: main
import javax.smartcardio.Card; //导入方法依赖的package包/类
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.");
}
示例8: main
import javax.smartcardio.Card; //导入方法依赖的package包/类
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.");
}