用Java访问智能卡

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2819203/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 13:14:24  来源:igfitidea点击:

Accessing smart card with Java

javasmartcard

提问by Tom Brito

I'm trying to learn about how does Java access smart cards, due to a project analysis. I wonder if there is any kind of virtual smart card which I could use to make some tests with Java?

由于项目分析,我正在尝试了解 Java 如何访问智能卡。我想知道是否有任何类型的虚拟智能卡可以用来用 Java 进行一些测试?

By the way, I've read about Java Card, and looks like it is used to run Java in cards, not to smart card data access using Java, right?

顺便说一句,我读过 Java Card,看起来它是用来在卡中运行 Java,而不是使用 Java 访问智能卡数据,对吧?

采纳答案by Bozho

Look at this tutorial + example. And related. (I have used these examples and they work fine).

看看这个教程+例子。和相关的。(我已经使用了这些示例并且它们工作正常)。

An important point is that you can't get anything out of the smart card. You can only send things to its processor. So whenever you get a PrivateKeyobject, you don't actually have the private key - this is only a proxy to the SmartCard processor, and calling methods on it, calls the processor.

重要的一点是你不能从智能卡中得到任何东西。您只能将东西发送到其处理器。所以每当你得到一个PrivateKey对象时,你实际上并没有私钥——这只是智能卡处理器的代理,调用它的方法,调用处理器。

I'm not aware of virtual smart cards, though.

不过,我不知道虚拟智能卡。

An API of interest is javax.smartcardio

一个感兴趣的 API 是 javax.smartcardio

回答by Shane

There is a Java Card emulator bundled with the Java Card Development Kit. If you plan on using a real card at some stage, get version 2.2.1 or 2.2.2 as I would not expect any version 3 cards for a while. You will still need an applet to put on the card. A java card does nothing by itself. It isn't until you load a card applet that it will perform any useful function.

Java Card 开发工具包捆绑了一个 Java Card 模拟器。如果您打算在某个阶段使用真正的卡,请使用 2.2.1 或 2.2.2 版,因为我暂时不会期望任何版本 3 卡。您仍然需要一个小程序才能放在卡上。java卡本身什么都不做。直到您加载一个卡片小程序,它才会执行任何有用的功能。

One problem with the emulator in the JCDK is that you cannot use javax.smartcardio to access the card and this is the prefered method at the moment for communicating with a card. The other popular alternative, OpenCard Framework, has not been actively maintained in some time.

JCDK 中的模拟器的一个问题是您不能使用 javax.smartcardio 访问卡,这是目前与卡通信的首选方法。另一个流行的替代方案 OpenCard 框架已经有一段时间没有得到积极维护了。

回答by Fa11enAngel

You can get a virtual smartcard (and a virtual reader) here: http://sourceforge.net/projects/vsmartcard/

您可以在此处获取虚拟智能卡(和虚拟阅读器):http: //sourceforge.net/projects/vsmartcard/

回答by MikhailDudarev

If you need to emulate JavaCard try to use jCardSim: http://jcardsim.org. It also supports access via javax.smartcardio API and apdu-scripts.

如果您需要模拟 JavaCard,请尝试使用 jCardSim:http://jcardsim.org 。它还支持通过 javax.smartcardio API 和 apdu-scripts 进行访问。

回答by user4935264

Javacard use Java only a subset of the Java development You'd better not use Java development environment Because there are some special effects is not support You can download the plugin or a dedicated development IDE, you can download it from here www.javacos.com related development environment.

Javacard使用Java只是Java开发的一个子集 最好不要使用Java开发环境 因为有一些特效不支持 可以下载插件或者专用的开发IDE,可以从这里下载www.javacos.com相关的开发环境。