Java Web应用程序可以访问远程工作站上的智能卡读卡器吗?

我正在为一个现有的基于Java的Web应用程序开发一些新function。 Web应用程序本身托管在我们的一个内部服务器上,可以通过浏览器访问我们工厂的多个计算机终端。 该应用程序用于在我们的生产过程的各个阶段进行质量检查。 目前,用户需要通过从下拉列表中选择用户名并在进行每次质量检查之前输入密码来手动登录。 为了加快这个过程,我被要求实施智能卡读取登录。

我已经使用javax.smartcardio编写了一个实用程序类,我可以访问插入笔记本电脑的USB读卡器终端,从卡中读取ATR并在我在本地运行应用程序时使用信息登录到应用程序tomcat7服务器。 所以,在我的本地机器上,一切都很棒。

不幸的是,一旦我将应用程序部署到我们的Web服务器,我就再也无法检测到读卡器终端,因为我相信Java Web应用程序实际上正在寻找部署到它的机器上的读取器。

有什么方法可以让我的java代码通过与浏览器的交互访问插入远程工作站的读卡器?

Web应用程序是用GWT编写的,我使用RPC调用来访问后端服务器端代码。 任何帮助是极大的赞赏。 读卡器代码非常简单,所以如果有帮助我会发布它:

import java.util.List; import javax.smartcardio.Card; import javax.smartcardio.CardTerminal; import javax.smartcardio.TerminalFactory; public class SwipeCardUtil { private static org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger("hwslqc"); /** * @return ATR */ public static String readCardATR() { String ATR = ""; try { // Show the list of available terminals TerminalFactory factory = TerminalFactory.getDefault(); List terminals = factory.terminals().list(); if (terminals.size() == 0) { LOGGER.error("No Swipe Card Terminals Found"); return null; } //System.out.println("Terminal: " + terminals.get(0).getName()); // Get the first terminal in the list CardTerminal terminal = terminals.get(0); if(terminal.isCardPresent()) { // Establish a connection with the card using // "T=0", "T=1", "T=CL" or "*" Card theCard = terminal.connect("*"); // Get ATR byte[] baATR = theCard.getATR().getBytes(); ATR = SwipeCardUtil.byteArrayToHexString(baATR); //System.out.println("ATR: " + ATR); // Disconnect // true: reset the card after disconnecting card. theCard.disconnect(true); } else{ return null; } } catch (Exception ex) { LOGGER.error("No Card Reader Connected. Please connect a Card Reader and try again. "+ex.toString()); ex.printStackTrace(); } return ATR; } /** * @param theBytes * @return theByteArray as a hex string */ public static String byteArrayToHexString(byte[] theBytes) { StringBuffer sb = new StringBuffer(theBytes.length * 2); for (int i = 0; i < theBytes.length; i++) { int byteToRead = theBytes[i] & 0xff; if (byteToRead < 16) { sb.append('0'); } sb.append(Integer.toHexString(byteToRead)); } return sb.toString().toUpperCase(); } } 

您的客户端是Web浏览器,您的Web应用程序部署在远程服务器上。 从客户端获取读者数据的唯一方法是实现在客户端运行的一个软件。 有几种方法可以做到这一点,但许多方法不会在客户端的Web浏览器上运行。

您可以尝试实现applet,但是applet无法获得访问客户端硬件的足够权限的可能性很高。 要提升applet权限,必须由浏览器信任的CA签名。 这是一项非常努力的事情。

另一种方法是根本不使用Web浏览器,而是实现富客户端软件。 但这与之前的建议一样痛苦,因为整个产品都基于瘦客户端/网络浏览器概念。

也许你可以使用单点登录方法。 如果用户在Windows计算机上并使用他们的帐户登录,则可以使用华夫cookies。