【发布时间】:2017-06-15 09:45:04
【问题描述】:
我已经实现了一个 Andoid 应用程序 - 服务器端应用程序。服务器与智能卡读卡器通信。当用户触摸按钮时 在 Android 应用程序中,正在构建与服务器的连接以获取用户身份验证。应用程序之间交换的消息 和服务器的格式如下:
<type> 0x00 0x00 0x00 <length> 0x00 0x00 0x00 <[data]>
- 如果消息的类型值
06表示智能卡读卡器出现错误。 - 如果消息的类型值
07表示智能卡中存在错误。
我正在使用如下代码与智能卡读卡器进行通信:
// show the list of available terminals
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Terminals: " + terminals);
// get the first terminal
CardTerminal terminal = terminals.get(0);
// establish a connection with the card
Card card = terminal.connect("T=0");
System.out.println("card: " + card);
CardChannel channel = card.getBasicChannel();
ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
System.out.println("response: " + toString(r.getBytes()));
// disconnect
card.disconnect(false);
智能卡 IO API 具有用于异常的 CardException 类。我的问题是我不知道何时发送06 或07 类型的消息,因为我无法区分卡生成的错误和CardException 引发时读取器生成的错误.我该如何处理?
【问题讨论】:
标签: java smartcard apdu smartcard-reader pcsc