我有一个使用javax.smartcardio的servlet尝试访问连接到服务器的PCSC智能卡读卡器。不幸的是,当我尝试在servlet中列出附加的读者时,列表为空。但是,当我运行运行相同代码的本地java程序时,该列表包含所连接的阅读器。有人可以解释为什么会这样 - 它与安全和沙盒有关吗?有没有办法解决这个问题?
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
if (terminals.size() < 2) {
out.println("no readers");
return;
}
out.println("Terminals: " + terminals);
CardTerminal terminal = terminals.get(1);
// establish a connection with the card
Card card = terminal.connect("T=1");
out.println("card: " + card);
CardChannel channel = card.getBasicChannel();
在命令行上的本地java程序中运行时,上面的输出是:
Terminals: [PC/SC terminal SDI011 USB Smart Card Reader 00 00, PC/SC terminal SDI011 USB Smart Card Reader 00 01]
card: PC/SC card in SDI011 USB Smart Card Reader 00 01, protocol T=1, state OK
在服务器上我得到了
no readers